Package com.google.common.geometry
Class S2LatLngRect.Builder
java.lang.Object
com.google.common.geometry.S2LatLngRectBase
com.google.common.geometry.S2LatLngRect.Builder
- All Implemented Interfaces:
S2Region
,Serializable
- Enclosing class:
S2LatLngRect
This class is a builder for S2LatLngRect instances. This is much more efficient when creating
the bounds from numerous operations, as it ensures that the S2LatLngRect is only created once.
Example usage:
S2LatLngRect union(List<S2LatLng> points) { S2LatLngRect.Builder builder = new
S2LatLngRect.Builder(); for (S2LatLng point : points) { builder.addPoint(point); } return
builder.build(); }
- See Also:
-
Field Summary
Fields inherited from class com.google.common.geometry.S2LatLngRectBase
lat, lng
-
Constructor Summary
ConstructorsConstructorDescriptionBuilder
(R1Interval lat, S1Interval lng) Creates a new S2LatLngRect.Builder as a copy ofb
. -
Method Summary
Modifier and TypeMethodDescriptionIncreases the size of the bounding rectangle to include the given point.build()
Returns a new immutable S2LatLngRect copied from the current state of this builder.clone()
convolveWithCap
(S1Angle angle) Mutates the current rectangle to contain the convolution of this rectangle with a cap of the given angle.static S2LatLngRect.Builder
empty()
A builder initialized to be empty (such that it doesn't contain anything).Mutates the rectangle to contain all points whose latitude distance from this rectangle is at most margin.lat(), and whose longitude distance from this rectangle is at most margin.lng().Return a bounding latitude-longitude rectangle.intersection
(S2LatLngRect other) Mutates this rectangle to be the smallest rectangle containing the intersection of the current and given rectangles.final R1Interval
lat()
Returns the latitude range of this rectangle.final S1Interval
lng()
Returns the longitude range of this rectangle.If the rectangle does not include either pole, leave it unmodified.setFull()
Sets the rectangle to the full rectangle.union
(S2LatLngRect other) Mutates this rectangle to be the smallest rectangle containing the union of the current and given rectangles.Methods inherited from class com.google.common.geometry.S2LatLngRectBase
approxEquals, approxEquals, approxEquals, area, boundaryIntersects, contains, contains, contains, contains, equals, getCapBound, getCenter, getCentroid, getDirectedHausdorffDistance, getDistance, getDistance, getHausdorffDistance, getSize, getVertex, hashCode, hi, interiorContains, interiorContains, interiorContains, interiorIntersects, intersects, intersects, intersectsLatEdge, intersectsLngEdge, isEmpty, isFull, isInverted, isPoint, isValid, latHi, latLo, lngHi, lngLo, lo, mayIntersect, toString, toStringDegrees
-
Constructor Details
-
Builder
-
Builder
-
Builder
Creates a new S2LatLngRect.Builder as a copy ofb
.
-
-
Method Details
-
lat
Description copied from class:S2LatLngRectBase
Returns the latitude range of this rectangle.- Specified by:
lat
in classS2LatLngRectBase
-
lng
Description copied from class:S2LatLngRectBase
Returns the longitude range of this rectangle.- Specified by:
lng
in classS2LatLngRectBase
-
build
Returns a new immutable S2LatLngRect copied from the current state of this builder. -
empty
A builder initialized to be empty (such that it doesn't contain anything). -
setFull
Sets the rectangle to the full rectangle. -
addPoint
-
addPoint
Increases the size of the bounding rectangle to include the given point. The rectangle is expanded by the minimum amount possible. -
expanded
Mutates the rectangle to contain all points whose latitude distance from this rectangle is at most margin.lat(), and whose longitude distance from this rectangle is at most margin.lng(). In particular, latitudes are clamped while longitudes are wrapped. Note that any expansion of an empty interval remains empty, and both components of the given margin must be non-negative.NOTE: If you are trying to grow a rectangle by a certain *distance* on the sphere (e.g. 5km), use the convolveWithCap() method instead.
-
polarClosure
If the rectangle does not include either pole, leave it unmodified. Otherwise expand the longitude range to full() so that the rectangle contains all possible representations of the contained pole(s). -
union
Mutates this rectangle to be the smallest rectangle containing the union of the current and given rectangles. -
intersection
Mutates this rectangle to be the smallest rectangle containing the intersection of the current and given rectangles. Note that the region of intersection may consist of two disjoint rectangles, in which case we set the rectangle to be a single rectangle spanning both of them. -
convolveWithCap
Mutates the current rectangle to contain the convolution of this rectangle with a cap of the given angle. This expands the rectangle by a fixed distance (as opposed to growing the rectangle in latitude-longitude space). The new rectangle includes all points whose minimum distance to the original rectangle is at most the given angle. -
clone
-
getRectBound
Description copied from interface:S2Region
Return a bounding latitude-longitude rectangle.
-