Ticket #1173 (closed defect: wontfix)

Opened 21 months ago

Last modified 16 months ago

TopologyException from intersection of valid geography

Reported by: jgilman Owned by: strk
Priority: medium Milestone: PostGIS 2.0.0
Component: postgis Version: trunk
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

Changed 21 months ago by jgilman

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)' ) ) );

Changed 21 months ago by jgilman

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"

Changed 20 months ago by dmiranda

  • version changed from 1.5.X to trunk

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?

Changed 17 months ago by strk

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.

Changed 17 months ago by strk

  • owner changed from pramsey to strk
  • status changed from new to assigned

Changed 17 months ago by strk

r8445 fixes the message (but not the exception)

Changed 17 months ago by strk

  • status changed from assigned to closed
  • resolution set to invalid

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)

Changed 17 months ago by jgilman

  • status changed from closed to reopened
  • resolution invalid deleted

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.

Changed 16 months ago by pramsey

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

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.