@Test public void testMultiLineString() throws Exception { Map<String, Object> json = loadJSONResource("multilinestring.json"); MultiLineString geom = (MultiLineString) GeoJSONReader2.toGeometry(json); assertEquals(2, geom.getNumGeometries()); LineString ls1 = (LineString) geom.getGeometryN(0); LineString ls2 = (LineString) geom.getGeometryN(1); assertEquals(2, ls1.getNumPoints()); assertEquals(2, ls2.getNumPoints()); CoordinateSequence cs2 = ls2.getCoordinateSequence(); Coordinate c2 = cs2.getCoordinate(1); assertEquals(103.0, c2.x, 1e6); assertEquals(3.0, c2.y, 1e6); }
public static Geometry toGeometry(Map<String, Object> geometry) { String geomType = GeoJSONUtil.getString(geometry, GeoJSON.TYPE); if (geomType == null) { throw new IllegalArgumentException("Invalid geometry type"); } switch (geomType) { case GeoJSON.POINT: return toPoint(geometry); case GeoJSON.LINESTRING: return toLineString(geometry); case GeoJSON.POLYGON: return toPolygon(geometry); case GeoJSON.MULTI_POINT: return toMultiPoint(geometry); case GeoJSON.MULTI_LINESTRING: return toMultiLineString(geometry); case GeoJSON.MULTI_POLYGON: return toMultiPolygon(geometry); case GeoJSON.GEOMETRY_COLLECTION: return toGeometryCollection(geometry); } throw new IllegalArgumentException("Invalid geometry type"); }
GeoJSONReader2 { public static Geometry toGeometry(Map<String, Object> geometry) { String geomType = GeoJSONUtil.getString(geometry, GeoJSON.TYPE); if (geomType == null) { throw new IllegalArgumentException("Invalid geometry type"); } switch (geomType) { case GeoJSON.POINT: return toPoint(geometry); case GeoJSON.LINESTRING: return toLineString(geometry); case GeoJSON.POLYGON: return toPolygon(geometry); case GeoJSON.MULTI_POINT: return toMultiPoint(geometry); case GeoJSON.MULTI_LINESTRING: return toMultiLineString(geometry); case GeoJSON.MULTI_POLYGON: return toMultiPolygon(geometry); case GeoJSON.GEOMETRY_COLLECTION: return toGeometryCollection(geometry); } throw new IllegalArgumentException("Invalid geometry type"); } }
GeoJSONReader2 { public static Geometry toGeometry(Map<String, Object> geometry) { String geomType = GeoJSONUtil.getString(geometry, GeoJSON.TYPE); if (geomType == null) { throw new IllegalArgumentException("Invalid geometry type"); } switch (geomType) { case GeoJSON.POINT: return toPoint(geometry); case GeoJSON.LINESTRING: return toLineString(geometry); case GeoJSON.POLYGON: return toPolygon(geometry); case GeoJSON.MULTI_POINT: return toMultiPoint(geometry); case GeoJSON.MULTI_LINESTRING: return toMultiLineString(geometry); case GeoJSON.MULTI_POLYGON: return toMultiPolygon(geometry); case GeoJSON.GEOMETRY_COLLECTION: return toGeometryCollection(geometry); } throw new IllegalArgumentException("Invalid geometry type"); }  }
GeoJSONReader2 { public static Geometry toGeometry(Map<String, Object> geometry) { String geomType = GeoJSONUtil.getString(geometry, GeoJSON.TYPE); if (geomType == null) { throw new IllegalArgumentException("Invalid geometry type"); } switch (geomType) { case GeoJSON.POINT: return toPoint(geometry); case GeoJSON.LINESTRING: return toLineString(geometry); case GeoJSON.POLYGON: return toPolygon(geometry); case GeoJSON.MULTI_POINT: return toMultiPoint(geometry); case GeoJSON.MULTI_LINESTRING: return toMultiLineString(geometry); case GeoJSON.MULTI_POLYGON: return toMultiPolygon(geometry); case GeoJSON.GEOMETRY_COLLECTION: return toGeometryCollection(geometry); } throw new IllegalArgumentException("Invalid geometry type"); }  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 Geometry toGeometry(Map<String, Object> geometry) { String geomType = GeoJSONUtil.getString(geometry, GeoJSON.TYPE); if (geomType == null) { throw new IllegalArgumentException("Invalid geometry type"); } switch (geomType) { case GeoJSON.POINT: return toPoint(geometry); case GeoJSON.LINESTRING: return toLineString(geometry); case GeoJSON.POLYGON: return toPolygon(geometry); case GeoJSON.MULTI_POINT: return toMultiPoint(geometry); case GeoJSON.MULTI_LINESTRING: return toMultiLineString(geometry); case GeoJSON.MULTI_POLYGON: return toMultiPolygon(geometry); case GeoJSON.GEOMETRY_COLLECTION: return toGeometryCollection(geometry); } throw new IllegalArgumentException("Invalid geometry type"); }  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);  }