changeset 2093:a9d28c489761

Waterway profile import: Do all the calculations in geography domain.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 01 Feb 2019 17:18:49 +0100
parents f70f67eaa7aa
children 7a3378c14397
files pkg/imports/wp.go
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/imports/wp.go	Fri Feb 01 17:03:28 2019 +0100
+++ b/pkg/imports/wp.go	Fri Feb 01 17:18:49 2019 +0100
@@ -78,7 +78,7 @@
 const (
 	createGeomTempTableSQL = `
 CREATE TEMP TABLE wp_geoms (
-  geom geometry(linestring, 4326)
+  geom geography(linestring, 4326)
 ) ON COMMIT DROP`
 
 	createTempIndexSQL = `
@@ -94,8 +94,8 @@
 	insertWaterwayProfileSQL = `
 WITH point AS (
   SELECT
-    ST_Buffer(geom::geometry, 0.0001) AS geom,
-    geom::geometry AS point
+    ST_Buffer(geom, 10) AS geom,
+    geom                AS point
   FROM waterway.distance_marks_virtual
   WHERE location_code =
     ($1::char(2), $2::char(3), $3::char(5), $4::char(5), $5::int)
@@ -113,10 +113,10 @@
   source_organization
 ) VALUES (
   ($1, $2, $3, $4, $5),
-  ( SELECT wp_geoms.geom::geography
+  ( SELECT wp_geoms.geom
     FROM wp_geoms, point
     WHERE wp_geoms.geom && point.geom
-    ORDER BY ST_Distance(point.point, wp_geoms.geom)
+    ORDER BY ST_Distance(point.point, wp_geoms.geom, true)
     LIMIT 1
   ),
   $6,