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.StringBUFFERprotected static java.lang.StringBUFFER_UNITSprotected SpatialContextctxprotected ShapeFactoryshapeFactory
-
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.StringgetFormatName()Shaperead(java.io.Reader reader)Read aShapefrom the reader.Shaperead(java.lang.Object value)protected CirclereadCircle(org.noggit.JSONParser parser)protected voidreadCoordListXYZ(org.noggit.JSONParser parser, ShapeFactory.PointsBuilder pointsBuilder)protected voidreadCoordXYZ(org.noggit.JSONParser parser, ShapeFactory.PointsBuilder pointsBuilder)protected doublereadDistance(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.ShapereadIfSupported(java.lang.Object value)protected ShapereadLineString(org.noggit.JSONParser parser)protected ShapereadMultiLineString(org.noggit.JSONParser parser)protected ShapereadMultiPoint(org.noggit.JSONParser parser)protected ShapereadMultiPolygon(org.noggit.JSONParser parser)protected ShapereadPoint(org.noggit.JSONParser parser)protected ShapeFactory.PolygonBuilderreadPolygon(org.noggit.JSONParser parser, ShapeFactory.PolygonBuilder polygonBuilder)protected ShapereadShape(org.noggit.JSONParser parser)protected ShapereadShapeFromCoordinates(java.lang.String type, org.noggit.JSONParser parser)protected voidreadUntilEvent(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:
getFormatNamein 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:ShapeReaderRead aShapefrom the reader.- Specified by:
readin interfaceShapeReader- Parameters:
reader- -- the input. Note, it will not be closed by this function- Returns:
- a valid Shape (never null)
- Throws:
java.io.IOExceptionjava.text.ParseException
-
read
public Shape read(java.lang.Object value) throws java.io.IOException, java.text.ParseException, InvalidShapeException
- Specified by:
readin interfaceShapeReader- Parameters:
value- -- the input value, could be a String or other object- Returns:
- a shape valid shape (not null)
- Throws:
java.io.IOExceptionjava.text.ParseExceptionInvalidShapeException
-
readIfSupported
public Shape readIfSupported(java.lang.Object value) throws InvalidShapeException
- Specified by:
readIfSupportedin 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
InvalidShapeExceptionwhen 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.IOExceptionjava.text.ParseException
-
readCoordListXYZ
protected void readCoordListXYZ(org.noggit.JSONParser parser, ShapeFactory.PointsBuilder pointsBuilder) throws java.io.IOException, java.text.ParseException- Throws:
java.io.IOExceptionjava.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.IOExceptionjava.text.ParseException
-
readLineString
protected Shape readLineString(org.noggit.JSONParser parser) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOExceptionjava.text.ParseException
-
readCircle
protected Circle readCircle(org.noggit.JSONParser parser) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOExceptionjava.text.ParseException
-
readDistance
protected double readDistance(java.lang.String distProperty, java.lang.String distUnitsProperty, org.noggit.JSONParser parser) throws java.io.IOExceptionHelper 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.IOExceptionjava.text.ParseException
-
readShapeFromCoordinates
protected Shape readShapeFromCoordinates(java.lang.String type, org.noggit.JSONParser parser) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOExceptionjava.text.ParseException
-
readPolygon
protected ShapeFactory.PolygonBuilder readPolygon(org.noggit.JSONParser parser, ShapeFactory.PolygonBuilder polygonBuilder) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOExceptionjava.text.ParseException
-
readMultiPoint
protected Shape readMultiPoint(org.noggit.JSONParser parser) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOExceptionjava.text.ParseException
-
readMultiLineString
protected Shape readMultiLineString(org.noggit.JSONParser parser) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOExceptionjava.text.ParseException
-
readMultiPolygon
protected Shape readMultiPolygon(org.noggit.JSONParser parser) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOExceptionjava.text.ParseException
-
-