Sometimes it is a data quality requirement for linear data (roads, pipelines, transmission lines) that curves within the lines must have a radius greater than a particular amount.

Recently a customer asked me to write some TSQL functions to help them run data quality checks over linear data loaded into a SQL Server 2008 geometry column directly from a CAD package.

The function I created is called CheckRadii and is as follows:

CREATEFUNCTION[CheckRadii](

@p_geom geometry,

@p_min_radius FLOAT,

@p_precision INT)

RETURNS geometry

AS

BEGIN

-- Implementation

END;

Description

Function that checks vertices in a linestring/multilinestring to see if the circular arc they describe
have radius less than the provided amount. Each set of three vertices (which could be overlapping)
that fail the test are written to a single MultiPoint object. If no circular arcs in the linestring
describe a circle with radius less than the required amount a NULL geometry is returned.
If another other than a (Multi)linestring is provided it is returned as is.

The parameter p_min_radius is a not null value that describes the minimum radiue of any arc within the linestring.

The function returns a projected 2D MultiPoint geometry.

The function only works for projected data and does not honour dimensions over 2.

## Comment