Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#1650 closed defect (fixed)

Invalid edge (no two distinct vertices exist)

Reported by: lrssvt Owned by: strk
Priority: medium Milestone: PostGIS 2.0.0
Component: topology Version: 2.0.x
Keywords: Cc:

Description

Running script toleranceDemoTopo.sql i get:

ERROR: Invalid edge (no two distinct vertices exist)
SQL state: P0001
Context: PL/pgSQL function "topogeo_addlinestring" line 147 at assignment
SQL statement "INSERT INTO test_topo.relation(topogeo_id, layer_id, element_type, element_id) SELECT 1, 1, 2, topogeo_addLineString('test_topo', '01020000201555000003000000329ABD50D7F92041C6FE24DDB5AF014159102D22D7F92041DDB54250BBAF0141FC05F508D7F9204144A619EEC2AF0141'::geometry, 2);"
PL/pgSQL function "totopogeom" line 120 at EXECUTE statement

i'm passing the value 2 as tolerance in CreateTopology function.

Attachments (3)

toleranceDemoTopo.sql (1.0 KB ) - added by lrssvt 12 years ago.
dongleNode.png (1.6 KB ) - added by lrssvt 12 years ago.
topoPipes.png (5.1 KB ) - added by lrssvt 12 years ago.

Download all attachments as: .zip

Change History (18)

by lrssvt, 12 years ago

Attachment: toleranceDemoTopo.sql added

comment:1 by strk, 12 years ago

One of your edges is shorter than 2, what do you think postgis should do in that case ?

=# select id, st_length(wkb_geometry) from test.pipes;
 id |    st_length     
----+------------------
  1 |  1.6405966228982
  2 | 129.304797905447
(2 rows)

I guess these are the options:

  1. Add _nothing_ to the topology, return a NULL TopoGeometry
  2. Add _nothing_ to the topology, return an EMPTY TopoGeometry
  3. Add a single node to the topology, return a NULL TopoGeometry
  4. Add a single node to the topology, return an EMPTY TopoGeometry
  5. Add a single node to the topology, return a Puntal TopoGeometry

Note that a Puntal TopoGeometry will fail to be inserted into a Lineal layer.

I'm not sure this is to be considered a bug.

comment:2 by strk, 12 years ago

For the record, shorter form:

select createTopology('tt');
select topogeo_addlinestring('tt', 'LINESTRING(0 0,0 1)', 2);

comment:3 by strk, 12 years ago

I'd pick 4. (Add a single node to the topology, return an EMPTY TopoGeometry)

in reply to:  3 comment:4 by lrssvt, 12 years ago

Replying to strk:

I'd pick 4. (Add a single node to the topology, return an EMPTY TopoGeometry)

yes! it is probably not a bug!

<future_development> you have to understand what the end user wants. In this direction, we can think of a GUI (like qgis plugin) in the future. Possibly with the addition of creating topologies for two related geometries (for example line and polygon), create rules and set the ranks! </future_development>

comment:5 by strk, 12 years ago

Resolution: fixed
Status: newclosed

r9407 implements returning EMPTY on collapsed edge. Future development discussion is welcome but better on the list (or separate ticket)

comment:6 by strk, 12 years ago

r9408 does it better, skipping _only_ the collapsed portion of a possibly multi-edge line

by lrssvt, 12 years ago

Attachment: dongleNode.png added

comment:7 by lrssvt, 12 years ago

I did test on r9408 and I get a dongle node:

I don't know if that is correct!

comment:8 by strk, 12 years ago

I can see that possibly happening, show the input, the tolerance and some measures as well ?

in reply to:  7 comment:9 by lrssvt, 12 years ago

Replying to lrssvt:

I did test on r9408 and I get a dongle node:

I don't know if that is correct!

ops, dongle = dangle!!!

comment:10 by strk, 12 years ago

The GEOS Snap operation could probably do something better than it does now, see: http://trac.osgeo.org/geos/ticket/501

by lrssvt, 12 years ago

Attachment: topoPipes.png added

in reply to:  8 comment:11 by lrssvt, 12 years ago

Replying to strk:

I can see that possibly happening, show the input, the tolerance and some measures as well ?

I simply run the attached script, I have not changed anything!

Topology (in red, edge and node) and Feature "pipes" (blue)

comment:12 by strk, 12 years ago

The vertical line is shorter than 2 units, which is the tolerance you are using. It collapses to a single point, which is added as expected (Add a single node to the topology, return an EMPTY TopoGeometry).

Then the horizontal line is added. I've to admit in this case the horizontal line should be snapped to the node… not sure why it isn't. Worth another ticket !

comment:13 by strk, 12 years ago

Resolution: fixed
Status: closedreopened

This is the query with unexpected result:

psql:toleranceDemoTopo.sql:18: DEBUG:  SELECT a.node_id FROM test_topo.node as a WHERE ST_DWithin(a.geom,'
010100002015550000BAF06A7E96F92041CD9B5862AAAF0141'::geometry,2) ORDER BY ST_Distance('010100002015550000B
AF06A7E96F92041CD9B5862AAAF0141'::geometry, a.geom) LIMIT 1;
psql:toleranceDemoTopo.sql:18: DEBUG:  No existing node within tolerance distance

I'd expect the node that belongs to the first edge to be within distance 2 instead !

comment:14 by strk, 12 years ago

Resolution: fixed
Status: reopenedclosed

Sorry, I take it back, that's not the query. I'll wait for a separate ticket to deal with this. It's about adding an edge failing to snap to an existing node. To reproduce: add one point, then add a line which is within tolerance distance from the point.

comment:15 by strk, 12 years ago

I filed a new ticket for the new case: #1654

Note: See TracTickets for help on using tickets.