public class JtsSpatialContext extends SpatialContext
SpatialContext
with support for Polygons (and
other geometries) using JTS.
To the extent possible, our JtsGeometry
adds some amount of geodetic support over
vanilla JTS which only has a Euclidean (flat plane) model.Modifier and Type | Field and Description |
---|---|
protected boolean |
allowMultiOverlap |
protected boolean |
autoIndex |
protected DatelineRule |
datelineRule |
static JtsSpatialContext |
GEO |
protected GeometryFactory |
geometryFactory |
protected boolean |
useJtsLineString |
protected boolean |
useJtsPoint |
protected ValidationRule |
validationRule |
Constructor and Description |
---|
JtsSpatialContext(JtsSpatialContextFactory factory)
Called by
JtsSpatialContextFactory.newSpatialContext() . |
Modifier and Type | Method and Description |
---|---|
DatelineRule |
getDatelineRule()
Returns the rule used to handle geometry objects that have dateline crossing considerations.
|
GeometryFactory |
getGeometryFactory() |
Geometry |
getGeometryFrom(Shape shape)
|
ValidationRule |
getValidationRule()
Returns the rule used to handle errors when creating a JTS
Geometry , particularly after it has been
read from one of the ShapeReader s. |
boolean |
isAllowMultiOverlap()
If geom might be a multi geometry of some kind, then might multiple
component geometries overlap? Strict OGC says this is invalid but we
can accept it by computing the union.
|
boolean |
isAutoIndex()
If JtsGeometry shapes should be automatically "prepared" (i.e.
|
Shape |
makeLineString(List<Point> points)
Constructs a line string.
|
Point |
makePoint(double x,
double y)
Construct a point.
|
Rectangle |
makeRectFromRectangularPoly(Geometry geom)
INTERNAL: Returns a Rectangle of the JTS
Envelope (bounding box) of the given geom . |
JtsGeometry |
makeShape(Geometry geom)
|
JtsGeometry |
makeShape(Geometry geom,
boolean dateline180Check,
boolean allowMultiOverlap)
INTERNAL
|
Shape |
makeShapeFromGeometry(Geometry geom)
INTERNAL Usually creates a JtsGeometry, potentially validating, repairing, and indexing ("preparing").
|
double |
normX(double x)
Normalize the 'x' dimension.
|
double |
normY(double y)
Normalize the 'y' dimension.
|
String |
toString() |
String |
toString(Shape shape)
Writes the shape to a String using the old/deprecated
LegacyShapeWriter . |
boolean |
useJtsLineString()
Should
makeLineString(java.util.List) return JtsGeometry ? |
boolean |
useJtsPoint()
Should
makePoint(double, double) return JtsPoint ? |
calcDistance, calcDistance, getBinaryCodec, getDistCalc, getFormats, getWktShapeParser, getWorldBounds, isGeo, isNormWrapLongitude, makeBufferedLineString, makeCircle, makeCircle, makeCollection, makeRectangle, makeRectangle, readShape, readShapeFromWkt, verifyX, verifyY
public static final JtsSpatialContext GEO
protected final GeometryFactory geometryFactory
protected final boolean allowMultiOverlap
protected final boolean useJtsPoint
protected final boolean useJtsLineString
protected final DatelineRule datelineRule
protected final ValidationRule validationRule
protected final boolean autoIndex
public JtsSpatialContext(JtsSpatialContextFactory factory)
JtsSpatialContextFactory.newSpatialContext()
.public boolean isAllowMultiOverlap()
ShapeCollection.relateContainsShortCircuits()
.public DatelineRule getDatelineRule()
public ValidationRule getValidationRule()
Geometry
, particularly after it has been
read from one of the ShapeReader
s.public boolean isAutoIndex()
ShapeReader
.JtsGeometry.index()
public double normX(double x)
SpatialContext
WKTReader
before creating a shape.normX
in class SpatialContext
public double normY(double y)
SpatialContext
WKTReader
before creating a shape.normY
in class SpatialContext
public String toString(Shape shape)
SpatialContext
LegacyShapeWriter
. The JTS based subclass will write it
to WKT if the legacy format doesn't support that shape.
Spatial4j in the near future won't support writing shapes to strings.toString
in class SpatialContext
shape
- non-nullpublic Geometry getGeometryFrom(Shape shape)
Geometry
for the given Shape
. Some shapes hold a
JTS geometry whereas new ones must be created for the rest.shape
- Not nullpublic boolean useJtsPoint()
makePoint(double, double)
return JtsPoint
?public Point makePoint(double x, double y)
SpatialContext
makePoint
in class SpatialContext
public boolean useJtsLineString()
makeLineString(java.util.List)
return JtsGeometry
?public Shape makeLineString(List<Point> points)
SpatialContext
makeLineString
in class SpatialContext
public Shape makeShapeFromGeometry(Geometry geom)
ShapeReader
instances.
If given a direct instance of GeometryCollection
then it's contents will be
recursively converted and then the resulting list will be passed to
SpatialContext.makeCollection(List)
and returned.
If given a Point
then SpatialContext.makePoint(double, double)
is called, which will return a JtsPoint
if useJtsPoint()
; otherwise
a standard Spatial4j Point is returned.
If given a LineString
and if useJtsLineString()
is true then
then the geometry's parts are exposed to call SpatialContext.makeLineString(List)
.public JtsGeometry makeShape(Geometry geom, boolean dateline180Check, boolean allowMultiOverlap)
geom
- Non-nulldateline180Check
- if both this is true and SpatialContext.isGeo()
, then JtsGeometry will check
for adjacent coordinates greater than 180 degrees longitude apart, and
it will do tricks to make that line segment (and the shape as a whole)
cross the dateline even though JTS doesn't have geodetic support.allowMultiOverlap
- See isAllowMultiOverlap()
.makeShape(com.vividsolutions.jts.geom.Geometry)
public JtsGeometry makeShape(Geometry geom)
Shape
from a JTS Geometry
. Generally, this shouldn't be
called when one of the other factory methods are available, such as for points. The caller
needs to have done some verification/normalization of the coordinates by now, if any. Also,
note that direct instances of GeometryCollection
isn't supported.
Instead of calling this method, consider JtsWKTReader#makeShapeFromGeometry(Geometry)
whichpublic GeometryFactory getGeometryFactory()
public String toString()
toString
in class SpatialContext
public Rectangle makeRectFromRectangularPoly(Geometry geom)
Envelope
(bounding box) of the given geom
. This asserts
that Geometry.isRectangle()
is true. This method reacts to the DatelineRule
setting.geom
- non-nullCopyright © 2015. All rights reserved.