Opened 10 years ago

Closed 10 years ago

#3356 closed defect (fixed)

OGR unreliability when detecting inner rings from outer rings for small polygons with big coordinates

Reported by: packalen Owned by: Even Rouault
Priority: normal Milestone: 1.7.1
Component: default Version: unspecified
Severity: major Keywords: multipolygon polygon shapefile
Cc: warmerdam, aki.suvanto@…

Description

Recent releases of GDAL/OGR recognize some multipolygons as polygons. This defect occur only with ESRI Shapefile driver. I have attached an example file which demonstrates this bug. The out.shp contains one multipolygon which is an outcome of intersection by OGR/GEOS. With GDAL 1.4.0.0

ogrinfo -al out.shp

recognizes the geometry correctly as MultiPolygon?, but with GDAL 1.7.0b2

ogrinfo -al out.shp

recognizes the geometry incorrectly as Polygon (incorrectly interior ring is outside of exterior ring). The same defect occur both under Windows and Linux.

Petteri

Attachments (1)

test_data.zip (1.8 KB) - added by packalen 10 years ago.

Download all attachments as: .zip

Change History (3)

Changed 10 years ago by packalen

Attachment: test_data.zip added

comment:1 Changed 10 years ago by Even Rouault

Owner: changed from warmerdam to Even Rouault
Status: newassigned

comment:2 Changed 10 years ago by Even Rouault

Cc: warmerdam added
Milestone: 1.7.1
Resolution: fixed
Status: assignedclosed
Summary: MultiPolygon vs. Polygon issue with ESRI Shapefile driverOGR unreliability when detecting inner rings from outer rings for small polygons with big coordinates

Ok, this turned out to be a very interesting problem. The way to detect inner and outer rings in polygons has changed a lot between GDAL 1.4 and 1.5 (or 1.6). The new code relied on an existing method to detect the winding order (clock wise or counter clock wise) which was subject to numerical instabilities with polygons that have a small area, but big coordinates, which is the case in your sample. As it also turned out that this algorithm was derived from the getArea() method, getArea() was wrongly returning 0 in that case.

The fix is the following :

Fixed in trunk in r18674. Tests added in r18675. Backported in 1.7 branch in r18676

Ticket to follow with similar issues (and fix :-)) in shapelib when writing a polygon...

Note: See TracTickets for help on using tickets.