changeset 3640:10471aa73ad8 single-beam

Merged default into single-beam branch.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 12 Jun 2019 12:57:14 +0200
parents 2a4216c81e7b (current diff) 89a39783c20a (diff)
children 810b28f59b8b
files
diffstat 2 files changed, 53 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/identify/formatter.js	Wed Jun 12 12:56:18 2019 +0200
+++ b/client/src/components/identify/formatter.js	Wed Jun 12 12:57:14 2019 +0200
@@ -5,9 +5,10 @@
     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.key === "gm_measuredate"
+      (p.key === "date_info" ||
+        p.key === "fa_date_info" ||
+        p.key === "gm_measuredate") &&
+      p.val !== null
     ) {
       p.val = new Date(p.val).toLocaleString();
     }
@@ -57,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	Wed Jun 12 12:56:18 2019 +0200
+++ b/schema/geoserver_views.sql	Wed Jun 12 12:57:14 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,