Package org.apache.lucene.geo
Class SimpleGeoJSONPolygonParser
- java.lang.Object
-
- org.apache.lucene.geo.SimpleGeoJSONPolygonParser
-
class SimpleGeoJSONPolygonParser extends java.lang.ObjectDoes minimal parsing of a GeoJSON object, to extract either Polygon or MultiPolygon, either directly as the top-level type, or if the top-level type is Feature, as the geometry of that feature.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.Object>coordinates(package private) java.lang.Stringinputprivate java.lang.StringpolyTypeprivate intupto
-
Constructor Summary
Constructors Constructor Description SimpleGeoJSONPolygonParser(java.lang.String input)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static booleanisJSONWhitespace(char ch)private booleanisValidGeometryPath(java.lang.String path)Returns true if the object path is a valid location to see a Multi/Polygon geometryprivate java.text.ParseExceptionnewParseException(java.lang.String details)When calling this, upto should be at the position of the incorrect character!Polygon[]parse()private java.util.List<java.lang.Object>parseArray(java.lang.String path)private java.lang.NumberparseNumber()private voidparseObject(java.lang.String path)path is the "address" by keys of where we are, e.g.private double[][]parsePoints(java.util.List<java.lang.Object> o)Parses [[lat, lon], [lat, lon] ...] into 2d double arrayprivate PolygonparsePolygon(java.util.List<java.lang.Object> coordinates)private java.lang.StringparseString()private charpeek()private voidreadEnd()private voidscan(char expected)Scans across whitespace and consumes the expected character, or throwsParseExceptionif the character is wrongprivate voidscan(java.lang.String expected)Scans the expected string, or throwsParseException
-
-
-
Method Detail
-
parse
public Polygon[] parse() throws java.text.ParseException
- Throws:
java.text.ParseException
-
parseObject
private void parseObject(java.lang.String path) throws java.text.ParseExceptionpath is the "address" by keys of where we are, e.g. geometry.coordinates- Throws:
java.text.ParseException
-
isValidGeometryPath
private boolean isValidGeometryPath(java.lang.String path)
Returns true if the object path is a valid location to see a Multi/Polygon geometry
-
parsePolygon
private Polygon parsePolygon(java.util.List<java.lang.Object> coordinates) throws java.text.ParseException
- Throws:
java.text.ParseException
-
parsePoints
private double[][] parsePoints(java.util.List<java.lang.Object> o) throws java.text.ParseExceptionParses [[lat, lon], [lat, lon] ...] into 2d double array- Throws:
java.text.ParseException
-
parseArray
private java.util.List<java.lang.Object> parseArray(java.lang.String path) throws java.text.ParseException- Throws:
java.text.ParseException
-
parseNumber
private java.lang.Number parseNumber() throws java.text.ParseException- Throws:
java.text.ParseException
-
parseString
private java.lang.String parseString() throws java.text.ParseException- Throws:
java.text.ParseException
-
peek
private char peek() throws java.text.ParseException- Throws:
java.text.ParseException
-
scan
private void scan(char expected) throws java.text.ParseExceptionScans across whitespace and consumes the expected character, or throwsParseExceptionif the character is wrong- Throws:
java.text.ParseException
-
readEnd
private void readEnd() throws java.text.ParseException- Throws:
java.text.ParseException
-
scan
private void scan(java.lang.String expected) throws java.text.ParseExceptionScans the expected string, or throwsParseException- Throws:
java.text.ParseException
-
isJSONWhitespace
private static boolean isJSONWhitespace(char ch)
-
newParseException
private java.text.ParseException newParseException(java.lang.String details) throws java.text.ParseExceptionWhen calling this, upto should be at the position of the incorrect character!- Throws:
java.text.ParseException
-
-