Package org.apache.lucene.geo
Class SimpleWKTShapeParser
- java.lang.Object
-
- org.apache.lucene.geo.SimpleWKTShapeParser
-
public class SimpleWKTShapeParser extends java.lang.ObjectParses shape geometry represented in WKT format complies with OGC® document: 12-063r5 and ISO/IEC 13249-3:2016 standard located at http://docs.opengeospatial.org/is/12-063r5/12-063r5.html
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSimpleWKTShapeParser.ShapeTypeEnumerated type for Shapes
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCOMMAstatic java.lang.StringEMPTYprivate static java.lang.StringEOFprivate static java.lang.StringEOLstatic java.lang.StringLPARENstatic java.lang.StringNANprivate static java.lang.StringNUMBERstatic java.lang.StringRPARENstatic java.lang.StringSPACE
-
Constructor Summary
Constructors Modifier Constructor Description privateSimpleWKTShapeParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static voidcheckEOF(java.io.StreamTokenizer stream)next word in the streamprivate static booleanisNumberNext(java.io.StreamTokenizer stream)checks if the next token is a numberprivate static java.lang.StringnextCloser(java.io.StreamTokenizer stream)checks if next token is a closing parenprivate static java.lang.StringnextCloserOrComma(java.io.StreamTokenizer stream)expects either a closing LPAREN or comma as the next tokenprivate static java.lang.StringnextComma(java.io.StreamTokenizer stream)expects a comma as next tokenprivate static java.lang.StringnextEmptyOrOpen(java.io.StreamTokenizer stream)checks if next token is an EMPTY or open parenprivate static doublenextNumber(java.io.StreamTokenizer stream)next number in the streamprivate static java.lang.StringnextOpener(java.io.StreamTokenizer stream)expects an open RPAREN as the next tokeprivate static java.lang.StringnextWord(java.io.StreamTokenizer stream)next word in the streamstatic java.lang.Objectparse(java.lang.String wkt)private static RectangleparseBBox(java.io.StreamTokenizer stream)parses an ENVELOPEprivate static voidparseCoordinate(java.io.StreamTokenizer stream, java.util.ArrayList<java.lang.Double> lats, java.util.ArrayList<java.lang.Double> lons)parses a single coordinate, w/ optional 3rd dimensionprivate static voidparseCoordinates(java.io.StreamTokenizer stream, java.util.ArrayList<java.lang.Double> lats, java.util.ArrayList<java.lang.Double> lons)Parses a list of points into latitude and longitude arraylistsstatic java.lang.ObjectparseExpectedType(java.lang.String wkt, SimpleWKTShapeParser.ShapeType shapeType)private static java.lang.ObjectparseGeometry(java.io.StreamTokenizer stream, SimpleWKTShapeParser.ShapeType shapeType)parse geometry from the stream tokenizerprivate static java.lang.Object[]parseGeometryCollection(java.io.StreamTokenizer stream)parses a GEOMETRYCOLLECTIONprivate static LineparseLine(java.io.StreamTokenizer stream)parses a LINESTRINGprivate static Line[]parseMultiLine(java.io.StreamTokenizer stream)parses a MULTILINESTRINGprivate static double[][]parseMultiPoint(java.io.StreamTokenizer stream)parses a MULTIPOINT typeprivate static Polygon[]parseMultiPolygon(java.io.StreamTokenizer stream)parses a MULTIPOLYGONprivate static double[]parsePoint(java.io.StreamTokenizer stream)Parses a point as a double arrayprivate static PolygonparsePolygon(java.io.StreamTokenizer stream)parses a POLYGONprivate static PolygonparsePolygonHole(java.io.StreamTokenizer stream)parses the hole of a polygonprivate static java.lang.StringtokenString(java.io.StreamTokenizer stream)next token in the stream
-
-
-
Field Detail
-
EMPTY
public static final java.lang.String EMPTY
- See Also:
- Constant Field Values
-
SPACE
public static final java.lang.String SPACE
- See Also:
- Constant Field Values
-
LPAREN
public static final java.lang.String LPAREN
- See Also:
- Constant Field Values
-
RPAREN
public static final java.lang.String RPAREN
- See Also:
- Constant Field Values
-
COMMA
public static final java.lang.String COMMA
- See Also:
- Constant Field Values
-
NAN
public static final java.lang.String NAN
- See Also:
- Constant Field Values
-
NUMBER
private static final java.lang.String NUMBER
- See Also:
- Constant Field Values
-
EOF
private static final java.lang.String EOF
- See Also:
- Constant Field Values
-
EOL
private static final java.lang.String EOL
- See Also:
- Constant Field Values
-
-
Method Detail
-
parse
public static java.lang.Object parse(java.lang.String wkt) throws java.io.IOException, java.text.ParseException- Throws:
java.io.IOExceptionjava.text.ParseException
-
parseExpectedType
public static java.lang.Object parseExpectedType(java.lang.String wkt, SimpleWKTShapeParser.ShapeType shapeType) throws java.io.IOException, java.text.ParseException- Throws:
java.io.IOExceptionjava.text.ParseException
-
parseGeometry
private static java.lang.Object parseGeometry(java.io.StreamTokenizer stream, SimpleWKTShapeParser.ShapeType shapeType) throws java.io.IOException, java.text.ParseExceptionparse geometry from the stream tokenizer- Throws:
java.io.IOExceptionjava.text.ParseException
-
parsePoint
private static double[] parsePoint(java.io.StreamTokenizer stream) throws java.io.IOException, java.text.ParseExceptionParses a point as a double array- Throws:
java.io.IOExceptionjava.text.ParseException
-
parseCoordinates
private static void parseCoordinates(java.io.StreamTokenizer stream, java.util.ArrayList<java.lang.Double> lats, java.util.ArrayList<java.lang.Double> lons) throws java.io.IOException, java.text.ParseExceptionParses a list of points into latitude and longitude arraylists- Throws:
java.io.IOExceptionjava.text.ParseException
-
parseCoordinate
private static void parseCoordinate(java.io.StreamTokenizer stream, java.util.ArrayList<java.lang.Double> lats, java.util.ArrayList<java.lang.Double> lons) throws java.io.IOException, java.text.ParseExceptionparses a single coordinate, w/ optional 3rd dimension- Throws:
java.io.IOExceptionjava.text.ParseException
-
parseMultiPoint
private static double[][] parseMultiPoint(java.io.StreamTokenizer stream) throws java.io.IOException, java.text.ParseExceptionparses a MULTIPOINT type- Throws:
java.io.IOExceptionjava.text.ParseException
-
parseLine
private static Line parseLine(java.io.StreamTokenizer stream) throws java.io.IOException, java.text.ParseException
parses a LINESTRING- Throws:
java.io.IOExceptionjava.text.ParseException
-
parseMultiLine
private static Line[] parseMultiLine(java.io.StreamTokenizer stream) throws java.io.IOException, java.text.ParseException
parses a MULTILINESTRING- Throws:
java.io.IOExceptionjava.text.ParseException
-
parsePolygonHole
private static Polygon parsePolygonHole(java.io.StreamTokenizer stream) throws java.io.IOException, java.text.ParseException
parses the hole of a polygon- Throws:
java.io.IOExceptionjava.text.ParseException
-
parsePolygon
private static Polygon parsePolygon(java.io.StreamTokenizer stream) throws java.io.IOException, java.text.ParseException
parses a POLYGON- Throws:
java.io.IOExceptionjava.text.ParseException
-
parseMultiPolygon
private static Polygon[] parseMultiPolygon(java.io.StreamTokenizer stream) throws java.io.IOException, java.text.ParseException
parses a MULTIPOLYGON- Throws:
java.io.IOExceptionjava.text.ParseException
-
parseBBox
private static Rectangle parseBBox(java.io.StreamTokenizer stream) throws java.io.IOException, java.text.ParseException
parses an ENVELOPE- Throws:
java.io.IOExceptionjava.text.ParseException
-
parseGeometryCollection
private static java.lang.Object[] parseGeometryCollection(java.io.StreamTokenizer stream) throws java.io.IOException, java.text.ParseExceptionparses a GEOMETRYCOLLECTION- Throws:
java.io.IOExceptionjava.text.ParseException
-
nextWord
private static java.lang.String nextWord(java.io.StreamTokenizer stream) throws java.text.ParseException, java.io.IOExceptionnext word in the stream- Throws:
java.text.ParseExceptionjava.io.IOException
-
nextNumber
private static double nextNumber(java.io.StreamTokenizer stream) throws java.io.IOException, java.text.ParseExceptionnext number in the stream- Throws:
java.io.IOExceptionjava.text.ParseException
-
tokenString
private static java.lang.String tokenString(java.io.StreamTokenizer stream)
next token in the stream
-
isNumberNext
private static boolean isNumberNext(java.io.StreamTokenizer stream) throws java.io.IOExceptionchecks if the next token is a number- Throws:
java.io.IOException
-
nextEmptyOrOpen
private static java.lang.String nextEmptyOrOpen(java.io.StreamTokenizer stream) throws java.io.IOException, java.text.ParseExceptionchecks if next token is an EMPTY or open paren- Throws:
java.io.IOExceptionjava.text.ParseException
-
nextCloser
private static java.lang.String nextCloser(java.io.StreamTokenizer stream) throws java.io.IOException, java.text.ParseExceptionchecks if next token is a closing paren- Throws:
java.io.IOExceptionjava.text.ParseException
-
nextComma
private static java.lang.String nextComma(java.io.StreamTokenizer stream) throws java.io.IOException, java.text.ParseExceptionexpects a comma as next token- Throws:
java.io.IOExceptionjava.text.ParseException
-
nextOpener
private static java.lang.String nextOpener(java.io.StreamTokenizer stream) throws java.io.IOException, java.text.ParseExceptionexpects an open RPAREN as the next toke- Throws:
java.io.IOExceptionjava.text.ParseException
-
nextCloserOrComma
private static java.lang.String nextCloserOrComma(java.io.StreamTokenizer stream) throws java.io.IOException, java.text.ParseExceptionexpects either a closing LPAREN or comma as the next token- Throws:
java.io.IOExceptionjava.text.ParseException
-
checkEOF
private static void checkEOF(java.io.StreamTokenizer stream) throws java.text.ParseException, java.io.IOExceptionnext word in the stream- Throws:
java.text.ParseExceptionjava.io.IOException
-
-