# HG changeset patch # User Sascha Wilde # Date 1563880355 -7200 # Node ID 9f6a6b8ad965a20955facad6781d736df888cf22 # Parent 3fcb95a079487d4f3b00adce87d46b36b0db68a5# Parent 7afa18971d387810aa54c041926f5cbd445eff72 Merged default. diff -r 3fcb95a07948 -r 9f6a6b8ad965 client/src/components/fairway/AvailableFairwayDepth.vue --- a/client/src/components/fairway/AvailableFairwayDepth.vue Tue Jul 23 13:10:51 2019 +0200 +++ b/client/src/components/fairway/AvailableFairwayDepth.vue Tue Jul 23 13:12:35 2019 +0200 @@ -81,7 +81,7 @@ import { FREQUENCIES } from "@/store/fairwayavailability"; import { defaultDiagramTemplate } from "@/lib/DefaultDiagramTemplate"; -const hoursInDays = x => x / 24; +const hoursInDays = x => Math.round(x / 24); export default { mixins: [diagram, pdfgen, templateLoader], diff -r 3fcb95a07948 -r 9f6a6b8ad965 client/src/components/map/Map.vue --- a/client/src/components/map/Map.vue Tue Jul 23 13:10:51 2019 +0200 +++ b/client/src/components/map/Map.vue Tue Jul 23 13:12:35 2019 +0200 @@ -42,6 +42,7 @@ import { displayError } from "@/lib/errors"; import { pane } from "@/lib/mixins"; import { layerFactory } from "@/components/map/layers"; +import { ImageWMS as ImageSource } from "ol/source"; import "ol/ol.css"; /* for the sake of debugging */ @@ -60,7 +61,7 @@ ...mapState("map", ["initialLoad", "extent", "syncedMaps", "syncedView"]), ...mapState("bottlenecks", ["selectedSurvey"]), ...mapState("fairwayprofile", ["additionalSurvey"]), - ...mapState("application", ["paneSetup", "paneRotate"]), + ...mapState("application", ["paneSetup", "paneRotate", "config"]), ...mapState("imports", ["selectedStretchId", "selectedSectionId"]), layers() { return layerFactory(this.paneId); @@ -207,6 +208,13 @@ } }, mountMap() { + const source = new ImageSource({ + preload: 1, + url: this.config.ecdis_wms_url, + crossOrigin: "anonymous", + params: JSON.parse(this.config.ecdis_wms_params) + }); + this.layers.get("INLANDECDIS").setSource(source); this.map = new Map({ layers: this.layers.config, target: "map-" + this.paneId, @@ -222,7 +230,6 @@ }) }); this.map.getLayer = id => this.layers.get(id); - // store map position on every move // will be obsolete once we abandoned the separated admin context this.map.on("moveend", event => { diff -r 3fcb95a07948 -r 9f6a6b8ad965 client/src/components/map/layers.js --- a/client/src/components/map/layers.js Tue Jul 23 13:10:51 2019 +0200 +++ b/client/src/components/map/layers.js Tue Jul 23 13:12:35 2019 +0200 @@ -243,12 +243,7 @@ id: "INLANDECDIS", label: "Inland ECDIS chart Danube", visible: true, - source: new ImageSource({ - preload: 1, - url: store.state.application.config.ecdis_wms_url, - crossOrigin: "anonymous", - params: JSON.parse(store.state.application.config.ecdis_wms_params) - }) + source: null }), new ImageLayer({ id: "WATERWAYAREA", diff -r 3fcb95a07948 -r 9f6a6b8ad965 client/src/components/systemconfiguration/MapLayers.vue --- a/client/src/components/systemconfiguration/MapLayers.vue Tue Jul 23 13:10:51 2019 +0200 +++ b/client/src/components/systemconfiguration/MapLayers.vue Tue Jul 23 13:12:35 2019 +0200 @@ -144,16 +144,22 @@ this.lookupWMSCapabilities(); }, submit() { - this.$store.dispatch("application/saveConfig", { - ecdis_wms_url: this.config.ecdis_wms_url, - ecdis_wms_params: JSON.stringify({ - LAYERS: this.selectedWMSLayers - .filter(l => this.availableWMSLayers.find(al => al === l)) - .join(","), - VERSION: this.wmsVersion, - TILED: true + const layers = this.selectedWMSLayers + .filter(l => this.availableWMSLayers.find(al => al === l)) + .join(","); + const wmsParams = JSON.stringify({ + LAYERS: layers, + VERSION: this.wmsVersion, + TILED: true + }); + this.$store + .dispatch("application/saveConfig", { + ecdis_wms_url: this.config.ecdis_wms_url, + ecdis_wms_params: wmsParams }) - }); + .then(() => { + this.config.ecdis_wms_params = wmsParams; + }); } }, mounted() { diff -r 3fcb95a07948 -r 9f6a6b8ad965 pkg/imports/agm.go --- a/pkg/imports/agm.go Tue Jul 23 13:10:51 2019 +0200 +++ b/pkg/imports/agm.go Tue Jul 23 13:12:35 2019 +0200 @@ -4,13 +4,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later // License-Filename: LICENSES/AGPL-3.0.txt // -// Copyright (C) 2018 by via donau +// Copyright (C) 2018, 2019 by via donau // – Österreichische Wasserstraßen-Gesellschaft mbH // Software engineering by Intevation GmbH // // Author(s): // * Sascha L. Teichmann // * Sascha Wilde +// * Tom Gottfried package imports @@ -120,14 +121,16 @@ } type agmLine struct { - CountryCode string `json:"country-code"` - Sender string `json:"sender"` - LanguageCode string `json:"language-code"` - DateIssue timetz `json:"date-issue"` - ReferenceCode string `json:"reference-code"` - WaterLevel float64 `json:"water-level"` - DateInfo timetz `json:"date-info"` - SourceOrganization string `json:"source-organization"` + Location models.Isrs `json:"fk-gauge-id"` + CountryCode string `json:"country-code"` + Sender string `json:"sender"` + LanguageCode string `json:"language-code"` + DateIssue timetz `json:"date-issue"` + ReferenceCode string `json:"reference-code"` + MeasureDate timetz `json:"measure-date"` + WaterLevel float64 `json:"water-level"` + DateInfo timetz `json:"date-info"` + SourceOrganization string `json:"source-organization"` } func (a *agmLine) hasDiff(b *agmLine) bool { @@ -309,8 +312,11 @@ warn := warnLimiter.Warn defer warnLimiter.Close() + agmLines := []*agmLine{} + ignored := 0 + lines: - for line, ignored := 1, 0; ; line++ { + for line := 1; ; line++ { row, err := r.Read() switch { @@ -322,7 +328,6 @@ if ignored == line-1 { return nil, UnchangedError("No entries imported") } - feedback.Info("Imported %d entries with changes", len(entries)) break lines case err != nil: return nil, fmt.Errorf("CSV parsing failed: %v", err) @@ -364,6 +369,38 @@ return nil, fmt.Errorf("Invalid 'measure_date' line %d: %v", line, err) } + newSender := agm.Originator + newCountryCode := gid.CountryCode + newLanguageCode := misc.CCtoLang[gid.CountryCode] + newDateIssue := time.Now() + newReferenceCode := "ZPG" + + value, err := strconv.ParseFloat(row[valueIdx], 32) + if err != nil { + return nil, fmt.Errorf("Invalid 'value' line %d: %v", line, err) + } + newValue := value + + newDateInfo := newDateIssue + + newSourceOrganization := newSender + + agmLines = append(agmLines, newAGMLine( + *gid, + newCountryCode, + newSender, + newLanguageCode, + newDateIssue, + newReferenceCode, + md, + newValue, + newDateInfo, + newSourceOrganization, + )) + } + +agmLines: + for _, line := range agmLines { var ( oldID int64 oldCountryCode string @@ -378,12 +415,12 @@ err = selectStmt.QueryRowContext( ctx, - gid.CountryCode, - gid.LoCode, - gid.FairwaySection, - gid.Orc, - gid.Hectometre, - md, + line.Location.CountryCode, + line.Location.LoCode, + line.Location.FairwaySection, + line.Location.Orc, + line.Location.Hectometre, + line.MeasureDate.Time, ).Scan( &oldID, &oldCountryCode, @@ -405,22 +442,6 @@ return nil, err } - newSender := agm.Originator - newCountryCode := gid.CountryCode - newLanguageCode := misc.CCtoLang[gid.CountryCode] - newDateIssue := time.Now() - newReferenceCode := "ZPG" - - value, err := strconv.ParseFloat(row[valueIdx], 32) - if err != nil { - return nil, fmt.Errorf("Invalid 'value' line %d: %v", line, err) - } - newValue := value - - newDateInfo := newDateIssue - - newSourceOrganization := newSender - switch err := func() error { tx, err := conn.BeginTx(ctx, nil) if err != nil { @@ -432,20 +453,20 @@ if err := tx.StmtContext(ctx, insertStmt).QueryRowContext( ctx, - gid.CountryCode, - gid.LoCode, - gid.FairwaySection, - gid.Orc, - gid.Hectometre, - md, - newCountryCode, - newSender, - newLanguageCode, - newDateIssue, - newReferenceCode, - newValue, - newDateInfo, - newSourceOrganization, + line.Location.CountryCode, + line.Location.LoCode, + line.Location.FairwaySection, + line.Location.Orc, + line.Location.Hectometre, + line.MeasureDate.Time, + line.CountryCode, + line.Sender, + line.LanguageCode, + line.DateIssue.Time, + line.ReferenceCode, + line.WaterLevel, + line.DateInfo.Time, + line.SourceOrganization, ).Scan(&newID); err != nil { warn(handleError(err).Error()) ignored++ @@ -464,49 +485,41 @@ return err }(); { case err == errContinue: - continue lines + continue agmLines case err != nil: return nil, err } - n := newAGMLine( - newCountryCode, - newSender, - newLanguageCode, - newDateIssue, - newReferenceCode, - newValue, - newDateInfo, - newSourceOrganization, - ) - ase := &agmSummaryEntry{ - FKGaugeID: *gid, - MeasureDate: timetz{md}, + FKGaugeID: line.Location, + MeasureDate: line.MeasureDate, } if newEntry { - ase.Versions = []*agmLine{n} + ase.Versions = []*agmLine{line} } else { o := newAGMLine( + line.Location, oldCountryCode, oldSender, oldLanguageCode, oldDateIssue, oldReferenceCode, + line.MeasureDate.Time, oldValue, oldDateInfo, oldSourceOrganization, ) // Ignore if there is no diff. - if !n.hasDiff(o) { + if !line.hasDiff(o) { continue } - ase.Versions = []*agmLine{o, n} + ase.Versions = []*agmLine{o, line} } entries = append(entries, ase) } + feedback.Info("Imported %d entries with changes", len(entries)) feedback.Info("Importing approved gauge measurements took %s", time.Since(start)) @@ -514,21 +527,25 @@ } func newAGMLine( + location models.Isrs, countryCode string, sender string, languageCode string, dateIssue time.Time, referenceCode string, + measureDate time.Time, waterLevel float64, dateInfo time.Time, sourceOrganization string, ) *agmLine { return &agmLine{ + Location: location, CountryCode: countryCode, Sender: sender, LanguageCode: languageCode, DateIssue: timetz{dateIssue}, ReferenceCode: referenceCode, + MeasureDate: timetz{measureDate}, WaterLevel: waterLevel, DateInfo: timetz{dateInfo}, SourceOrganization: sourceOrganization,