Spatial4j, 0.8
org.locationtech.spatial4j.context

## Class SpatialContext

• ### Field Summary

Fields
Modifier and Type Field and Description
`static SpatialContext` `GEO`
A popular default SpatialContext implementation for geospatial.
• ### Constructor Summary

Constructors
Constructor and Description
`SpatialContext(boolean geo)`
Deprecated.
```SpatialContext(boolean geo, DistanceCalculator calculator, Rectangle worldBounds)```
Deprecated.
`SpatialContext(SpatialContextFactory factory)`
• ### Method Summary

All Methods
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>ShapeCollection<S>` `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.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### GEO

`public static final SpatialContext GEO`
A popular default SpatialContext implementation for geospatial.
• ### Constructor Detail

• #### SpatialContext

```@Deprecated
public SpatialContext(boolean geo,
DistanceCalculator calculator,
Rectangle worldBounds)```
Deprecated.
Consider using `SpatialContextFactory` instead.
Parameters:
`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.
• #### SpatialContext

```@Deprecated
public SpatialContext(boolean geo)```
Deprecated.
• #### SpatialContext

`public SpatialContext(SpatialContextFactory factory)`
• ### Method Detail

• #### getShapeFactory

`public ShapeFactory getShapeFactory()`
A factory for `Shape`s.
• #### getFormats

`public SupportedFormats getFormats()`
• #### getDistCalc

`public DistanceCalculator getDistCalc()`
• #### calcDistance

```public double calcDistance(Point p,
double x2,
double y2)```
Convenience that uses `getDistCalc()`
• #### calcDistance

```public double calcDistance(Point p,
Point p2)```
Convenience that uses `getDistCalc()`
• #### getWorldBounds

`public Rectangle getWorldBounds()`
The extent of x & y coordinates should fit within the return'ed rectangle. Do *NOT* invoke reset() on this return type.
• #### isNormWrapLongitude

```@Deprecated
public boolean isNormWrapLongitude()```
Deprecated.
If true then `normX(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
public double normX(double x)```
Deprecated.
Normalize the 'x' dimension. Might reduce precision or wrap it to be within the bounds. This is called by `WKTReader` before creating a shape.
• #### normY

```@Deprecated
public double normY(double y)```
Deprecated.
Normalize the 'y' dimension. Might reduce precision or wrap it to be within the bounds. This is called by `WKTReader` before creating a shape.
• #### verifyX

```@Deprecated
public void verifyX(double x)```
Deprecated.
Ensure fits in `getWorldBounds()`. It's called by any shape factory method that gets an 'x' dimension.
• #### verifyY

```@Deprecated
public void verifyY(double y)```
Deprecated.
Ensure fits in `getWorldBounds()`. It's called by any shape factory method that gets a 'y' dimension.
• #### makePoint

```@Deprecated
public Point makePoint(double x,
double y)```
Deprecated.
Construct a point.
• #### makeRectangle

```@Deprecated
public Rectangle makeRectangle(Point lowerLeft,
Point upperRight)```
Deprecated.
Construct a rectangle.
• #### makeRectangle

```@Deprecated
public Rectangle makeRectangle(double minX,
double maxX,
double minY,
double maxY)```
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
public Circle makeCircle(double x,
double y,
double distance)```
Deprecated.
Construct a circle. The units of "distance" should be the same as x & y.
• #### makeCircle

```@Deprecated
public Circle makeCircle(Point point,
double distance)```
Deprecated.
Construct a circle. The units of "distance" should be the same as x & y.
• #### makeLineString

```@Deprecated
public Shape makeLineString(List<Point> points)```
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
public Shape makeBufferedLineString(List<Point> points,
double buf)```
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
public <S extends Shape> ShapeCollection<S> makeCollection(List<S> coll)```
Deprecated.
Construct a ShapeCollection, analogous to an OGC GeometryCollection.
• #### getWktShapeParser

```@Deprecated
Deprecated.

```@Deprecated
public Shape readShapeFromWkt(String wkt)
throws ParseException,
InvalidShapeException```
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`
`WKTReader`
• #### getBinaryCodec

`public BinaryCodec getBinaryCodec()`

```@Deprecated
public Shape readShape(String value)
throws InvalidShapeException```
Deprecated.
Try to read a shape from any supported formats
Returns:
shape or null if unable to parse any shape
Throws:
`InvalidShapeException`
• #### toString

```@Deprecated
public String toString(Shape shape)```
Deprecated.
Writes the shape to a String using the old/deprecated `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.
Parameters:
`shape` - non-null
Returns:
non-null
• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`