--
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+/* #define POSTGIS_TOPOLOGY_DEBUG 1 */
--{
--
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;
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');
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