public class JtsWktShapeParser extends WktShapeParser
WktShapeParser
adding support for polygons, using JTS.Modifier and Type | Class and Description |
---|---|
static class |
JtsWktShapeParser.DatelineRule
Indicates the algorithm used to process JTS Polygons and JTS LineStrings for detecting dateline
crossings.
|
static class |
JtsWktShapeParser.ValidationRule
Indicates how JTS geometries (notably polygons but applies to other geometries too) are
validated (if at all) and repaired (if at all).
|
WktShapeParser.State
Modifier and Type | Field and Description |
---|---|
protected boolean |
autoIndex |
protected JtsSpatialContext |
ctx |
protected JtsWktShapeParser.DatelineRule |
datelineRule |
protected JtsWktShapeParser.ValidationRule |
validationRule |
Constructor and Description |
---|
JtsWktShapeParser(JtsSpatialContext ctx,
JtsSpatialContextFactory factory) |
Modifier and Type | Method and Description |
---|---|
protected com.vividsolutions.jts.geom.Coordinate |
coordinate(WktShapeParser.State state)
Reads a
Coordinate from the current position. |
protected com.vividsolutions.jts.geom.Coordinate[] |
coordinateSequence(WktShapeParser.State state)
Reads a JTS Coordinate sequence from the current position.
|
protected List<com.vividsolutions.jts.geom.Coordinate[]> |
coordinateSequenceList(WktShapeParser.State state)
Reads a list of JTS Coordinate sequences from the current position.
|
JtsWktShapeParser.DatelineRule |
getDatelineRule() |
JtsWktShapeParser.ValidationRule |
getValidationRule() |
boolean |
isAutoIndex()
If JtsGeometry shapes should be automatically prepared (i.e.
|
boolean |
isAutoValidate()
JtsGeometry shapes are automatically validated when
getValidationRule() isn't
none . |
protected Rectangle |
makeRectFromPoly(com.vividsolutions.jts.geom.Geometry geometry) |
protected JtsGeometry |
makeShapeFromGeometry(com.vividsolutions.jts.geom.Geometry geometry)
Creates the JtsGeometry, potentially validating, repairing, and preparing.
|
protected double |
normDist(double v)
Called to normalize a value that isn't X or Y.
|
protected Shape |
parseLineStringShape(WktShapeParser.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(WktShapeParser.State state)
Parses a MULTIPOLYGON shape from the raw string.
|
protected Shape |
parsePolygonShape(WktShapeParser.State state)
Parses a POLYGON shape from the raw string.
|
protected Shape |
parseShapeByType(WktShapeParser.State state,
String shapeType)
(internal) Parses the remainder of a shape definition following the shape's name
given as
shapeType already consumed via
WktShapeParser.State.nextWord() . |
protected com.vividsolutions.jts.geom.Polygon |
polygon(WktShapeParser.State state)
Reads a polygon, returning a JTS polygon.
|
getCtx, newState, parse, parseBufferShape, parseEnvelopeShape, parseGeometryCollectionShape, parseIfSupported, parseMultiLineStringShape, parseMultiPointShape, parsePointShape, point, pointList, shape
protected final JtsSpatialContext ctx
protected final JtsWktShapeParser.DatelineRule datelineRule
protected final JtsWktShapeParser.ValidationRule validationRule
protected final boolean autoIndex
public JtsWktShapeParser(JtsSpatialContext ctx, JtsSpatialContextFactory factory)
public JtsWktShapeParser.ValidationRule getValidationRule()
JtsWktShapeParser.ValidationRule
public boolean isAutoValidate()
getValidationRule()
isn't
none
.public boolean isAutoIndex()
JtsGeometry.index()
public JtsWktShapeParser.DatelineRule getDatelineRule()
JtsWktShapeParser.DatelineRule
protected Shape parseShapeByType(WktShapeParser.State state, String shapeType) throws ParseException
WktShapeParser
shapeType
already consumed via
WktShapeParser.State.nextWord()
. If
it's able to parse the shape, WktShapeParser.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
WktShapeParser.State.nextIfEmptyAndSkipZM()
.parseShapeByType
in class WktShapeParser
shapeType
- Non-Null string; could have mixed case. The first character is a letter.ParseException
protected Shape parseLineStringShape(WktShapeParser.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 WktShapeParser
ParseException
WktShapeParser.pointList(WktShapeParser.State)
protected Shape parsePolygonShape(WktShapeParser.State state) throws ParseException
Rectangle
if the polygon is one.
coordinateSequenceList
ParseException
protected Rectangle makeRectFromPoly(com.vividsolutions.jts.geom.Geometry geometry)
protected com.vividsolutions.jts.geom.Polygon polygon(WktShapeParser.State state) throws ParseException
ParseException
protected Shape parseMulitPolygonShape(WktShapeParser.State state) throws ParseException
'(' polygon (',' polygon )* ')'
ParseException
protected List<com.vividsolutions.jts.geom.Coordinate[]> coordinateSequenceList(WktShapeParser.State state) throws ParseException
'(' coordinateSequence (',' coordinateSequence )* ')'
ParseException
protected com.vividsolutions.jts.geom.Coordinate[] coordinateSequence(WktShapeParser.State state) throws ParseException
'(' coordinate (',' coordinate )* ')'
ParseException
protected com.vividsolutions.jts.geom.Coordinate coordinate(WktShapeParser.State state) throws ParseException
Coordinate
from the current position.
It's akin to WktShapeParser.point(com.spatial4j.core.io.WktShapeParser.State)
but for
a JTS Coordinate. Only the first 2 numbers are parsed; any remaining are ignored.ParseException
protected double normDist(double v)
WktShapeParser
SpatialContext.normX(double)
& normY.normDist
in class WktShapeParser
protected JtsGeometry makeShapeFromGeometry(com.vividsolutions.jts.geom.Geometry geometry)
Copyright © 2016 LocationTech. All rights reserved.