Export (0) Print
Expand All

STNumPoints (geography Data Type)


Applies To: SQL Server 2014, SQL Server 2016 Preview

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

Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database.

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

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();

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();

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();

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft