public class SpatialContext extends Object
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.
Modifier and Type | Field and Description |
---|---|
static SpatialContext |
GEO
A popular default SpatialContext implementation for geospatial.
|
Constructor and Description |
---|
SpatialContext(boolean geo)
Deprecated.
|
SpatialContext(boolean geo,
DistanceCalculator calculator,
Rectangle worldBounds)
Deprecated.
|
SpatialContext(SpatialContextFactory factory)
Called by
SpatialContextFactory.newSpatialContext() . |
Modifier and Type | Method and Description |
---|---|
double |
calcDistance(Point p,
double x2,
double y2)
Convenience that uses
getDistCalc() |
double |
calcDistance(Point p,
Point p2)
Convenience that uses
getDistCalc() |
BinaryCodec |
getBinaryCodec() |
DistanceCalculator |
getDistCalc() |
SupportedFormats |
getFormats() |
ShapeFactory |
getShapeFactory()
A factory for
Shape s. |
WKTReader |
getWktShapeParser()
Deprecated.
|
Rectangle |
getWorldBounds()
The extent of x & y coordinates should fit within the return'ed rectangle.
|
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 |
isNormWrapLongitude()
Deprecated.
|
Shape |
makeBufferedLineString(List<Point> points,
double buf)
Deprecated.
|
Circle |
makeCircle(double x,
double y,
double distance)
Deprecated.
|
Circle |
makeCircle(Point point,
double distance)
Deprecated.
|
<S extends Shape> |
makeCollection(List<S> coll)
Deprecated.
|
Shape |
makeLineString(List<Point> points)
Deprecated.
|
Point |
makePoint(double x,
double y)
Deprecated.
|
Rectangle |
makeRectangle(double minX,
double maxX,
double minY,
double maxY)
Deprecated.
|
Rectangle |
makeRectangle(Point lowerLeft,
Point upperRight)
Deprecated.
|
double |
normX(double x)
Deprecated.
|
double |
normY(double y)
Deprecated.
|
Shape |
readShape(String value)
Deprecated.
|
Shape |
readShapeFromWkt(String wkt)
Deprecated.
|
String |
toString() |
String |
toString(Shape shape)
Deprecated.
|
void |
verifyX(double x)
Deprecated.
|
void |
verifyY(double y)
Deprecated.
|
public static final SpatialContext GEO
@Deprecated public SpatialContext(boolean geo, DistanceCalculator calculator, Rectangle worldBounds)
SpatialContextFactory
instead.geo
- Establishes geo vs cartesian / Euclidean.calculator
- Optional; defaults to haversine or cartesian depending on geo
.worldBounds
- Optional; defaults to GEO_WORLDBOUNDS or MAX_WORLDBOUNDS depending on units.@Deprecated public SpatialContext(boolean geo)
public SpatialContext(SpatialContextFactory factory)
SpatialContextFactory.newSpatialContext()
.public ShapeFactory getShapeFactory()
Shape
s.public SupportedFormats getFormats()
public DistanceCalculator getDistCalc()
public double calcDistance(Point p, double x2, double y2)
getDistCalc()
public double calcDistance(Point p, Point p2)
getDistCalc()
public Rectangle getWorldBounds()
@Deprecated public boolean isNormWrapLongitude()
normX(double)
will wrap longitudes outside of the standard
geodetic boundary into it. Example: 181 will become -179.public boolean isGeo()
@Deprecated public double normX(double x)
WKTReader
before creating a shape.@Deprecated public double normY(double y)
WKTReader
before creating a shape.@Deprecated public void verifyX(double x)
getWorldBounds()
. It's called by any shape factory method that
gets an 'x' dimension.@Deprecated public void verifyY(double y)
getWorldBounds()
. It's called by any shape factory method that
gets a 'y' dimension.@Deprecated public Point makePoint(double x, double y)
@Deprecated public Rectangle makeRectangle(Point lowerLeft, Point upperRight)
@Deprecated public Rectangle makeRectangle(double minX, double maxX, double minY, double maxY)
@Deprecated public Circle makeCircle(double x, double y, double distance)
@Deprecated public Circle makeCircle(Point point, double distance)
@Deprecated public Shape makeLineString(List<Point> points)
@Deprecated public Shape makeBufferedLineString(List<Point> points, double buf)
@Deprecated public <S extends Shape> ShapeCollection<S> makeCollection(List<S> coll)
@Deprecated public WKTReader getWktShapeParser()
WKTReader
used by readShapeFromWkt(String)
.@Deprecated public Shape readShapeFromWkt(String wkt) throws ParseException, InvalidShapeException
wkt
- non-null WKT.ParseException
- if it failed to parse.InvalidShapeException
WKTReader
public BinaryCodec getBinaryCodec()
@Deprecated public Shape readShape(String value) throws InvalidShapeException
InvalidShapeException
@Deprecated public String toString(Shape shape)
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.shape
- non-nullCopyright © 2020 LocationTech. All rights reserved.