Class ShapeBinaryParser


  • public class ShapeBinaryParser
    extends Object
    Parse binary representation of geometries. Currently, only text rep (hexed) implementation is tested. It should be easy to add char[] and CharSequence ByteGetter instances, although the latter one is not compatible with older jdks. I did not implement real unsigned 32-bit integers or emulate them with long, as both java Arrays and Strings currently can have only 2^31-1 elements (bytes), so we cannot even get or build Geometries with more than approx. 2^28 coordinates (8 bytes each).
    Author:
    Markus Schaber, markus.schaber@logix-tt.com
    • Constructor Detail

      • ShapeBinaryParser

        public ShapeBinaryParser()
    • Method Detail

      • valueGetterForEndian

        public static org.postgis.binary.ValueGetter valueGetterForEndian​(org.postgis.binary.ByteGetter bytes)
        Get the appropriate ValueGetter for my endianness
        Parameters:
        bytes - The appropriate Byte Getter
        Returns:
        the ValueGetter
      • parse

        public int parse​(String value,
                         GeneralPath path)
        Parse a hex encoded geometry Is synchronized to protect offset counter. (Unfortunately, Java does not have neither call by reference nor multiple return values.)
        Parameters:
        value - String representation of the value to be parsed
        path - GeneralPath to provide the parsed value to
        Returns:
        a potential SRID or Geometry.UNKNOWN_SRID if not present
      • parse

        public int parse​(byte[] value,
                         GeneralPath path)
        Parse a binary encoded geometry. Is synchronized to protect offset counter. (Unfortunately, Java does not have neither call by reference nor multiple return values.)
        Parameters:
        value - byte array representation of the value to be parsed
        path - GeneralPath to provide the parsed value to
        Returns:
        a potential SRID or Geometry.UNKNOWN_SRID if not present
      • parseGeometry

        protected int parseGeometry​(org.postgis.binary.ValueGetter data,
                                    GeneralPath path)
        Parse a geometry starting at offset.
        Parameters:
        data - ValueGetter containing the value to be parsed
        path - GeneralPath to provide the parsed value to
        Returns:
        a potential SRID or Geometry.UNKNOWN_SRID if not present