# HG changeset patch # User Sascha L. Teichmann # Date 1623920941 -7200 # Node ID d188baf44ed0a376f93193bc068f3265ef4bdddc # Parent da04fa72cee817c8de12e9fc784faa8c5cafdb30# Parent 12a5e128255fdcf382cba7de42a4fafbbd512381 Merged zpg-exception back into default. diff -r da04fa72cee8 -r d188baf44ed0 client/src/components/Pdftool.vue --- a/client/src/components/Pdftool.vue Tue Mar 02 15:11:15 2021 +0100 +++ b/client/src/components/Pdftool.vue Thu Jun 17 11:09:01 2021 +0200 @@ -270,7 +270,7 @@ this.form.paperSize = this.templateData.properties.paperSize; this.form.resolution = this.templateData.properties.resolution; }, - numberSoundingsVisible() { + getSoundingInfo() { return new Promise((resolve, reject) => { const map = this.openLayersMap(); const currentExtent = map.getView().calculateExtent(map.getSize()); @@ -280,7 +280,6 @@ featurePrefix: "gemma", featureTypes: ["sounding_results_areas_geoserver"], outputFormat: "application/json", - resultType: "hits", bbox: currentExtent, geometryName: "areas" }; @@ -310,14 +309,22 @@ }); }, download() { - this.numberSoundingsVisible() + this.getSoundingInfo() .then(response => { - const parser = new DOMParser(); - const responseXML = parser.parseFromString(response.data, "text/xml"); - const totalNumber = responseXML - .getElementsByTagName("wfs:FeatureCollection")[0] - .getAttribute("numberOfFeatures"); - this.generatePDF(totalNumber > 0); + let soundingInfo = {}; + if (this.selectedSurvey) { + soundingInfo = { + number: response.data.numberMatched || 0, + feature: + response.data.features.filter( + f => f.properties.date_info === this.selectedSurvey.date_info + )[0] || {} + }; + } else { + soundingInfo = { number: 0, feature: {} }; + } + this.$store.commit("bottlenecks/setSoundingInfo", soundingInfo); + this.generatePDF(soundingInfo); }) .catch(error => { console.log(error); @@ -332,7 +339,7 @@ }); }); }, - generatePDF(soundingsVisible) { + generatePDF(soundingInfo) { /** * In order to generate the image with the appropriate resolution * we have to temporaily scale the visible part of the map. @@ -367,7 +374,6 @@ this.pdf.width, this.pdf.height ); - if (this.templateData) { this.pdf.doc.setFont("linbiolinum", "normal"); let defaultFontSize = 11, @@ -386,7 +392,8 @@ e.width, e.fontSize || defaultFontSize, e.color || defaultTextColor, - e.text + e.text, + soundingInfo ); break; } @@ -436,7 +443,7 @@ e.rounding === 0 || e.rounding ? e.rounding : defaultRounding, e.color || defaultTextColor, e.brcolor || defaultBorderColor, - soundingsVisible + soundingInfo.number > 0 ); break; } @@ -446,7 +453,7 @@ e.offset || defaultOffset, e.rounding === 0 || e.rounding ? e.rounding : defaultRounding, e.brcolor || defaultBorderColor, - soundingsVisible + soundingInfo.number > 0 ); break; } @@ -496,7 +503,7 @@ let filename = "map"; if ( this.bottleneckForPrint && - (soundingsVisible || isBottlenckVisible()) + (soundingInfo.number > 0 || isBottlenckVisible()) ) { filename = `BN-${sanitize(this.bottleneckForPrint).replace( / /g, @@ -738,9 +745,9 @@ this.pdf.doc.setFontStyle("normal"); this.pdf.doc.text(size < 3 ? x1 - 0.5 : x1 - 1.3, y3 + 1, "N"); }, - addLegend(position, offset, rounding, brcolor, soundingsVisible) { + addLegend(position, offset, rounding, brcolor, hasSounding) { if ( - soundingsVisible && + hasSounding && this.bottleneckForPrint && this.selectedSurvey && this.openLayersMap() @@ -780,16 +787,9 @@ ); } }, - addBottleneckInfo( - position, - offset, - rounding, - color, - brcolor, - soundingsVisible - ) { + addBottleneckInfo(position, offset, rounding, color, brcolor, hasSounding) { if ( - soundingsVisible && + hasSounding && this.bottleneckForPrint && this.selectedSurvey && this.openLayersMap() diff -r da04fa72cee8 -r d188baf44ed0 client/src/components/identify/formatter.js --- a/client/src/components/identify/formatter.js Tue Mar 02 15:11:15 2021 +0100 +++ b/client/src/components/identify/formatter.js Thu Jun 17 11:09:01 2021 +0200 @@ -6,7 +6,11 @@ all(p) { if (p.key === "objnam") p.key = app.$gettext("Name"); if (p.key === "objname") p.key = app.$gettext("Name"); - if (p.key === "staging_done" || p.key === "fa_critical") + if ( + p.key === "staging_done" || + p.key === "fa_critical" || + p.key === "zpg_exception" + ) p.val = p.val ? app.$gettext("yes") : app.$gettext("no"); if ( (p.key === "date_info" || @@ -20,7 +24,6 @@ // remove certain props let propsToRemove = ["bbox"]; if (propsToRemove.indexOf(p.key) !== -1) return null; - return p; }, bottlenecks_geoserver: { @@ -121,6 +124,7 @@ if (propsToRemove.indexOf(p.key) !== -1) return null; if (p.key === "surtyp") p.key = app.$gettext("Survey type"); if (p.key === "bottleneck_id") p.key = app.$gettext("Bottleneck"); + if (p.key === "zpg_exception") p.key = app.$gettext("ZPG exception"); return p; } } diff -r da04fa72cee8 -r d188baf44ed0 client/src/components/importconfiguration/types/Soundingresults.vue --- a/client/src/components/importconfiguration/types/Soundingresults.vue Tue Mar 02 15:11:15 2021 +0100 +++ b/client/src/components/importconfiguration/types/Soundingresults.vue Thu Jun 17 11:09:01 2021 +0200 @@ -469,11 +469,15 @@ }, depthReferenceOptions() { if (this.bottleneck) { + const bnProperties =this.bottleneck.properties; const referenceLevels = JSON.parse( - this.bottleneck.properties.reference_water_levels - ); + bnProperties.reference_water_levels + )||{}; const result = Object.keys(referenceLevels); - if (!referenceLevels["ZPG"]) result.push("ZPG"); // ZPG should always be available + const bottleneckBGorRO = bnProperties.responsible_country=="BG" || bnProperties.responsible_country=="RO"; + const hasLDC = referenceLevels.hasOwnProperty("LDC"); + const hasZPG = referenceLevels.hasOwnProperty("ZPG"); + if (((hasLDC && !hasZPG) || (!hasLDC && !hasZPG && bottleneckBGorRO)) ) result.push("ZPG"); return result; } return []; diff -r da04fa72cee8 -r d188baf44ed0 client/src/lib/mixins.js --- a/client/src/lib/mixins.js Tue Mar 02 15:11:15 2021 +0100 +++ b/client/src/lib/mixins.js Thu Jun 17 11:09:01 2021 +0200 @@ -165,7 +165,8 @@ export const pdfgen = { computed: { ...mapState("application", ["logoForPDF"]), - ...mapState("user", ["user"]) + ...mapState("user", ["user"]), + ...mapState("bottlenecks", ["soundingInfo"]) }, methods: { downloadImage(elementName, title) { @@ -455,6 +456,19 @@ if (text.includes("{user}")) { text = text.replace("{user}", this.user); } + if (text.includes("{zpg-exception}")) { + // Print the text followed by "zpg-exception" if this value set to true + if ( + this.soundingInfo && + this.soundingInfo.number > 0 && + this.soundingInfo.feature.properties.zpg_exception + ) { + text = text.replace("{zpg-exception}", ""); + // Otherwise nothing to print + } else { + text = ""; + } + } return text; }, addImage(url, format, position, offset, width, height) { diff -r da04fa72cee8 -r d188baf44ed0 client/src/store/bottlenecks.js --- a/client/src/store/bottlenecks.js Tue Mar 02 15:11:15 2021 +0100 +++ b/client/src/store/bottlenecks.js Thu Jun 17 11:09:01 2021 +0200 @@ -25,7 +25,8 @@ surveys: [], selectedSurvey: null, surveysLoading: false, - bottleneckForPrint: null + bottleneckForPrint: null, + soundingInfo: null }; }; @@ -64,6 +65,9 @@ } }, mutations: { + setSoundingInfo: (state, data) => { + state.soundingInfo = data; + }, setBottleneckForPrint: (state, bottleneck) => { state.bottleneckForPrint = bottleneck; }, diff -r da04fa72cee8 -r d188baf44ed0 pkg/imports/sr.go --- a/pkg/imports/sr.go Tue Mar 02 15:11:15 2021 +0100 +++ b/pkg/imports/sr.go Thu Jun 17 11:09:01 2021 +0200 @@ -134,7 +134,8 @@ date_info, depth_reference, area, - surtyp + surtyp, + zpg_exception ) SELECT bottleneck_id, $2::date, @@ -145,7 +146,8 @@ ELSE ST_MakeValid(ST_Transform(ST_GeomFromWKB($5, $6::integer), 4326))::geography END), - $7 + $7, + $8 FROM waterway.bottlenecks WHERE objnam = $1 AND validity @> CAST($2 AS timestamptz) RETURNING @@ -207,6 +209,10 @@ AND grwl.depth_reference like 'LDC%' ` + selectZPGExceptionAllowedSQL = ` +SELECT rolname = 'sys_admin' OR country IN ('BG', 'RO') +FROM users.list_users WHERE username = current_user` + reprojectPointsSingleBeamSQL = ` SELECT ST_AsBinary( @@ -294,6 +300,8 @@ xform = identityTransform } + var zpgException bool + if m.DepthReference == "ZPG" { feedback.Info("Found ZPG as reference system -> translating Z values to LDC") var ldc float64 @@ -308,19 +316,29 @@ ) switch { case err == sql.ErrNoRows: - return nil, errors.New("cannot load LDC value") + if err := conn.QueryRowContext( + ctx, selectZPGExceptionAllowedSQL).Scan(&zpgException); err != nil { + return nil, err + } + if !zpgException { + return nil, errors.New("cannot load LDC value") + } + feedback.Warn("Not LCD found, but ZPG exception granted") + case err != nil: return nil, err } - // LDC is cm. The data is in m. - ldc /= 100 - xform = chainTransforms( - xform, - func(v mesh.Vertex) mesh.Vertex { - return mesh.Vertex{X: v.X, Y: v.Y, Z: v.Z + ldc} - }) - m.DepthReference = depthReference + if !zpgException { + // LDC is cm. The data is in m. + ldc /= 100 + xform = chainTransforms( + xform, + func(v mesh.Vertex) mesh.Vertex { + return mesh.Vertex{X: v.X, Y: v.Y, Z: v.Z + ldc} + }) + m.DepthReference = depthReference + } } if err := m.Validate(ctx, conn); err != nil { @@ -372,6 +390,7 @@ m, xyz, boundary, + zpgException, ) if err != nil { return nil, err @@ -397,6 +416,7 @@ m *models.SoundingResultMeta, xyz mesh.MultiPointZ, boundary polygonSlice, + zpgException bool, ) (interface{}, error) { if sr.singleBeam() { @@ -626,6 +646,7 @@ clippingPolygonWKB, epsg, sr.surtype(), + zpgException, ).Scan( &id, &lat, diff -r da04fa72cee8 -r d188baf44ed0 schema/default_sysconfig.sql --- a/schema/default_sysconfig.sql Tue Mar 02 15:11:15 2021 +0100 +++ b/schema/default_sysconfig.sql Thu Jun 17 11:09:01 2021 +0200 @@ -213,7 +213,8 @@ to_char(date_info, 'YYYY-MM-DD') AS date_info, height, areas, - surtyp + surtyp, + zpg_exception FROM waterway.sounding_results_iso_areas ia JOIN waterway.sounding_results sr ON sr.id = ia.sounding_result_id $$), diff -r da04fa72cee8 -r d188baf44ed0 schema/gemma.sql --- a/schema/gemma.sql Tue Mar 02 15:11:15 2021 +0100 +++ b/schema/gemma.sql Thu Jun 17 11:09:01 2021 +0200 @@ -798,6 +798,7 @@ surtyp varchar REFERENCES survey_types, coverage varchar REFERENCES coverage_types, depth_reference varchar NOT NULL, -- REFERENCES depth_references, + zpg_exception bool NOT NULL DEFAULT FALSE, -- Found no LDC in ZPG case. octree_checksum varchar, octree_index bytea, mesh_checksum varchar, diff -r da04fa72cee8 -r d188baf44ed0 schema/updates/1440/01.add_zpg_exception.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/updates/1440/01.add_zpg_exception.sql Thu Jun 17 11:09:01 2021 +0200 @@ -0,0 +1,1 @@ +ALTER TABLE waterway.sounding_results ADD COLUMN zpg_exception bool NOT NULL DEFAULT FALSE; diff -r da04fa72cee8 -r d188baf44ed0 schema/updates/1441/01.extend_sounding_result_view.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/updates/1441/01.extend_sounding_result_view.sql Thu Jun 17 11:09:01 2021 +0200 @@ -0,0 +1,11 @@ +UPDATE sys_admin.published_services SET view_def = $$ + SELECT bottleneck_id, + to_char(date_info, 'YYYY-MM-DD') AS date_info, + height, + areas, + surtyp, + zpg_exception + FROM waterway.sounding_results_iso_areas ia + JOIN waterway.sounding_results sr ON sr.id = ia.sounding_result_id +$$ + WHERE schema = 'waterway' AND name = 'sounding_results_areas_geoserver'; diff -r da04fa72cee8 -r d188baf44ed0 schema/version.sql --- a/schema/version.sql Tue Mar 02 15:11:15 2021 +0100 +++ b/schema/version.sql Thu Jun 17 11:09:01 2021 +0200 @@ -1,1 +1,1 @@ -INSERT INTO gemma_schema_version(version) VALUES (1439); +INSERT INTO gemma_schema_version(version) VALUES (1441);