Opened 7 years ago

Closed 7 years ago

#5538 closed defect (fixed)

OGR JSON reader does not process ArcGIS Polygons correctly

Reported by: jpalmer Owned by: warmerdam
Priority: normal Milestone: 1.11.2
Component: default Version: svn-trunk
Severity: normal Keywords: JSON GEOJSON
Cc: Mateusz Łoskot, Even Rouault

Description

The GeoJSON driver (which also reads Esri JSON) does not correctly process polygon rings and creates invalid OGC polygons.

Example:

ogrinfo -dialect sqlite -sql "SELECT TA2013_V1_00_NAME, ST_IsValid(GEOMETRY) FROM OGRGeoJSON" http://maps.stats.govt.nz/wss/service/arcgis1/guest/Boundaries/2013_Geographies/MapServer/9/query?f=json&objectIds=36&returnGeometry=true&outSR=4167

returns

GEOS warning: Hole lies outside shell at or near point 174.78189611685229 -41.077770200471164

Layer name: SELECT
Geometry: None
Feature Count: 1
Layer SRS WKT:

(unknown)

TA2013_V1_00_NAME: String (0.0)
ST_IsValid(GEOMETRY): Integer (0.0)

OGRFeature(SELECT):0
  TA2013_V1_00_NAME (String) = Porirua City
  ST_IsValid(GEOMETRY) (Integer) = 0


The Esri docs state that polygons can have any number of rings, either exterior or interior. Exterior rings are oriented clockwise, while holes are oriented counter-clockwise.

http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r3000000n1000000

I think the OGR driver should be improved to check for this. If more than one exterior ring is found then an OGC multi-polygon geometry object should be returned.

Change History (3)

comment:1 Changed 7 years ago by Mateusz Łoskot

Cc: Mateusz Łoskot added

comment:2 Changed 7 years ago by jpalmer

Cc: Even Rouault added

From Even:

Looking at the ogresrijsonreader.cpp code I can see I assumed that a esriPolygon was just a OGC Polygon, so with outer ring first and then inner rings. Fixing the code to support multi polygons should basically be a matter of calling OGRGeometryFactory::organizePolygon

comment:3 Changed 7 years ago by Even Rouault

Milestone: 2.01.11.2
Resolution: fixed
Status: newclosed

trunk r28349, branches/1.11 r28350 "ESRIJson: parse correctly rings of esriGeometryPolygon objects to build correct Polygon or MultiPolygon? (#5538)"

Note: See TracTickets for help on using tickets.