Skip to content

Latest commit

 

History

History
110 lines (77 loc) · 3.76 KB

stcurven-geometry-data-type.md

File metadata and controls

110 lines (77 loc) · 3.76 KB
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
STCurveN method (geometry)
TSQL
=azuresqldb-current||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current

STCurveN (geometry Data Type)

[!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.

Syntax

  
.STCurveN ( curve_index )  

Arguments

curve_index
Is an int expression between 1 and the number of curves in the geometry instance.

Return Types

[!INCLUDEssNoVersion] return type: geometry

CLR return type: SqlGeometry

Exceptions

If curve_index < 1 then an ArgumentOutOfRangeException is thrown.

Remarks

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

Examples

A. Using STCurveN() on a CircularString instance

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)

B. Using STCurveN() on a CompoundCurve instance with one CircularString instance

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)

C. Using STCurveN() on a CompoundCurve instance with three CircularString instances

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.

D. Validating the parameter before calling STCurveN()

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

See Also

STNumCurves (geometry Data Type)
OGC Methods on Geometry Instances