Mercurial > gemma
changeset 4093:c1c6a375305f historization_ng
Merged default
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Thu, 25 Jul 2019 17:39:40 +0200 |
parents | 30a567b1cc2e (current diff) 8b98ac6a1de8 (diff) |
children | b65837b65479 |
files | schema/gemma.sql schema/version.sql |
diffstat | 4 files changed, 59 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/Pdftool.vue Thu Jul 25 17:21:03 2019 +0200 +++ b/client/src/components/Pdftool.vue Thu Jul 25 17:39:40 2019 +0200 @@ -53,6 +53,17 @@ </select> </div> </div> + <div class="d-flex flex-fill-row"> + <small class="my-auto text-muted"> + <translate>Scale to 1:</translate> + </small> + <input + class="form-control form-control-sm w-100 ml-2" + placeholder="10000" + v-model.number="form.scale" + type="number" + /> + </div> <button @click="download" :key="'downloadBtn'" @@ -126,7 +137,8 @@ format: "landscape", paperSize: "a4", downloadType: "download", - resolution: "80" + resolution: "80", + scale: null }, templates: [ { @@ -257,7 +269,6 @@ * */ this.readyToGenerate = false; - console.log( "will generate pdf with", this.form.paperSize, @@ -287,13 +298,14 @@ this.pdf.doc = new jsPDF(this.form.format, "mm", this.form.paperSize); this.rendercompleteListener = map.once("rendercomplete", event => { let canvas = event.context.canvas; - let view = map.getView(); - let proj = view.getProjection(); - let metersPerPixel = // average meters (reality) per pixel (map) - getPointResolution(proj, view.getResolution(), view.getCenter()) * - proj.getMetersPerUnit(); let scaleDenominator = Math.round( - 1000 * pixelsPerMapMillimeter * metersPerPixel + 1000 * + pixelsPerMapMillimeter * + this.getMeterPerPixel( + this.openLayersMap() + .getView() + .getResolution() + ) ); console.log("scaleDenominator = ", scaleDenominator); var snapshot = canvas.toDataURL("image/jpeg"); @@ -424,11 +436,30 @@ map.getView().setResolution(this.resolution); this.readyToGenerate = true; }); + const size = map.getSize(); const [width, height] = mapSizeForPrint; map.setSize(mapSizeForPrint); const scaling = Math.min(width / size[0], height / size[1]); - map.getView().setResolution(this.resolution / scaling); + map + .getView() + .setResolution( + this.form.scale + ? this.getResolutionFromScale() + : this.resolution / scaling + ); + }, + getResolutionFromScale() { + const scaling = Math.round(this.form.scale / 1000); + return scaling / this.getMeterPerPixel(this.form.resolution / 25.4); + }, + getMeterPerPixel(f) { + var map = this.openLayersMap(); + let view = map.getView(); + let proj = view.getProjection(); + return ( + getPointResolution(proj, f, view.getCenter()) * proj.getMetersPerUnit() + ); }, cancel() { this.openLayersMap().un(
--- a/pkg/controllers/gauges.go Thu Jul 25 17:21:03 2019 +0200 +++ b/pkg/controllers/gauges.go Thu Jul 25 17:39:40 2019 +0200 @@ -636,7 +636,7 @@ } } - cs[i].Value = common.NashSutcliffe(predicted, observed) + cs[i].Value = sanitizeFloat64(common.NashSutcliffe(predicted, observed)) cs[i].Samples = len(predicted) predicted = predicted[:0] @@ -652,6 +652,18 @@ return } +func sanitizeFloat64(x float64) float64 { + switch { + case math.IsNaN(x): + return 0 + case math.IsInf(x, +1): + return math.MaxFloat64 + case math.IsInf(x, -1): + return -math.MaxFloat64 + } + return x +} + func waterlevels(rw http.ResponseWriter, req *http.Request) { gauge := mux.Vars(req)["gauge"]
--- a/schema/gemma.sql Thu Jul 25 17:21:03 2019 +0200 +++ b/schema/gemma.sql Thu Jul 25 17:39:40 2019 +0200 @@ -834,8 +834,8 @@ id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, state import_state NOT NULL DEFAULT 'queued', kind varchar NOT NULL, - enqueued timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - due timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + enqueued timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, + due timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, retry_wait interval CHECK(retry_wait IS NULL OR retry_wait >= interval '0 microseconds'), @@ -858,7 +858,7 @@ CREATE TABLE import_logs ( import_id int NOT NULL REFERENCES imports(id) ON DELETE CASCADE, - time timestamp NOT NULL DEFAULT now(), + time timestamp with time zone NOT NULL DEFAULT now(), kind log_type NOT NULL DEFAULT 'info', msg TEXT NOT NULL )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/updates/1010/01.timezones-imports.sql Thu Jul 25 17:39:40 2019 +0200 @@ -0,0 +1,3 @@ +ALTER TABLE import.imports ALTER COLUMN enqueued TYPE timestamp with time zone; +ALTER TABLE import.imports ALTER COLUMN due TYPE timestamp with time zone; +ALTER TABLE import.import_logs ALTER COLUMN time TYPE timestamp with time zone;