Edit

Share via


Extended methods on geometry instances

Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance SQL database in Microsoft Fabric

SQL Server supports extended methods on geometry instances that go beyond the Open Geospatial Consortium (OGC) standard methods. These extended methods provide additional functionality for working with planar geometric data, including Z (elevation) and M (measure) values, precise buffer operations, simplified representations, and enhanced WKT/WKB formats.

Extended methods vs. OGC methods

While OGC methods provide standardized spatial operations defined by the OpenGIS specification, extended methods offer SQL Server-specific enhancements:

  • OGC methods: Standardized operations for interoperability with other geospatial systems. Use when standards compliance is required.
  • Extended methods: SQL Server-specific operations that provide additional functionality, performance optimizations, or support for features not covered by OGC standards (such as circular arcs, Z/M values, and advanced buffer control).

For most spatial tasks, OGC methods provide the necessary functionality. Use extended methods when you need the extra capabilities they provide.

Enhanced representation formats

These methods provide alternative formats for representing geometry data, including support for Z (elevation) and M (measure) values.

Method Description
AsBinaryZM (geometry DataType) Returns the OGC Well-Known Binary (WKB) representation augmented with Z (elevation) and M (measure) values.
AsTextZM (geometry Data Type) Returns the OGC Well-Known Text (WKT) representation augmented with Z (elevation) and M (measure) values.
AsGml (geometry Data Type) Returns the Geography Markup Language (GML) representation of a geometry instance.
ToString (geometry Data Type) Returns the string representation of a geometry instance augmented with Z and M values.

Z and M coordinate access

These methods access the Z (elevation) and M (measure) values of geometry instances, supporting 3D and 4D spatial data.

Method Description
Z (geometry Data Type) Returns the Z (elevation) value of a geometry instance. Null if not defined.
M (geometry Data Type) Returns the M (measure) value of a geometry instance. Null if not defined.
HasZ (geometry DataType) Returns 1 if a geometry instance contains at least one point with a Z value.
HasM (geometry DataType) Returns 1 if a geometry instance contains at least one point with an M value.

Advanced buffer operations

These methods provide more control over buffer calculations than the standard OGC STBuffer method.

Method Description
BufferWithTolerance (geometry Data Type) Returns a geometric object representing all points within a specified distance from a geometry instance, with explicit tolerance control for precision.
BufferWithCurves (geometry Data Type) Returns a geometry instance representing all points within a specified distance, preserving circular arc segments in the result.

Geometry simplification

These methods create simplified versions of geometry instances, useful for performance optimization and visualization at different scales.

Method Description
Reduce (geometry Data Type) Returns a simplified approximation of a geometry instance produced by running the Douglas-Peucker algorithm with the specified tolerance.
CurveToLineWithTolerance (geometry Data Type) Returns a polygonal approximation of a geometry instance containing circular arc segments, with explicit tolerance control.

Spatial relationship queries

These methods perform advanced spatial relationship queries.

Method Description
ShortestLineTo (geography Data Type) Returns a LineString instance with two points representing the shortest distance between the two geometry instances.

Validity and type checking

These methods provide detailed validity checking and type information.

Method Description
IsValidDetailed (geometry DataType) Returns a message that helps identify problems with an invalid geometry instance.
MakeValid (geometry Data Type) Converts an invalid geometry instance into a valid instance with a valid OGC type.
InstanceOf (geometry Data Type) Returns 1 if a geometry instance is of the specified type.
IsNull (geometry Data Type) Returns 1 if a geometry instance is null.

Spatial operations

These methods perform spatial operations with enhanced capabilities.

Method Description
Filter (geometry Data Type) Offers a fast, index-only intersection method to determine if a geometry instance intersects another instance.

Version compatibility

These methods provide information about SQL Server version compatibility.

Method Description
MinDbCompatibilityLevel (geometry Data Type) Returns the minimum database compatibility level that recognizes the geometry data type.