Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#1045 closed defect (worksforme)

TopologyException if I don't use ST_Dump to resolve single geometries before I do ST_Intersection

Reported by: Lars Aksel Opsahl Owned by: pramsey
Priority: medium Milestone: PostGIS 1.5.4
Component: postgis Version: master
Keywords: TopologyException ST_intersection ST_Dump Cc: lop@…

Description

I have a set of polygon's in table “tmp_test2.union_bestand_flate_covered” that that I use to find the difference from table “tmp_test2.dekning_omr_flate”. The result of this difference I use to do a intersection against tmp_test2.satskog_landsdekkende_flate.

The SQL below fails

SELECT
ST_Intersection(db2.non_covered,s.geo) dekn_sats
FROM (
SELECT
ST_Difference(d2.geo,db1.bestand_flate_covered) non_covered
FROM tmp_test2.union_bestand_flate_covered db1, tmp_test2.dekning_omr_flate d2
) as db2, tmp_test2.satskog_landsdekkende_flate s
where ST_Intersects(db2.non_covered,s.geo)

with the error

NOTICE: TopologyException: found non-noded intersection between LINESTRING (11.8148 64.517, 11.8056 64.5117) and LINESTRING (11.8076 64.5129, 11.809 64.51 3 ERROR: GEOS Intersection() threw an error!

Here is a SQL that works ok

SELECT
ST_Intersection(db2.non_covered,s.geo) dekn_sats
FROM (
SELECT
(ST_Dump(ST_Difference(d2.geo, db1.bestand_flate_covered))).geom as non_covered
FROM tmp_test2.union_bestand_flate_covered db1, tmp_test2.dekning_omr_flate d2
) as db2, tmp_test2.satskog_landsdekkende_flate s
where ST_Intersects(db2.non_covered,s.geo)

and I get the result below. 0103000020A21000000100000005000000AB505691D08627400E85D5077C205040B068C5E193862740B7954B9A7C205040ACCA75DE8E8627401DF1C3F87C205040E13EFD33D18627400749EDD0 27400E85D5077C205040 (1 row)

The function ST_Valid returns true for all involved polygons in all tables. The object tmp_test2.satskog_landsdekkende_flate is also valid, but the boundary of the polygon to intersect with itself. (From OpenGIS® Simple Features Specification, 3.3.2.9 Polygons (The Linear Rings in the boundary of a polygon may intersect at most at a single point but only as a tangent. ))

I run on the following versions of postgreSQL and postgis.

PostgreSQL 8.4.4 on x86_64-redhat-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48), 64-bit

POSTGIS="1.5.1" GEOS="3.2.2-CAPI-1.6.2" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.6.26" USE_STATS

In the file /tmp/tmp_test2.dump I have added all the tables that I use.

Lars

Attachments (1)

tmp_test2.dump (122.9 KB ) - added by Lars Aksel Opsahl 13 years ago.
This file contains all tables needed to reproduce the error described here.

Download all attachments as: .zip

Change History (6)

by Lars Aksel Opsahl, 13 years ago

Attachment: tmp_test2.dump added

This file contains all tables needed to reproduce the error described here.

comment:1 by Lars Aksel Opsahl, 13 years ago

Cc: lop@… added

comment:2 by dmiranda, 13 years ago

Version: 1.5.Xtrunk

I have a similar problem and I am getting the same error message when using st_union:

ERROR: GEOSUnionCascaded: TopologyException: found non-noded intersection between LINESTRING (-54.7158 -28.0099, -54.7156 -28.0116) and LINESTRING (-54.7158 -28.0099, -54.7158 -28.0119) at -54.7158 -28.0099

SQL state: XX000

BUT I have yet to find a reliable test case. If I dump a small subset of data, reload an try again, the task will complete just fine. The whole dataset is bigger than the upload limit of 5MB (if I dump and reload the entire dataset the message shows up again).

Ubuntu 11.04 Postgresql 9.1 postgis 2.0.0svn R7856 Last Changed Date: 2011-09-15 14:43:57 GEOS 3.4.0dev Rev: 3465 Last Changed Date: 2011-09-12 01:47:39

Does it have anything to do with #1173?

comment:3 by Lars Aksel Opsahl, 13 years ago

Here is the add add geometry collumns

insert into geometry_columns values(,'tmp_test2','dekning_omr_flate','geo',2,4258,'POLYGON'); insert into geometry_columns values(,'tmp_test2','union_bestand_flate_covered','geo',2,4258,'POLYGON'); insert into geometry_columns values(,'tmp_test2','union_bestand_flate_covered','bestand_flate_covered',2,4258,'POLYGON'); insert into geometry_columns values(,'tmp_test2','satskog_landsdekkende_flate','geo',2,4258,'POLYGON');

comment:4 by strk, 12 years ago

Resolution: worksforme
Status: newclosed

Works here with GEOS-3.3.2:

 POSTGIS="2.0.0SVN" GEOS="3.3.2dev-CAPI-1.7.2" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.6" USE_STATS

=# SELECT
ST_Summary(ST_Intersection(db2.non_covered,s.geo)) dekn_sats
FROM (
SELECT
ST_Difference(d2.geo,db1.bestand_flate_covered) non_covered
FROM tmp_test2.union_bestand_flate_covered db1, tmp_test2.dekning_omr_flate d2
) as db2, tmp_test2.satskog_landsdekkende_flate s
where ST_Intersects(db2.non_covered,s.geo)
;
        dekn_sats        
-------------------------
 Polygon[B] with 1 rings
    ring 0 has 5 points
 
(1 row)

What version of GEOS are you using ? Output of SELECT postgis_full_version().

comment:5 by Lars Aksel Opsahl, 12 years ago

Her is the output, I use a older geos and a older postgis. POSTGIS="1.5.3" GEOS="3.2.2-CAPI-1.6.2" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.6.26" USE_STATS (1 row)

Seems like I have to start to test postgis 2.0.

I just leave the bug closed and I will reopen it if fail's with postgis 2.0, but it seems to work for you.

Thanks Lars

Note: See TracTickets for help on using tickets.