changeset 3636:89a39783c20a

Add forecast and measurement quality parameters to sections and stretches
author Tom Gottfried <tom@intevation.de>
date Tue, 11 Jun 2019 20:32:25 +0200
parents 6d6577a87963
children 10471aa73ad8 6bb8def12f20 f9032442620a
files client/src/components/identify/formatter.js schema/geoserver_views.sql
diffstat 2 files changed, 49 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/identify/formatter.js	Tue Jun 11 20:28:38 2019 +0200
+++ b/client/src/components/identify/formatter.js	Tue Jun 11 20:32:25 2019 +0200
@@ -58,10 +58,22 @@
     label: "Waterway Profile"
   },
   stretches_geoserver: {
-    label: "Stretch"
+    label: "Stretch",
+    props: p => {
+      if (p.key === "gm_measuredate") p.key = "Min. Gauge Waterlevel Date";
+      if (p.key === "gm_n_14d") p.key = "Min. G.W. Count in Last 14 Days";
+
+      return p;
+    }
   },
   sections_geoserver: {
-    label: "Section"
+    label: "Section",
+    props: p => {
+      if (p.key === "gm_measuredate") p.key = "Min. Gauge Waterlevel Date";
+      if (p.key === "gm_n_14d") p.key = "Min. G.W. Count in Last 14 Days";
+
+      return p;
+    }
   },
   gauges_geoserver: {
     label: "Gauge",
--- a/schema/geoserver_views.sql	Tue Jun 11 20:28:38 2019 +0200
+++ b/schema/geoserver_views.sql	Tue Jun 11 20:32:25 2019 +0200
@@ -139,34 +139,46 @@
 
 CREATE OR REPLACE VIEW waterway.stretches_geoserver AS
     SELECT
-        id,
-        name,
-        (stretch).lower::varchar as lower,
-        (stretch).upper::varchar as upper,
-        area::Geometry(MULTIPOLYGON, 4326),
-        objnam,
-        nobjnam,
-        date_info,
-        source_organization,
+        s.id,
+        s.name,
+        (s.stretch).lower::varchar as lower,
+        (s.stretch).upper::varchar as upper,
+        s.area::Geometry(MULTIPOLYGON, 4326),
+        s.objnam,
+        s.nobjnam,
+        s.date_info,
+        s.source_organization,
         (SELECT string_agg(country_code, ', ')
             FROM waterway.stretch_countries
-            WHERE stretches_id = id) AS countries,
-        staging_done
-    FROM waterway.stretches;
+            WHERE stretches_id = s.id) AS countries,
+        s.staging_done,
+        min(g.gm_measuredate) AS gm_measuredate,
+        min(g.gm_n_14d) AS gm_n_14d,
+        max(g.forecast_accuracy_3d) AS forecast_accuracy_3d,
+        max(g.forecast_accuracy_1d) AS forecast_accuracy_1d
+    FROM waterway.stretches s
+        LEFT JOIN waterway.gauges_geoserver g ON g.location <@ s.stretch
+    GROUP BY s.id;
 
 CREATE OR REPLACE VIEW waterway.sections_geoserver AS
     SELECT
-        id,
-        name,
-        (section).lower::varchar as lower,
-        (section).upper::varchar as upper,
-        area::Geometry(MULTIPOLYGON, 4326),
-        objnam,
-        nobjnam,
-        date_info,
-        source_organization,
-        staging_done
-    FROM waterway.sections;
+        s.id,
+        s.name,
+        (s.section).lower::varchar as lower,
+        (s.section).upper::varchar as upper,
+        s.area::Geometry(MULTIPOLYGON, 4326),
+        s.objnam,
+        s.nobjnam,
+        s.date_info,
+        s.source_organization,
+        s.staging_done,
+        min(g.gm_measuredate) AS gm_measuredate,
+        min(g.gm_n_14d) AS gm_n_14d,
+        max(g.forecast_accuracy_3d) AS forecast_accuracy_3d,
+        max(g.forecast_accuracy_1d) AS forecast_accuracy_1d
+    FROM waterway.sections s
+        LEFT JOIN waterway.gauges_geoserver g ON g.location <@ s.section
+    GROUP BY s.id;
 
 CREATE OR REPLACE VIEW waterway.sounding_results_contour_lines_geoserver AS
     SELECT bottleneck_id,