JSONArray polygons = geometryObj.getJSONArray("coordinates");
if( null == polygons ) {
throw new Exception("A geometry must contain an array called 'coordinates'");
}
MultiPolygon multiPolygon = new MultiPolygon();
for(int polyIndex=0,polyEnd=polygons.length(); polyIndex<polyEnd; ++polyIndex){
JSONArray lineStrings = polygons.getJSONArray(polyIndex);
Polygon polygon = new Polygon();
for(int lsIndex=0,lsEnd=lineStrings.length(); lsIndex<lsEnd; ++lsIndex){
JSONArray points = lineStrings.getJSONArray(lsIndex);
LineString lineString = new LineString();
for(int pointIndex=0,pointEnd=points.length(); pointIndex<pointEnd; ++pointIndex){
JSONArray coordinates = points.getJSONArray(pointIndex);
Point point = new Point();
for(int coordIndex=0,coordEnd=coordinates.length(); coordIndex<coordEnd; ++coordIndex){
double position = coordinates.getDouble(coordIndex);
point.addPosition(position);
}
lineString.addPoint(point);
}
polygon.addLinearRing(lineString);
}
multiPolygon.addPolygon(polygon);
}
return multiPolygon;
} catch(Exception e) {