Opened 6 years ago

Closed 6 years ago

#2172 closed defect (fixed)

Attempt to add antarctica main body twice fails second time

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


Topology created with no tolerance. Boundary of main body of antarctica (attached) gets added once with TopoGeo_addLineString, results in the creation of a single edge. When you try to add it once again you get:

ERROR:  Spatial exception - geometry intersects edge 1

This happens with:

POSTGIS="2.0.3SVN r10964" GEOS="3.4.0dev-CAPI-1.8.0 r3743" PROJ="Rel. 4.7.1, 23 September 2009" GDAL="GDAL 1.9dev, released 2011/01/18" LIBXML="2.7.8" TOPOLOGY RASTER
 PostgreSQL 8.4.15 on i686-pc-linux-gnu, compiled by GCC gcc-4.6.real (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 32-bit

NOTE: the same dataset on a 64bit linux WORKS FINE.

Another note: the projection is latlon so antarctica takes -180..180.

Attachments (1) (11.3 KB) - added by strk 6 years ago.

Download all attachments as: .zip

Change History (7)

Changed 6 years ago by strk

Attachment: added

comment:1 Changed 6 years ago by strk

So, one of the "shaking" operations that happen in this case is that the line, which is a _closed_ line, gets rotated to start at the leftmost vertex, due to union, difference, intersection operations performed.

After that we are left with _two_ edges to add, because the original first point was added as a node in the first insertion and now ends up splitting the geometry.

This occurrence isn't supposed to result in a problem later, but it's worth pointing out that the effect of it is that of inserting two edges rather than a single one, so not the same as adding the identical thing twice.

An effort could be made to reduce the shaking in these cases, but would still not fix the bug resulting from adding those two new edges (splitted on leftmost vertex).

comment:2 Changed 6 years ago by strk

The issue with rotation above reveals itself when splitting the existing edge by the point (which is supposedly an existing vertex of the geometry). In particular, splitting the edge by point POINT(-180 -90) and unioning the resulting edges gives a line which is not equal to the original edge

comment:3 Changed 6 years ago by strk

In other words, assuming your closed linestring is put in a table called "offending" and a field called "geom", the following query returns FALSE:

select st_equals(
    st_geometryn(st_split(geom, st_pointn(geom,745)), 1),
    st_geometryn(st_split(geom, st_pointn(geom,745)), 2)
) from offending;

Note that we are passing a vertex point to ST_Split !

comment:4 Changed 6 years ago by strk

See #2173 for a spinoff of this bug (the ST_Split part)

comment:5 Changed 6 years ago by strk

With the fix in ST_Split (#2173) this bug is also closed.

comment:6 Changed 6 years ago by strk

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.