Package org.locationtech.jts.io.geojson
Class GeoJsonReader
java.lang.Object
org.locationtech.jts.io.geojson.GeoJsonReader
Reads a GeoJson Geometry from a JSON fragment into a
Geometry.
A specification of the GeoJson format can be found at the GeoJson web site: http://geojson.org/geojson-spec.html.
It is the caller's responsibility to ensure that the supplied
PrecisionModel matches the precision of the incoming data. If a lower
precision for the data is required, a subsequent process must be run on the
data to reduce its precision.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor uses the SRID from the Geojson CRS and the defaultPrecisionModelto create aGeometryFactory.GeoJsonReader(GeometryFactory geometryFactory) This constructor accepts aGeometryFactorythat is used to create the output geometries and to override the GeoJson CRS. -
Method Summary
Modifier and TypeMethodDescriptionprivate Geometrycreate(Map<String, Object> geometryMap, GeometryFactory geometryFactory) private CoordinateSequencecreateCoordinate(List<Number> ordinates) private CoordinateSequencecreateCoordinateSequence(List<List<Number>> coordinates) private GeometrycreateGeometryCollection(Map<String, Object> geometryMap, GeometryFactory geometryFactory) private GeometrycreateLineString(Map<String, Object> geometryMap, GeometryFactory geometryFactory) private GeometrycreateMultiLineString(Map<String, Object> geometryMap, GeometryFactory geometryFactory) private GeometrycreateMultiPoint(Map<String, Object> geometryMap, GeometryFactory geometryFactory) private GeometrycreateMultiPolygon(Map<String, Object> geometryMap, GeometryFactory geometryFactory) private GeometrycreatePoint(Map<String, Object> geometryMap, GeometryFactory geometryFactory) private GeometrycreatePolygon(Map<String, Object> geometryMap, GeometryFactory geometryFactory) private GeometryFactorygetGeometryFactory(Map<String, Object> geometryMap) Reads a GeoJson Geometry from a String into a singleGeometry.
-
Field Details
-
gf
-
-
Constructor Details
-
GeoJsonReader
public GeoJsonReader()The default constructor uses the SRID from the Geojson CRS and the defaultPrecisionModelto create aGeometryFactory. If there is no CRS specified then the default CRS is a geographic coordinate reference system, using the WGS84 datum, and with longitude and latitude units of decimal degrees (SRID = 4326) -
GeoJsonReader
This constructor accepts aGeometryFactorythat is used to create the output geometries and to override the GeoJson CRS.- Parameters:
geometryFactory- a GeometryFactory
-
-
Method Details
-
read
Reads a GeoJson Geometry from a String into a singleGeometry.- Parameters:
json- The GeoJson String to parse- Returns:
- the resulting JTS Geometry
- Throws:
ParseException- throws a ParseException if the JSON string cannot be parsed
-
read
- Parameters:
reader- The input source- Returns:
- The resulting JTS Geometry
- Throws:
ParseException- throws a ParseException if the JSON string cannot be parsed
-
create
private Geometry create(Map<String, Object> geometryMap, GeometryFactory geometryFactory) throws ParseException- Throws:
ParseException
-
createGeometryCollection
private Geometry createGeometryCollection(Map<String, Object> geometryMap, GeometryFactory geometryFactory) throws ParseException- Throws:
ParseException
-
createMultiPolygon
private Geometry createMultiPolygon(Map<String, Object> geometryMap, GeometryFactory geometryFactory) throws ParseException- Throws:
ParseException
-
createMultiLineString
private Geometry createMultiLineString(Map<String, Object> geometryMap, GeometryFactory geometryFactory) throws ParseException- Throws:
ParseException
-
createMultiPoint
private Geometry createMultiPoint(Map<String, Object> geometryMap, GeometryFactory geometryFactory) throws ParseException- Throws:
ParseException
-
createPolygon
private Geometry createPolygon(Map<String, Object> geometryMap, GeometryFactory geometryFactory) throws ParseException- Throws:
ParseException
-
createLineString
private Geometry createLineString(Map<String, Object> geometryMap, GeometryFactory geometryFactory) throws ParseException- Throws:
ParseException
-
createPoint
private Geometry createPoint(Map<String, Object> geometryMap, GeometryFactory geometryFactory) throws ParseException- Throws:
ParseException
-
getGeometryFactory
- Throws:
ParseException
-
createCoordinateSequence
-
createCoordinate
-