Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

STCurveN (geography Data Type)

SQL Server 2012

Returns the curve specified from a geography instance that is a LineString, CircularString, or CompoundCurve.

.STCurveN( n )
n

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

SQL Server return type: geography

CLR return type: SqlGeography

If n < 1 then an ArgumentOutOfRangeException is thrown.

NULL is returned when the following criteria occurs.

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.