Class CircleImpl
- java.lang.Object
-
- org.locationtech.spatial4j.shape.BaseShape<SpatialContext>
-
- org.locationtech.spatial4j.shape.impl.CircleImpl
-
- Direct Known Subclasses:
GeoCircle
public class CircleImpl extends BaseShape<SpatialContext> implements Circle
A circle, also known as a point-radius, based on aDistanceCalculator
which does all the work. This implementation should work for both cartesian 2D and geodetic sphere surfaces.
-
-
Constructor Summary
Constructors Constructor Description CircleImpl(Point p, double radiusDEG, SpatialContext ctx)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(double x, double y)
boolean
equals(java.lang.Object obj)
The sub-classes of Shape generally implement the same contract forObject.equals(Object)
andObject.hashCode()
amongst the same sub-interface type.static boolean
equals(Circle thiz, java.lang.Object o)
AllCircle
implementations should use this definition ofObject.equals(Object)
.double
getArea(SpatialContext ctx)
Calculates the area of the shape, in square-degrees.Rectangle
getBoundingBox()
Note that the bounding box might contain a minX that is > maxX, due to WGS84 anti-meridian.Circle
getBuffered(double distance, SpatialContext ctx)
Returns a buffered version of this shape.Point
getCenter()
Returns the center point of this shape.double
getRadius()
The distance from the point's center to its edge, measured in the same units as x & y (e.g.protected double
getXAxis()
TheX
coordinate of where the circle axis intersect.protected double
getYAxis()
TheY
coordinate of where the circle axis intersect.boolean
hasArea()
Does the shape have area? This will be false for points and lines.int
hashCode()
static int
hashCode(Circle thiz)
AllCircle
implementations should use this definition ofObject.hashCode()
.boolean
isEmpty()
Shapes can be "empty", which is to say it exists nowhere.SpatialRelation
relate(Circle circle)
SpatialRelation
relate(Point point)
SpatialRelation
relate(Rectangle r)
SpatialRelation
relate(Shape other)
Describe the relationship between the two objects.protected SpatialRelation
relateRectanglePhase2(Rectangle r, SpatialRelation bboxSect)
void
reset(double x, double y, double radiusDEG)
Expert: Resets the state of this shape given the arguments.java.lang.String
toString()
-
Methods inherited from class org.locationtech.spatial4j.shape.BaseShape
getContext
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.locationtech.spatial4j.shape.Shape
getContext
-
-
-
-
Constructor Detail
-
CircleImpl
public CircleImpl(Point p, double radiusDEG, SpatialContext ctx)
-
-
Method Detail
-
reset
public void reset(double x, double y, double radiusDEG)
Description copied from interface:Circle
Expert: 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
public boolean isEmpty()
Description copied from interface:Shape
Shapes can be "empty", which is to say it exists nowhere. The underlying coordinates are typically NaN.
-
getCenter
public Point getCenter()
Description copied from interface:Shape
Returns the center point of this shape. This is usually the same asgetBoundingBox().getCenter()
but it doesn't have to be.Postcondition:
this.relate(this.getCenter()) == CONTAINS
-
getRadius
public double getRadius()
Description copied from interface:Circle
The distance from the point's center to its edge, measured in the same units as x & y (e.g. degrees if WGS84).
-
getArea
public double getArea(SpatialContext ctx)
Description copied from interface:Shape
Calculates 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.
-
getBuffered
public Circle getBuffered(double distance, SpatialContext ctx)
Description copied from interface:Shape
Returns 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:
getBuffered
in interfaceShape
- Returns:
- Not null, and the returned shape should contain the current shape.
-
contains
public boolean contains(double x, double y)
-
hasArea
public boolean hasArea()
Description copied from interface:Shape
Does 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).
-
getBoundingBox
public Rectangle getBoundingBox()
Note that the bounding box might contain a minX that is > maxX, due to WGS84 anti-meridian.- Specified by:
getBoundingBox
in interfaceShape
-
relate
public SpatialRelation relate(Shape other)
Description copied from interface:Shape
Describe 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
public SpatialRelation relate(Point point)
-
relate
public SpatialRelation relate(Rectangle r)
-
relateRectanglePhase2
protected SpatialRelation relateRectanglePhase2(Rectangle r, SpatialRelation bboxSect)
-
getYAxis
protected double getYAxis()
TheY
coordinate of where the circle axis intersect.
-
getXAxis
protected double getXAxis()
TheX
coordinate of where the circle axis intersect.
-
relate
public SpatialRelation relate(Circle circle)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
Description copied from interface:Shape
The 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
public static boolean equals(Circle thiz, java.lang.Object o)
AllCircle
implementations should use this definition ofObject.equals(Object)
.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-