Package org.voltdb.types
Class GeographyPointValue
java.lang.Object
org.voltdb.types.GeographyPointValue
The Java class that corresponds to the SQL type GEOGRAPHY_POINT.
Represents a point as defined by its longitude and latitude.
-
Constructor Summary
ConstructorsConstructorDescriptionGeographyPointValue
(double longitude, double latitude) Construct a new GeographyPointValue from its coordinates. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compare this point with another object.void
flattenToBuffer
(ByteBuffer buffer) Serialize this point to a ByteBuffer.static GeographyPointValue
Create a GeographyPointValue from a well-known text string.double
Return the latitude of this point in degrees.static int
Returns the number of bytes an instance of this class requires when serialized to a ByteBuffer.double
Return the longitude of this point in degrees.static int
The largest number of characters needed to represent a point value as a string.static GeographyPointValue
normalizeLngLat
(double longitude, double latitude) Create a GeographyPointValue with normalized coordinates.void
serialize
(DataOutput output) Serialize this point to aDataOutput
static void
serializeNull
(ByteBuffer buffer) Serialize the null point (that is, a SQL null value) to a ByteBuffer, at the buffer's current position.toString()
Return this point as a well-known text string.toWKT()
Return this point as a well-known text string.static GeographyPointValue
unflattenFromBuffer
(ByteBuffer inBuffer) Deserialize a point from a ByteBuffer at the buffer's current positionstatic GeographyPointValue
unflattenFromBuffer
(ByteBuffer inBuffer, int offset) Deserializes a point from a ByteBuffer, at an absolute offset.
-
Constructor Details
-
GeographyPointValue
public GeographyPointValue(double longitude, double latitude) Construct a new GeographyPointValue from its coordinates.- Parameters:
longitude
- in degrees.latitude
- in degrees.
-
-
Method Details
-
fromWKT
Create a GeographyPointValue from a well-known text string.- Parameters:
param
- A well-known text string.- Returns:
- A new instance of GeographyPointValue.
-
getLatitude
public double getLatitude()Return the latitude of this point in degrees.- Returns:
- The latitude of this point in degrees.
-
getLongitude
public double getLongitude()Return the longitude of this point in degrees.- Returns:
- The longitude of this point in degrees.
-
toString
Return this point as a well-known text string. -
toWKT
Return this point as a well-known text string.- Returns:
- This point as a well-known text string.
-
getValueDisplaySize
public static int getValueDisplaySize()The largest number of characters needed to represent a point value as a string.- Returns:
- number of characters needed for display
-
equals
Compare this point with another object. Returns true if this point is being compared to another point that represents the same location. -
getLengthInBytes
public static int getLengthInBytes()Returns the number of bytes an instance of this class requires when serialized to a ByteBuffer.- Returns:
- The number of bytes an instance of this class requires when serialized to a ByteBuffer.
-
flattenToBuffer
Serialize this point to a ByteBuffer.- Parameters:
buffer
- The ByteBuffer to which this point will be serialized.
-
serialize
Serialize this point to aDataOutput
- Parameters:
output
- to which this point will be serialized- Throws:
IOException
- if any I/O error occurs
-
unflattenFromBuffer
Deserializes a point from a ByteBuffer, at an absolute offset.- Parameters:
inBuffer
- The ByteBuffer from which to read the bytes for a point.offset
- Absolute offset of point data in buffer.- Returns:
- A new instance of GeographyPointValue.
-
unflattenFromBuffer
Deserialize a point from a ByteBuffer at the buffer's current position- Parameters:
inBuffer
- The ByteBuffer from which to read the bytes for a point.- Returns:
- A new instance of GeographyPointValue.
-
serializeNull
Serialize the null point (that is, a SQL null value) to a ByteBuffer, at the buffer's current position.- Parameters:
buffer
- The ByteBuffer to which a null point will be serialized.
-
normalizeLngLat
Create a GeographyPointValue with normalized coordinates. The longitude and latitude inputs may be any real numbers. They are not restricted to be in the ranges [-180,180] or [-90,90] respectively. The created instance will will have coordinates between (-180,180) and [-90,90].- Parameters:
longitude
- in degrees, not range-restricted.latitude
- in degrees, not range-restricted.- Returns:
- A GeographyPointValue with the given coordinates normalized.
-