| title | STCurveN (geometry Data Type) | |
|---|---|---|
| description | STCurveN (geometry Data Type) | |
| author | MladjoA | |
| ms.author | mlandzic | |
| ms.date | 08/03/2017 | |
| ms.service | sql | |
| ms.subservice | t-sql | |
| ms.topic | reference | |
| ms.custom |
|
|
| helpviewer_keywords |
|
|
| dev_langs |
|
|
| monikerRange | =azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric-sqldb |
[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance FabricSQLDB]
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();
ENDSTNumCurves (geometry Data Type)
OGC Methods on Geometry Instances