CheckRadii: Identifying Tight Radius Curves sections within LineString geometry data

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:

   @p_geom       geometry,
   @p_min_radius FLOAT,
   @p_precision  INT )
 RETURNS geometry
   -- Implementation


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.


And can be called as follows:

 SELECT [CheckRadii](geometry::STGeomFromText('MULTILINESTRING(
 (0.0 0.0,10.0 0.0,10.0 10.0),
 (20.0 0.0,30.0 0.0,30.0 10.0))',0), 15.0,3).STAsText();

Some examples of running this against test road data with a 15.0 meter radius and precision of 3 (ie 1 mm) are as follows.

If anyone wants a copy of this function, or wishes for a similar function to be written for them, please contact me.