Class PostgisGeometry


  • public class PostgisGeometry
    extends Object
    A parser API for Postgres Geometry types
    Author:
    Robert Coup
    • Field Detail

      • HEXEWKB_EMPTY_GEOMETRYCOLLECTION

        private static final String HEXEWKB_EMPTY_GEOMETRYCOLLECTION
        Static Hex EKWB for a GEOMETRYCOLLECTION EMPTY.
        See Also:
        Constant Field Values
      • wkb

        private final byte[] wkb
        PostGIS Extended-Well-Known-Binary (EWKB) geometry representation. An extension of the Open Geospatial Consortium Well-Known-Binary format. Since EWKB is a superset of WKB, we use EWKB here. https://postgis.net/docs/using_postgis_dbmanagement.html#EWKB_EWKT http://www.opengeospatial.org/standards/sfa
      • srid

        private final Integer srid
        Coordinate reference system identifier. While it's technically user-defined, the standard/common values in use are the EPSG code list http://www.epsg.org/ null if unset/unspecified
    • Constructor Detail

      • PostgisGeometry

        private PostgisGeometry​(byte[] ewkb,
                                Integer srid)
        Create a PostgisGeometry using the supplied EWKB and SRID.
        Parameters:
        ewkb - the Extended Well-Known binary representation of the coordinate in the standard format
        srid - the coordinate system identifier (SRID); null if unset/unknown
    • Method Detail

      • fromHexEwkb

        public static PostgisGeometry fromHexEwkb​(String hexEwkb)
        Create a PostgisGeometry using the supplied PostGIS Hex EWKB string. SRID is extracted from the EWKB
      • fromEwkb

        public static PostgisGeometry fromEwkb​(byte[] ewkb)
        Create a PostgisGeometry using the supplied PostGIS EWKB. SRID is extracted from the EWKB
      • createEmpty

        public static PostgisGeometry createEmpty()
        Create a GEOMETRYCOLLECTION EMPTY PostgisGeometry
        Returns:
        a PostgisGeometry which represents a PostgisGeometry API
      • getWkb

        public byte[] getWkb()
        Returns the standard well-known binary representation
        Returns:
        byte which represents the standard well-known binary
      • getSrid

        public Integer getSrid()
        Returns the coordinate reference system identifier (SRID)
        Returns:
        srid
      • parseSrid

        private static Integer parseSrid​(byte[] ewkb)
        Parses an EWKB Geometry and extracts the SRID (if any) https://trac.osgeo.org/postgis/browser/trunk/doc/ZMSgeoms.txt
        Parameters:
        ewkb - PostGIS EWKB geometry
        Returns:
        Geometry SRID or null if there is no SRID.