Opened 5 weeks ago

Last modified 5 weeks ago

#5797 new defect

TopoGeo_addPoint fails: end node not geometry end point

Reported by: strk Owned by: strk
Priority: medium Milestone: PostGIS 3.5.1
Component: topology Version: 3.5.x
Keywords: Cc:

Description

Testcase:

SELECT NULL FROM topology.CreateTopology ('topo');                                                                                                                                             
SELECT NULL FROM topology.TopoGeo_addLinestring('topo', 'LINESTRING(0 0, 5 1, 10 0)');                                                                                                         
SELECT NULL FROM topology.TopoGeo_addPoint('topo', 'POINT(9 5)', 5);       

Results in:

ERROR:  SQL/MM Spatial exception - end node not geometry end point.

PostGIS-3.4 is not affected, this is the code in the experimental edge merging.

Change History (2)

comment:1 by strk, 5 weeks ago

The problem is that the input point (9 5) is first projected to the existing edge and then the edge is snapped to it, effectively moving its last point.

comment:2 by strk, 5 weeks ago

Debug output:

psql:test0.sql:7: DEBUG:  [topo/lwgeom_topo.c:_lwt_AddPoint:6687] Adding point: POINT(9 5)
psql:test0.sql:7: DEBUG:  [topo/lwgeom_topo.c:_lwt_AddPoint:6763] New point is within 5 units of 1 edges
psql:test0.sql:7: DEBUG:  [topo/lwgeom_topo.c:_lwt_SplitAllEdgesToNewNode:6452] Edge 1 distance: 4.70678724331642
psql:test0.sql:7: DEBUG:  [topo/lwgeom_topo.c:_lwt_SplitAllEdgesToNewNode:6507] Projected point: POINT(8.076923076923077 0.384615384615385)
psql:test0.sql:7: DEBUG:  [topo/lwgeom_topo.c:_lwt_SplitAllEdgesToNewNode:6533] Splitting closest edge 1
psql:test0.sql:7: DEBUG:  [topo/lwgeom_topo.c:_lwt_SplitAllEdgesToNewNode:6543] Edge 1 does not contain projected point to it
psql:test0.sql:7: DEBUG:  [topo/lwgeom_topo.c:_lwt_toposnap:443] It took 1/1 iterations to properly snap
psql:test0.sql:7: DEBUG:  [topo/lwgeom_topo.c:_lwt_SplitAllEdgesToNewNode:6561] Edge snapped with tolerance 5
psql:test0.sql:7: DEBUG:  [topo/lwgeom_topo.c:_lwt_SplitAllEdgesToNewNode:6569] Edge LINESTRING(0 0,5 1,10 0) snapped became LINESTRING(0 0,5 1,8.076923076923077 0.384615384615385)
psql:test0.sql:7: DEBUG:  [topo/lwgeom_topo.c:_lwt_SplitAllEdgesToNewNode:6582] Edge first point is 0 0, snapline first point is 0 0
psql:test0.sql:7: DEBUG:  [topo/lwgeom_topo.c:_lwt_SplitAllEdgesToNewNode:6606] Snapping did not move first point
psql:test0.sql:7: DEBUG:  [topo/lwgeom_topo.c:lwt_ChangeEdgeGeom:3308] lwt_ChangeEdgeGeom: old edge has 3 points, new edge has 3 points
psql:test0.sql:7: ERROR:  SQL/MM Spatial exception - end node not geometry end point.

The code only checks for moving first point, not last point.

Note: See TracTickets for help on using tickets.