Package org.voltdb.types
Class GeographyValue
java.lang.Object
org.voltdb.types.GeographyValue
The Java class used to represent data with the SQL type GEOGRAPHY.
For now, this means polygons, but may include other kinds of geospatial
types in the future.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default length (in bytes) for a column with type GEOGRAPHY, if no length is specified.static final int
The maximum-allowed length (in bytes) for a column with type GEOGRAPHY.static final int
The minimum-allowed length (in bytes) for a column with type GEOGRAPHY. -
Constructor Summary
ConstructorDescriptionGeographyValue
(String wkt) Create a GeographyValue object from an OGC well-known text-formatted string.GeographyValue
(List<List<GeographyPointValue>> rings) Create a polygon from a list of rings. -
Method Summary
Modifier and TypeMethodDescriptionadd
(GeographyPointValue offset) Deprecated.boolean
void
Serialize this object to a ByteBuffer.static GeographyValue
Create a GeographyValue object from a well-known text string.int
Return the number of bytes in the serialization for this polygon.getRings()
Return the list of rings of a polygon.static int
getValueDisplaySize
(int numBytes) Given a column of type GEOGRAPHY(nbytes), return an upper bound on the number of characters needed to represent any entity of this type in WKT.void
serialize
(DataOutput output) Serialize this object to aDataOutput
toString()
Return a representation of this object as well-known text.toWKT()
Return a representation of this object as well-known text.static GeographyValue
unflattenFromBuffer
(ByteBuffer inBuffer) Deserialize a GeographyValue from a ByteBuffer at the ByteBuffer's current position.static GeographyValue
unflattenFromBuffer
(ByteBuffer inBuffer, int offset) Deserialize a GeographyValue from a ByteBuffer from an absolute offset.
-
Field Details
-
DEFAULT_LENGTH
public static final int DEFAULT_LENGTHThe default length (in bytes) for a column with type GEOGRAPHY, if no length is specified.- See Also:
-
MIN_SERIALIZED_LENGTH
public static final int MIN_SERIALIZED_LENGTHThe minimum-allowed length (in bytes) for a column with type GEOGRAPHY. This is the length of a polygon with just three vertices.- See Also:
-
MAX_SERIALIZED_LENGTH
public static final int MAX_SERIALIZED_LENGTHThe maximum-allowed length (in bytes) for a column with type GEOGRAPHY. This is the usual max column length.- See Also:
-
-
Constructor Details
-
GeographyValue
Create a polygon from a list of rings. Each ring is a list of points:- The first ring in the list is the outer ring, also known as the shell.
- Subsequent rings should be inside of the outer ring and represent "holes" in the polygon.
- The shell should have its vertices listed in counter-clockwise order, so that the area inside the ring is on the left side of the line segments formed by adjacent vertices.
- Each hole, or inner ring, should have its vertices listed in clockwise order, so that the area inside the ring (the "hole") is on the right side of the line segments formed by adjacent vertices.
- Parameters:
rings
- A list of lists of points that will form a polygon.
-
GeographyValue
Create a GeographyValue object from an OGC well-known text-formatted string. Currently only polygons can be created via this method. Well-known text format for polygons is composed of the "POLYGON" keyword followed by a list of rings enclosed in parenthesis. For example:
Each point in a ring is composed of a coordinate of longitude and a coordinate of latitude separated by a space. Note that longitude comes first in this notation. Additional notes about rings:POLYGON((0 0, 20 0, 20 20, 0 20, 0 0),(5 5, 5 15, 15 15, 15 5, 5 5))
- The first ring in the list is the outer ring, also known as the shell.
- Subsequent rings should be inside of the outer ring and represent "holes" in the polygon.
- The shell should have its vertices listed in counter-clockwise order, so that the area inside the ring is on the left side of the line segments formed by adjacent vertices.
- Each hole, or inner ring, should have its vertices listed in clockwise order, so that the area inside the ring (the "hole") is on the right side of the line segments formed by adjacent vertices.
- Each ring must be closed; that is, the last point in the ring must be equal to this first.
- Parameters:
wkt
- A well-known text-formatted string for a polygon.
-
-
Method Details
-
fromWKT
Create a GeographyValue object from a well-known text string. This format is described inthe WKT constructor
for this class.- Parameters:
text
- A well-known text string- Returns:
- A new instance of GeographyValue
-
getRings
Return the list of rings of a polygon. The list has the same values as the list of rings used to construct the polygon, or the sequence of WKT rings used to construct the polygon.- Returns:
- A list of rings.
-
toString
Return a representation of this object as well-known text. -
toWKT
Return a representation of this object as well-known text.- Returns:
- A well-known text string for this object.
-
equals
-
getLengthInBytes
public int getLengthInBytes()Return the number of bytes in the serialization for this polygon. Returned value does not include the 4-byte length prefix that precedes variable-length types.- Returns:
- The number of bytes in the serialization for this polygon.
-
getValueDisplaySize
public static int getValueDisplaySize(int numBytes) Given a column of type GEOGRAPHY(nbytes), return an upper bound on the number of characters needed to represent any entity of this type in WKT.- Parameters:
numBytes
- The size of the GEOGRAPHY value in bytes- Returns:
- Upper bound of characters needed for WKT string
-
flattenToBuffer
Serialize this object to a ByteBuffer. (Assumes that the 4-byte length prefix for variable-length data has already been serialized.)- Parameters:
buf
- The ByteBuffer into which the serialization will be placed.
-
serialize
Serialize this object to aDataOutput
To be consisitent with
flattenToBuffer(ByteBuffer)
(Assumes that the 4-byte length prefix for variable-length data has already been serialized.)- Parameters:
output
- into which this object will be serialized- Throws:
IOException
- if any I/O error occurs
-
unflattenFromBuffer
Deserialize a GeographyValue from a ByteBuffer from an absolute offset. (Assumes that the 4-byte length prefix has already been deserialized, and that offset points to the start of data just after the prefix.)- Parameters:
inBuffer
- The ByteBuffer from which to read a GeographyValueoffset
- The absolute offset in the ByteBuffer from which to read data- Returns:
- A new GeographyValue instance.
-
unflattenFromBuffer
Deserialize a GeographyValue from a ByteBuffer at the ByteBuffer's current position. (Assumes that the 4-byte length prefix has already been deserialized.)- Parameters:
inBuffer
- The ByteBuffer from which to read a GeographyValue- Returns:
- A new GeographyValue instance.
-
add
Deprecated.Create a new GeographyValue which is offset from this one by the given point. The latitude and longitude values stay in range because we are using the normalizing operations in GeographyPointValue.- Parameters:
offset
- The point by which to translate vertices in this- Returns:
- The resulting GeographyValue.
-