]> granicus.if.org Git - postgis/commitdiff
Fix adding a splitting point into a 2.5d topology (#2033)
authorSandro Santilli <strk@keybit.net>
Fri, 5 Oct 2012 19:26:57 +0000 (19:26 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 5 Oct 2012 19:26:57 +0000 (19:26 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10381 b70326c6-7e19-0410-871a-916f4a2858ee

topology/sql/populate.sql.in.c
topology/test/regress/topogeo_addpoint.sql
topology/test/regress/topogeo_addpoint_expected

index 492e3606edf3463f28f8ef10b1f71979777181a4..4b0d1970e80efa1e95b7f6731d2ed1f0a080a625 100644 (file)
@@ -695,6 +695,7 @@ DECLARE
   snapedge GEOMETRY;
   snaptol FLOAT8;
   tol FLOAT8;
+  z FLOAT8;
 BEGIN
 
   -- 0. Check arguments
@@ -742,6 +743,12 @@ BEGIN
   IF rec IS NOT NULL THEN
     -- project point to line, split edge by point
     prj := ST_ClosestPoint(rec.geom, apoint);
+    -- This is a workaround for ClosestPoint lack of Z support:
+    -- http://trac.osgeo.org/postgis/ticket/2033
+    z := ST_Z(apoint);
+    IF z IS NOT NULL THEN
+      prj := ST_Translate(ST_Force_3DZ(prj), 0, 0, z); -- no ST_SetZ ...
+    END IF;
 #ifdef POSTGIS_TOPOLOGY_DEBUG
     RAISE DEBUG 'Splitting edge % with closest point %', rec.edge_id, ST_AsText(prj);
 #endif
index 7ea45693d6609bff3f870483a60bfddde87aaad2..5275ff535d4713da276ebefbb700c8a2be06f11a 100644 (file)
@@ -47,3 +47,10 @@ SELECT 'E', n.edge_id, n.start_node, n.end_node
 ORDER BY n.edge_id;
 
 SELECT DropTopology('city_data');
+
+-- See http://trac.osgeo.org/postgis/ticket/2033
+SELECT 'tt2033.start', CreateTopology('t',0,0,true) > 0;
+SELECT 'tt2033', 'E' || topogeo_addlinestring('t', 'LINESTRING(0 0 0,0 1 0,0 2 1)');
+SELECT 'tt2033', 'N' || topogeo_addpoint('t', 'POINT(0.2 1 1)', 0.5);
+SELECT 'tt2033', 'NC', node_id, ST_AsText(geom) FROM t.node ORDER BY node_id;
+SELECT 'tt2033.end' || DropTopology('t');
index a48f496dc338746348f17edd8bcfa6340fcf69a9..af6e614de2b4da6fbed450d872ab347db901d10b 100644 (file)
@@ -20,3 +20,10 @@ N|25||POINT(26 30)
 E|2|2|25
 E|27|25|2
 Topology 'city_data' dropped
+tt2033.start|t
+tt2033|E1
+tt2033|N3
+tt2033|NC|1|POINT Z (0 0 0)
+tt2033|NC|2|POINT Z (0 2 1)
+tt2033|NC|3|POINT Z (0 1 1)
+tt2033.endTopology 't' dropped