| title | BufferWithCurves (geography Data Type) | ||
|---|---|---|---|
| description | BufferWithCurves (geography Data Type) | ||
| author | MladjoA | ||
| ms.author | mlandzic | ||
| ms.date | 08/11/2017 | ||
| ms.service | sql | ||
| ms.subservice | t-sql | ||
| ms.topic | reference | ||
| ms.custom |
|
||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| dev_langs |
|
||
| monikerRange | =azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric-sqldb |
[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance FabricSQLDB]
Returns a geography instance that represents the set of all points whose distance from the calling geography instance is less than or equal to the distance parameter.
.BufferWithCurves ( distance )
distance
Is a float indicating the maximum distance that points forming the buffer can be from the geography instance.
[!INCLUDEssNoVersion] return type: geography
CLR return type: SqlGeography
The following criteria will throw an ArgumentException.
-
No parameter is passed to the method such as
@g.BufferWithCurves() -
A non-numeric parameter is passed to the method such as
@g.BufferWithCurves('a') -
NULL is passed to the method, such as
@g.BufferWithCurves(NULL)
The following table shows the results returned for different distance values.
| distance Value | Type Dimensions | Spatial Type Returned |
|---|---|---|
| distance < 0 | Zero or One | Empty GeometryCollection instance |
| distance < 0 | Two or More | A CurvePolygon or GeometryCollection instance with a negative buffer. Note: A negative buffer may create an empty GeometryCollection |
| distance = 0 | All dimensions | Copy of the invoking geography instance |
| distance > 0 | All dimensions | CurvePolygon or GeometryCollection instance |
Note
Since distance is a float, a very small value can equate to zero in the calculations. When this occurs, then a copy of the calling geography instance is returned.
If a string parameter is passed to the method, then it will be converted to a float or it will throw an ArgumentException.
The following example returns an empty GeometryCollection instance:
DECLARE @g geography= 'LINESTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653)';
SELECT @g.BufferWithCurves(-1).ToString();The following example returns a CurvePolygon instance with a negative buffer:
DECLARE @g geography = 'CURVEPOLYGON(CIRCULARSTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))';
SELECT @g.BufferWithCurves(-1).ToString()The following example shows what occurs when the distance parameter equals -2:
DECLARE @g geography = 'CURVEPOLYGON(CIRCULARSTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))';
SELECT @g.BufferWithCurves(-2).ToString();This SELECT statement returns GEOMETRYCOLLECTION EMPTY
The following example returns a copy of the calling geography instance:
DECLARE @g geography = 'LINESTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653)';
SELECT @g.BufferWithCurves(0).ToString();The following example also returns a copy of the calling geography instance:
DECLARE @g geography = 'LINESTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653)';
DECLARE @distance float = 1e-20;
SELECT @g.BufferWithCurves(@distance).ToString();The following example returns a CurvePolygon instance:
DECLARE @g geography= 'LINESTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653)';
SELECT @g.BufferWithCurves(2).ToString();The following example returns the same CurvePolygon instance as mentioned earlier, but a string parameter is passed to the method:
DECLARE @g geography= 'LINESTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653)';
SELECT @g.BufferWithCurves('2').ToString();The following example will throw an error:
DECLARE @g geography = 'LINESTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653)'
SELECT @g.BufferWithCurves('a').ToString();Note that the previous two examples passed a string literal to the BufferWithCurves() method. The first example works because the string literal can be converted to a numeric value. However, the second example throws an ArgumentException.
Extended Methods on Geography Instances
BufferWithCurves (geometry Data Type)