Class Geography


  • public class Geography
    extends Object
    Geography datatype represents data in a round-earth coordinate system. This class will stay in this current package for backwards compatibility.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Geography​(byte[] clr)
      Private constructor used for creating a Geography object from internal SQL Server format.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String asTextZM()
      Returns the Well-Known Text (WKT) representation of the Geography object.
      static Geography deserialize​(byte[] clr)
      Constructor for a Geography instance from an internal SQL Server format for spatial data.
      List<Figure> getFigureList()
      Get figure list
      Double getLatitude()
      Returns the latitude value.
      Double getLongitude()
      Returns the longitude value.
      Double getM()
      Returns the M (measure) value of the object.
      List<Point> getPointList()
      Get point list
      List<Segment> getSegmentList()
      Get segment list
      List<Shape> getShapeList()
      Get shape list
      int getSrid()
      Returns the Spatial Reference Identifier (SRID) value.
      Double getZ()
      Returns the Z (elevation) value of the object.
      boolean hasM()
      Returns if the object contains a M (measure) value.
      boolean hasZ()
      Returns if the object contains a Z (elevation) value.
      boolean isNull()
      Returns if the Geography object is null.
      static Geography parse​(String wkt)
      Constructor for a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation.
      static Geography point​(double lat, double lon, int srid)
      Constructor for a Geography instance that represents a Point instance from its latitude and longitude values and a Spatial Reference Identifier.
      byte[] serialize()
      Returns the bytes that represent an internal SQL Server format of Geography type.
      byte[] STAsBinary()
      Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a Geography instance.
      String STAsText()
      Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a Geography instance.
      String STGeographyType()
      Returns the Open Geospatial Consortium (OGC) type name represented by a Geography instance.
      static Geography STGeomFromText​(String wkt, int srid)
      Constructor for a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation augmented with any Z (elevation) and M (measure) values carried by the instance.
      static Geography STGeomFromWKB​(byte[] wkb)
      Constructor for a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation.
      int STNumPoints()
      Returns the number of points in the Geography object.
      String toString()
      Returns the String representation of the Geography object.
    • Constructor Detail

      • Geography

        protected Geography​(byte[] clr)
                     throws SQLServerException
        Private constructor used for creating a Geography object from internal SQL Server format.
        Parameters:
        clr - Internal SQL Server format provided by the user.
        Throws:
        SQLServerException - if an exception occurs
    • Method Detail

      • STGeomFromText

        public static Geography STGeomFromText​(String wkt,
                                               int srid)
                                        throws SQLServerException
        Constructor for a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation augmented with any Z (elevation) and M (measure) values carried by the instance.
        Parameters:
        wkt - Well-Known Text (WKT) provided by the user.
        srid - Spatial Reference Identifier (SRID) provided by the user.
        Returns:
        Geography Geography instance created from WKT and SRID
        Throws:
        SQLServerException - if an exception occurs
      • STGeomFromWKB

        public static Geography STGeomFromWKB​(byte[] wkb)
                                       throws SQLServerException
        Constructor for a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation. Note: This method currently uses internal SQL Server format (CLR) to create a Geography instance, but in the future this will be changed to accept WKB data instead, as the SQL Server counterpart of this method (STGeomFromWKB) uses WKB. For existing users who are already using this method, consider switching to deserialize(byte) instead.
        Parameters:
        wkb - Well-Known Binary (WKB) provided by the user.
        Returns:
        Geography Geography instance created from WKB
        Throws:
        SQLServerException - if an exception occurs
      • deserialize

        public static Geography deserialize​(byte[] clr)
                                     throws SQLServerException
        Constructor for a Geography instance from an internal SQL Server format for spatial data.
        Parameters:
        clr - Internal SQL Server format provided by the user.
        Returns:
        Geography Geography instance created from clr
        Throws:
        SQLServerException - if an exception occurs
      • parse

        public static Geography parse​(String wkt)
                               throws SQLServerException
        Constructor for a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation. Spatial Reference Identifier is defaulted to 4326.
        Parameters:
        wkt - Well-Known Text (WKT) provided by the user.
        Returns:
        Geography Geography instance created from WKT
        Throws:
        SQLServerException - if an exception occurs
      • point

        public static Geography point​(double lat,
                                      double lon,
                                      int srid)
                               throws SQLServerException
        Constructor for a Geography instance that represents a Point instance from its latitude and longitude values and a Spatial Reference Identifier.
        Parameters:
        lat - latitude
        lon - longitude
        srid - Spatial Reference Identifier value
        Returns:
        Geography Geography instance
        Throws:
        SQLServerException - if an exception occurs
      • STAsText

        public String STAsText()
                        throws SQLServerException
        Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a Geography instance. This text will not contain any Z (elevation) or M (measure) values carried by the instance.
        Returns:
        the WKT representation without the Z and M values.
        Throws:
        SQLServerException - if an exception occurs
      • STAsBinary

        public byte[] STAsBinary()
        Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a Geography instance. This value will not contain any Z or M values carried by the instance.
        Returns:
        byte array representation of the Geography object.
      • serialize

        public byte[] serialize()
        Returns the bytes that represent an internal SQL Server format of Geography type.
        Returns:
        byte array representation of the Geography object.
      • hasM

        public boolean hasM()
        Returns if the object contains a M (measure) value.
        Returns:
        boolean that indicates if the object contains M value.
      • hasZ

        public boolean hasZ()
        Returns if the object contains a Z (elevation) value.
        Returns:
        boolean that indicates if the object contains Z value.
      • getLatitude

        public Double getLatitude()
        Returns the latitude value.
        Returns:
        double value that represents the latitude.
      • getLongitude

        public Double getLongitude()
        Returns the longitude value.
        Returns:
        double value that represents the longitude.
      • getM

        public Double getM()
        Returns the M (measure) value of the object.
        Returns:
        double value that represents the M value.
      • getZ

        public Double getZ()
        Returns the Z (elevation) value of the object.
        Returns:
        double value that represents the Z value.
      • getSrid

        public int getSrid()
        Returns the Spatial Reference Identifier (SRID) value.
        Returns:
        int value of SRID.
      • isNull

        public boolean isNull()
        Returns if the Geography object is null.
        Returns:
        boolean that indicates if the object is null.
      • STNumPoints

        public int STNumPoints()
        Returns the number of points in the Geography object.
        Returns:
        int that indicates the number of points in the Geography object.
      • STGeographyType

        public String STGeographyType()
        Returns the Open Geospatial Consortium (OGC) type name represented by a Geography instance.
        Returns:
        String that contains the Geography object's type name
      • asTextZM

        public String asTextZM()
        Returns the Well-Known Text (WKT) representation of the Geography object.
        Returns:
        String that contains the WKT representation of the Geography object.
      • toString

        public String toString()
        Returns the String representation of the Geography object.
        Overrides:
        toString in class Object
        Returns:
        String that contains the WKT representation of the Geography object.
      • getPointList

        public List<Point> getPointList()
        Get point list
        Returns:
        point list
      • getFigureList

        public List<Figure> getFigureList()
        Get figure list
        Returns:
        figure list
      • getShapeList

        public List<Shape> getShapeList()
        Get shape list
        Returns:
        shape list
      • getSegmentList

        public List<Segment> getSegmentList()
        Get segment list
        Returns:
        segment list