Package com.spatial4j.core.io
Class GeoJSONReader
- java.lang.Object
-
- com.spatial4j.core.io.GeoJSONReader
-
- All Implemented Interfaces:
ShapeIO,ShapeReader
- Direct Known Subclasses:
JtsGeoJSONReader
public class GeoJSONReader extends Object implements ShapeReader
-
-
Constructor Summary
Constructors Constructor Description GeoJSONReader(SpatialContext ctx, SpatialContextFactory factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetFormatName()protected ShapemakeShapeFromCoords(String type, List coords)Shaperead(Reader reader)Read aShapefrom the reader.Shaperead(Object value)protected CirclereadCircle(org.noggit.JSONParser parser)List<?>readCoordinates(org.noggit.JSONParser parser)List<double[]>readCoordListXY(org.noggit.JSONParser parser)double[]readCoordXY(org.noggit.JSONParser parser)protected doublereadDistance(String distProperty, 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(Object value)protected ShapereadLineString(org.noggit.JSONParser parser)protected ShapereadPoint(org.noggit.JSONParser parser)protected ShapereadPolygon(org.noggit.JSONParser parser)This method takes a polygon and makes a bbox from it NOTE: not currently used! polygon is currently implemented in:makeShapeFromCoords(String, List)We could add a 'strict' or 'leinent' mode that would try the best it canShapereadShape(org.noggit.JSONParser parser)protected voidreadUntilEvent(org.noggit.JSONParser parser, int event)
-
-
-
Field Detail
-
BUFFER
protected static final String BUFFER
- See Also:
- Constant Field Values
-
BUFFER_UNITS
protected static final String BUFFER_UNITS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GeoJSONReader
public GeoJSONReader(SpatialContext ctx, SpatialContextFactory factory)
-
-
Method Detail
-
getFormatName
public String getFormatName()
- Specified by:
getFormatNamein interfaceShapeIO- Returns:
- the format name
-
read
public final Shape read(Reader reader) throws IOException, 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:
IOExceptionParseException
-
read
public Shape read(Object value) throws IOException, 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:
IOExceptionParseExceptionInvalidShapeException
-
readIfSupported
public Shape readIfSupported(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
-
readCoordinates
public List<?> readCoordinates(org.noggit.JSONParser parser) throws IOException, ParseException
- Throws:
IOExceptionParseException
-
readCoordXY
public double[] readCoordXY(org.noggit.JSONParser parser) throws IOException, ParseException- Throws:
IOExceptionParseException
-
readCoordListXY
public List<double[]> readCoordListXY(org.noggit.JSONParser parser) throws IOException, ParseException
- Throws:
IOExceptionParseException
-
readUntilEvent
protected void readUntilEvent(org.noggit.JSONParser parser, int event) throws IOException- Throws:
IOException
-
readPoint
protected Shape readPoint(org.noggit.JSONParser parser) throws IOException, ParseException
- Throws:
IOExceptionParseException
-
readLineString
protected Shape readLineString(org.noggit.JSONParser parser) throws IOException, ParseException
- Throws:
IOExceptionParseException
-
readCircle
protected Circle readCircle(org.noggit.JSONParser parser) throws IOException, ParseException
- Throws:
IOExceptionParseException
-
readDistance
protected double readDistance(String distProperty, String distUnitsProperty, org.noggit.JSONParser parser) throws 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:
IOException
-
readPolygon
protected Shape readPolygon(org.noggit.JSONParser parser) throws IOException, ParseException
This method takes a polygon and makes a bbox from it NOTE: not currently used! polygon is currently implemented in:makeShapeFromCoords(String, List)We could add a 'strict' or 'leinent' mode that would try the best it can- Throws:
ParseExceptionIOException
-
readShape
public Shape readShape(org.noggit.JSONParser parser) throws IOException, ParseException
- Throws:
IOExceptionParseException
-
-