Package com.google.common.geometry
Class S2PointRegion
- java.lang.Object
-
- com.google.common.geometry.S2PointRegion
-
- All Implemented Interfaces:
S2Region
,java.io.Serializable
,java.lang.Comparable<S2PointRegion>
@GwtCompatible(serializable=true) public final class S2PointRegion extends java.lang.Object implements S2Region, java.lang.Comparable<S2PointRegion>, java.io.Serializable
An S2PointRegion is a region that contains a single point. It is more expensive than the raw S2Point type and is useful mainly for completeness.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private S2Point
point
private static byte
POINT_REGION_LOSSLESS_ENCODING_VERSION
The byte in a stream that signifies the lossless encoding of an S2PointRegion follows.
-
Constructor Summary
Constructors Constructor Description S2PointRegion()
S2PointRegion(double x, double y, double z)
S2PointRegion(S2Point point)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(S2PointRegion other)
boolean
contains(S2Cell cell)
If this method returns true, the region completely contains the given cell.boolean
contains(S2Point p)
Returns true if and only if the given point is contained by the region.(package private) static S2PointRegion
decode(LittleEndianInput is)
Returns a new S2PointRegion decoded from the given little endian input stream.static S2PointRegion
decode(java.io.InputStream is)
Returns a new S2PointRegion decoded from the given input stream.(package private) void
encode(LittleEndianOutput os)
Writes this point region to the given little endian output stream.void
encode(java.io.OutputStream os)
Writes this point region to the given output stream.boolean
equals(java.lang.Object that)
S2Cap
getCapBound()
Return a bounding spherical cap.S2Point
getPoint()
S2LatLngRect
getRectBound()
Return a bounding latitude-longitude rectangle.double
getX()
double
getY()
double
getZ()
int
hashCode()
Calcualates hashcode based on stored coordinates.boolean
lessThan(S2PointRegion vb)
boolean
mayIntersect(S2Cell cell)
If this method returns false, the region does not intersect the given cell.java.lang.String
toDegreesString()
java.lang.String
toString()
-
-
-
Field Detail
-
POINT_REGION_LOSSLESS_ENCODING_VERSION
private static final byte POINT_REGION_LOSSLESS_ENCODING_VERSION
The byte in a stream that signifies the lossless encoding of an S2PointRegion follows.- See Also:
- Constant Field Values
-
point
private final S2Point point
-
-
Constructor Detail
-
S2PointRegion
public S2PointRegion()
-
S2PointRegion
public S2PointRegion(double x, double y, double z)
-
S2PointRegion
public S2PointRegion(S2Point point)
-
-
Method Detail
-
getPoint
public S2Point getPoint()
-
getX
public double getX()
-
getY
public double getY()
-
getZ
public double getZ()
-
equals
public boolean equals(java.lang.Object that)
- Overrides:
equals
in classjava.lang.Object
-
lessThan
public boolean lessThan(S2PointRegion vb)
-
compareTo
public int compareTo(S2PointRegion other)
- Specified by:
compareTo
in interfacejava.lang.Comparable<S2PointRegion>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toDegreesString
public java.lang.String toDegreesString()
-
hashCode
public int hashCode()
Calcualates hashcode based on stored coordinates. Since we want +0.0 and -0.0 to be treated the same, we ignore the sign of the coordinates.- Overrides:
hashCode
in classjava.lang.Object
-
contains
public boolean contains(S2Cell cell)
Description copied from interface:S2Region
If this method returns true, the region completely contains the given cell. Otherwise, either the region does not contain the cell or the containment relationship could not be determined.
-
contains
public boolean contains(S2Point p)
Description copied from interface:S2Region
Returns true if and only if the given point is contained by the region.p
is generally required to be unit length, although some subtypes may relax this restriction.
-
getCapBound
public S2Cap getCapBound()
Description copied from interface:S2Region
Return a bounding spherical cap.- Specified by:
getCapBound
in interfaceS2Region
-
getRectBound
public S2LatLngRect getRectBound()
Description copied from interface:S2Region
Return a bounding latitude-longitude rectangle.- Specified by:
getRectBound
in interfaceS2Region
-
mayIntersect
public boolean mayIntersect(S2Cell cell)
Description copied from interface:S2Region
If this method returns false, the region does not intersect the given cell. Otherwise, either region intersects the cell, or the intersection relationship could not be determined.- Specified by:
mayIntersect
in interfaceS2Region
-
encode
public void encode(java.io.OutputStream os) throws java.io.IOException
Writes this point region to the given output stream.- Throws:
java.io.IOException
-
encode
void encode(LittleEndianOutput os) throws java.io.IOException
Writes this point region to the given little endian output stream.- Throws:
java.io.IOException
-
decode
public static S2PointRegion decode(java.io.InputStream is) throws java.io.IOException
Returns a new S2PointRegion decoded from the given input stream.- Throws:
java.io.IOException
-
decode
static S2PointRegion decode(LittleEndianInput is) throws java.io.IOException
Returns a new S2PointRegion decoded from the given little endian input stream.- Throws:
java.io.IOException
-
-