Revision: 5436
          http://sourceforge.net/p/jump-pilot/code/5436
Author:   edso
Date:     2017-05-04 12:14:02 +0000 (Thu, 04 May 2017)
Log Message:
-----------
fix GEOJSON reading exception, when reading GeomColls

"
Caused by: com.vividsolutions.jts.io.ParseException: coordinates is not a list: 
{"type":"GeometryCollection","geometries":[...]}
"
https://sourceforge.net/p/jump-pilot/bugs/459/

Modified Paths:
--------------
    core/trunk/src/com/vividsolutions/jump/io/geojson/GeoJSONReader.java

Modified: core/trunk/src/com/vividsolutions/jump/io/geojson/GeoJSONReader.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/io/geojson/GeoJSONReader.java        
2017-04-16 12:15:18 UTC (rev 5435)
+++ core/trunk/src/com/vividsolutions/jump/io/geojson/GeoJSONReader.java        
2017-05-04 12:14:02 UTC (rev 5436)
@@ -280,18 +280,23 @@
       geometryFactory = (GeometryFactory) m2.invoke(this, geometryMap);
     }
 
-    Object coords = geometryMap.get(GeoJsonConstants.NAME_COORDINATES);
-    // are we a list of objects?
-    if (!(coords instanceof List))
-      throw new com.vividsolutions.jts.io.ParseException(
-          GeoJsonConstants.NAME_COORDINATES + " is not a list: "
-              + JSONObject.toJSONString(geometryMap));
-    // are we an empty list? OJ allows empty geometries, so do we
-    if (((List)coords).isEmpty()){
-      String type = (String) geometryMap.get(GeoJsonConstants.NAME_TYPE);
+    // GeomColls have no coord list, but list geoms instead, so we skip this
+    // test for them
+    if 
(!GeoJsonConstants.NAME_GEOMETRYCOLLECTION.equals(geometryMap.get(GeoJsonConstants.NAME_TYPE)))
 {
+      Object coords = geometryMap.get(GeoJsonConstants.NAME_COORDINATES);
+      // are we a list of objects?
+      if (!(coords instanceof List))
+        throw new com.vividsolutions.jts.io.ParseException(
+            GeoJsonConstants.NAME_COORDINATES + " is not a list: " + 
JSONObject.toJSONString(geometryMap));
+
+      // are we an empty list? OJ allows empty geometries, so do we
+      // TODO: we do not handle empty coord lists within GeomColls so far
+      if (((List) coords).isEmpty()) {
+        String type = (String) geometryMap.get(GeoJsonConstants.NAME_TYPE);
         return GeometryUtils.createEmptyGeometry(type, geometryFactory);
+      }
     }
-    
+
     return (Geometry) m.invoke(this, geometryMap, geometryFactory);
   }
 }


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to