Package com.spatial4j.core.io.jts
Class JtsWKTReader
- java.lang.Object
-
- com.spatial4j.core.io.WKTReader
-
- com.spatial4j.core.io.jts.JtsWKTReader
-
- All Implemented Interfaces:
ShapeIO,ShapeReader
- Direct Known Subclasses:
JtsWKTReaderShapeParser
public class JtsWKTReader extends WKTReader
ExtendsWKTReaderadding support for polygons, using JTS.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.spatial4j.core.io.WKTReader
WKTReader.State
-
-
Constructor Summary
Constructors Constructor Description JtsWKTReader(JtsSpatialContext ctx, JtsSpatialContextFactory factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.vividsolutions.jts.geom.Coordinatecoordinate(WKTReader.State state)Reads aCoordinatefrom the current position.protected com.vividsolutions.jts.geom.Coordinate[]coordinateSequence(WKTReader.State state)Reads a JTS Coordinate sequence from the current position.protected List<com.vividsolutions.jts.geom.Coordinate[]>coordinateSequenceList(WKTReader.State state)Reads a list of JTS Coordinate sequences from the current position.DatelineRulegetDatelineRule()protected doublenormDist(double v)Called to normalize a value that isn't X or Y.protected ShapeparseLineStringShape(WKTReader.State state)BypassesJtsSpatialContext.makeLineString(java.util.List)so that we can more efficiently get the LineString without creating aList<Point>.protected ShapeparseMulitPolygonShape(WKTReader.State state)Parses a MULTIPOLYGON shape from the raw string.protected ShapeparsePolygonShape(WKTReader.State state)Parses a POLYGON shape from the raw string.protected ShapeparseShapeByType(WKTReader.State state, String shapeType)(internal) Parses the remainder of a shape definition following the shape's name given asshapeTypealready consumed viaWKTReader.State.nextWord().protected com.vividsolutions.jts.geom.Polygonpolygon(WKTReader.State state)Reads a polygon, returning a JTS polygon.-
Methods inherited from class com.spatial4j.core.io.WKTReader
getFormatName, newState, parse, parseBufferShape, parseEnvelopeShape, parseGeometryCollectionShape, parseIfSupported, parseMultiLineStringShape, parseMultiPointShape, parsePointShape, point, pointList, read, read, readIfSupported, shape
-
-
-
-
Field Detail
-
ctx
protected final JtsSpatialContext ctx
-
-
Constructor Detail
-
JtsWKTReader
public JtsWKTReader(JtsSpatialContext ctx, JtsSpatialContextFactory factory)
-
-
Method Detail
-
getDatelineRule
public DatelineRule getDatelineRule()
- See Also:
DatelineRule
-
parseShapeByType
protected Shape parseShapeByType(WKTReader.State state, String shapeType) throws ParseException
Description copied from class:WKTReader(internal) Parses the remainder of a shape definition following the shape's name given asshapeTypealready consumed viaWKTReader.State.nextWord(). If it's able to parse the shape,WKTReader.State.offsetshould be advanced beyond it (e.g. to the ',' or ')' or EOF in general). The default implementation checks the name against some predefined names and calls corresponding parse methods to handle the rest. Overriding this method is an excellent extension point for additional shape types. Or, use this class by delegation to this method. When writing a parse method that reacts to a specific shape type, remember to handle the dimension and EMPTY token viaWKTReader.State.nextIfEmptyAndSkipZM().- Overrides:
parseShapeByTypein classWKTReadershapeType- Non-Null string; could have mixed case. The first character is a letter.- Returns:
- The shape or null if not supported / unknown.
- Throws:
ParseException
-
parseLineStringShape
protected Shape parseLineStringShape(WKTReader.State state) throws ParseException
BypassesJtsSpatialContext.makeLineString(java.util.List)so that we can more efficiently get the LineString without creating aList<Point>.- Overrides:
parseLineStringShapein classWKTReader- Throws:
ParseException- See Also:
WKTReader.pointList(WKTReader.State)
-
parsePolygonShape
protected Shape parsePolygonShape(WKTReader.State state) throws ParseException
Parses a POLYGON shape from the raw string. It might return aRectangleif the polygon is one.coordinateSequenceList
- Throws:
ParseException
-
polygon
protected com.vividsolutions.jts.geom.Polygon polygon(WKTReader.State state) throws ParseException
Reads a polygon, returning a JTS polygon.- Throws:
ParseException
-
parseMulitPolygonShape
protected Shape parseMulitPolygonShape(WKTReader.State state) throws ParseException
Parses a MULTIPOLYGON shape from the raw string.'(' polygon (',' polygon )* ')'- Throws:
ParseException
-
coordinateSequenceList
protected List<com.vividsolutions.jts.geom.Coordinate[]> coordinateSequenceList(WKTReader.State state) throws ParseException
Reads a list of JTS Coordinate sequences from the current position.'(' coordinateSequence (',' coordinateSequence )* ')'- Throws:
ParseException
-
coordinateSequence
protected com.vividsolutions.jts.geom.Coordinate[] coordinateSequence(WKTReader.State state) throws ParseException
Reads a JTS Coordinate sequence from the current position.'(' coordinate (',' coordinate )* ')'- Throws:
ParseException
-
coordinate
protected com.vividsolutions.jts.geom.Coordinate coordinate(WKTReader.State state) throws ParseException
Reads aCoordinatefrom the current position. It's akin toWKTReader.point(com.spatial4j.core.io.WKTReader.State)but for a JTS Coordinate. Only the first 2 numbers are parsed; any remaining are ignored.- Throws:
ParseException
-
normDist
protected double normDist(double v)
Description copied from class:WKTReaderCalled to normalize a value that isn't X or Y. X & Y or normalized viaSpatialContext.normX(double)& normY.
-
-