Opened 13 years ago

Closed 13 years ago

#1173 closed defect (wontfix)

TopologyException from intersection of valid geography

Reported by: jgilman Owned by: strk
Priority: medium Milestone: PostGIS 2.0.0
Component: postgis Version: master
Keywords: Cc:

Description

I have a polygon that wraps around the north pole. When I do an intersection with this polygon and a point below the equator I get a TopologyException.

SQL: select ST_AsText( ST_Intersection( ST_GeogFromText( 'SRID=4326;POLYGON((45 80,135 80,-135 80,-45 80,45 80))' ), ST_GeogFromText( 'SRID=4326;POINT(45 -70)' ) ) );

Result: NOTICE: TopologyException: found non-noded intersection between LINESTRING (5.00938e+06 1.54966e+07, 1.50281e+07 1.54966e+07) and LINESTRING (1.50281e+07 1.54966e+07, -1.50281e+07 1.54966e+07) at 5.00938e+06 1.54966e+07 CONTEXT: SQL function "st_intersection" statement 1 ERROR: GEOS Intersection() threw an error! CONTEXT: SQL function "st_intersection" statement 1

Change History (9)

comment:1 by jgilman, 13 years ago

It seems like this doesn't have to do with an equator at all. A point at 45 lon 60 lat, only 20 degrees south of the polygon fails the intersection as well.

select ST_AsText( ST_Intersection( ST_GeogFromText( 'SRID=4326;POLYGON((45 80,135 80,-135 80,-45 80,45 80))' ), ST_GeogFromText( 'SRID=4326;POINT(45 60)' ) ) );

comment:2 by jgilman, 13 years ago

I built PostGIS 2.0.0 from scratch in Ubuntu. It seems like the problem exists there as well. The error I get is just "ERROR: Error Performing Intersection" "CONTEXT: SQL function "st_intersection" statement 1"

comment:3 by dmiranda, 13 years ago

Version: 1.5.Xtrunk

I also confirm this problem. 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 #1045?

comment:4 by strk, 13 years ago

doesn't have to do with geography either, same exception with geometry. contrary to postgis-1.5, postgis-2.0 doesn't print the TopologyException value.

comment:5 by strk, 13 years ago

Owner: changed from pramsey to strk
Status: newassigned

comment:6 by strk, 13 years ago

r8445 fixes the message (but not the exception)

comment:7 by strk, 13 years ago

Resolution: invalid
Status: assignedclosed

The first operand is really invalid:

strk=# select ST_IsValid( 'POLYGON((45 80,135 80,-135 80,-45 80,45 80))' );
NOTICE:  Self-intersection at or near point -135 80
 st_isvalid 
------------
 f
(1 row)

comment:8 by jgilman, 13 years ago

Resolution: invalid
Status: closedreopened

The geography described by those points is not invalid. The documentation says that st_isvalid only works on geometry (not geography). http://postgis.refractions.net/docs/ST_IsValid.html As such it won't correctly validate the geography that I was using to demonstrate this problem. This is a polygon that wraps around the north pole which isn't possible as a geometry object in postgis but should be possible as geography.

comment:9 by pramsey, 13 years ago

Resolution: wontfix
Status: reopenedclosed

The problem is that the ST_Intersection function is not actually a geography implementation, it's a geography wrapper around a reprojection. And for sufficiently large objects the reprojection is into mercator which means you end up with an invalid geometry and boom, everything is over at that point. The answer is a more subtle hack in reprojection-wrappers for geography, I think.

Note: See TracTickets for help on using tickets.