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 , 13 years ago
comment:2 by , 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 , 13 years ago
Version: | 1.5.X → 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?
comment:4 by , 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 , 13 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:7 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
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 , 13 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
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 , 13 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
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.
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)' ) ) );