Export (0) Print
Expand All

STNumPoints (geography Data Type)


THIS TOPIC APPLIES TO:yesSQL Server (starting with 2008)yesAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

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

OGC Methods on Geography Instances

Community Additions

© 2016 Microsoft