# HG changeset patch # User Sascha Wilde # Date 1551454104 -3600 # Node ID 960550ccca55d85c0fe331b50bfc342b2eb996d1 # Parent 7677a2850a2d7cee32e67d4a9133df891b58ee9d Added gauges layer. diff -r 7677a2850a2d -r 960550ccca55 client/src/components/Maplayer.vue --- a/client/src/components/Maplayer.vue Fri Mar 01 15:52:53 2019 +0100 +++ b/client/src/components/Maplayer.vue Fri Mar 01 16:28:24 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 7677a2850a2d -r 960550ccca55 client/src/store/map.js --- a/client/src/store/map.js Fri Mar 01 15:52:53 2019 +0100 +++ b/client/src/store/map.js Fri Mar 01 16:28:24 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 7677a2850a2d -r 960550ccca55 schema/demo-data/published_services.sql --- a/schema/demo-data/published_services.sql Fri Mar 01 15:52:53 2019 +0100 +++ b/schema/demo-data/published_services.sql Fri Mar 01 16:28:24 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 7677a2850a2d -r 960550ccca55 schema/gemma.sql --- a/schema/gemma.sql Fri Mar 01 15:52:53 2019 +0100 +++ b/schema/gemma.sql Fri Mar 01 16:28:24 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, @@ -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'),