# HG changeset patch # User Sascha L. Teichmann # Date 1551461330 -3600 # Node ID bca9a7a89f280af093e850081b013b7b7d5d8503 # Parent 86173ac7f222ac3c73723aa2b7205e66b365195a# Parent 219c5b57ef5bde60ea9bec4592e6baf37273c2ad Merged default into octree-diff branch. diff -r 86173ac7f222 -r bca9a7a89f28 client/src/components/ImportSoundingresults.vue --- a/client/src/components/ImportSoundingresults.vue Fri Mar 01 18:28:12 2019 +0100 +++ b/client/src/components/ImportSoundingresults.vue Fri Mar 01 18:28:50 2019 +0100 @@ -111,7 +111,10 @@ Download Meta.json @@ -323,16 +326,18 @@ return this.$gettext("Confirm"); }, dataLink() { - return ( - "data:text/json;charset=utf-8," + - encodeURIComponent( - JSON.stringify({ - depthReference: this.depthReference, - bottleneck: this.bottleneck.properties.objnam, - date: this.importDate - }) - ) - ); + if (this.bottleneck && this.depthReference && this.import) { + return ( + "data:text/json;charset=utf-8," + + encodeURIComponent( + JSON.stringify({ + depthReference: this.depthReference, + bottleneck: this.bottleneck.properties.objnam, + date: this.importDate + }) + ) + ); + } }, depthReferenceOptions() { if ( diff -r 86173ac7f222 -r bca9a7a89f28 client/src/components/Maplayer.vue --- a/client/src/components/Maplayer.vue Fri Mar 01 18:28:12 2019 +0100 +++ b/client/src/components/Maplayer.vue Fri Mar 01 18:28:50 2019 +0100 @@ -337,6 +337,21 @@ ); layer.data.setVisible(layer.isVisible); + layer = this.getLayerByName(LAYERS.GAUGES); + layer.data.getSource().setLoader( + this.buildVectorLoader( + { + featureNS: "gemma", + featurePrefix: "gemma", + featureTypes: ["gauges_geoserver"], + geometryName: "geom" + }, + "/internal/wfs", + layer.data.getSource() + ) + ); + layer.data.setVisible(layer.isVisible); + layer = this.getLayerByName(LAYERS.STRETCHES); layer.data.getSource().setLoader( this.buildVectorLoader( diff -r 86173ac7f222 -r bca9a7a89f28 client/src/components/Search.vue --- a/client/src/components/Search.vue Fri Mar 01 18:28:12 2019 +0100 +++ b/client/src/components/Search.vue Fri Mar 01 18:28:50 2019 +0100 @@ -58,6 +58,12 @@ class="mr-1" fixed-width /> + {{ entry.name }} @@ -269,6 +275,7 @@ if (resultEntry.type === "bottleneck") zoom = 17; if (resultEntry.type === "rhm") zoom = 15; if (resultEntry.type === "city") zoom = 13; + if (resultEntry.type === "gauge") zoom = 15; this.$store.commit("map/moveMap", { coordinates: resultEntry.geom.coordinates, zoom, diff -r 86173ac7f222 -r bca9a7a89f28 client/src/components/importoverview/ImportOverview.vue --- a/client/src/components/importoverview/ImportOverview.vue Fri Mar 01 18:28:12 2019 +0100 +++ b/client/src/components/importoverview/ImportOverview.vue Fri Mar 01 18:28:50 2019 +0100 @@ -7,10 +7,10 @@ />
@@ -55,7 +55,7 @@ icon="angle-down" fixed-width > - +
Logs @@ -85,6 +85,11 @@ export default { name: "importoverview", + data() { + return { + reload: false + }; + }, components: { Staging: () => import("./staging/Staging.vue"), Logs: () => import("./importlogs/Logs.vue") @@ -100,22 +105,30 @@ this.$store.commit("imports/setLogsVisibility", !this.logsVisible); }, refresh() { + this.reload = true; this.loadImportQueue(); this.loadLogs(); }, loadImportQueue() { - this.$store.dispatch("imports/getStaging").catch(error => { - const { status, data } = error.response; - displayError({ - title: "Backend Error", - message: `${status}: ${data.message || data}` + this.$store + .dispatch("imports/getStaging") + .then(() => { + this.reload = false; + }) + .catch(error => { + const { status, data } = error.response; + displayError({ + title: "Backend Error", + message: `${status}: ${data.message || data}` + }); }); - }); }, loadLogs() { this.$store .dispatch("imports/getImports") - .then(() => {}) + .then(() => { + this.reload = false; + }) .catch(error => { const { status, data } = error.response; displayError({ diff -r 86173ac7f222 -r bca9a7a89f28 client/src/components/importoverview/importlogs/LogDetail.vue --- a/client/src/components/importoverview/importlogs/LogDetail.vue Fri Mar 01 18:28:12 2019 +0100 +++ b/client/src/components/importoverview/importlogs/LogDetail.vue Fri Mar 01 18:28:50 2019 +0100 @@ -51,72 +51,62 @@
- - - - - - - - - - + Kind + Date + + Message + +
+
+ {{ entry.kind.toUpperCase() }} -
- - - - -
- Kind - - Date - - - Message -
- {{ entry.kind.toUpperCase() }} - - {{ formatDateTime(entry.time) }} - - {{ entry.message }} -
+ {{ formatDateTime(entry.time) }} + {{ entry.message }} +
+
@@ -265,6 +255,10 @@ diff -r 86173ac7f222 -r bca9a7a89f28 client/src/components/importoverview/importlogs/Logs.vue --- a/client/src/components/importoverview/importlogs/Logs.vue Fri Mar 01 18:28:12 2019 +0100 +++ b/client/src/components/importoverview/importlogs/Logs.vue Fri Mar 01 18:28:50 2019 +0100 @@ -10,7 +10,7 @@ - @@ -39,7 +42,13 @@ - +
+

+ {{ templateToUpload.name }} uploaded successfully +

+
@@ -84,7 +98,9 @@ data() { return { templates: [], - uploading: false + uploading: false, + templateToUpload: "", + showSuccessUploadMsg: false }; }, methods: { @@ -119,6 +135,8 @@ ) .then(() => { this.loadTemplates(); + this.templateToUpload = template; + this.showSuccessUploadMsg = true; }) .catch(e => { const { status, data } = e.response; @@ -129,6 +147,7 @@ }) .finally(() => { this.uploading = false; + this.$refs.uploadTemplate.value = null; }); } else { displayError({ diff -r 86173ac7f222 -r bca9a7a89f28 client/src/store/imports.js --- a/client/src/store/imports.js Fri Mar 01 18:28:12 2019 +0100 +++ b/client/src/store/imports.js Fri Mar 01 18:28:50 2019 +0100 @@ -160,7 +160,8 @@ }, getImports({ commit }, filter) { let queryParams = ""; - if (filter) queryParams = "?states=" + filter.join(","); + if (filter && filter.length > 0) + queryParams = "?states=" + filter.join(","); return new Promise((resolve, reject) => { HTTP.get("/imports" + queryParams, { headers: { "X-Gemma-Auth": localStorage.getItem("token") } diff -r 86173ac7f222 -r bca9a7a89f28 client/src/store/map.js --- a/client/src/store/map.js Fri Mar 01 18:28:12 2019 +0100 +++ b/client/src/store/map.js Fri Mar 01 18:28:50 2019 +0100 @@ -20,7 +20,15 @@ import { Tile as TileLayer, Vector as VectorLayer } from "ol/layer.js"; import OSM from "ol/source/OSM"; import Draw from "ol/interaction/Draw.js"; -import { Icon, Stroke, Style, Fill, Text, Circle } from "ol/style.js"; +import { + Icon, + Stroke, + Style, + Fill, + Text, + Circle, + RegularShape +} from "ol/style.js"; import VectorSource from "ol/source/Vector.js"; import Point from "ol/geom/Point.js"; import { bbox as bboxStrategy } from "ol/loadingstrategy"; @@ -47,6 +55,7 @@ BOTTLENECKISOLINE: "Bottleneck isolines", DISTANCEMARKS: "Distance marks", DISTANCEMARKSAXIS: "Distance marks, Axis", + GAUGES: "Gauges", DRAWTOOL: "Draw Tool", CUTTOOL: "Cut Tool" }; @@ -369,6 +378,39 @@ showInLegend: true }, { + name: LAYERS.GAUGES, + forLegendStyle: { point: true, resolution: 8 }, + data: new VectorLayer({ + source: new VectorSource({ + strategy: bboxStrategy + }), + style: function(feature) { + return new Style({ + image: new RegularShape({ + radius: 6, + fill: new Fill({ color: "rgba(255, 255, 0, 0.1)" }), + stroke: new Stroke({ color: "red", width: 1 }), + points: 3, + rotation: 0, + angle: 0 + }), + text: new Text({ + font: '10px "Open Sans", "sans-serif"', + offsetY: 10, + fill: new Fill({ + color: "black" + }), + text: feature.get("objname") + }) + }); + }, + maxResolution: 100, + minResolution: 0 + }), + isVisible: true, + showInLegend: true, + }, + { name: LAYERS.DRAWTOOL, data: new VectorLayer({ source: new VectorSource({ wrapX: false }), diff -r 86173ac7f222 -r bca9a7a89f28 schema/demo-data/published_services.sql --- a/schema/demo-data/published_services.sql Fri Mar 01 18:28:12 2019 +0100 +++ b/schema/demo-data/published_services.sql Fri Mar 01 18:28:50 2019 +0100 @@ -14,6 +14,7 @@ INSERT INTO sys_admin.published_services (name) VALUES ('waterway.stretches_geoserver'), ('waterway.fairway_dimensions'), + ('waterway.gauges_geoserver'), ('waterway.distance_marks_ashore_geoserver'), ('waterway.distance_marks_geoserver'), ('waterway.sounding_results_contour_lines_geoserver'), diff -r 86173ac7f222 -r bca9a7a89f28 schema/gemma.sql --- a/schema/gemma.sql Fri Mar 01 18:28:12 2019 +0100 +++ b/schema/gemma.sql Fri Mar 01 18:28:50 2019 +0100 @@ -252,6 +252,28 @@ value int NOT NULL ) + CREATE VIEW gauges_geoserver AS + SELECT + g.location, + isrs_asText(g.location) AS isrs_code, + g.objname, + g.geom, + g.applicability_from_km, + g.applicability_to_km, + g.validity, + g.zero_point, + g.geodref, + g.date_info, + g.source_organization, + json_strip_nulls(json_object_agg(coalesce(r.depth_reference,'empty'), + r.value)) + AS reference_water_levels + FROM gauges g LEFT JOIN LATERAL ( + SELECT gauge_id, depth_reference, value + FROM gauges_reference_water_levels + ) r ON r.gauge_id = g.location + GROUP BY g.location + CREATE TABLE gauge_measurements ( id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, fk_gauge_id isrs NOT NULL REFERENCES gauges, @@ -482,7 +504,7 @@ CHECK(ST_IsValid(CAST(area AS geometry))), surtyp varchar REFERENCES survey_types, coverage varchar REFERENCES coverage_types, - depth_reference varchar(4) NOT NULL REFERENCES depth_references, + depth_reference varchar(4) NOT NULL, -- REFERENCES depth_references, point_cloud geography(MULTIPOINTZ, 4326) NOT NULL CHECK(ST_IsSimple(CAST(point_cloud AS geometry))), octree_checksum varchar, @@ -630,6 +652,7 @@ -- Configure primary keys for geoserver views INSERT INTO waterway.gt_pk_metadata VALUES + ('waterway', 'gauges_geoserver', 'location'), ('waterway', 'distance_marks_geoserver', 'location_code'), ('waterway', 'distance_marks_ashore_geoserver', 'id'), ('waterway', 'bottlenecks_geoserver', 'id'), diff -r 86173ac7f222 -r bca9a7a89f28 schema/isrs_functions.sql --- a/schema/isrs_functions.sql Fri Mar 01 18:28:12 2019 +0100 +++ b/schema/isrs_functions.sql Fri Mar 01 18:28:50 2019 +0100 @@ -66,11 +66,8 @@ SELECT refgeom UNION -- Fill eventual gap - SELECT ST_MakeLine( - ST_ClosestPoint( - ST_Boundary(refgeom), ST_Boundary(geom)), - ST_ClosestPoint( - ST_Boundary(geom), ST_Boundary(refgeom))) + SELECT ST_ShortestLine( + ST_Boundary(refgeom), ST_Boundary(geom)) UNION -- Linestring to be added SELECT geom))) diff -r 86173ac7f222 -r bca9a7a89f28 schema/isrs_tests.sql --- a/schema/isrs_tests.sql Fri Mar 01 18:28:12 2019 +0100 +++ b/schema/isrs_tests.sql Fri Mar 01 18:28:50 2019 +0100 @@ -42,26 +42,24 @@ ) IS NULL, 'ISRSrange_area returns NULL, if given area does not intersect with axis'); -SELECT ok( - ST_DWithin( - (SELECT geom FROM waterway.distance_marks_virtual - WHERE location_code = ('AT', 'XXX', '00001', '00000', 0)::isrs), - ST_Boundary(ISRSrange_area(isrsrange( - ('AT', 'XXX', '00001', '00000', 0)::isrs, - ('AT', 'XXX', '00001', '00000', 1)::isrs), - (SELECT ST_Collect(CAST(area AS geometry)) - FROM waterway.waterway_area))), - 1) - AND - ST_DWithin( - (SELECT geom FROM waterway.distance_marks_virtual - WHERE location_code = ('AT', 'XXX', '00001', '00000', 1)::isrs), - ST_Boundary(ISRSrange_area(isrsrange( - ('AT', 'XXX', '00001', '00000', 0)::isrs, - ('AT', 'XXX', '00001', '00000', 1)::isrs), - (SELECT ST_Collect(CAST(area AS geometry)) - FROM waterway.waterway_area))), - 1), +SELECT results_eq($$ + SELECT every(ST_DWithin( + ST_Boundary(ISRSrange_area( + isrsrange( + ('AT', 'XXX', '00001', '00000', 0)::isrs, + ('AT', 'XXX', '00001', '00000', 1)::isrs), + (SELECT ST_Collect(CAST(area AS geometry)) + FROM waterway.waterway_area))), + geom, + 1)) + FROM waterway.distance_marks_virtual + WHERE location_code IN( + ('AT', 'XXX', '00001', '00000', 0)::isrs, + ('AT', 'XXX', '00001', '00000', 1)::isrs) + $$, + $$ + SELECT true + $$, 'Resulting polygon almost ST_Touches points corresponding to stretch'); \set test_area 'POLYGON((-1 1, 2 1, 2 -1, -1 -1, -1 1))' @@ -101,11 +99,22 @@ 4326))), 'Self-intersecting multipolygon leads to one polygon in result'); -SELECT ok( - ISRSrange_area( - isrsrange( +SELECT results_eq($$ + SELECT every(ST_DWithin( + ST_Boundary(ISRSrange_area( + isrsrange( + ('AT', 'XXX', '00001', '00000', 0)::isrs, + ('AT', 'XXX', '00001', '00000', 2)::isrs), + (SELECT ST_Collect(CAST(area AS geometry)) + FROM waterway.waterway_area))), + geom, + 1)) + FROM waterway.distance_marks_virtual + WHERE location_code IN( ('AT', 'XXX', '00001', '00000', 0)::isrs, - ('AT', 'XXX', '00001', '00000', 2)::isrs), - (SELECT ST_Collect(CAST(area AS geometry)) - FROM waterway.waterway_area)) IS NOT NULL, + ('AT', 'XXX', '00001', '00000', 2)::isrs) + $$, + $$ + SELECT true + $$, 'Area generated from non-matching distance mark and non-contiguous axis'); diff -r 86173ac7f222 -r bca9a7a89f28 schema/search_functions.sql --- a/schema/search_functions.sql Fri Mar 01 18:28:12 2019 +0100 +++ b/schema/search_functions.sql Fri Mar 01 18:28:50 2019 +0100 @@ -51,10 +51,30 @@ END; $$; +CREATE OR REPLACE FUNCTION search_gauges(search_string text) RETURNS jsonb + LANGUAGE plpgsql + AS $$ +DECLARE + _result jsonb; +BEGIN + SELECT COALESCE(json_agg(r),'[]') + INTO _result + FROM (SELECT objname AS name, + ST_AsGeoJSON(geom)::json AS geom, + 'gauge' AS type + FROM waterway.gauges + WHERE objname ILIKE '%' || search_string || '%' + ORDER BY name) r; + RETURN _result; +END; +$$; + CREATE OR REPLACE FUNCTION search_most(search_string text) RETURNS jsonb LANGUAGE plpgsql AS $$ BEGIN - RETURN search_bottlenecks(search_string) || search_cities(search_string); + RETURN search_bottlenecks(search_string) + || search_gauges(search_string) + || search_cities(search_string); END; $$;