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 |
static JtsSpatialContext |
GEO |
protected com.vividsolutions.jts.geom.GeometryFactory |
geometryFactory |
protected boolean |
useJtsLineString |
protected boolean |
useJtsPoint |
Constructor and Description |
---|
JtsSpatialContext(JtsSpatialContextFactory factory)
Called by
JtsSpatialContextFactory.newSpatialContext() . |
Modifier and Type | Method and Description |
---|---|
com.vividsolutions.jts.geom.GeometryFactory |
getGeometryFactory() |
com.vividsolutions.jts.geom.Geometry |
getGeometryFrom(Shape shape)
Gets a JTS
Geometry for the given Shape . |
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.
|
Shape |
makeLineString(List<Point> points)
Constructs a line string.
|
Point |
makePoint(double x,
double y)
Construct a point.
|
JtsGeometry |
makeShape(com.vividsolutions.jts.geom.Geometry geom)
INTERNAL: Creates a
Shape from a JTS Geometry . |
JtsGeometry |
makeShape(com.vividsolutions.jts.geom.Geometry geom,
boolean dateline180Check,
boolean allowMultiOverlap)
INTERNAL
|
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
LegacyShapeReadWriterFormat . |
boolean |
useJtsLineString()
Should
makeLineString(java.util.List) return JtsGeometry ? |
boolean |
useJtsPoint()
Should
makePoint(double, double) return JtsPoint ? |
calcDistance, calcDistance, getBinaryCodec, getDistCalc, getWktShapeParser, getWorldBounds, isGeo, isNormWrapLongitude, makeBufferedLineString, makeCircle, makeCircle, makeCollection, makeRectangle, makeRectangle, readShape, readShapeFromWkt, verifyX, verifyY
public static final JtsSpatialContext GEO
protected final com.vividsolutions.jts.geom.GeometryFactory geometryFactory
protected final boolean allowMultiOverlap
protected final boolean useJtsPoint
protected final boolean useJtsLineString
public JtsSpatialContext(JtsSpatialContextFactory factory)
JtsSpatialContextFactory.newSpatialContext()
.public boolean isAllowMultiOverlap()
ShapeCollection.relateContainsShortCircuits()
.public double normX(double x)
SpatialContext
WktShapeParser
before creating a shape.normX
in class SpatialContext
public double normY(double y)
SpatialContext
WktShapeParser
before creating a shape.normY
in class SpatialContext
public String toString(Shape shape)
SpatialContext
LegacyShapeReadWriterFormat
. 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 com.vividsolutions.jts.geom.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 JtsGeometry makeShape(com.vividsolutions.jts.geom.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(com.vividsolutions.jts.geom.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.public com.vividsolutions.jts.geom.GeometryFactory getGeometryFactory()
public String toString()
toString
in class SpatialContext
Copyright © 2016 LocationTech. All rights reserved.