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
ConstructorDescriptionGeographyPointValue
(double longitude, double latitude) Construct a new GeographyPointValue from its coordinates. -
Method Summary
Modifier and TypeMethodDescriptionadd
(GeographyPointValue offset) Deprecated.add
(GeographyPointValue offset, double alpha) Deprecated.boolean
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.mul
(double alpha) Deprecated.static GeographyPointValue
normalizeLngLat
(double longitude, double latitude) Create a GeographyPointValue with normalized coordinates.rotate
(double phi, GeographyPointValue center) Deprecated.scale
(GeographyPointValue center, double alpha) Deprecated.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.sub
(GeographyPointValue offset) Deprecated.sub
(GeographyPointValue offset, double scale) Deprecated.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.
-
add
Deprecated.Return a point which is offset by the given offset point multiplied by alpha. That is, the return value isthis + alpha*offset
, except that Java does not allow one to write it in this way. In particular,this - other
is equal toadd(other, -1)
, but fewer temporary objects are created. Normalize the coordinates.- Parameters:
offset
- A point to add to this.alpha
- Coordinates of offset will be scaled by this much.- Returns:
- A new point offset by the scaled offset.
-
add
Deprecated.Add a point to this, and return the result.- Parameters:
offset
- The offset to add to this.- Returns:
- A new point which is this plus the offset.
-
sub
Deprecated.Subtract a given offset point from this, and return the result.- Parameters:
offset
- The offset to subtract from this.- Returns:
- A new point translated by -offset.
-
sub
Deprecated.Subtract a point from this, and return the result. The point being subtracted is computed by scaling a given offset point.- Parameters:
offset
- The offset to subtract from this.scale
- The amount by which to scale the offset point.- Returns:
- A new point translated by -offset.
-
mul
Deprecated.Return a point scaled by the given alpha value.- Parameters:
alpha
- The amount by which to scale this.- Returns:
- The scaled point.
-
rotate
Deprecated.Return a new point which is this point rotated by the angle phi around a given center point.- Parameters:
phi
- The angle to rotate in degrees.center
- The center of rotation.- Returns:
- A new, rotated point.
-
scale
Deprecated.Returnalpha*(this - center) + center
. This is used to scale the vector from center to this as an offset by alpha. This is equivalent tothis.sub(center).mul(alpha).add(center)
, but with fewer object creations.- Parameters:
center
- The origin of scaling.alpha
- The scale factor.- Returns:
- The scaled point.
-