title | description | author | ms.author | ms.date | ms.service | ms.subservice | ms.topic | helpviewer_keywords | dev_langs | monikerRange | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|
STCurveN (geometry Data Type) |
STCurveN (geometry Data Type) |
MladjoA |
mlandzic |
08/03/2017 |
sql |
t-sql |
reference |
|
|
=azuresqldb-current||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current |
[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance]
Returns the curve specified from a geometry instance that is a LineString, CircularString, CompoundCurve, or MultiLineString.
.STCurveN ( curve_index )
curve_index
Is an int expression between 1 and the number of curves in the geometry instance.
[!INCLUDEssNoVersion] return type: geometry
CLR return type: SqlGeometry
If curve_index < 1 then an ArgumentOutOfRangeException
is thrown.
NULL is returned when any of the following occurs:
-
the geometry instance is declared, but not instantiated
-
the geometry instance is empty
-
curve_index exceeds the number of curves in the geometry instance
-
the geometry instance is a Point, MultiPoint, Polygon, CurvePolygon, or MultiPolygon
The following example returns the second curve in a CircularString
instance:
DECLARE @g geometry = 'CIRCULARSTRING(0 0, 1 2.1082, 3 6.3246, 0 7, -3 6.3246, -1 2.1082, 0 0)';
SELECT @g.STCurveN(2).ToString();
The example earlier in this topic returns:
CIRCULARSTRING (3 6.3246, 0 7, -3 6.3246)
The following example returns the second curve in a CompoundCurve
instance:
DECLARE @g geometry = 'COMPOUNDCURVE(CIRCULARSTRING(0 0, 1 2.1082, 3 6.3246, 0 7, -3 6.3246, -1 2.1082, 0 0))';
SELECT @g.STCurveN(2).ToString();
The example earlier in this topic returns:
CIRCULARSTRING (3 6.3246, 0 7, -3 6.3246)
The following example uses a CompoundCurve
instance that combines three separate CircularString
instances into the same curve sequence as the previous example:
DECLARE @g geometry = 'COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 2.1082, 3 6.3246), CIRCULARSTRING(3 6.3246, 0 7, -3 6.3246), CIRCULARSTRING(-3 6.3246, -1 2.1082, 0 0))';
SELECT @g.STCurveN(2).ToString();
The example earlier in this topic returns:
CIRCULARSTRING (3 6.3246, 0 7, -3 6.3246)
Notice that the results are the same for the previous three examples. Whichever WKT (Well-known Text) format is used to enter the same curve sequence, the results returned by STCurveN()
are the same when a CompoundCurve
instance is used.
The following example shows how to make sure @n
is valid before you call the STCurveN()
method:
DECLARE @g geometry;
DECLARE @n int;
SET @n = 3;
SET @g = geometry::Parse('CIRCULARSTRING(0 0, 1 2.1082, 3 6.3246, 0 7, -3 6.3246, -1 2.1082, 0 0)');
IF @n >= 1 AND @n <= @g.STNumCurves()
BEGIN
SELECT @g.STCurveN(@n).ToString();
END
STNumCurves (geometry Data Type)
OGC Methods on Geometry Instances