OGC methods on Geometry & Geography instances
Overview
Cinchy CQL supports the following on Open Geospatial Consortium (OGC) methods on geometry and geography instances.
All functions that have Geometry in parenthesis are only applicable to OGC methods on geometry instances.
This function isn't currently supported in PostgreSQL deployments of the Cinchy platform. Please check back at a later time. For a full list of in-progress function translations, see the CQL functions reference page.
The OGC Methods covered in this section are:
STArea
STArea()
returns the total surface area of a geometry/geography instance.
Syntax
Return Types
CQL: Number
Remarks
When the geometry/geography instance contains only zero and one-dimensional figures, or if it's empty, STArea()
returns 0.
Geometry Example
This example creates a Polygon
geometry instance and computes the area of the Polygon:
Geography Example
This example creates a Polygon
geography instance and computes the area of the Polygon
:
STAsBinary
STAsBinary()
returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a geometry/geography instance.
Syntax
Return Types
CQL: Base64 Text
Geometry Example
This example creates a LineString
geometry instance from (0,0) to (2,3) from text. STAsBinary()
returns the result in WKB:
Geography Example
This example uses STAsBinary()
to create a LineString
geography instance from (-122.360, 47.656) to (-122.343, 47.656) from text. It then returns the result in WKB:
STAsText
STAsText()
returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a geometry/geography instance.
Syntax
Return Types
CQL: Text
Remarks
OGC type of a geography instance can be determined by invoking STGeometryType()
The return text won't containZ
(elevation) and M
(measure) values carried by the instance.
Geometry Example
This example creates a LineString
geometry instance from (0,0) to (2,3) from text. STAsText()
returns the result in text:
Geography Example
This example uses STAsText()
to create a LineString
geography instance from (-122.360, 47.656) to (-122.343, 47.656) from text. It then returns the result in text:
STBoundary (Geometry)
STBoundary()
returns the boundary of a geometry instance.
Syntax
Return Types
CQL: geometry
Geometry Example
This example uses STBoundary()
on a CurvePolygon
instance. STBoundary()
returns a CircularString
instance:
STBuffer
STBuffer()
returns a geometric/geography object that represents the union of all points whose distance from a geometry/geography instance is less than or equal to a specified value.
Syntax
Arguments
distance A value of type float (double in the .NET Framework) specifying the distance from the geometry/geography instance around which to calculate the buffer.
Return Types
CQL: geometry/geography
Remarks
STBuffer()
calculates a buffer specifying tolerance = distance * .001 and relative = false.
A negative buffer removes all points within the given distance of the boundary of the geometry/geography instance.
The error between the theoretical and computed buffer is max(tolerance, extents 1.E-7) where tolerance = distance * .001.
Geometry:
When distance > 0 then either a Polygon
or MultiPolygon
instance is returned. When distance = 0, then a copy of the calling geometry instance is returned. When distance < 0, then:
When the dimensions of the instance are 0 or 1, an empty
GeometryCollection
instance is returned.when the dimensions of the instance are 2 or more, a negative buffer is returned.
Geography:
STBuffer()
will return a FullGlobe
instance in certain cases; for example, STBuffer()
returns a FullGlobe
instance when the buffer distance is greater than the distance from the equator to the poles. A buffer can't exceed the full globe.
This method will throw an ArgumentException
in FullGlobe
instances where the distance of the buffer exceeds the following limitation: 0.999 * π * minorAxis
* minorAxis
/ majorAxis
(~0.999 * 1/2 Earth's circumference).
Geometry Example
This example returns a Polygon
instance with a negative buffer from a CurvePolygon
instance:
Geography Example
This example creates a LineString
geography instance. It then uses STBuffer()
to return the region within 1 meter of the instance:
STCentroid
STCentroid()
returns the geometry/geography center of a geometry/geography instance that consists of one or more Polygons
.
Syntax
Return Types
CQL: geometry/geography
Remarks
If the geometry/geography instance isn't a Polygon
, CurvePolygon
, or MultiPolygon
typeSTCentroid()
returns null.
Geometry Example
This example uses STCentroid()
to compute the centroid of a polygon
geography instance:
STContains (Geometry)
STContains()
returns 1 if a geometry instance completely contains another geometry instance. Otherwise, returns 0.
Syntax
Arguments
other_instance
Another geometry instance to compare against the instance on which STContains()
is invoked.
Return Types
CQL: Yes/No
Remarks
If the spatial reference identifiers (SRIDs) of the geometry instances don't match, STContains()
always returns null.
Geometry Example
This example uses STContains()
to test two geometry instances to see if the first instance contains the second instance:
STConvexHull (Geometry)
STConvexHull()
returns an object representing the convex hull of a geometry instance.
Syntax
Return Types
CQL: geometry
Remarks
Points or co-linear LineString
instances will produce an instance of the same type as that of the input. STConvexHull()
returns the smallest convex Polygon
that contains the given geometry instance.
Geometry Example
This example uses STConvexHull()
to find the convex hull of a non-convex Polygon
geometry instance:
STCrosses (Geometry)
STCrosses()
returns 1 if a geometry instance crosses another geometry instance. Otherwise, returns 0.
Syntax
Arguments
other_instance
Another geometry/geography instance to compare against the instance on which STCrosses()
is invoked.
Return Types
CQL: Yes/No
Remarks
If the spatial reference IDs (SRIDs) of the geometry instances don't match, this method always returns null.
Both conditions must be true for two geometry instances to cross:
The intersection of the two geometry instances results in a geometry whose dimensions are less than the maximum dimension of the source geometry instances.
The intersection set is interior to both source geometry instances.
Geometry Examples
This example uses STCrosses()
to test two geometry instances to see if they cross:
STCurveToLine (Geometry)
STCurveToLine()
returns a polygonal approximation of a geometry instance that contains circular arc segments.
Syntax
Return Types
CQL: geometry
Remarks
Returns null for uninitialized geometry variables
The polygonal approximation that the method returns depends on the geometry instance used to call the method:
Returns a
LineString
instance for aCircularString
orCompoundCurve
instance.Returns a
Polygon
instance for aCurvePolygon
instance.Returns a copy of the geometry instance if that instance isn't a
CircularString
,CompoundCurve
, orCurvePolygon
instance.
Any z-coordinate values present in the calling geometry instance are ignored.
Geometry Example
In this example, the SELECT statement uses a LineString
instance to call the STCurveToLine
method. Thus, the method returns a LineString
instance:
STDifference (Geometry)
STDifference()
returns an object that represents the point set from one geometry instance that doesn't lie within another geometry instance.
Syntax
Arguments
other_instance
Another geometry instance to compare against the instance on which STDifference()
is invoked.
Return Types
CQL: geometry
Remarks
Returns null if the spatial reference IDs (SRIDs) of the geometry instances don't match.
Geometry Example
This example uses STDifference()
to compute the difference between two Polygons
:
STDisjoint (Geometry)
STDisjoint()
returns 1 if a geometry instance is spatially disjoint from another geometry instance. Otherwise, returns 0.
Syntax
Arguments
other_instance
Another geometry instance to compare against the instance on which STDisjoint()
is invoked.
Return Types
CQL: Yes/No
Remarks
If the intersection of the two geometry instances point sets are empty, they disjoint.
Returns null if the spatial reference IDs (SRIDs) of the geometry instances don't match.
Geometry Example
This example uses STDisjoint()
to test two geometry instances for spatial disjoint:
STDistance
STDistance()
returns the shortest distance between a point in a geometry/geography instance and a point in another geometry/geography instance.
Syntax
Arguments
other_instance
Another geometry/geography instance to compare against the instance on which STDistance()
is invoked.
Return Types
CQL: Number
Remarks
STDistance()
always returns null if the spatial reference IDs (SRIDs) of the geometry/geography instances don't match.
Geometry Example
This example finds the distance between two geometry instances:
Geography Example
This example finds the distance between two geography instances:
STEndpoint (Geometry)
STEndPoint()
returns the end point of a geometry instance.
Syntax
Return Types
CQL: geometry
Remarks
STEndPoint()
is the equivalent of STPointN()
.
Returns null if called on an empty geometry instance.
Geometry Example
This example creates a LineString
instance with STGeomFromText()
and uses STEndpoint()
to retrieve the end point of the LineString:
STEnvelope (Geometry)
STEnvelope()
returns the minimum axis-aligned bounding rectangle of the instance.
Syntax
Return Types
CQL: geometry
Geometry Example
This example uses STGeomFromText()
to create a LineString
instance from (0,0) to (2,3), and uses STEnvelope()
to return the bounding box of the LineString:
STEquals (Geometry)
STEquals()
returns 1 if a geometry instance represents the same point set as another geometry instance. Otherwise, returns 0.
Syntax
Arguments
other_instance
Another geometry instance to compare against the instance on which STEquals()
is invoked.
Return Types
CQL: Yes/No
Remarks
Returns null if the spatial reference IDs (SRIDs) of the geometry instances don't match.
Geometry Example
This example creates two geometry instances with STGeomFromText()
that are equal but not trivially equal, and uses STEquals()
to test their equality:
STExteriorRing (Geometry)
STExteriorRing()
returns the exterior ring of a geometry instance that's a Polygon
.
Syntax
Return Types
CQL: geometry
Remarks
Returns null if the geometry instance isn't a Polygon
.
Geometry Example
This example creates a polygon instance and uses STExteriorRing()
to return the exterior ring of the polygon as a LineString
:
STGeometryN (Geometry)
STGeometryN()
returns a specified geometry in a geometry collection.
Syntax
Arguments
expression
Is an int expression between 1 and the number of geometry instances in the GeometryCollection
.
Return Types
CQL: geometry
Remarks
Returns null if the parameter is larger than the result of STGeometryN()
and will throw an ArgumentOutOfRangeException
if the expression parameter is less than 1.
Geometry Example
This example creates a MultiPoint
GeometryCollection
and uses STGeometryN()
to find the second geometry instance of the collection:
STGeometryType (Geometry)
STGeometryType()
returns the Open Geospatial Consortium (OGC) type name represented by geometry instance.
Syntax
Return Types
CQL: Text
Remarks
The OGC type names that can be returned by STGeometryType()
are Point
, LineString
, CircularString
, CompoundCurve
, Polygon
, CurvePolygon
, GeometryCollection
, MultiPoint
, MultiLineString
, MultiPolygon
, and FullGlobe
.
Geometry Example
This example creates a Polygon
instance and uses STGeometryType()
to confirm that it's a Polygon:
STGeomCollFromText (Geometry)
Augmented with any Z
(elevation) and M
(measure) values carried by the instance, STGeomCollFromText()
returns a geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation.
Syntax
Arguments
geometrycollection_tagged_text
An nvarchar(max) expression that's the WKT representation of the geometry instance you wish to return.
SRID An int expression representing the spatial reference ID (SRID) of the geometry instance you wish to return.
Return Types
CQL: geometry
Remarks
The OGC type of the geometry instance returned by STGeomCollFromText()
is set to the corresponding WKT input.
Throws an ArgumentException
if the input isn't valid.
Geometry Example
This example uses STGeomCollFromText()
to create a geometry instance:
STGeomFromText
Augmented with any Z
(elevation) and M
(measure) values carried by the instance, STGeomFromText()
returns a geometry/geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation.
Syntax
Arguments
instance_tagged_text
An nvarchar(max) expression that's the WKT representation of the geometry/geography instance you wish to return.
SRID An int expression representing the spatial reference ID (SRID) of the geometry/geography instance you wish to return.
Return Types
CQL: geometry/geography
Remarks
The OGC type of the geometry/geography instance returned by STGeomFromText()
is set to the corresponding WKT input.
If the input isn't well-formatted, method will throw a FormatException
.
Geography:
Throws an ArgumentException
if the input contains an antipodal edge.
Geometry Example
This example uses STGeomFromText()
to create a geometry instance:
Geography Example
This example uses STGeomCollFromText()
to create a geography instance:
STGeomFromWKB
STGeomFromWKB()
returns a geometry/geography instance from an Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation.
Syntax
Arguments
WKB_instance
An nvarchar(max) expression that's the WKB representation of the geometry/geography instance to return.
SRID An int expression representing the spatial reference ID (SRID) of the geometry/geography instance to return.
Return Types
CQL: geometry/geography
Remarks
The OGC type of the geometry/geography instance returned by STGeomFromWKB()
is set to the corresponding WKB input.
If the input isn't well-formatted, method will throw a FormatException
.
Geography:
Throws an ArgumentException
if the input contains an antipodal edge.
Geometry Example
This example uses STGeomFromWKB()
to create a geometry instance:
Geography Example
This example uses STGeomFromWKB()
to create a geography instance:
STInteriorRingN (Geometry)
STInteriorRingN()
returns the specified interior ring of a Polygon
geometry instance.
Syntax
Arguments
expression An int expression between 1 and the number of interior rings in the geometry instance.
Return Types
CQL: geometry
Remarks
Returns null if the geometry instance isn't a Polygon
.
This method will throw an ArgumentOutOfRangeException
if the expression is larger than the number of rings. The number of rings can be returned using STNumInteriorRing()
.
Geometry Example
This example creates a Polygon
instance and uses STInteriorRingN()
to return the interior ring of the Polygon
as a LineString
:
STIntersection
STIntersection()
returns an object that represents the points where a geometry/geography instance intersects another geometry/geography instance.
Syntax
Arguments
other_instance
Another geometry/geography instance to compare against the instance on which STIntersection()
is invoked.
Return Types
CQL: geometry/geography
Remarks
If the spatial reference IDs (SRIDs) of the geometry/geography instances don't match, STIntersection()
always returns null.
The result may contain circular arc segments only if the input instances contain them.
Geometry Example
This example uses STIntersection()
to compute the intersection of two polygons:
Geography Example
This example uses STIntersection()
to compute the intersection of a Polygon
and a LineString:
STIntersects
STIntersects()
returns 1 if a geometry instance intersects another geometry instance. Otherwise, returns 0.
Syntax
Arguments
other_instance
Another geometry/geography instance to compare against the instance on which STIntersects()
is invoked.
Return Types
CQL: Yes/No
Remarks
Returns null if the spatial reference IDs (SRIDs) of the geometry/geography instances don't match.
Geometry Example
This example uses STIntersects()
to determine if two geometry instances intersect each other:
Geography Example
This example uses STIntersects()
to determine whether two geography instances intersect each other:
STIsClosed (Geometry)
STIsClosed()
returns 1 if the start and end points of the given geometry instance are the same. Returns 1 for GeometryCollection
types if each contained geometry instance is closed. Returns 0 if the instance isn't closed.
Syntax
Return Types
CQL: Yes/No
Remarks
Returns 0 if any figures of a geometry instance are points, or if the instance is empty.
All Polygon
instances are considered closed.
Geometry Example
This example creates a LineString
instance and uses STIsClosed()
to test if the LineString
is closed:
STIsEmpty (Geometry)
STIsEmpty()
returns 1 if a geometry instance is empty. Returns 0 if a geometry instance isn't empty.
Syntax
Return Types
CQL: Yes/No
Geometry Example
This example creates an empty geometry instance and uses STIsEmpty()
to test whether the instance is empty:
STIsRing (Geometry)
STIsRing()
returns 1 if a geometry instance fulfills the following requirements:
It's a
LineString
instance.It's closed (for a geometry to be closed, STIsClosed() needs to return 1 when invoked on the instance).
It's simple (for a geometry to be simple, STIsSimple() needs to return 1 when invoked on the instance).
Returns 0 if the
LineString
instance doesn't meet the requirements.
Syntax
Return Types
CQL: Yes/No
Remarks
Returns null if the instance isn't a LineString
.
Geometry Example
This example creates a LineString
instance and uses STIsRing()
to test whether the instance is a ring:
STIsSimple (Geometry)
STIsSimple()
returns 1 if a geometry instance is simple, as defined by the Open Geospatial Consortium (OGC). Returns 0 if a geometry instance isn't simple.
Syntax
Return Types
CQL: Yes/No
Remarks
To be simple a geometry instance must meet the requirements:
Except at the endpoints, each figure of the instance must not intersect itself.
No two figures of the instance can intersect each other at a point that's not in both of their boundaries.
Geometry Example
This example creates a non-simple LineString
instance that intersects itself and uses STIsSimple()
to test whether the LineString
is simple:
STIsValid (Geometry)
STIsValid()
returns true if a geometry instance is well-formed, based on its Open Geospatial Consortium (OGC) type. Returns false if a geometry instance isn't well-formed.
Syntax
Return Types
CQL: Yes/No
Remarks
The OGC type of a geometry instance can be determined by invoking STGeometryType()
.
SQL Server produces only valid geometry instances, but allows for the storage and retrieval of invalid instances.
Geometry Example
This example creates a geometry instance and uses STIsValid()
to test if the instance is valid:
STLength
STLength()
returns the total length of the elements in a geometry/geography instance or the geometry/geography instances within a GeometryCollection
.
Syntax
Return Types
CQL: Yes/No
Remarks
If a geometry/geography instance is closed, its length is calculated as the total length around the instance
The length of a GeometryCollection
is found by calculating the sum of the lengths of all of the geometry/geography instances contained within the collection.
STLength()
works on both valid and invalid LineString
.
Geometry Example
This example creates a LineString
instance and uses STLength()
to find the length of the instance:
Geography Example
This example creates a LineString
instance and uses STLength()
to find the length of the instance:
STLineFromText (Geometry)
Augmented with any Z
(elevation) and M
(measure) values carried by the instance,STLineFromText()
returns a geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation.
Syntax
Arguments
linestring_tagged_text
An nvarchar(max) expression that's the WKT representation of the geometry LineString
instance you wish to return.
SRID
An int expression representing the spatial reference ID (SRID) of the geometry LineString
instance you want to return.
Return Types
CQL: geometry
Remarks
If the input isn't well-formatted, method will throw a FormatException
.
Geometry Example
This example uses STLineFromText()
to create a geometry instance:
STLineFromWKB (Geometry)
STLineFromWKB()
returns a geometry LineString
instance from an Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation.
Syntax
Arguments
WKB_linestring
A varbinary(max) expression that's the WKB representation of the geometry LineString
instance to return.
SRID
An int expression representing the spatial reference ID (SRID) of the geometry LineString
instance you want to return.
Return Types
CQL: geometry
Remarks
If the input isn't well-formatted, method will throw a FormatException
.
Geometry Example
This example uses STLineFromWKB()
to create a geometry instance:
STMLineFromText (Geometry)
Augmented with any Z
(elevation) and M
(measure) values carried by the instance, STMLineFromText()
returns a geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation.
Syntax
Arguments
multilinestring_tagged_text
An nvarchar(max) expression that's the WKT representation of the geometryMultiLineString
instance you wish to return.
SRID
An int expression representing the spatial reference ID (SRID) of the geometry MultiLineString
instance you wish to return.
Return Types
CQL: geometry
Remarks
If the input isn't well-formatted, method will throw a FormatException
.
Geometry Example
This example uses STMLineFromText()
to create a geometry instance:
STMPointFromText (Geometry)
Augmented with any Z
(elevation) and M
(measure) values carried by the instance, STMPointFromText()
returns a geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation.
Syntax
Arguments
multipoint_tagged_text
An nvarchar(max) expression that's the WKT representation of the geometry MultiPoint
instance you wish to return.
SRID
An int expression representing the spatial reference ID (SRID) of the geometryMultiPoint
instance you wish to return.
Return Types
CQL: geometry
Remarks
If the input isn't well-formatted, method will throw a FormatException
.
Geometry Example
This example uses STMPointFromText()
to create a geometry instance:
STMPolyFromText (Geometry)
Augmented with any Z
(elevation) and M
(measure) values carried by the instance, STMPolyFromText()
returns a geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation.
Syntax
Arguments
multipolygon_tagged_text
An nvarchar(max) expression that's the WKT representation of the geometry MultiPolygon
instance you wish to return.
SRID
Is an int expression representing the spatial reference ID (SRID) of the geometry MultiPolygon
instance you wish to return.
ReturnTypes
CQL: geometry
Remarks
If the input isn't well-formatted, method will throw a FormatException
.
Example
This example usesSTMPolyFromText()
to create a geometry instance:
STNumCurves (Geometry)
STNumCurves()
returns the number of curves in a one-dimensional geometry instance.
Syntax
Return Types
CQL: geometry
Remarks
An empty one-dimensional geometry instance returns 0.
Null is returned when the geometry instance isn't a one-dimensional instance or is an uninitialized instance.
One-dimensional spatial data types include LineString
, CircularString
, and CompoundCurve
. STNumCurves()
works only on simple types; it doesn't work with geometry collections like MultiLineString
.
Example
This example shows how to get the number of curves in a CircularString
instance:
STNumGeometries (Geometry)
STNumGeometries()
returns the number of geometries that comprise a geometry instance.
Syntax
Return Types
CQL: Number
Remarks
This method returns 1 if the geometry instance isn't a MultiPoint
, MultiLineString
, MultiPolygon
, or GeometryCollection
instance, and 0 if the geometry instance is empty.
Example
This example creates a MultiPoint
instance and uses STNumGeometries()
to find out how many geometries the instance contains:
STNumInteriorRing (Geometry)
STNumInteriorRing()
returns the number of interior rings of a Polygon
geometry instance.
Syntax
Return Types
CQL: Number
Remarks
Returns null if the geometry instance isn't a Polygon
.
Example
This example creates a Polygon
instance and uses STNumInteriorRing()
to find how many interior rings the instance has:
STNumPoints (Geometry)
STNumPoints()
returns the sum of the number of points in each of the figures in a geometry instance.
Syntax
Return Types
CQL: Number
Remarks
STNumPoints()
counts the points (duplicate points are counted) in the description of a geometry instance. If this instance is a collection type, this method returns the sum of the points in each of its elements.
Example
This example creates a LineString
instance and uses STNumPoints()
to determine how many points were used in the description of the instance:
STOverlaps (Geometry)
STOveralps()
returns 1 if a geometry instance overlaps another geometry instance. Otherwise, returns 0.
Syntax
Arguments
other_instance
Another geometry instance to compare against the instance on which STOverlaps()
is invoked.
Return Types
CQL: Yes/No
Remarks
If the points where the geometry instances intersect aren't in the same dimension, STOverlaps()
always returns 0.
If the spatial reference IDs (SRIDs) of the geometry instances don't match, STOverlaps()
returns null.
Two geometry instances overlap if the region representing their intersection has the same dimension as the instances do and the region doesn't equal either instance.
Example
This example uses STOverlaps()
to test two geometry instances for overlap:
STPointFromText (Geometry)
Only available in SQL Server implementations.
Augmented with any Z
(elevation) and M
(measure) values carried by the instance, STPointFromText()
returns a geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation.
Syntax
Arguments
point_tagged_text
An nvarchar(max) expression that's the WKT representation of the geometry Point
instance you wish to return.
SRID
An int expression representing the spatial reference ID (SRID) of the geometry Point
instance you wish to return.
ReturnTypes
CQL: geometry
Remarks
If the input isn't well-formatted, method will throw a FormatException
.
Example
This example usesSTPointFromText()
to create a geometry instance:
STPointFromWKB (Geometry)
STPointFromWKB()
returns a geometry Point instance from an Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation.
Syntax
Arguments
WKB_point
A varbinary(max) expression that's the WKB representation of the geometry Point
instance you wish to return.
SRID
An int expression representing the spatial reference ID (SRID) of the geometry Point
instance you wish to return.
Return Types
CQL: geometry
Remarks
If the input isn't well-formatted, method will throw a FormatException
.
Example
This example usesSTPointFromWKB()
to create a geometry instance:
STPointN (Geometry)
STPointN()
returns a specified point in a geometry instance.
Syntax
Arguments
expression An int expression between 1 and the number of points in the geometry instance.
Return Types
CQL: geometry
Remarks
Throws an ArgumentOutOfRangeException
, if this method is called with a value less than 1.
Returns null if this method is called with a value greater than the number of points in the instance.
STPointN()
returns the point specified by expression, if a geometry instance is user created. (occurs by ordering the points in which they were originally input).
STPointN()
returns the point specified by expression, if a geometry instance was constructed by the system (by ordering all the points in the same order they would be output: first by geometry, then by ring within the instance (if appropriate), and then by point within the ring).
Example
This example creates a LineString
instance and uses STPointN()
to retrieve the second point in the description of the instance:
STPointOnSurface (Geometry)
STPointOnSurface()
returns an arbitrary point located within the interior of a geometry instance.
Syntax
Return Types
CQL: geometry
Remarks
If the instance is empty, method returns null.
Example
This example creates a Polygon
instance and uses STPointOnSurface()
to find a point on the instance:
STPolyFromText (Geometry)
Only available in SQL Server implementations.
Augmented with any Z
(elevation) and M
(measure) values carried by the instance, STPolyFromText()
returns a geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation.
Syntax
Arguments
polygon_tagged_text
An nvarchar(max) expression that's the WKT representation of the geometry Polygon
instance you wish to return.
SRID
An int expression representing the spatial reference ID (SRID) of the geometry Polygon
instance you wish to return.
Return Types
CQL: geometry
Remarks
If the input isn't well-formatted, method will throw a FormatException
.
Example
This example usesSTPolyFromText()
to create a geometry instance:
STRelate (Geometry)
STRelate()
returns 1 if a geometry instance is related to another geometry instance, otherwise, returns 0. (The relationship between the geometry instances is defined by a Dimensionally Extended 9 Intersection Model (DE-9IM) pattern matrix value)
Syntax
Arguments
other_instance
Another geometry instance to compare against the instance on which STRelate()
is invoked.
intersection_pattern_matrix
Is a string of type nchar(9) encoding acceptable values for the DE-9IM pattern matrix device between the two geometry instances.
Return Types
CQL: Yes/No
Remarks
If the spatial reference IDs (SRIDs) of the geometry instances don't match, method returns null.
If matrix isn't well-formed, an ArgumentException
will be thrown.
Example
This example uses STRelate()
to test two geometry instances for spatial disjoint using an explicit DE-9IM pattern:
STStartPoint (Geometry)
STStartPoint()
returns the start point of a geometry instance.
Syntax
Return Types
CQL: geometry
Remarks
STStartPoint()
is the equivalent of STPointN()
.
Example
This example uses STStartPoint()
to retrieve the start point of the instance and creates a LineString
instance:
STSymDifference (Geometry)
STSymDifference()
returns an object that represents all points that are either in one geometry instance or another geometry instance, but not those points that lie in both instances.
Syntax
Arguments
other_instance
Another geometry instance to compare against the instance on which STSymDifference()
is invoked.
Return Types
CQL: geometry/geography
Remarks
If the spatial reference IDs (SRIDs) of the geometry instances don't match, method returns null.
Result may contain circular arc segments (only if the input instances contain circular arc segments).
Example
This example uses STSymDifference()
to compute the symmetric difference of two Polygon
instances:
STTouches (Geometry)
STTouches()
returns 1 if a geometry instance spatially touches another geometry instance. Returns 0 if it doesn't.
Syntax
Arguments
other_instance
Another geometry instance to compare against the instance on which STTouches()
is invoked.
Return Types
CQL: Yes/No
Remarks
If two geometry instances point sets intersect, they're touching but their interiors don't intersect.
If the spatial reference IDs (SRIDs) of the geometry instances don't match, method returns null.
Example
This example uses STTouches()
to test two geometry
instances to see if they touch:
STUnion (Geometry)
STUnion()
returns an object that represents the union of a geometry instance with another geometry instance.
Syntax
Arguments
other_instance
Another geometry instance to compare against the instance on which STUnion()
is invoked.
Return Types
CQL: geometry
Remarks
If the spatial reference IDs (SRIDs) of the geometry instances don't match, method returns null.
Result may contain circular arc segments (only if the input instances contain circular arc segments).
Example
This example uses STUnion()
to compute the union of two Polygon
instances:
STWithin (Geometry)
STWithin()
returns 1 if a geometry instance is completely within another geometry instance; otherwise, returns 0.
Syntax
Arguments
other_instance
Another geometry instance to compare against the instance on which STWithin()
is invoked.
Return Types
CQL: Yes/No
Remarks
The STWithin
command is case-sensitive.
If the spatial reference IDs (SRIDs) of the geometry instances don't match, method returns null.
Example
This example uses STWithin()
to test two geometry
instances to see if the first instance is completely within the second instance:
Last updated