Package com.microsoft.sqlserver.jdbc
Class Geometry
java.lang.Object
com.microsoft.sqlserver.jdbc.Geometry
Geometry datatype represents data in a Euclidean (flat) coordinate system. This class will stay in this current
package for backwards compatibility.
-
Constructor Summary
ModifierConstructorDescriptionprotected
Geometry()
Creates a Geometry objectprotected
Geometry
(byte[] clr) Private constructor used for creating a Geometry object from internal SQL Server format.protected
Private constructor used for creating a Geometry object from WKT and Spatial Reference Identifier. -
Method Summary
Modifier and TypeMethodDescriptionasTextZM()
Returns the Well-Known Text (WKT) representation of the Geometry object.static Geometry
deserialize
(byte[] clr) Constructor for a Geometry instance from an internal SQL Server format for spatial data.Get figure listgetM()
Returns the M (measure) value of the object.Get point listGet segment listGet shape listint
getSrid()
Returns the Spatial Reference Identifier (SRID) value.getX()
Returns the X coordinate value.getY()
Returns the Y coordinate value.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 Geometry object is null.static Geometry
Constructor for a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation.static Geometry
point
(double x, double y, int srid) Constructor for a Geometry instance that represents a Point instance from its X and Y values and an Spatial Reference Identifier.byte[]
Returns the bytes that represent an internal SQL Server format of Geometry type.byte[]
Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a Geometry instance.STAsText()
Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a Geometry instance.Returns the Open Geospatial Consortium (OGC) type name represented by a geometry instance.static Geometry
STGeomFromText
(String wkt, int srid) Constructor for a Geometry 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 Geometry
STGeomFromWKB
(byte[] wkb) Constructor for a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation.int
Returns the number of points in the Geometry object.toString()
Returns the String representation of the Geometry object.
-
Constructor Details
-
Geometry
protected Geometry()Creates a Geometry object -
Geometry
Private constructor used for creating a Geometry object from WKT and Spatial Reference Identifier.- Parameters:
wkt
- Well-Known Text (WKT) provided by the user.srid
- Spatial Reference Identifier (SRID) provided by the user.- Throws:
SQLServerException
- if an exception occurs
-
Geometry
Private constructor used for creating a Geometry object from internal SQL Server format.- Parameters:
clr
- Internal SQL Server format provided by the user.- Throws:
SQLServerException
- if an exception occurs
-
-
Method Details
-
STGeomFromText
Constructor for a Geometry 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:
- Geometry Geometry instance created from WKT and SRID
- Throws:
SQLServerException
- if an exception occurs
-
STGeomFromWKB
Constructor for a Geometry 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 Geometry 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:
- Geometry Geometry instance created from WKB
- Throws:
SQLServerException
- if an exception occurs
-
deserialize
Constructor for a Geometry instance from an internal SQL Server format for spatial data.- Parameters:
clr
- Internal SQL Server format provided by the user.- Returns:
- Geometry Geometry instance created from clr
- Throws:
SQLServerException
- if an exception occurs
-
parse
Constructor for a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation. Spatial Reference Identifier is defaulted to 0.- Parameters:
wkt
- Well-Known Text (WKT) provided by the user.- Returns:
- Geometry Geometry instance created from WKT
- Throws:
SQLServerException
- if an exception occurs
-
point
Constructor for a Geometry instance that represents a Point instance from its X and Y values and an Spatial Reference Identifier.- Parameters:
x
- x coordinatey
- y coordinatesrid
- Spatial Reference Identifier value- Returns:
- Geometry Geography instance
- Throws:
SQLServerException
- if an exception occurs
-
STAsText
Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a Geometry 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 Geometry instance. This value will not contain any Z or M values carried by the instance.- Returns:
- byte array representation of the Geometry object.
-
serialize
public byte[] serialize()Returns the bytes that represent an internal SQL Server format of Geometry type.- Returns:
- byte array representation of the Geometry 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.
-
getX
Returns the X coordinate value.- Returns:
- double value that represents the X coordinate.
-
getY
Returns the Y coordinate value.- Returns:
- double value that represents the Y coordinate.
-
getM
Returns the M (measure) value of the object.- Returns:
- double value that represents the M value.
-
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 Geometry object is null.- Returns:
- boolean that indicates if the object is null.
-
STNumPoints
public int STNumPoints()Returns the number of points in the Geometry object.- Returns:
- int that indicates the number of points in the Geometry object.
-
STGeometryType
Returns the Open Geospatial Consortium (OGC) type name represented by a geometry instance.- Returns:
- String that contains the Geometry object's type name
-
asTextZM
Returns the Well-Known Text (WKT) representation of the Geometry object.- Returns:
- String that contains the WKT representation of the Geometry object.
-
toString
Returns the String representation of the Geometry object. -
getPointList
Get point list- Returns:
- point list
-
getFigureList
Get figure list- Returns:
- figure list
-
getShapeList
Get shape list- Returns:
- shape list
-
getSegmentList
Get segment list- Returns:
- segment list
-