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 com.vividsolutions.jts.geom.Coordinate |
coordinate(WKTReader.State state)
Reads a
Coordinate from 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.
|
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 com.vividsolutions.jts.geom.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, shapeprotected final JtsSpatialContext ctx
public JtsWKTReader(JtsSpatialContext ctx, JtsSpatialContextFactory factory)
public DatelineRule getDatelineRule()
DatelineRuleprotected Shape parseShapeByType(WKTReader.State state, String shapeType) throws ParseException
WKTReadershapeType 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 WKTReadershapeType - Non-Null string; could have mixed case. The first character is a letter.ParseExceptionprotected 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 WKTReaderParseExceptionWKTReader.pointList(WKTReader.State)protected Shape parsePolygonShape(WKTReader.State state) throws ParseException
Rectangle if the polygon is one.
coordinateSequenceList
ParseExceptionprotected com.vividsolutions.jts.geom.Polygon polygon(WKTReader.State state) throws ParseException
ParseExceptionprotected Shape parseMulitPolygonShape(WKTReader.State state) throws ParseException
'(' polygon (',' polygon )* ')'
ParseExceptionprotected List<com.vividsolutions.jts.geom.Coordinate[]> coordinateSequenceList(WKTReader.State state) throws ParseException
'(' coordinateSequence (',' coordinateSequence )* ')'
ParseExceptionprotected com.vividsolutions.jts.geom.Coordinate[] coordinateSequence(WKTReader.State state) throws ParseException
'(' coordinate (',' coordinate )* ')'
ParseExceptionprotected com.vividsolutions.jts.geom.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.ParseExceptionprotected double normDist(double v)
WKTReaderSpatialContext.normX(double) & normY.Copyright © 2025. All rights reserved.