From: Sandro Santilli Date: Wed, 29 Feb 2012 15:59:14 +0000 (+0000) Subject: Check first point after snapping an edge to a new point (#1631) X-Git-Tag: 2.0.0beta1~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c19f7f94011ee5013fbd7ec19a4a91556cc80d7;p=postgis Check first point after snapping an edge to a new point (#1631) git-svn-id: http://svn.osgeo.org/postgis/trunk@9352 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/topology/sql/populate.sql.in.c b/topology/sql/populate.sql.in.c index 3d78ec3fa..4c7ec9220 100644 --- a/topology/sql/populate.sql.in.c +++ b/topology/sql/populate.sql.in.c @@ -14,6 +14,7 @@ -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +/* #define POSTGIS_TOPOLOGY_DEBUG 1 */ --{ -- @@ -713,6 +714,17 @@ BEGIN RAISE DEBUG 'Tolerance for snapping to point % = %', ST_AsText(prj), snaptol; #endif snapedge := ST_Snap(rec.geom, prj, snaptol); + + -- Snapping currently snaps the first point below tolerance + -- so may possibly move first point. See ticket #1631 + IF NOT ST_Equals(ST_StartPoint(rec.geom), ST_StartPoint(snapedge)) + THEN +#ifdef POSTGIS_TOPOLOGY_DEBUG + RAISE WARNING 'Snapping moved first edge vertex, fixing'; +#endif + snapedge := ST_MakeLine(ST_StartPoint(rec.geom), snapedge); + END IF; + #ifdef POSTGIS_TOPOLOGY_DEBUG IF NOT ST_Contains(snapedge, prj) THEN -- or if equal ? RAISE WARNING 'Edge within % distance from node still does not contain the node after snapping to it with tolerance %', tolerance, snaptol; diff --git a/topology/test/regress/topogeo_addlinestring.sql b/topology/test/regress/topogeo_addlinestring.sql index 564e9b4e9..1b92e4fbd 100644 --- a/topology/test/regress/topogeo_addlinestring.sql +++ b/topology/test/regress/topogeo_addlinestring.sql @@ -126,6 +126,22 @@ SELECT check_changes(); SELECT '#1613.2', TopoGeo_addLineString('city_data', 'LINESTRING(556250 144887, 556267 144887.07, 556310.04 144887)') ORDER BY 2; SELECT check_changes(); +-- See http://trac.osgeo.org/postgis/attachment/ticket/1631 + +-- clean all up first +DELETE FROM city_data.edge_data; +DELETE FROM city_data.node; +--DELETE FROM city_data.face; -- a bug forbids this (TODO: check what it is) + +SELECT '#1631.1', TopoGeo_addLineString('city_data', + 'LINESTRING(556267.56295432 144887.06663814,556267.566 144888)' +) ORDER BY 2; +SELECT check_changes(); +SELECT '#1631.2', TopoGeo_addLineString('city_data', + 'LINESTRING(556254.67 144886.62, 556267.66 144887.07)' +) ORDER BY 2; +SELECT check_changes(); + -- Cleanups DROP FUNCTION check_changes(); SELECT DropTopology('city_data'); diff --git a/topology/test/regress/topogeo_addlinestring_expected b/topology/test/regress/topogeo_addlinestring_expected index 0ed92a18b..e820ee739 100644 --- a/topology/test/regress/topogeo_addlinestring_expected +++ b/topology/test/regress/topogeo_addlinestring_expected @@ -108,4 +108,17 @@ E|51|sn46|en49 E|52|sn49|en47 E|53|sn48|en49 E|54|sn49|en50 +#1631.1|55 +N|51||POINT(556267.6 144887) +N|52||POINT(556267.6 144888) +E|55|sn51|en52 +#1631.2|57 +#1631.2|58 +N|53||POINT(556254.6 144886.6) +N|54||POINT(556267.6 144887) +N|55||POINT(556267.6 144887) +E|55|sn51|en54 +E|56|sn54|en52 +E|57|sn53|en54 +E|58|sn54|en55 Topology 'city_data' dropped