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 SummaryFieldsModifier and TypeFieldDescriptionstatic final intThe default length (in bytes) for a column with type GEOGRAPHY, if no length is specified.static final intThe maximum-allowed length (in bytes) for a column with type GEOGRAPHY.static final intThe minimum-allowed length (in bytes) for a column with type GEOGRAPHY.
- 
Constructor SummaryConstructorsConstructorDescriptionGeographyValue(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 SummaryModifier and TypeMethodDescriptionbooleanvoidSerialize this object to a ByteBuffer.static GeographyValueCreate a GeographyValue object from a well-known text string.intReturn the number of bytes in the serialization for this polygon.getRings()Return the list of rings of a polygon.static intgetValueDisplaySize(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.voidserialize(DataOutput output) Serialize this object to aDataOutputtoString()Return a representation of this object as well-known text.toWKT()Return a representation of this object as well-known text.static GeographyValueunflattenFromBuffer(ByteBuffer inBuffer) Deserialize a GeographyValue from a ByteBuffer at the ByteBuffer's current position.static GeographyValueunflattenFromBuffer(ByteBuffer inBuffer, int offset) Deserialize a GeographyValue from a ByteBuffer from an absolute offset.
- 
Field Details- 
DEFAULT_LENGTHpublic static final int DEFAULT_LENGTHThe default length (in bytes) for a column with type GEOGRAPHY, if no length is specified.- See Also:
 
- 
MIN_SERIALIZED_LENGTHpublic 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_LENGTHpublic 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- 
GeographyValueCreate 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.
 
- 
GeographyValueCreate 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- 
fromWKTCreate a GeographyValue object from a well-known text string. This format is described inthe WKT constructorfor this class.- Parameters:
- text- A well-known text string
- Returns:
- A new instance of GeographyValue
 
- 
getRingsReturn 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.
 
- 
toStringReturn a representation of this object as well-known text.
- 
toWKTReturn a representation of this object as well-known text.- Returns:
- A well-known text string for this object.
 
- 
equals
- 
getLengthInBytespublic 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.
 
- 
getValueDisplaySizepublic 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
 
- 
flattenToBufferSerialize 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.
 
- 
serializeSerialize this object to aDataOutputTo 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
 
- 
unflattenFromBufferDeserialize 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 GeographyValue
- offset- The absolute offset in the ByteBuffer from which to read data
- Returns:
- A new GeographyValue instance.
 
- 
unflattenFromBufferDeserialize 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.
 
 
-