From: Sandro Santilli Date: Fri, 5 Oct 2012 19:26:57 +0000 (+0000) Subject: Fix adding a splitting point into a 2.5d topology (#2033) X-Git-Tag: 2.1.0beta2~581 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7d6daaf5485bb47db4be374d72cfc6d95a20c165;p=postgis Fix adding a splitting point into a 2.5d topology (#2033) git-svn-id: http://svn.osgeo.org/postgis/trunk@10381 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/topology/sql/populate.sql.in.c b/topology/sql/populate.sql.in.c index 492e3606e..4b0d1970e 100644 --- a/topology/sql/populate.sql.in.c +++ b/topology/sql/populate.sql.in.c @@ -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 diff --git a/topology/test/regress/topogeo_addpoint.sql b/topology/test/regress/topogeo_addpoint.sql index 7ea45693d..5275ff535 100644 --- a/topology/test/regress/topogeo_addpoint.sql +++ b/topology/test/regress/topogeo_addpoint.sql @@ -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'); diff --git a/topology/test/regress/topogeo_addpoint_expected b/topology/test/regress/topogeo_addpoint_expected index a48f496dc..af6e614de 100644 --- a/topology/test/regress/topogeo_addpoint_expected +++ b/topology/test/regress/topogeo_addpoint_expected @@ -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