]> granicus.if.org Git - postgis/commitdiff
Check first point after snapping an edge to a new point (#1631)
authorSandro Santilli <strk@keybit.net>
Wed, 29 Feb 2012 15:59:14 +0000 (15:59 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 29 Feb 2012 15:59:14 +0000 (15:59 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9352 b70326c6-7e19-0410-871a-916f4a2858ee

topology/sql/populate.sql.in.c
topology/test/regress/topogeo_addlinestring.sql
topology/test/regress/topogeo_addlinestring_expected

index 3d78ec3fa3cae0fc88c3d9d9d4391bcf4b793c99..4c7ec9220991a84ee447051f10201dff97c18afe 100644 (file)
@@ -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;
index 564e9b4e9274bed200dd6b277614ed0766627a67..1b92e4fbd8863ddbba3fe6d1077b737c77ef07ff 100644 (file)
@@ -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');
index 0ed92a18b38309013f94b88390f579a926dc517f..e820ee73918c6642f7a4f9ea5044b40ceaf5fd33 100644 (file)
@@ -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