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

STCurveN (geometry Data Type)

SQL Server 2012

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.

SQL Server 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

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

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

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.