Opened 6 years ago

Closed 10 months ago

Last modified 10 months ago

#1946 closed defect (fixed)

'Spatial exception - geometry intersects edge 5' exception at adding 3 polygons

Reported by: wimned Owned by: strk
Priority: medium Milestone: PostGIS 2.5.0
Component: topology Version: trunk
Keywords: Cc:


The code:

 returns void as
    declare geom0 geometry;
    declare geom1 geometry;
    declare geom2 geometry;
    raise notice 'version: %', postgis_full_version();
    --perform CreateTopology('wimpy', 4326);
    perform CreateTopology('wimpy', 4326, 0.00001);

    geom0 = ST_GeometryFromText(
     'POLYGON((76.68554 30.74,76.68726 30.74248,
             76.69223 30.74157,76.68554 30.74))',4326);

    geom1 = ST_GeometryFromText(
     'POLYGON((76.68554 30.74,76.67933 30.75,
          76.68727 30.74249,76.68727 30.74248,
          76.68726 30.74248,76.68554 30.74))',4326);

    geom2 = ST_GeometryFromText(
     'POLYGON((76.68728 30.74248,76.68727 30.74248,
          76.68727 30.74249,76.67933 30.75,
          76.69223 30.74157,76.68728 30.74248))',4326);

    perform topogeo_AddPolygon('wimpy', geom0);
    perform topogeo_AddPolygon('wimpy', geom1);
    perform topogeo_AddPolygon('wimpy', geom2);
LANGUAGE plpgsql;

Raises the exception mentioned in the title.

Version printed is:

POSTGIS="2.1.0SVN r10156" GEOS="3.3.4-CAPI-1.7.3" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.8" TOPOLOGY

I want to use the software to cleanse some external area data.

That is why I use nonzero tolerance.

Code works well, when no tolerance is given.

Geometry of 'edge number 5' is

LINESTRING(76.67933 30.75,76.68727 30.74249,
             76.68727 30.74248,76.68726 30.74248)

Geometry of curve to be added:

LINESTRING(76.6872793512476 30.7424764568138,
               76.68727 30.74249,76.67933 30.75)

Change History (16)

comment:1 Changed 6 years ago by wimned

Did a workaround:

  • pass output of ST_SimplifyPreserveTopology() with tolerance 0.00001 to topogeo_AddPolygon()
  • after each topogeo_AddPolygon() I remove small polygons (when ST_IsEmpty(ST_Buffer(input_geom, -0.00005))). Remove by calling ST_RemEdgeModFace() with the longest edge of the face.
  • remove the nodes with exactly 2, different edges. for determining 'proper' longest edges, with ST_ModEdgeHeal()

comment:2 Changed 6 years ago by strk

Milestone: PostGIS 2.1.0PostGIS 2.0.2

Another case of snapping that breaks the code...

comment:3 Changed 6 years ago by strk

Milestone: PostGIS 2.0.2PostGIS 2.0.3

comment:4 Changed 5 years ago by pramsey

Milestone: PostGIS 2.0.4PostGIS 2.0.5

comment:5 Changed 4 years ago by pramsey

Milestone: PostGIS 2.0.5PostGIS 2.0.6

comment:6 Changed 3 years ago by strk

This seems to work with current trunk version (to become 2.2.0 as of r14155) but now with the tip of the 2.1 branch (to become 2.1.9 as of r14154). Can you confirm ?

I hadn't tried to figure out what changed between the two versions.

The summary of the topology built with 2.2.0dev is:

 Topology wimpy (id 2626, SRID 4326, precision 1e-05)+
 6 nodes, 9 edges, 4 faces, 0 topogeoms in 0 layers  +

comment:7 Changed 3 years ago by strk

Note that 1e-5 is ~ 1km with SRID=4326

comment:8 Changed 3 years ago by strk

Alright, I spotted the difference between 2.2 and 2.1. In 2.1, the "working tolerance" of topology is honoured: '1e-05', while in 2.2, the "working tolerance" is re-calculated as 2.76092028808593e-13

comment:9 Changed 3 years ago by strk

Ok, after fixing the regression in trunk, this case also fails with 2.2.0dev ... (see #3304). Handling of big tolerances is still an issue.

comment:10 Changed 3 years ago by strk

your workaround of pre-simplifying (or pre grid-snapping) is a good one

comment:11 Changed 3 years ago by pramsey

Milestone: PostGIS 2.0.7PostGIS 2.0.8

comment:12 Changed 11 months ago by pramsey

Milestone: PostGIS 2.0.8PostGIS 2.2.6

comment:13 Changed 10 months ago by pramsey

Milestone: PostGIS 2.2.6PostGIS 2.2.7

comment:14 Changed 10 months ago by strk

This issue is also solved by merging 0911624e7570fb026cea56772ac746e64bf3a457 from the pull-request associated with bug #3838

comment:15 Changed 10 months ago by strk

Resolution: fixed
Status: newclosed

In 16039:

Add test for topology bug #1946

Previous commits fix #1946 too

comment:16 Changed 10 months ago by strk

Milestone: PostGIS 2.2.7PostGIS 2.5.0
Note: See TracTickets for help on using tickets.