Class RectangleImpl
java.lang.Object
org.locationtech.spatial4j.shape.BaseShape<SpatialContext>
org.locationtech.spatial4j.shape.impl.RectangleImpl
A simple Rectangle implementation that also supports a longitudinal
wrap-around. When minX > maxX, this will assume it is world coordinates that
cross the date line using degrees. Immutable & threadsafe.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionRectangleImpl(double minX, double maxX, double minY, double maxY, SpatialContext ctx) A simple constructor without normalization / validation.RectangleImpl(Point lowerLeft, Point upperRight, SpatialContext ctx) A convenience constructor which pulls out the coordinates.RectangleImpl(Rectangle r, SpatialContext ctx) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanThe sub-classes of Shape generally implement the same contract forObject.equals(Object)andObject.hashCode()amongst the same sub-interface type.static booleanAllRectangleimplementations should use this definition ofObject.equals(Object).doublegetArea(SpatialContext ctx) Calculates the area of the shape, in square-degrees.Get the bounding box for this Shape.getBuffered(double distance, SpatialContext ctx) Returns a buffered version of this shape.Returns the center point of this shape.booleanOnly meaningful for geospatial contexts.doubleThe height.doublegetMaxX()The right edge of the X coordinate.doublegetMaxY()The top edge of the Y coordinate.doublegetMinX()The left edge of the X coordinate.doublegetMinY()The bottom edge of the Y coordinate.doublegetWidth()The width.booleanhasArea()Does the shape have area?inthashCode()static intAllRectangleimplementations should use this definition ofObject.hashCode().booleanisEmpty()Shapes can be "empty", which is to say it exists nowhere.Describe the relationship between the two objects.relateXRange(double ext_minX, double ext_maxX) A specialization ofShape.relate(Shape)for a horizontal line.relateYRange(double ext_minY, double ext_maxY) A specialization ofShape.relate(Shape)for a vertical line.voidreset(double minX, double maxX, double minY, double maxY) Expert: Resets the state of this shape given the arguments.toString()Methods inherited from class BaseShape
getContextMethods inherited from interface Shape
getContext
-
Constructor Details
-
RectangleImpl
A simple constructor without normalization / validation. -
RectangleImpl
A convenience constructor which pulls out the coordinates. -
RectangleImpl
Copy constructor.
-
-
Method Details
-
reset
public void reset(double minX, double maxX, double minY, double maxY) Description copied from interface:RectangleExpert: Resets the state of this shape given the arguments. This is a performance feature to avoid excessive Shape object allocation as well as some argument error checking. Mutable shapes is error-prone so use with care. -
isEmpty
-
getBuffered
Description copied from interface:ShapeReturns a buffered version of this shape. The buffer is usually a rounded-corner buffer, although some shapes might buffer differently. This is an optional operation.- Specified by:
getBufferedin interfaceShape- Returns:
- Not null, and the returned shape should contain the current shape.
-
hasArea
public boolean hasArea()Description copied from interface:ShapeDoes the shape have area? This will be false for points and lines. It will also be false for shapes that normally have area but are constructed in a degenerate case as to not have area (e.g. a circle with 0 radius or rectangle with no height or no width). -
getArea
Description copied from interface:ShapeCalculates the area of the shape, in square-degrees. If ctx is null then simple Euclidean calculations will be used. This figure can be an estimate. -
getCrossesDateLine
public boolean getCrossesDateLine()Description copied from interface:RectangleOnly meaningful for geospatial contexts.- Specified by:
getCrossesDateLinein interfaceRectangle
-
getHeight
-
getWidth
-
getMaxX
-
getMaxY
-
getMinX
-
getMinY
-
getBoundingBox
Description copied from interface:ShapeGet the bounding box for this Shape. This means the shape is within the bounding box and that it touches each side of the rectangle.Postcondition:
this.getBoundingBox().relate(this) == CONTAINS- Specified by:
getBoundingBoxin interfaceShape
-
relate
Description copied from interface:ShapeDescribe the relationship between the two objects. For example- this is WITHIN other
- this CONTAINS other
- this is DISJOINT other
- this INTERSECTS other
If the shapes are equal then the result is CONTAINS (preferred) or WITHIN.
-
relate
-
relate
-
relateYRange
Description copied from interface:RectangleA specialization ofShape.relate(Shape)for a vertical line.- Specified by:
relateYRangein interfaceRectangle
-
relateXRange
Description copied from interface:RectangleA specialization ofShape.relate(Shape)for a horizontal line.- Specified by:
relateXRangein interfaceRectangle
-
toString
-
getCenter
-
equals
Description copied from interface:ShapeThe sub-classes of Shape generally implement the same contract forObject.equals(Object)andObject.hashCode()amongst the same sub-interface type. This means, for example, that multiple Point implementations of different classes are equal if they share the same x & y. -
equals
AllRectangleimplementations should use this definition ofObject.equals(Object). -
hashCode
-
hashCode
AllRectangleimplementations should use this definition ofObject.hashCode().
-