public class JtsWKTReader extends WKTReader
WKTReader
adding support for polygons, using JTS.WKTReader.State
Modifier and Type | Field and Description |
---|---|
protected JtsSpatialContext |
ctx |
Constructor and Description |
---|
JtsWKTReader(JtsSpatialContext ctx,
JtsSpatialContextFactory factory) |
Modifier and Type | Method and Description |
---|---|
protected Coordinate |
coordinate(WKTReader.State state)
Reads a
Coordinate from the current position. |
protected Coordinate[] |
coordinateSequence(WKTReader.State state)
Reads a JTS Coordinate sequence from the current position.
|
protected List<Coordinate[]> |
coordinateSequenceList(WKTReader.State state)
Reads a list of JTS Coordinate sequences from the current position.
|
DatelineRule |
getDatelineRule() |
protected double |
normDist(double v)
Called to normalize a value that isn't X or Y.
|
protected Shape |
parseLineStringShape(WKTReader.State state)
Bypasses
JtsSpatialContext.makeLineString(java.util.List) so that we can more
efficiently get the LineString without creating a List<Point> . |
protected Shape |
parseMulitPolygonShape(WKTReader.State state)
Parses a MULTIPOLYGON shape from the raw string.
|
protected Shape |
parsePolygonShape(WKTReader.State state)
Parses a POLYGON shape from the raw string.
|
protected Shape |
parseShapeByType(WKTReader.State state,
String shapeType)
(internal) Parses the remainder of a shape definition following the shape's name given as
shapeType already consumed via WKTReader.State.nextWord() . |
protected Polygon |
polygon(WKTReader.State state)
Reads a polygon, returning a JTS polygon.
|
getFormatName, newState, parse, parseBufferShape, parseEnvelopeShape, parseGeometryCollectionShape, parseIfSupported, parseMultiLineStringShape, parseMultiPointShape, parsePointShape, point, pointList, read, read, readIfSupported, shape
protected final JtsSpatialContext ctx
public JtsWKTReader(JtsSpatialContext ctx, JtsSpatialContextFactory factory)
public DatelineRule getDatelineRule()
DatelineRule
protected Shape parseShapeByType(WKTReader.State state, String shapeType) throws ParseException
WKTReader
shapeType
already consumed via WKTReader.State.nextWord()
. If it's able to parse the
shape, WKTReader.State.offset
should 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 via
WKTReader.State.nextIfEmptyAndSkipZM()
.parseShapeByType
in class WKTReader
shapeType
- Non-Null string; could have mixed case. The first character is a letter.ParseException
protected Shape parseLineStringShape(WKTReader.State state) throws ParseException
JtsSpatialContext.makeLineString(java.util.List)
so that we can more
efficiently get the LineString without creating a List<Point>
.parseLineStringShape
in class WKTReader
ParseException
WKTReader.pointList(WKTReader.State)
protected Shape parsePolygonShape(WKTReader.State state) throws ParseException
Rectangle
if the polygon is one.
coordinateSequenceList
ParseException
protected Polygon polygon(WKTReader.State state) throws ParseException
ParseException
protected Shape parseMulitPolygonShape(WKTReader.State state) throws ParseException
'(' polygon (',' polygon )* ')'
ParseException
protected List<Coordinate[]> coordinateSequenceList(WKTReader.State state) throws ParseException
'(' coordinateSequence (',' coordinateSequence )* ')'
ParseException
protected Coordinate[] coordinateSequence(WKTReader.State state) throws ParseException
'(' coordinate (',' coordinate )* ')'
ParseException
protected Coordinate coordinate(WKTReader.State state) throws ParseException
Coordinate
from the current position. It's akin to
WKTReader.point(com.spatial4j.core.io.WKTReader.State)
but for a JTS Coordinate. Only the first
2 numbers are parsed; any remaining are ignored.ParseException
protected double normDist(double v)
WKTReader
SpatialContext.normX(double)
& normY.Copyright © 2015. All rights reserved.