Class SpatialContext
java.lang.Object
org.locationtech.spatial4j.context.SpatialContext
- Direct Known Subclasses:
JtsSpatialContext
This is a facade to most of Spatial4j, holding things like
DistanceCalculator
,
ShapeFactory
,
ShapeIO
.
If you want a typical geodetic context, just reference GEO
. Otherwise,
You should either create and configure a SpatialContextFactory
and then call
SpatialContextFactory.newSpatialContext()
, OR, call
SpatialContextFactory.makeSpatialContext(java.util.Map, ClassLoader)
to do this via configuration data.
Thread-safe & immutable.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BinaryCodec
private final DistanceCalculator
private final SupportedFormats
private final boolean
static final SpatialContext
A popular default SpatialContext implementation for geospatial.private final ShapeFactory
private final Rectangle
-
Constructor Summary
ConstructorsConstructorDescriptionSpatialContext
(boolean geo) Deprecated.SpatialContext
(boolean geo, DistanceCalculator calculator, Rectangle worldBounds) Deprecated.SpatialContext
(SpatialContextFactory factory) Called bySpatialContextFactory.newSpatialContext()
. -
Method Summary
Modifier and TypeMethodDescriptiondouble
calcDistance
(Point p, double x2, double y2) Convenience that usesgetDistCalc()
double
calcDistance
(Point p, Point p2) Convenience that usesgetDistCalc()
A factory forShape
s.Deprecated.The extent of x & y coordinates should fit within the return'ed rectangle.private static SpatialContextFactory
initFromLegacyConstructor
(boolean geo, DistanceCalculator calculator, Rectangle worldBounds) boolean
isGeo()
Is the mathematical world model based on a sphere, or is it a flat plane? The word "geodetic" or "geodesic" is sometimes used to refer to the former, and the latter is sometimes referred to as "Euclidean" or "cartesian".boolean
Deprecated.makeBufferedLineString
(List<Point> points, double buf) Deprecated.makeCircle
(double x, double y, double distance) Deprecated.makeCircle
(Point point, double distance) Deprecated.<S extends Shape>
ShapeCollection<S> makeCollection
(List<S> coll) Deprecated.makeLineString
(List<Point> points) Deprecated.makePoint
(double x, double y) Deprecated.makeRectangle
(double minX, double maxX, double minY, double maxY) Deprecated.makeRectangle
(Point lowerLeft, Point upperRight) Deprecated.double
normX
(double x) Deprecated.double
normY
(double y) Deprecated.Deprecated.readShapeFromWkt
(String wkt) Deprecated.toString()
Deprecated.void
verifyX
(double x) Deprecated.void
verifyY
(double y) Deprecated.
-
Field Details
-
GEO
A popular default SpatialContext implementation for geospatial. -
geo
private final boolean geo -
shapeFactory
-
calculator
-
worldBounds
-
binaryCodec
-
formats
-
-
Constructor Details
-
SpatialContext
@Deprecated public SpatialContext(boolean geo, DistanceCalculator calculator, Rectangle worldBounds) Deprecated.Consider usingSpatialContextFactory
instead.- Parameters:
geo
- Establishes geo vs cartesian / Euclidean.calculator
- Optional; defaults to haversine or cartesian depending ongeo
.worldBounds
- Optional; defaults to GEO_WORLDBOUNDS or MAX_WORLDBOUNDS depending on units.
-
SpatialContext
Deprecated. -
SpatialContext
Called bySpatialContextFactory.newSpatialContext()
.
-
-
Method Details
-
initFromLegacyConstructor
private static SpatialContextFactory initFromLegacyConstructor(boolean geo, DistanceCalculator calculator, Rectangle worldBounds) -
getShapeFactory
A factory forShape
s. -
getFormats
-
getDistCalc
-
calcDistance
Convenience that usesgetDistCalc()
-
calcDistance
Convenience that usesgetDistCalc()
-
getWorldBounds
The extent of x & y coordinates should fit within the return'ed rectangle. Do *NOT* invoke reset() on this return type. -
isNormWrapLongitude
Deprecated.If true thennormX(double)
will wrap longitudes outside of the standard geodetic boundary into it. Example: 181 will become -179. -
isGeo
public boolean isGeo()Is the mathematical world model based on a sphere, or is it a flat plane? The word "geodetic" or "geodesic" is sometimes used to refer to the former, and the latter is sometimes referred to as "Euclidean" or "cartesian". -
normX
Deprecated.Normalize the 'x' dimension. Might reduce precision or wrap it to be within the bounds. This is called byWKTReader
before creating a shape. -
normY
Deprecated.Normalize the 'y' dimension. Might reduce precision or wrap it to be within the bounds. This is called byWKTReader
before creating a shape. -
verifyX
Deprecated.Ensure fits ingetWorldBounds()
. It's called by any shape factory method that gets an 'x' dimension. -
verifyY
Deprecated.Ensure fits ingetWorldBounds()
. It's called by any shape factory method that gets a 'y' dimension. -
makePoint
Deprecated.Construct a point. -
makeRectangle
Deprecated.Construct a rectangle. -
makeRectangle
Deprecated.Construct a rectangle. If just one longitude is on the dateline (+/- 180) (aka anti-meridian) then potentially adjust its sign to ensure the rectangle does not cross the dateline. -
makeCircle
Deprecated.Construct a circle. The units of "distance" should be the same as x & y. -
makeCircle
Deprecated.Construct a circle. The units of "distance" should be the same as x & y. -
makeLineString
Deprecated.Constructs a line string. It's an ordered sequence of connected vertexes. There is no official shape/interface for it yet so we just return Shape. -
makeBufferedLineString
Deprecated.Constructs a buffered line string. It's an ordered sequence of connected vertexes, with a buffer distance along the line in all directions. There is no official shape/interface for it so we just return Shape. -
makeCollection
Deprecated.Construct a ShapeCollection, analogous to an OGC GeometryCollection. -
getWktShapeParser
Deprecated.TheWKTReader
used byreadShapeFromWkt(String)
. -
readShapeFromWkt
Deprecated.Reads a shape from the string formatted in WKT.- Parameters:
wkt
- non-null WKT.- Returns:
- non-null
- Throws:
ParseException
- if it failed to parse.InvalidShapeException
- See Also:
-
getBinaryCodec
-
readShape
Deprecated.Try to read a shape from any supported formats- Returns:
- shape or null if unable to parse any shape
- Throws:
InvalidShapeException
-
toString
Deprecated.Writes the shape to a String using the old/deprecatedLegacyShapeWriter
. 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.- Parameters:
shape
- non-null- Returns:
- non-null
-
toString
-