Ticket #1650 (closed defect: fixed)

Opened 15 months ago

Last modified 15 months ago

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

toleranceDemoTopo.sql Download (1.0 KB) - added by lrssvt 15 months ago.
dongleNode.png Download (1.6 KB) - added by lrssvt 15 months ago.
topoPipes.png Download (5.1 KB) - added by lrssvt 15 months ago.

Change History

Changed 15 months ago by lrssvt

  Changed 15 months ago by strk

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.

  Changed 15 months ago by strk

For the record, shorter form:

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

follow-up: ↓ 4   Changed 15 months ago by strk

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

in reply to: ↑ 3   Changed 15 months ago by lrssvt

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>

  Changed 15 months ago by strk

  • status changed from new to closed
  • resolution set to fixed

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

  Changed 15 months ago by strk

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

Changed 15 months ago by lrssvt

follow-up: ↓ 9   Changed 15 months ago by lrssvt

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

I don't know if that is correct!

follow-up: ↓ 11   Changed 15 months ago by strk

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

in reply to: ↑ 7   Changed 15 months ago by lrssvt

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!!!

  Changed 15 months ago by strk

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

Changed 15 months ago by lrssvt

in reply to: ↑ 8   Changed 15 months ago by lrssvt

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)

  Changed 15 months ago by strk

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 !

  Changed 15 months ago by strk

  • status changed from closed to reopened
  • resolution fixed deleted

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 !

  Changed 15 months ago by strk

  • status changed from reopened to closed
  • resolution set to fixed

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.

  Changed 15 months ago by strk

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

Note: See TracTickets for help on using tickets.