Package org.locationtech.spatial4j.io
Class GeoJSONReader
- java.lang.Object
-
- org.locationtech.spatial4j.io.GeoJSONReader
-
- All Implemented Interfaces:
ShapeIO
,ShapeReader
public class GeoJSONReader extends java.lang.Object implements ShapeReader
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
BUFFER
protected static java.lang.String
BUFFER_UNITS
protected SpatialContext
ctx
protected ShapeFactory
shapeFactory
-
Constructor Summary
Constructors Constructor Description GeoJSONReader(SpatialContext ctx, SpatialContextFactory factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getFormatName()
Shape
read(java.io.Reader reader)
Read aShape
from the reader.Shape
read(java.lang.Object value)
protected Circle
readCircle(org.noggit.JSONParser parser)
protected void
readCoordListXYZ(org.noggit.JSONParser parser, ShapeFactory.PointsBuilder pointsBuilder)
protected void
readCoordXYZ(org.noggit.JSONParser parser, ShapeFactory.PointsBuilder pointsBuilder)
protected double
readDistance(java.lang.String distProperty, java.lang.String distUnitsProperty, org.noggit.JSONParser parser)
Helper method to read a up until a distance value (radius, buffer) and it's corresponding unit are found.Shape
readIfSupported(java.lang.Object value)
protected Shape
readLineString(org.noggit.JSONParser parser)
protected Shape
readMultiLineString(org.noggit.JSONParser parser)
protected Shape
readMultiPoint(org.noggit.JSONParser parser)
protected Shape
readMultiPolygon(org.noggit.JSONParser parser)
protected Shape
readPoint(org.noggit.JSONParser parser)
protected ShapeFactory.PolygonBuilder
readPolygon(org.noggit.JSONParser parser, ShapeFactory.PolygonBuilder polygonBuilder)
protected Shape
readShape(org.noggit.JSONParser parser)
protected Shape
readShapeFromCoordinates(java.lang.String type, org.noggit.JSONParser parser)
protected void
readUntilEvent(org.noggit.JSONParser parser, int event)
-
-
-
Field Detail
-
BUFFER
protected static final java.lang.String BUFFER
- See Also:
- Constant Field Values
-
BUFFER_UNITS
protected static final java.lang.String BUFFER_UNITS
- See Also:
- Constant Field Values
-
ctx
protected final SpatialContext ctx
-
shapeFactory
protected final ShapeFactory shapeFactory
-
-
Constructor Detail
-
GeoJSONReader
public GeoJSONReader(SpatialContext ctx, SpatialContextFactory factory)
-
-
Method Detail
-
getFormatName
public java.lang.String getFormatName()
- Specified by:
getFormatName
in interfaceShapeIO
- Returns:
- the format name
-
read
public final Shape read(java.io.Reader reader) throws java.io.IOException, java.text.ParseException
Description copied from interface:ShapeReader
Read aShape
from the reader.- Specified by:
read
in interfaceShapeReader
- Parameters:
reader
- -- the input. Note, it will not be closed by this function- Returns:
- a valid Shape (never null)
- Throws:
java.io.IOException
java.text.ParseException
-
read
public Shape read(java.lang.Object value) throws java.io.IOException, java.text.ParseException, InvalidShapeException
- Specified by:
read
in interfaceShapeReader
- Parameters:
value
- -- the input value, could be a String or other object- Returns:
- a shape valid shape (not null)
- Throws:
java.io.IOException
java.text.ParseException
InvalidShapeException
-
readIfSupported
public Shape readIfSupported(java.lang.Object value) throws InvalidShapeException
- Specified by:
readIfSupported
in interfaceShapeReader
- Parameters:
value
- -- the input value, could be a String or other object- Returns:
- a shape or null, if the input was un readable.
This will throw
InvalidShapeException
when we could read a shape, but it was invalid - Throws:
InvalidShapeException
-
readCoordXYZ
protected void readCoordXYZ(org.noggit.JSONParser parser, ShapeFactory.PointsBuilder pointsBuilder) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOException
java.text.ParseException
-
readCoordListXYZ
protected void readCoordListXYZ(org.noggit.JSONParser parser, ShapeFactory.PointsBuilder pointsBuilder) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOException
java.text.ParseException
-
readUntilEvent
protected void readUntilEvent(org.noggit.JSONParser parser, int event) throws java.io.IOException
- Throws:
java.io.IOException
-
readPoint
protected Shape readPoint(org.noggit.JSONParser parser) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOException
java.text.ParseException
-
readLineString
protected Shape readLineString(org.noggit.JSONParser parser) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOException
java.text.ParseException
-
readCircle
protected Circle readCircle(org.noggit.JSONParser parser) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOException
java.text.ParseException
-
readDistance
protected double readDistance(java.lang.String distProperty, java.lang.String distUnitsProperty, org.noggit.JSONParser parser) throws java.io.IOException
Helper method to read a up until a distance value (radius, buffer) and it's corresponding unit are found.This method returns 0 if no distance value is found. This method currently only handles distance units of "km".
- Parameters:
distProperty
- The name of the property containing the distance value.distUnitsProperty
- The name of the property containing the distance unit.- Throws:
java.io.IOException
-
readShape
protected Shape readShape(org.noggit.JSONParser parser) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOException
java.text.ParseException
-
readShapeFromCoordinates
protected Shape readShapeFromCoordinates(java.lang.String type, org.noggit.JSONParser parser) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOException
java.text.ParseException
-
readPolygon
protected ShapeFactory.PolygonBuilder readPolygon(org.noggit.JSONParser parser, ShapeFactory.PolygonBuilder polygonBuilder) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOException
java.text.ParseException
-
readMultiPoint
protected Shape readMultiPoint(org.noggit.JSONParser parser) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOException
java.text.ParseException
-
readMultiLineString
protected Shape readMultiLineString(org.noggit.JSONParser parser) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOException
java.text.ParseException
-
readMultiPolygon
protected Shape readMultiPolygon(org.noggit.JSONParser parser) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOException
java.text.ParseException
-
-