Class S2LatLngRectBase
java.lang.Object
com.google.common.geometry.S2LatLngRectBase
- All Implemented Interfaces:
S2Region, Serializable
- Direct Known Subclasses:
S2LatLngRect, S2LatLngRect.Builder
@GwtCompatible(serializable=false)
public abstract class S2LatLngRectBase
extends Object
implements S2Region, Serializable
Base class for methods shared between the immutable
S2LatLngRect and the mutable S2LatLngRect.Builder.- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanapproxEquals(S2LatLngRectBase other) Returns true if this rectangle is very nearly identical to the given other rectangle.final booleanapproxEquals(S2LatLngRectBase other, double maxError) Returns true if the latitude and longitude intervals of the two rectangles are the same up to the given tolerance.final booleanapproxEquals(S2LatLngRectBase other, S2LatLng maxError) AsapproxEquals(S2LatLngRectBase, double), but with separate tolerances for latitude and longitude.final doublearea()Returns the surface area of this rectangle on the unit sphere.final booleanboundaryIntersects(S2Point v0, S2Point v1) Returns true if the boundary of this rectangle intersects the given geodesic edge (v0, v1).final booleanReturns true if this latitude/longitude region contains the given cell.final booleanMore efficient version of contains() that accepts a S2LatLng rather than an S2Point.final booleancontains(S2LatLngRectBase other) Returns true if and only if the rectangle contains the given other rectangle.final booleanThe point 'p' does not need to be normalized.final booleanReturns true if these are the same type of rectangle and contain the same set of points.Return a bounding spherical cap.final S2LatLngReturns the center of the rectangle in latitude-longitude space (in general this is not the center of the region on the sphere).final S2Pointfinal S1AngleReturns the directed Hausdorff distance (measured along the surface of the sphere) to the given S2LatLngRect.final S1AngleReturns the minimum distance (measured along the surface of the sphere) from a given point to the rectangle (both its boundary and its interior).final S1AnglegetDistance(S2LatLngRectBase other) Returns the minimum distance (measured along the surface of the sphere) to the given S2LatLngRectBase.final S1AngleReturns the undirected Hausdorff distance (measured along the surface of the sphere) to the given S2LatLngRect.final S2LatLnggetSize()Returns the width and height of this rectangle in latitude-longitude space.final S2LatLnggetVertex(int k) Returns the kth vertex of the rectangle (k = 0,1,2,3) in CCW order (lower-left, lower right, upper right, upper left).final inthashCode()final S2LatLnghi()final booleanMore efficient version of interiorContains() that accepts a S2LatLng rather than an S2Point.final booleaninteriorContains(S2LatLngRectBase other) Returns true if and only if the interior of this rectangle contains all points of the given other rectangle (including its boundary).final booleanReturns true if and only if the given point is contained in the interior of the region (i.e. the region excluding its boundary).final booleanReturns true if and only if the interior of this rectangle intersects any point (including the boundary) of the given other rectangle.final booleanintersects(S2Cell cell) Returns true if this rectangle intersects the given cell.final booleanintersects(S2LatLngRectBase other) Returns true if this rectangle and the given other rectangle have any points in common.static final booleanintersectsLatEdge(S2Point a, S2Point b, double lat, S1Interval lng) Returns true if the edge AB intersects the given edge of constant latitude.static final booleanintersectsLngEdge(S2Point a, S2Point b, R1Interval lat, double lng) Returns true if the edge AB intersects the given edge of constant longitude.final booleanisEmpty()Returns true if the rectangle is empty, i.e. it contains no points at all.final booleanisFull()Returns true if the rectangle is full, i.e. it contains all points.final booleanReturns true if lng_.lo() > lng_.hi(), i.e. the rectangle crosses the 180 degree latitude line.final booleanisPoint()Returns true if the rectangle is a point, i.e. lo() == hi()final booleanisValid()Returns true if the rectangle is valid, which essentially just means that the latitude bounds do not exceed Pi/2 in absolute value and the longitude bounds do not exceed Pi in absolute value.abstract R1Intervallat()Returns the latitude range of this rectangle.final S1AnglelatHi()final S1AnglelatLo()abstract S1Intervallng()Returns the longitude range of this rectangle.final S1AnglelngHi()final S1AnglelngLo()final S2LatLnglo()final booleanmayIntersect(S2Cell cell) This test is cheap but is NOT exact.final StringtoString()final StringMethods inherited from interface S2Region
getRectBound
-
Field Details
-
lat
-
lng
-
-
Method Details
-
isValid
public final boolean isValid()Returns true if the rectangle is valid, which essentially just means that the latitude bounds do not exceed Pi/2 in absolute value and the longitude bounds do not exceed Pi in absolute value. Also, if either the latitude or longitude bound is empty then both must be. -
latLo
-
latHi
-
lngLo
-
lngHi
-
lat
Returns the latitude range of this rectangle. -
lng
Returns the longitude range of this rectangle. -
lo
-
hi
-
isEmpty
public final boolean isEmpty()Returns true if the rectangle is empty, i.e. it contains no points at all. -
isFull
public final boolean isFull()Returns true if the rectangle is full, i.e. it contains all points. -
isPoint
public final boolean isPoint()Returns true if the rectangle is a point, i.e. lo() == hi() -
isInverted
public final boolean isInverted()Returns true if lng_.lo() > lng_.hi(), i.e. the rectangle crosses the 180 degree latitude line. -
getVertex
Returns the kth vertex of the rectangle (k = 0,1,2,3) in CCW order (lower-left, lower right, upper right, upper left). -
getCenter
Returns the center of the rectangle in latitude-longitude space (in general this is not the center of the region on the sphere). -
getDistance
-
getDistance
Returns the minimum distance (measured along the surface of the sphere) to the given S2LatLngRectBase. Both S2LatLngRectBases must be non-empty. -
getHausdorffDistance
Returns the undirected Hausdorff distance (measured along the surface of the sphere) to the given S2LatLngRect. The directed Hausdorff distance from rectangle A to rectangle B is given byh(A, B) = max_{p in A} min_{q in B} d(p, q). The Hausdorff distance between rectangle A and rectangle B is given byH(A, B) = max{h(A, B), h(B, A)}. -
getDirectedHausdorffDistance
Returns the directed Hausdorff distance (measured along the surface of the sphere) to the given S2LatLngRect. The directed Hausdorff distance from rectangle A to rectangle B is given byh(A, B) = max_{p in A} min_{q in B} d(p, q). The Hausdorff distance between rectangle A and rectangle B is given byH(A, B) = max{h(A, B), h(B, A)}. -
getSize
Returns the width and height of this rectangle in latitude-longitude space. Empty rectangles have a negative width and height. -
getCentroid
-
contains
More efficient version of contains() that accepts a S2LatLng rather than an S2Point. -
interiorContains
Returns true if and only if the given point is contained in the interior of the region (i.e. the region excluding its boundary). The point 'p' does not need to be normalized. -
interiorContains
More efficient version of interiorContains() that accepts a S2LatLng rather than an S2Point. -
contains
Returns true if and only if the rectangle contains the given other rectangle. -
interiorContains
Returns true if and only if the interior of this rectangle contains all points of the given other rectangle (including its boundary). -
intersects
Returns true if this rectangle and the given other rectangle have any points in common. -
intersects
Returns true if this rectangle intersects the given cell. (This is an exact test and may be fairly expensive, see also MayIntersect below.) -
interiorIntersects
Returns true if and only if the interior of this rectangle intersects any point (including the boundary) of the given other rectangle. -
boundaryIntersects
-
area
public final double area()Returns the surface area of this rectangle on the unit sphere. -
equals
-
approxEquals
Returns true if the latitude and longitude intervals of the two rectangles are the same up to the given tolerance. SeeR1IntervalandS1Intervalfor details. -
approxEquals
Returns true if this rectangle is very nearly identical to the given other rectangle. -
approxEquals
AsapproxEquals(S2LatLngRectBase, double), but with separate tolerances for latitude and longitude. -
hashCode
-
getCapBound
Description copied from interface:S2RegionReturn a bounding spherical cap.- Specified by:
getCapBoundin interfaceS2Region
-
contains
Returns true if this latitude/longitude region contains the given cell. A latitude-longitude rectangle contains a cell if and only if it contains the cell's bounding rectangle, making this an exact test. Note, however, that the cell must be valid; an error may result if e.g.S2CellId.sentinel()is passed here. -
mayIntersect
This test is cheap but is NOT exact. Use Intersects() if you want a more accurate and more expensive test. Note that when this method is used by an S2RegionCoverer, the accuracy isn't all that important since if a cell may intersect the region then it is subdivided, and the accuracy of this method goes up as the cells get smaller.- Specified by:
mayIntersectin interfaceS2Region
-
contains
-
intersectsLngEdge
Returns true if the edge AB intersects the given edge of constant longitude. -
intersectsLatEdge
Returns true if the edge AB intersects the given edge of constant latitude. -
toString
-
toStringDegrees
-