Class ShapeFactoryImpl
- java.lang.Object
-
- org.locationtech.spatial4j.shape.impl.ShapeFactoryImpl
-
- All Implemented Interfaces:
ShapeFactory
- Direct Known Subclasses:
JtsShapeFactory
public class ShapeFactoryImpl extends Object implements ShapeFactory
The defaultShapeFactory
. It does not support polygon shapes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
ShapeFactoryImpl.GeneralShapeMultiShapeBuilder<T extends Shape>
-
Nested classes/interfaces inherited from interface org.locationtech.spatial4j.shape.ShapeFactory
ShapeFactory.LineStringBuilder, ShapeFactory.MultiLineStringBuilder, ShapeFactory.MultiPointBuilder, ShapeFactory.MultiPolygonBuilder, ShapeFactory.MultiShapeBuilder<T extends Shape>, ShapeFactory.PointsBuilder<T>, ShapeFactory.PolygonBuilder
-
-
Field Summary
Fields Modifier and Type Field Description protected SpatialContext
ctx
-
Constructor Summary
Constructors Constructor Description ShapeFactoryImpl(SpatialContext ctx, SpatialContextFactory factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Circle
circle(double x, double y, double distance)
Construct a circle.Circle
circle(Point point, double distance)
Construct a circle.SpatialContext
getSpatialContext()
boolean
isNormWrapLongitude()
If true thenShapeFactory.normX(double)
will wrap longitudes outside of the standard geodetic boundary into it.ShapeFactory.LineStringBuilder
lineString()
(Builder) Constructs a line string, with a possible buffer.Shape
lineString(List<Point> points, double buf)
Constructs a line string with a possible buffer.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>
ShapeFactory.MultiShapeBuilder<T>multiShape(Class<T> shapeClass)
(Builder) Constructs a Shape aggregate in which each component/member is an instance of the specified class.<S extends Shape>
ShapeCollection<S>multiShape(List<S> coll)
Construct a ShapeCollection, analogous to an OGC GeometryCollection.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.Rectangle
rect(double minX, double maxX, double minY, double maxY)
Construct a rectangle.Rectangle
rect(Point lowerLeft, Point upperRight)
Construct a rectangle.void
verifyX(double x)
Ensure fits in the world bounds.void
verifyY(double y)
void
verifyZ(double z)
(disclaimer: the Z dimension isn't fully supported)
-
-
-
Field Detail
-
ctx
protected final SpatialContext ctx
-
-
Constructor Detail
-
ShapeFactoryImpl
public ShapeFactoryImpl(SpatialContext ctx, SpatialContextFactory factory)
-
-
Method Detail
-
getSpatialContext
public SpatialContext getSpatialContext()
- Specified by:
getSpatialContext
in interfaceShapeFactory
-
isNormWrapLongitude
public boolean isNormWrapLongitude()
Description copied from interface:ShapeFactory
If true thenShapeFactory.normX(double)
will wrap longitudes outside of the standard geodetic boundary into it. Example: 181 will become -179.- Specified by:
isNormWrapLongitude
in interfaceShapeFactory
-
normX
public double normX(double x)
Description copied from interface:ShapeFactory
Normalize the 'x' dimension. Might reduce precision or wrap it to be within the bounds. This is called byShapeReader
s before creating a shape.- Specified by:
normX
in interfaceShapeFactory
-
normY
public double normY(double y)
- Specified by:
normY
in interfaceShapeFactory
- See Also:
ShapeFactory.normX(double)
-
normZ
public double normZ(double z)
Description copied from interface:ShapeFactory
(disclaimer: the Z dimension isn't fully supported)- Specified by:
normZ
in interfaceShapeFactory
- See Also:
ShapeFactory.normX(double)
-
normDist
public double normDist(double d)
Description copied from interface:ShapeFactory
Called to normalize a value that isn't X or Y or Z. X & Y & Z are normalized viaSpatialContext.normX(double)
& normY & normZ. This is called by aShapeReader
before creating a shape.- Specified by:
normDist
in interfaceShapeFactory
-
verifyX
public void verifyX(double x)
Description copied from interface:ShapeFactory
Ensure fits in the world bounds. It's called by any shape factory method that gets an 'x' dimension.- Specified by:
verifyX
in interfaceShapeFactory
-
verifyY
public void verifyY(double y)
- Specified by:
verifyY
in interfaceShapeFactory
- See Also:
ShapeFactory.verifyX(double)
-
verifyZ
public void verifyZ(double z)
Description copied from interface:ShapeFactory
(disclaimer: the Z dimension isn't fully supported)- Specified by:
verifyZ
in interfaceShapeFactory
- See Also:
ShapeFactory.verifyX(double)
-
pointXY
public Point pointXY(double x, double y)
Description copied from interface:ShapeFactory
Construct a point.- Specified by:
pointXY
in interfaceShapeFactory
-
pointXYZ
public Point pointXYZ(double x, double y, double z)
Description copied from interface:ShapeFactory
Construct a point of 3 dimensions. The implementation might ignore unsupported dimensions like 'z' or throw an error.- Specified by:
pointXYZ
in interfaceShapeFactory
-
rect
public Rectangle rect(Point lowerLeft, Point upperRight)
Description copied from interface:ShapeFactory
Construct a rectangle.- Specified by:
rect
in interfaceShapeFactory
-
rect
public Rectangle rect(double minX, double maxX, double minY, double maxY)
Description copied from interface:ShapeFactory
Construct a rectangle. If just one longitude is on the dateline (+/- 180) and ifSpatialContext.isGeo()
then potentially adjust its sign to ensure the rectangle does not cross the dateline (aka anti-meridian).- Specified by:
rect
in interfaceShapeFactory
-
circle
public Circle circle(double x, double y, double distance)
Description copied from interface:ShapeFactory
Construct a circle. The units of "distance" should be the same as x & y.- Specified by:
circle
in interfaceShapeFactory
-
circle
public Circle circle(Point point, double distance)
Description copied from interface:ShapeFactory
Construct a circle. The units of "distance" should be the same as x & y.- Specified by:
circle
in interfaceShapeFactory
-
lineString
public Shape lineString(List<Point> points, double buf)
Description copied from interface:ShapeFactory
Constructs a line string with a possible buffer. 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.- Specified by:
lineString
in interfaceShapeFactory
-
lineString
public ShapeFactory.LineStringBuilder lineString()
Description copied from interface:ShapeFactory
(Builder) Constructs a line string, with a possible buffer. It's an ordered sequence of connected vertexes. There is no official shape/interface for it yet so we just return Shape.- Specified by:
lineString
in interfaceShapeFactory
-
multiShape
public <S extends Shape> ShapeCollection<S> multiShape(List<S> coll)
Description copied from interface:ShapeFactory
Construct a ShapeCollection, analogous to an OGC GeometryCollection.- Specified by:
multiShape
in interfaceShapeFactory
-
multiShape
public <T extends Shape> ShapeFactory.MultiShapeBuilder<T> multiShape(Class<T> shapeClass)
Description copied from interface:ShapeFactory
(Builder) Constructs a Shape aggregate in which each component/member is an instance of the specified class.- Specified by:
multiShape
in interfaceShapeFactory
-
multiPoint
public ShapeFactory.MultiPointBuilder multiPoint()
Description copied from interface:ShapeFactory
(Builder) Constructs a MultiPoint.- Specified by:
multiPoint
in interfaceShapeFactory
-
multiLineString
public ShapeFactory.MultiLineStringBuilder multiLineString()
Description copied from interface:ShapeFactory
(Builder) Constructs a MultiLineString, or possibly the result of that buffered.- Specified by:
multiLineString
in interfaceShapeFactory
-
multiPolygon
public ShapeFactory.MultiPolygonBuilder multiPolygon()
Description copied from interface:ShapeFactory
(Builder) Constructs a MultiPolygon.- Specified by:
multiPolygon
in interfaceShapeFactory
-
polygon
public ShapeFactory.PolygonBuilder polygon()
Description copied from interface:ShapeFactory
(Builder) Constructs a polygon. There is no official shape/interface for it yet so we just return Shape.- Specified by:
polygon
in interfaceShapeFactory
-
-