changeset 2517:ac61c250337b octree-diff

Merged default into octree-diff branch.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 05 Mar 2019 17:08:51 +0100
parents 1ec4c5633eb6 (current diff) 79f4a20e31c2 (diff)
children 2fa12229c946
files
diffstat 7 files changed, 103 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/Maplayer.vue	Tue Mar 05 17:08:16 2019 +0100
+++ b/client/src/components/Maplayer.vue	Tue Mar 05 17:08:51 2019 +0100
@@ -367,6 +367,20 @@
     );
     layer.data.setVisible(layer.isVisible);
 
+    layer = this.getLayerByName(LAYERS.BOTTLENECKSTATUS);
+    layer.data.getSource().setLoader(
+      this.buildVectorLoader(
+        {
+          featureNS: "gemma",
+          featurePrefix: "gemma",
+          featureTypes: ["bottlenecks_geoserver"],
+          geometryName: "area"
+        },
+        "/internal/wfs",
+        layer.data.getSource()
+      )
+    );
+
     layer = this.getLayerByName(LAYERS.BOTTLENECKS);
     layer.data.getSource().setLoader(
       this.buildVectorLoader(
@@ -385,22 +399,22 @@
       headers: { "X-Gemma-Auth": localStorage.getItem("token") }
     })
       .then(response => {
-        this.btlnStrokeC = response.data.code;
+        let btlnStrokeC = response.data.code;
         HTTP.get("/system/style/Bottlenecks/fill", {
           headers: { "X-Gemma-Auth": localStorage.getItem("token") }
         })
           .then(response => {
-            this.btlnFillC = response.data.code;
-            var newstyle = new Style({
+            let btlnFillC = response.data.code;
+            var newStyle = new Style({
               stroke: new Stroke({
-                color: this.btlnStrokeC,
+                color: btlnStrokeC,
                 width: 4
               }),
               fill: new Fill({
-                color: this.btlnFillC
+                color: btlnFillC
               })
             });
-            layer.data.setStyle(newstyle);
+            layer.data.setStyle(newStyle);
           })
           .catch(error => {
             console.log(error);
--- a/client/src/components/identify/formatter.js	Tue Mar 05 17:08:16 2019 +0100
+++ b/client/src/components/identify/formatter.js	Tue Mar 05 17:08:51 2019 +0100
@@ -1,8 +1,9 @@
 const formatter = {
   all(p) {
     if (p.key === "objnam") p.key = "Name";
-    if (p.key === "staging_done") p.val = p.val ? "yes" : "no";
-    if (p.key === "date_info") {
+    if (p.key === "staging_done" || p.key === "fa_critical")
+      p.val = p.val ? "yes" : "no";
+    if (p.key === "date_info" || p.key === "fa_date_info") {
       p.val = new Date(p.val).toLocaleString();
     }
     return p;
@@ -12,6 +13,8 @@
     props: p => {
       if (p.key === "bottleneck_id") p.key = "ID";
       if (p.key === "responsible_country") p.key = "Responsible Country";
+      if (p.key === "fa_date_info") p.key = "Fairway Date";
+      if (p.key === "fa_critical") p.key = "Fairway Critical";
 
       // remove certain props
       let propsToRemove = ["nobjnm", "reference_water_levels"];
--- a/client/src/components/layers/LegendElement.vue	Tue Mar 05 17:08:16 2019 +0100
+++ b/client/src/components/layers/LegendElement.vue	Tue Mar 05 17:08:51 2019 +0100
@@ -95,7 +95,8 @@
         }
         mapStyle = this.mapLayer.data.getStyleFunction()(
           feature,
-          this.mapLayer.forLegendStyle.resolution
+          this.mapLayer.forLegendStyle.resolution,
+          true
         );
       }
 
--- a/client/src/components/usermanagement/Usermanagement.vue	Tue Mar 05 17:08:16 2019 +0100
+++ b/client/src/components/usermanagement/Usermanagement.vue	Tue Mar 05 17:08:51 2019 +0100
@@ -172,6 +172,7 @@
     sortedUsers() {
       const start = (this.currentPage - 1) * this.pageSize;
       return this.users
+        .filter(u => u) // to clone the array and leave the original store value intact
         .sort((a, b) => {
           if (
             a[this.sortColumn].toLowerCase() < b[this.sortColumn].toLowerCase()
--- a/client/src/store/map.js	Tue Mar 05 17:08:16 2019 +0100
+++ b/client/src/store/map.js	Tue Mar 05 17:08:51 2019 +0100
@@ -52,6 +52,7 @@
   WATERWAYAXIS: "Waterway Axis",
   WATERWAYPROFILES: "Waterway Profiles",
   BOTTLENECKS: "Bottlenecks",
+  BOTTLENECKSTATUS: "Critical Bottlenecks",
   BOTTLENECKISOLINE: "Bottleneck isolines",
   DISTANCEMARKS: "Distance marks",
   DISTANCEMARKSAXIS: "Distance marks, Axis",
@@ -288,15 +289,17 @@
           source: new VectorSource({
             strategy: bboxStrategy
           }),
-          style: new Style({
-            stroke: new Stroke({
-              color: "rgba(230, 230, 10, .8)",
-              width: 4
-            }),
-            fill: new Fill({
-              color: "rgba(230, 230, 10, .3)"
-            })
-          })
+          style: function() {
+            return new Style({
+              stroke: new Stroke({
+                color: "rgba(230, 230, 10, .8)",
+                width: 4
+              }),
+              fill: new Fill({
+                color: "rgba(230, 230, 10, .3)"
+              })
+            });
+          }
         }),
         isVisible: true,
         showInLegend: true
@@ -330,6 +333,46 @@
         showInLegend: true
       },
       {
+        name: LAYERS.BOTTLENECKSTATUS,
+        forLegendStyle: { point: true, resolution: 16 },
+        data: new VectorLayer({
+          source: new VectorSource({
+            strategy: bboxStrategy
+          }),
+          style: function(feature, resolution, isLegend) {
+            if ((feature.get("fa_critical") && resolution > 15) || isLegend) {
+              let bnCenter = getCenter(feature.getGeometry().getExtent());
+              return new Style({
+                geometry: new Point(bnCenter),
+                image: new RegularShape({
+                  points: 3,
+                  radius: isLegend ? 9 : 13,
+                  fill: new Fill({ color: "white" }),
+                  stroke: new Stroke({
+                    color: "rgba(255, 0, 0, 0.8)",
+                    width: isLegend ? 2 : 3
+                  })
+                }),
+                text: new Text({
+                  font:
+                    "bold " +
+                    (isLegend ? 8 : 12) +
+                    'px "Open Sans", "sans-serif"',
+                  placement: "point",
+                  fill: new Fill({ color: "black" }),
+                  text: "!",
+                  offsetY: isLegend ? 0 : 1,
+                  offsetX: isLegend ? 1 : 0
+                })
+              });
+            }
+            return [];
+          }
+        }),
+        isVisible: true,
+        showInLegend: true
+      },
+      {
         name: LAYERS.DISTANCEMARKS,
         forLegendStyle: { point: true, resolution: 8 },
         data: new VectorLayer({
@@ -706,11 +749,21 @@
               hitTolerance: 7
             });
             if (features) {
-              commit("setIdentifiedFeatures", features);
+              let identifiedFeatures = [];
 
-              // get selected bottleneck from identified features
               for (let feature of features) {
                 let id = feature.getId();
+
+                // avoid identifying the same feature twice
+                if (
+                  identifiedFeatures.findIndex(
+                    f => f.getId() === feature.getId()
+                  ) === -1
+                ) {
+                  identifiedFeatures.push(feature);
+                }
+
+                // get selected bottleneck
                 // RegExp.prototype.test() works with number, str and undefined
                 if (/^bottlenecks/.test(id)) {
                   if (
@@ -738,6 +791,8 @@
                   }
                 }
               }
+
+              commit("setIdentifiedFeatures", identifiedFeatures);
             }
 
             // DEBUG output and example how to remove the GeometryName
--- a/schema/isrs_functions.sql	Tue Mar 05 17:08:16 2019 +0100
+++ b/schema/isrs_functions.sql	Tue Mar 05 17:08:51 2019 +0100
@@ -25,7 +25,11 @@
 -- Uses the table waterway.distance_marks_virtual to map ISRS location codes
 -- to their geo-location.
 -- Distance marks are assumed to be near the axis.
-CREATE OR REPLACE FUNCTION ISRSrange_axis(stretch isrsrange) RETURNS geometry
+CREATE OR REPLACE FUNCTION ISRSrange_axis(
+    stretch isrsrange,
+    tolerance float
+    -- in m, up to which linestrings will be connected at their boundary
+) RETURNS geometry
 AS $$
     WITH RECURSIVE
         -- Get coordinates of location codes
@@ -76,6 +80,8 @@
                     (SELECT ST_Collect(points.geom) AS pts
                         FROM points) AS points
                 WHERE id <> ALL(refids)
+                    AND ST_DWithin(
+                        ST_Boundary(refgeom), ST_Boundary(geom), tolerance)
                     AND NOT ST_Covers(ST_Buffer(refgeom, 0.0001), points.pts)
                 ORDER BY ST_Distance(ST_Boundary(refgeom), ST_Boundary(geom))
                 FETCH FIRST ROW ONLY)),
@@ -118,7 +124,7 @@
 AS $$
     WITH
         axis_substring AS (
-            SELECT ISRSrange_axis(stretch) AS line),
+            SELECT ISRSrange_axis(stretch, 5) AS line),
         utm_zone AS (
             SELECT best_utm(stretch) AS z),
         area_subset AS (
--- a/schema/tap_tests_data.sql	Tue Mar 05 17:08:16 2019 +0100
+++ b/schema/tap_tests_data.sql	Tue Mar 05 17:08:51 2019 +0100
@@ -94,7 +94,7 @@
     ST_SetSRID('LINESTRING(0.5 0.5, 1 1)'::geometry, 4326),
     'testriver'
 ), (
-    ST_SetSRID('LINESTRING(1.5 0.1, 2 0)'::geometry, 4326),
+    ST_SetSRID('LINESTRING(1.5 0.00001, 2 0)'::geometry, 4326),
     'testriver'
 );