Opened 14 years ago

Closed 14 years ago

#780 closed defect (fixed)

Topology: adding a node over an edge fails to raise an exception

Reported by: aperi2007 Owned by: strk
Priority: medium Milestone: PostGIS 2.0.0
Component: topology Version: master
Keywords: Cc:

Description

I noitce that adding a new node over a vertex of a pre-existent edge seem don't split it.

select topology.AddEdge('schema_topo',ST_GeomFromEWKT('SRID=3003;LINESTRING(4 4, 5 5, 6 6)')); select topology.AddNode('schema_topo',ST_GeomFromEWKT('SRID=3003;POINT(5 5)'));

I think starting from EDGE(4 4,5 5,6 6) and adding a node in 5 5 it could split the edge in edge(4 4, 5 5) + edge (5 5, 6 6)

Change History (8)

comment:1 by aperi2007, 14 years ago

Type: enhancementdefect

This could be an error because the code try to raise an exception.

— Check if any edge crosses this node — (endpoints are fine) — FOR rec IN EXECUTE 'SELECT edge_id FROM '

quote_ident(atopology) '.edge '
'WHERE ST_Crosses(' quote_literal(apoint::text)
', geom)'

LOOP

RAISE EXCEPTION 'An edge crosses the given node.';

END LOOP;

I don't know why this exception don't raise. however change from enhancement to defect the ticket.

comment:2 by robe, 14 years ago

Strk,

Can a point ever cross a linestring. I think as the definition goes — its only considered crossing if they share points but not all the points are fully contained in the other. How can that ever be the case with a point and linestring.

e.g.

SELECT ST_Crosses('LINESTRING(1 2, 3 4, 5 6)'::geometry, 'POINT(3 4)'::geometry);
SELECT ST_Crosses('POINT(3 4)'::geometry, 'LINESTRING(1 2, 3 4, 5 6)'::geometry);

both return false.

But this returns true:

SELECT ST_Crosses('MULTIPOINT(3 4, 9 9)'::geometry, 'LINESTRING(1 2, 3 4, 5 6)'::geometry);

See manual description — which Kevin had written up. Though we should probably have an example of the point case.

http://www.postgis.org/documentation/manual-svn/ST_Crosses.html

comment:3 by strk, 14 years ago

Status: newassigned

yep, bug bug bug. it's impressive I haven't added such a case in the wonderful regress testing I'm growing. Good catch Andrea !

comment:4 by strk, 14 years ago

Summary: Topology: adding a node over an edge could split the edge.Topology: adding a node over an edge fails to raise an exception

Oh, for the "could split the edge" idea I'd like to have a broader and consistent plan involving also AddEdge and AddFace. In particular, these functions are currently returning the identifier of the primitive found or added. It's a single identifier, so, if we go for splitting… AddEdge interface would need to change as the return might not fit anymore a single identifier (if the edge has to be splitted)

comment:5 by robe, 14 years ago

strk,

If we implement the split feature — I think we should call it something else or at least have it take an additional argument. I forsee some cases where a user does this and didn't intend to. They would prefer an error thrown in that case. It would be better to force the user to state the intention for this I think and also keeps your AddEdge/AddFace clean.

in reply to:  5 comment:6 by aperi2007, 14 years ago

Replying to robe:

strk,

If we implement the split feature — I think we should call it something else or at least have it take an additional argument. I forsee some cases where a user does this and didn't intend to. They would prefer an error thrown in that case. It would be better to force the user to state the intention for this I think and also keeps your AddEdge/AddFace clean.

+1

comment:7 by strk, 14 years ago

agreed. Note there are a couple of ISO-dictated ST_NewEdgesSplit and ST_ModEdgesSplit functions for explicitly splitting an edge with a node.

comment:8 by strk, 14 years ago

Resolution: fixed
Status: assignedclosed

Fixed with r6659

Note: See TracTickets for help on using tickets.