changeset 922:1334756abb72

Merge
author Tom Gottfried <tom@intevation.de>
date Thu, 04 Oct 2018 19:13:48 +0200
parents 52cb0b82b490 (diff) 054561be4d68 (current diff)
children ec9c3a111bb7
files
diffstat 3 files changed, 21 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/cmd/octree2contour/main.go	Thu Oct 04 18:28:48 2018 +0200
+++ b/cmd/octree2contour/main.go	Thu Oct 04 19:13:48 2018 +0200
@@ -13,7 +13,8 @@
 
 var (
 	one        = flag.Bool("o", false, "create only a single contour")
-	step       = flag.Float64("s", 0.5, "step with")
+	step       = flag.Float64("s", 0.5, "step width")
+	tol        = flag.Float64("t", 0.1, "tolerance for simplification")
 	max        = flag.Float64("m", 10, "max height from lowest point")
 	bottleneck = flag.String("bottleneck", "", "bottleneck id")
 	date       = flag.String("date", "", "date info")
@@ -111,7 +112,7 @@
 		all := process(tree)
 		log.Printf("processing took: %v\n", time.Since(start))
 		start = time.Now()
-		if err = store(all, tree.EPSG, *bottleneck, dateInfo); err != nil {
+		if err = store(all, tree.EPSG, *bottleneck, dateInfo, *tol); err != nil {
 			log.Printf("error: %v\n", err)
 		}
 		log.Printf("storing took: %v\n", time.Since(start))
--- a/cmd/octree2contour/store.go	Thu Oct 04 18:28:48 2018 +0200
+++ b/cmd/octree2contour/store.go	Thu Oct 04 19:13:48 2018 +0200
@@ -26,15 +26,20 @@
   sr.id,
   $1,
   ST_Transform(
-    ST_Translate(
-      ST_Force3D(
-        ST_CollectionExtract(
-          ST_Force2D(
-            ST_Intersection(
-              ST_Transform(sr.area::geometry, $3::integer),
-              ST_SetSRID(
-                ST_GeomFromWKB($2), $3::integer))), 2)), 0.0, 0.0, $1::numeric),
-  4326)::geography
+    ST_Multi(
+      ST_CollectionExtract(
+        ST_Intersection(
+          ST_Transform(sr.area::geometry, $3::integer),
+          ST_SimplifyPreserveTopology(
+            ST_LineMerge(ST_Force2D(ST_GeomFromWKB($2, $3::integer))),
+            $6
+          )
+        ),
+        2
+      )
+    ),
+    4326
+  )
 FROM waterway.sounding_results sr
 WHERE bottleneck_id = $4 AND date_info = $5
 `
@@ -43,6 +48,7 @@
 func store(
 	all []result, epsg uint32,
 	bottleneck string, date time.Time,
+	tol float64,
 ) error {
 
 	return run(func(db *sql.DB) error {
@@ -66,6 +72,7 @@
 			if _, err := stmt.Exec(
 				r.h, r.lines.AsWKB(), epsg,
 				bottleneck, date,
+				tol,
 			); err != nil {
 				return err
 			}
--- a/schema/gemma.sql	Thu Oct 04 18:28:48 2018 +0200
+++ b/schema/gemma.sql	Thu Oct 04 19:13:48 2018 +0200
@@ -419,7 +419,7 @@
     CREATE TABLE sounding_results_contour_lines (
         sounding_result_id int NOT NULL REFERENCES sounding_results,
         height numeric NOT NULL,
-        lines geography(multilinestringz, 4326) NOT NULL,
+        lines geography(multilinestring, 4326) NOT NULL,
         UNIQUE (sounding_result_id, height)
     )
     -- A view to help geoserver serve contour lines.
@@ -428,7 +428,7 @@
         SELECT bottleneck_id,
                 date_info,
                 height,
-                CAST(lines AS geometry(multilinestringz, 4326)) AS lines
+                CAST(lines AS geometry(multilinestring, 4326)) AS lines
             FROM waterway.sounding_results_contour_lines cl
                 JOIN waterway.sounding_results sr
                     ON sr.id = cl.sounding_result_id