Class GeometryBytes

java.lang.Object
io.debezium.spatial.GeometryBytes

public class GeometryBytes extends Object
A simple geometry bytes helper class to handle operating on WKB (Well-Known Binary) and EWKB (Extended Well-Known Binary) formats used to represent spatial geometry.
Author:
Chris Cranford
  • Field Details

    • wkb

      private final byte[] wkb
    • srid

      private final Integer srid
  • Constructor Details

    • GeometryBytes

      public GeometryBytes(byte[] wkb, Integer srid)
      Create a geometry with a given byte array and an optional spatial reference identifier.
      Parameters:
      wkb - byte array, must not be null
      srid - spatial reference identifier, can be null
    • GeometryBytes

      public GeometryBytes(byte[] ewkb)
      Create a geometry with a given Extended Well-Known Binary (EWKB) format byte array. The SRID is decoded from the provided byte array.
      Parameters:
      ewkb - byte array, must not be null
  • Method Details

    • getBytes

      public byte[] getBytes()
      Get the raw geometry bytes.
      Returns:
      geometry byte array, never null
    • getSrid

      public Integer getSrid()
      Get the spatial reference identifier.
      Returns:
      spatial reference identifier, may be null
    • isExtended

      public boolean isExtended()
      Returns whether the geometry bytes using the Extended Well-Known Binary (EWKB) format.
    • isEmptyGeometryCollection

      public boolean isEmptyGeometryCollection()
      Returns whether the geometry represent a geometry collection that has no geometry elements.
    • swapCoordinates

      public GeometryBytes swapCoordinates()
      Swaps coordinates by limiting the swap to GeometryCoordinateSwapper.DEFAULT_SWAP_SRIDS.
      Returns:
      a new geometry instance that may or may not have its coordinated swapped.
    • swapCoordinatesNoCheck

      public GeometryBytes swapCoordinatesNoCheck()
      Swaps coordinates regardless of spatial reference identifiers.
      Returns:
      a geometry instance with the coordinates swapped
    • asExtendedWkb

      public GeometryBytes asExtendedWkb()
      Provides a geometry instance that uses EWKB format. If the current instance is already in EWKB format, the method returns the same instance.
    • asWkb

      public GeometryBytes asWkb()
      Provides a geometry instance that uses WKB format. If the current instance is already in WKB format, the method returns the same instance.
    • asLittleEndian

      public GeometryBytes asLittleEndian()
      Returns a new geometry instance using little endian byte order.
    • asBigEndian

      public GeometryBytes asBigEndian()
      Returns a new geometry instance using big endian byte order.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object