STCurveN (geography Data Type)
Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance
Returns the curve specified from a geography instance that is a LineString, CircularString, or CompoundCurve.
Syntax
.STCurveN( n )
Note
To view Transact-SQL syntax for SQL Server 2014 (12.x) and earlier versions, see Previous versions documentation.
Arguments
n
Is an int expression between 1 and the number of curves in the geography instance.
Return Types
SQL Server return type: geography
CLR return type: SqlGeography
Exceptions
If n < 1 then an ArgumentOutOfRangeException is thrown.
Remarks
NULL is returned when the following criteria occurs.
The geography instance is declared, but is not instantiated
The geography instance is empty
n exceeds the number of curves in the geography instance (See STNumCurves (geography Data Type)
The dimension for the geography instance does not equal (See STDimension (geography Data Type)
Examples
A. Using STCurveN() on a CircularString
The following example returns the second curve in a CircularString instance:
DECLARE @g geography = 'CIRCULARSTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653)';
SELECT @g.STCurveN(2).ToString();
The example returns.
CIRCULARSTRING (-122.348 47.658, -122.358 47.658, -122.358 47.653)
B. Using STCurveN() on a CompoundCurve
The following example returns the second curve in a CompoundCurve instance:
DECLARE @g geography = 'COMPOUNDCURVE(CIRCULARSTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))';
SELECT @g.STCurveN(2).ToString();
The example returns.
CIRCULARSTRING (-122.348 47.658, -122.358 47.658, -122.358 47.653)
C. Using STCurveN() on a CompoundCurve Containing Three CircularStrings
The following example uses a CompoundCurve instance that combines three separate CircularString instances into the same curve sequence as the previous example:
DECLARE @g geography = 'COMPOUNDCURVE (CIRCULARSTRING (-122.358 47.653, -122.348 47.649, -122.348 47.658), CIRCULARSTRING(-122.348 47.658, -122.358 47.658, -122.358 47.653))';
SELECT @g.STCurveN(2).ToString();
The example returns.
CIRCULARSTRING (-122.348 47.658, -122.358 47.658, -122.358 47.653)
STCurveN()
returns the same results regardless of Well-Known Text (WKT) format that is used.
D. Testing for Validity Before Calling STCurve()
The following example shows how to make sure that n is valid before you call the STCurveN() method:
DECLARE @g geography;
DECLARE @n int;
SET @n = 2;
SET @g = geography::Parse('LINESTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653)');
IF @n >= 1 AND @n <= @g.STNumCurves()
BEGIN
SELECT @g.STCurveN(@n).ToString();
END
See Also
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for