Class GeographyPointValue

java.lang.Object
org.voltdb.types.GeographyPointValue

public class GeographyPointValue extends Object
The Java class that corresponds to the SQL type GEOGRAPHY_POINT. Represents a point as defined by its longitude and latitude.
  • 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

      public static GeographyPointValue fromWKT(String param)
      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

      public String toString()
      Return this point as a well-known text string.
      Overrides:
      toString in class Object
      Returns:
      This point as a well-known text string.
    • toWKT

      public 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

      public boolean equals(Object o)
      Compare this point with another object. Returns true if this point is being compared to another point that represents the same location.
      Overrides:
      equals in class Object
      See Also:
    • 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

      public void flattenToBuffer(ByteBuffer buffer)
      Serialize this point to a ByteBuffer.
      Parameters:
      buffer - The ByteBuffer to which this point will be serialized.
    • serialize

      public void serialize(DataOutput output) throws IOException
      Serialize this point to a DataOutput
      Parameters:
      output - to which this point will be serialized
      Throws:
      IOException - if any I/O error occurs
    • unflattenFromBuffer

      public static GeographyPointValue unflattenFromBuffer(ByteBuffer inBuffer, int offset)
      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

      public static GeographyPointValue unflattenFromBuffer(ByteBuffer inBuffer)
      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

      public static void serializeNull(ByteBuffer buffer)
      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

      public static GeographyPointValue normalizeLngLat(double longitude, double latitude)
      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 public GeographyPointValue add(GeographyPointValue offset, double alpha)
      Deprecated.
      Return a point which is offset by the given offset point multiplied by alpha. That is, the return value is this + alpha*offset, except that Java does not allow one to write it in this way. In particular, this - other is equal to add(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 public GeographyPointValue sub(GeographyPointValue offset, double scale)
      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 public GeographyPointValue mul(double alpha)
      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 public GeographyPointValue rotate(double phi, GeographyPointValue center)
      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 public GeographyPointValue scale(GeographyPointValue center, double alpha)
      Deprecated.
      Return alpha*(this - center) + center. This is used to scale the vector from center to this as an offset by alpha. This is equivalent to this.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.