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

STNumPoints (geography Data Type)

Returns the total number of points in each of the figures in a geography instance.

.STNumPoints ( )

SQL Server return type: int

CLR return type: SqlInt32

This method counts the points in the description of a geography instance. Duplicate points are counted; however, connecting points between segments are counted only once. If this instance is a collection, this method returns the total number of points in the collection.

A. Retrieving the total number of points in a LineString

The following example creates a LineString instance and uses STNumPoints() to determine how many points were used in the description of the instance.

DECLARE @g geography;
SET @g = geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326);
SELECT @g.STNumPoints();

B. Retrieving the total number of points in a GeometryCollection

The following example returns a sum of the points for all elements in the GeometryCollection.

DECLARE @g geography = 'GEOMETRYCOLLECTION(CIRCULARSTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653)
    ,CURVEPOLYGON(CIRCULARSTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653)))';
SELECT @g.STNumPoints();

C. Returning the number of points in a CompoundCurve

The following example returns the number of points in a CompoundCurve instance. The query returns 5 instead of 6 because STNumPoints() only counts the connecting point between the segments once.

DECLARE @g geography = 'COMPOUNDCURVE(CIRCULARSTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658),( -122.348 47.658, -121.56 48.12, -122.358 47.653))'

SELECT @g.STNumPoints();

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

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.