@Test public void testComplexProperties() throws Exception { Map<String, Object> json = loadJSONResource("featureCollectionComplex.json"); CoordinateReferenceSystem crs84 = CRS.decode("EPSG:4326", true); SimpleFeatureType schema = GeoJSONSchemaDetector.getSchema(json, crs84); SimpleFeatureCollection fc = GeoJSONReader2.toFeatureCollection(json, schema); try (SimpleFeatureIterator it = fc.features()) { SimpleFeature f1 = it.hasNext() ? it.next() : null; SimpleFeature f2 = it.hasNext() ? it.next() : null; assertFalse(it.hasNext()); assertNotNull(f1); assertNotNull(f2); assertEquals("P_10000001", f1.getID()); assertEquals("P_10000002", f2.getID()); assertEquals(10000001, f1.getAttribute("placeId")); assertEquals(3, f1.getAttribute("placeVersionId")); assertEquals(1010110, f1.getAttribute("placeType")); assertEquals("M3233D4", f1.getAttribute("tm35MapSheet")); assertEquals("2008-12-05T22:00:00Z", f1.getAttribute("placeCreationTime")); assertNull(f1.getAttribute("placeNameDeletionTime")); Geometry expected = new WKTReader().read("POINT (21.3587384 61.3939013)"); assertEquals(expected, f1.getDefaultGeometry()); @SuppressWarnings("unchecked") List<Map<String, Object>> placenames = (List<Map<String, Object>>) f1.getAttribute("name"); assertEquals(1, placenames.size()); Map<String, Object> placename = placenames.get(0); assertEquals(40000001, placename.get("placeNameId")); assertEquals(1, placename.get("placeNameVersionId")); assertEquals("Isokloppa", placename.get("spelling")); assertEquals("fin", placename.get("language")); } }
public static SimpleFeatureCollection toFeatureCollection(Map<String, Object> json, SimpleFeatureType schema) { try { return toFeatureCollection(json, schema, null); } catch (MismatchedDimensionException | TransformException ignore) { throw new RuntimeException("Something bad happened"); } }
GeoJSONReader2 { public static SimpleFeatureCollection toFeatureCollection(Map<String, Object> json, SimpleFeatureType schema) { try { return toFeatureCollection(json, schema, null); } catch (MismatchedDimensionException | TransformException ignore) { throw new RuntimeException("Something bad happened"); } } }
GeoJSONReader2 { public static SimpleFeatureCollection toFeatureCollection(Map<String, Object> json, SimpleFeatureType schema) { try { return toFeatureCollection(json, schema, null); } catch (MismatchedDimensionException | TransformException ignore) { throw new RuntimeException("Something bad happened"); } }  }
GeoJSONReader2 { public static SimpleFeatureCollection toFeatureCollection(Map<String, Object> json, SimpleFeatureType schema) { try { return toFeatureCollection(json, schema, null); } catch (MismatchedDimensionException | TransformException ignore) { throw new RuntimeException("Something bad happened"); } }  static SimpleFeatureCollection toFeatureCollection(Map<String, Object> json, SimpleFeatureType schema); static SimpleFeatureCollection toFeatureCollection(Map<String, Object> json,
            SimpleFeatureType schema, MathTransform transform); static SimpleFeature toFeature(Map<String, Object> json, SimpleFeatureType schema); static SimpleFeature toFeature(Map<String, Object> json, SimpleFeatureType schema,
            MathTransform transform); static Geometry toGeometry(Map<String, Object> geometry); static Point toPoint(Map<String, Object> geometry); static LineString toLineString(Map<String, Object> geometry); static Polygon toPolygon(Map<String, Object> geometry); static MultiPoint toMultiPoint(Map<String, Object> geometry); static MultiLineString toMultiLineString(Map<String, Object> geometry); static MultiPolygon toMultiPolygon(Map<String, Object> geometry); static GeometryCollection toGeometryCollection(Map<String, Object> geometry); }
GeoJSONReader2 { public static SimpleFeatureCollection toFeatureCollection(Map<String, Object> json, SimpleFeatureType schema) { try { return toFeatureCollection(json, schema, null); } catch (MismatchedDimensionException | TransformException ignore) { throw new RuntimeException("Something bad happened"); } }  static SimpleFeatureCollection toFeatureCollection(Map<String, Object> json, SimpleFeatureType schema); static SimpleFeatureCollection toFeatureCollection(Map<String, Object> json,
            SimpleFeatureType schema, MathTransform transform); static SimpleFeature toFeature(Map<String, Object> json, SimpleFeatureType schema); static SimpleFeature toFeature(Map<String, Object> json, SimpleFeatureType schema,
            MathTransform transform); static Geometry toGeometry(Map<String, Object> geometry); static Point toPoint(Map<String, Object> geometry); static LineString toLineString(Map<String, Object> geometry); static Polygon toPolygon(Map<String, Object> geometry); static MultiPoint toMultiPoint(Map<String, Object> geometry); static MultiLineString toMultiLineString(Map<String, Object> geometry); static MultiPolygon toMultiPolygon(Map<String, Object> geometry); static GeometryCollection toGeometryCollection(Map<String, Object> geometry);  }