Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
BufferWithCurves (geography Data Type)

BufferWithCurves (geography Data Type)

 

Applies To: SQL Server 2014, SQL Server 2016 Preview

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.

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


.BufferWithCurves ( distance )

distance

Is a float indicating the maximum distance that points forming the buffer can be from the geography instance.

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

Exception Condition

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.

System_CAPS_noteNote

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

System_CAPS_noteNote

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.

Community Additions

ADD
Show:
© 2015 Microsoft