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 classShapeFactoryImpl.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 SpatialContextctx
-
Constructor Summary
Constructors Constructor Description ShapeFactoryImpl(SpatialContext ctx, SpatialContextFactory factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Circlecircle(double x, double y, double distance)Construct a circle.Circlecircle(Point point, double distance)Construct a circle.SpatialContextgetSpatialContext()booleanisNormWrapLongitude()If true thenShapeFactory.normX(double)will wrap longitudes outside of the standard geodetic boundary into it.ShapeFactory.LineStringBuilderlineString()(Builder) Constructs a line string, with a possible buffer.ShapelineString(List<Point> points, double buf)Constructs a line string with a possible buffer.ShapeFactory.MultiLineStringBuildermultiLineString()(Builder) Constructs a MultiLineString, or possibly the result of that buffered.ShapeFactory.MultiPointBuildermultiPoint()(Builder) Constructs a MultiPoint.ShapeFactory.MultiPolygonBuildermultiPolygon()(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.doublenormDist(double d)Called to normalize a value that isn't X or Y or Z.doublenormX(double x)Normalize the 'x' dimension.doublenormY(double y)doublenormZ(double z)(disclaimer: the Z dimension isn't fully supported)PointpointXY(double x, double y)Construct a point.PointpointXYZ(double x, double y, double z)Construct a point of 3 dimensions.ShapeFactory.PolygonBuilderpolygon()(Builder) Constructs a polygon.Rectanglerect(double minX, double maxX, double minY, double maxY)Construct a rectangle.Rectanglerect(Point lowerLeft, Point upperRight)Construct a rectangle.voidverifyX(double x)Ensure fits in the world bounds.voidverifyY(double y)voidverifyZ(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:
getSpatialContextin interfaceShapeFactory
-
isNormWrapLongitude
public boolean isNormWrapLongitude()
Description copied from interface:ShapeFactoryIf true thenShapeFactory.normX(double)will wrap longitudes outside of the standard geodetic boundary into it. Example: 181 will become -179.- Specified by:
isNormWrapLongitudein interfaceShapeFactory
-
normX
public double normX(double x)
Description copied from interface:ShapeFactoryNormalize the 'x' dimension. Might reduce precision or wrap it to be within the bounds. This is called byShapeReaders before creating a shape.- Specified by:
normXin interfaceShapeFactory
-
normY
public double normY(double y)
- Specified by:
normYin 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:
normZin interfaceShapeFactory- See Also:
ShapeFactory.normX(double)
-
normDist
public double normDist(double d)
Description copied from interface:ShapeFactoryCalled 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 aShapeReaderbefore creating a shape.- Specified by:
normDistin interfaceShapeFactory
-
verifyX
public void verifyX(double x)
Description copied from interface:ShapeFactoryEnsure fits in the world bounds. It's called by any shape factory method that gets an 'x' dimension.- Specified by:
verifyXin interfaceShapeFactory
-
verifyY
public void verifyY(double y)
- Specified by:
verifyYin 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:
verifyZin interfaceShapeFactory- See Also:
ShapeFactory.verifyX(double)
-
pointXY
public Point pointXY(double x, double y)
Description copied from interface:ShapeFactoryConstruct a point.- Specified by:
pointXYin interfaceShapeFactory
-
pointXYZ
public Point pointXYZ(double x, double y, double z)
Description copied from interface:ShapeFactoryConstruct a point of 3 dimensions. The implementation might ignore unsupported dimensions like 'z' or throw an error.- Specified by:
pointXYZin interfaceShapeFactory
-
rect
public Rectangle rect(Point lowerLeft, Point upperRight)
Description copied from interface:ShapeFactoryConstruct a rectangle.- Specified by:
rectin interfaceShapeFactory
-
rect
public Rectangle rect(double minX, double maxX, double minY, double maxY)
Description copied from interface:ShapeFactoryConstruct 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:
rectin interfaceShapeFactory
-
circle
public Circle circle(double x, double y, double distance)
Description copied from interface:ShapeFactoryConstruct a circle. The units of "distance" should be the same as x & y.- Specified by:
circlein interfaceShapeFactory
-
circle
public Circle circle(Point point, double distance)
Description copied from interface:ShapeFactoryConstruct a circle. The units of "distance" should be the same as x & y.- Specified by:
circlein interfaceShapeFactory
-
lineString
public Shape lineString(List<Point> points, double buf)
Description copied from interface:ShapeFactoryConstructs 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:
lineStringin 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:
lineStringin interfaceShapeFactory
-
multiShape
public <S extends Shape> ShapeCollection<S> multiShape(List<S> coll)
Description copied from interface:ShapeFactoryConstruct a ShapeCollection, analogous to an OGC GeometryCollection.- Specified by:
multiShapein 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:
multiShapein interfaceShapeFactory
-
multiPoint
public ShapeFactory.MultiPointBuilder multiPoint()
Description copied from interface:ShapeFactory(Builder) Constructs a MultiPoint.- Specified by:
multiPointin interfaceShapeFactory
-
multiLineString
public ShapeFactory.MultiLineStringBuilder multiLineString()
Description copied from interface:ShapeFactory(Builder) Constructs a MultiLineString, or possibly the result of that buffered.- Specified by:
multiLineStringin interfaceShapeFactory
-
multiPolygon
public ShapeFactory.MultiPolygonBuilder multiPolygon()
Description copied from interface:ShapeFactory(Builder) Constructs a MultiPolygon.- Specified by:
multiPolygonin 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:
polygonin interfaceShapeFactory
-
-