public class JtsShapeFactory extends ShapeFactoryImpl
ShapeFactoryImpl with support for Polygons
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.ShapeFactoryImpl.GeneralShapeMultiShapeBuilder<T extends Shape>ShapeFactory.LineStringBuilder, ShapeFactory.MultiLineStringBuilder, ShapeFactory.MultiPointBuilder, ShapeFactory.MultiPolygonBuilder, ShapeFactory.MultiShapeBuilder<T extends Shape>, ShapeFactory.PointsBuilder<T>, ShapeFactory.PolygonBuilder| Modifier and Type | Field and Description |
|---|---|
protected boolean |
allowMultiOverlap |
protected boolean |
autoIndex |
protected DatelineRule |
datelineRule |
protected static org.locationtech.jts.geom.LinearRing[] |
EMPTY_HOLES |
protected org.locationtech.jts.geom.GeometryFactory |
geometryFactory |
protected boolean |
useJtsLineString |
protected boolean |
useJtsMulti |
protected boolean |
useJtsPoint |
protected ValidationRule |
validationRule |
ctx| Constructor and Description |
|---|
JtsShapeFactory(JtsSpatialContext ctx,
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 (aka anti-meridian) crossing considerations.
|
org.locationtech.jts.geom.GeometryFactory |
getGeometryFactory() |
org.locationtech.jts.geom.Geometry |
getGeometryFrom(Shape shape)
Gets a JTS
Geometry for the given 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 ShapeReaders. |
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.
|
ShapeFactory.LineStringBuilder |
lineString()
(Builder) Constructs a line string, with a possible buffer.
|
Shape |
lineString(List<Point> points,
double bufferDistance)
Constructs a line string with a possible buffer.
|
Rectangle |
makeRectFromRectangularPoly(org.locationtech.jts.geom.Geometry geom)
INTERNAL: Returns a Rectangle of the JTS
Envelope (bounding box) of the given geom. |
JtsGeometry |
makeShape(org.locationtech.jts.geom.Geometry geom)
INTERNAL: Creates a
Shape from a JTS Geometry. |
JtsGeometry |
makeShape(org.locationtech.jts.geom.Geometry geom,
boolean dateline180Check,
boolean allowMultiOverlap)
INTERNAL
|
Shape |
makeShapeFromGeometry(org.locationtech.jts.geom.Geometry geom)
INTERNAL Usually creates a JtsGeometry, potentially validating, repairing, and indexing ("preparing").
|
ShapeFactory.MultiLineStringBuilder |
multiLineString()
(Builder) Constructs a MultiLineString, or possibly the result of that buffered.
|
ShapeFactory.MultiPointBuilder |
multiPoint()
(Builder) Constructs a MultiPoint.
|
ShapeFactory.MultiPolygonBuilder |
multiPolygon()
(Builder) Constructs a MultiPolygon.
|
<T extends Shape> |
multiShape(Class<T> shapeClass)
(Builder) Constructs a Shape aggregate in which each component/member
is an instance of the specified class.
|
double |
normDist(double d)
Called to normalize a value that isn't X or Y or Z.
|
double |
normX(double x)
Normalize the 'x' dimension.
|
double |
normY(double y) |
double |
normZ(double z)
(disclaimer: the Z dimension isn't fully supported)
|
Point |
pointXY(double x,
double y)
Construct a point.
|
Point |
pointXYZ(double x,
double y,
double z)
Construct a point of 3 dimensions.
|
ShapeFactory.PolygonBuilder |
polygon()
(Builder) Constructs a polygon.
|
boolean |
useJtsLineString()
Should
lineString(java.util.List,double) return JtsGeometry? |
boolean |
useJtsMulti()
Whether
multiPoint(), multiLineString(), and multiPolygon() should all use JTS's
subclasses of GeometryCollection instead of Spatial4j's basic impl. |
boolean |
useJtsPoint()
Should
pointXY(double, double) return JtsPoint? |
circle, circle, getSpatialContext, isNormWrapLongitude, multiShape, rect, rect, verifyX, verifyY, verifyZclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpointLatLonprotected static final org.locationtech.jts.geom.LinearRing[] EMPTY_HOLES
protected final org.locationtech.jts.geom.GeometryFactory geometryFactory
protected final boolean allowMultiOverlap
protected final boolean useJtsPoint
protected final boolean useJtsLineString
protected final boolean useJtsMulti
protected final DatelineRule datelineRule
protected final ValidationRule validationRule
protected final boolean autoIndex
public JtsShapeFactory(JtsSpatialContext ctx, 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 ShapeReaders.public boolean isAutoIndex()
ShapeReader.JtsGeometry.index()public double normX(double x)
ShapeFactoryShapeReaders before creating a shape.normX in interface ShapeFactorynormX in class ShapeFactoryImplpublic double normY(double y)
normY in interface ShapeFactorynormY in class ShapeFactoryImplShapeFactory.normX(double)public double normZ(double z)
ShapeFactorynormZ in interface ShapeFactorynormZ in class ShapeFactoryImplShapeFactory.normX(double)public double normDist(double d)
ShapeFactorySpatialContext.normX(double) & normY & normZ. This
is called by a ShapeReader before creating a shape.normDist in interface ShapeFactorynormDist in class ShapeFactoryImplpublic org.locationtech.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()
pointXY(double, double) return JtsPoint?public Point pointXY(double x, double y)
ShapeFactorypointXY in interface ShapeFactorypointXY in class ShapeFactoryImplpublic Point pointXYZ(double x, double y, double z)
ShapeFactorypointXYZ in interface ShapeFactorypointXYZ in class ShapeFactoryImplpublic boolean useJtsLineString()
lineString(java.util.List,double) return JtsGeometry?public Shape lineString(List<Point> points, double bufferDistance)
ShapeFactorylineString in interface ShapeFactorylineString in class ShapeFactoryImplpublic ShapeFactory.LineStringBuilder lineString()
ShapeFactorylineString in interface ShapeFactorylineString in class ShapeFactoryImplpublic ShapeFactory.PolygonBuilder polygon()
ShapeFactorypolygon in interface ShapeFactorypolygon in class ShapeFactoryImplpublic boolean useJtsMulti()
multiPoint(), multiLineString(), and multiPolygon() should all use JTS's
subclasses of GeometryCollection instead of Spatial4j's basic impl. The general multiShape(Class)
will never use GeometryCollection because that class doesn't support relations.public ShapeFactory.MultiPointBuilder multiPoint()
ShapeFactorymultiPoint in interface ShapeFactorymultiPoint in class ShapeFactoryImplpublic ShapeFactory.MultiLineStringBuilder multiLineString()
ShapeFactorymultiLineString in interface ShapeFactorymultiLineString in class ShapeFactoryImplpublic ShapeFactory.MultiPolygonBuilder multiPolygon()
ShapeFactorymultiPolygon in interface ShapeFactorymultiPolygon in class ShapeFactoryImplpublic <T extends Shape> ShapeFactory.MultiShapeBuilder<T> multiShape(Class<T> shapeClass)
ShapeFactorymultiShape in interface ShapeFactorymultiShape in class ShapeFactoryImplpublic Shape makeShapeFromGeometry(org.locationtech.jts.geom.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 JtsSpatialContext.useJtsPoint(); otherwise
a standard Spatial4j Point is returned.
If given a LineString and if JtsSpatialContext.useJtsLineString() is true then
then the geometry's parts are exposed to call SpatialContext.makeLineString(List).public JtsGeometry makeShape(org.locationtech.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(org.locationtech.jts.geom.Geometry)public JtsGeometry makeShape(org.locationtech.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. Also,
note that direct instances of GeometryCollection isn't supported.
Instead of calling this method, consider makeShapeFromGeometry(Geometry)
whichpublic org.locationtech.jts.geom.GeometryFactory getGeometryFactory()
public Rectangle makeRectFromRectangularPoly(org.locationtech.jts.geom.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 © 2025 LocationTech. All rights reserved.