public class SpatialContext extends Object
DistanceCalculator
,
ShapeIO
, and acting as a factory for the Shape
s.
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() |
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()
If true then
normX(double) will wrap longitudes outside of the standard
geodetic boundary into it. |
Shape |
makeBufferedLineString(List<Point> points,
double buf)
Constructs a buffered line string.
|
Circle |
makeCircle(double x,
double y,
double distance)
Construct a circle.
|
Circle |
makeCircle(Point point,
double distance)
Construct a circle.
|
<S extends Shape> |
makeCollection(List<S> coll)
Construct a ShapeCollection, analogous to an OGC GeometryCollection.
|
Shape |
makeLineString(List<Point> points)
Constructs a line string.
|
Point |
makePoint(double x,
double y)
Construct a point.
|
Rectangle |
makeRectangle(double minX,
double maxX,
double minY,
double maxY)
Construct a rectangle.
|
Rectangle |
makeRectangle(Point lowerLeft,
Point upperRight)
Construct a rectangle.
|
double |
normX(double x)
Normalize the 'x' dimension.
|
double |
normY(double y)
Normalize the 'y' dimension.
|
Shape |
readShape(String value)
Deprecated.
|
Shape |
readShapeFromWkt(String wkt)
Deprecated.
|
String |
toString() |
String |
toString(Shape shape)
Deprecated.
|
void |
verifyX(double x)
Ensure fits in
getWorldBounds() . |
void |
verifyY(double y)
Ensure fits in
getWorldBounds() . |
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 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()
public boolean isNormWrapLongitude()
normX(double)
will wrap longitudes outside of the standard
geodetic boundary into it. Example: 181 will become -179.public boolean isGeo()
public double normX(double x)
WKTReader
before creating a shape.public double normY(double y)
WKTReader
before creating a shape.public void verifyX(double x)
getWorldBounds()
. It's called by any shape factory method that
gets an 'x' dimension.public void verifyY(double y)
getWorldBounds()
. It's called by any shape factory method that
gets a 'y' dimension.public Point makePoint(double x, double y)
public Rectangle makeRectangle(Point lowerLeft, Point upperRight)
public Rectangle makeRectangle(double minX, double maxX, double minY, double maxY)
public Circle makeCircle(double x, double y, double distance)
public Circle makeCircle(Point point, double distance)
public Shape makeLineString(List<Point> points)
public Shape makeBufferedLineString(List<Point> points, double buf)
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
value
- 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 © 2015. All rights reserved.