#3467 closed defect (fixed)
OGRPolygon::PointOnSurface craches on self-intersecting polygon
Reported by: | ftrastour | Owned by: | chaitanya |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | OGR_SF | Version: | unspecified |
Severity: | normal | Keywords: | GEOS |
Cc: | warmerdam |
Description
The function OGRPolygon::PointOnSurface crashes on "butterfly" polygons ( self intersecting ). It crashes because the call to GEOSPointOnSurface returns null when the polygon is self intersecting ans the following createFromGEOS failed.
Here is a fix :
int OGRPolygon::PointOnSurface( OGRPoint *poPoint ) const { if( poPoint == NULL ) return OGRERR_FAILURE; #ifndef HAVE_GEOS return OGRERR_FAILURE; #else GEOSGeom hThisGeosGeom = NULL; GEOSGeom hOtherGeosGeom = NULL; hThisGeosGeom = exportToGEOS(); if( hThisGeosGeom != NULL ) { hOtherGeosGeom = GEOSPointOnSurface( hThisGeosGeom ); //Check if the function has find a such point. if( ! hOtherGeosGeom ) { // GEOSPointOnSurface sometimes failed on degenerated polygons. GEOSGeom_destroy( hThisGeosGeom ) ; return OGRERR_FAILURE ; } ...
Change History (6)
comment:1 by , 14 years ago
Cc: | added |
---|---|
Owner: | changed from | to
comment:2 by , 14 years ago
Keywords: | GEOS added |
---|---|
Milestone: | → 1.6.4 |
Status: | new → assigned |
comment:3 by , 14 years ago
Chaitanya,
here is a self intersecting WKT polygon :
POLYGON ((541777.73621003702 1789399.8326989261,541836.33734208031 1789280.1623735379,541867.88100016885 1789439.9155349836,541964.66262947978 1789325.2472433962,541777.73621003702 1789399.8326989261))
comment:4 by , 13 years ago
Added a test for centroid of butterfly polygon in trunk (r19981).
In any case, GEOS 3.1.1 has been returning non-null GEOSGeom objects in GEOSCentroid() and GEOSPointOnSurface() methods.
Currently PointOnSurface() method has neither C API interface nor python interface.
comment:5 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
Chaitanya,
Could you review and apply the suggested changes in trunk, 1.7 and 1.6 branches?
Frédéric,
Would it be possible for you to paste in the WKT for a polygon that triggers this? I'd like Chaitanya to add a test of this to the test suite.