Skip to content

SQL Server 2012: CompoundCurve – a new geospatial feature

There are three new geospatial features in Microsoft SQL Server 2012: CircularString, CurvePolygon, and CompoundCurve. For the fun and as an example, I will test CompoundCurve, a set of circular strings that may be combined with line strings, and store a “dbi” character set in a table.:-D

What is CompoundCurve?

It’s a set of circular strings, or circular strings combined with line strings, that form a desired curved shape. The end point of each element in the collection must match the starting point of the following element, so that compound curves are defined in a “connect-the-dots” fashion.

To be valid it must meet the following criteria:

  • It must contain at least one CircularString or LineString instance
  • The sequence of CircularString or LineString instances must be continuous
  • See msdn definition

Creating a table to store the “dbi” character set

We have to create a simple geometry column table to store the “dbi” character set:

b2ap3_thumbnail_Geometry-CreateTable.jpg

Creating the “d”

The first step is to create the “d” from dbi. The “d” character is made of an arc and a line.
An arc is defined with the command CircularString. For more information on CircularString, go to msdn reference

Let’s define 3 points for the “d” arc:

b2ap3_thumbnail_Geometry-D-arc.jpg

The second is the line and I use the command LineString. For more information about LineString, go to msdn reference.
Let’s define 2 points for the “d” line:

b2ap3_thumbnail_Geometry-D-Line.jpg

To create the “d”, you have to add the 2 previous geometries with a STUnion option.
For more information about STUnion, go to msdn reference.

b2ap3_thumbnail_Geometry-D-classique.jpg

This is a classical way to create a “d”, but in SQL server 2012, you can can use the CompoundCurve feature for this.
CompoundCurve is the combination of the features CircularString and LineString.

b2ap3_thumbnail_Geometry-D-compoundcurve.jpg

Notice that you don’t need to use the LineString command, it’s implied.

Creating the “b”

On the same principle, let’s create the “b” from dbi.

b2ap3_thumbnail_Geometry-B-compoundcurve.jpg

 

Creating the “i”

For the “i”, you needa simple point and the command LineString.

b2ap3_thumbnail_Geometry-I-point.jpg

b2ap3_thumbnail_Geometry-I-Line.jpg

Insert the “dbi” character set in the table

Now that you have created all geometries for the character set, you can concat all geometries with the STUnion feature and insert them in the table.

b2ap3_thumbnail_Geometry-insert.jpg

Finally, you can display the table with a simple select – and there is our “dbi” character set in the spatial result:
b2ap3_thumbnail_Geometry-table-select.jpg

Conclusion

It’s very easy to use the CompoundCurve features and it’s funny to play with geometrical features.😀

Let’s work together

Ready to operate at
the next level?

Tell us about your challenge. We’ll bring the depth, the expertise, and the Swiss precision.

Stéphane Haby

Stéphane Haby

Stéphane Haby has more than 20 years of experience in Microsoft solutions, specializing in the installation, migration, best practices, and performance analysis of Microsoft SQL Server, as well as Microsoft Business Intelligence solutions (SharePoint, Office) and .NET development for the banking sector. A former Microsoft Most Valuable Professional (MVP) and early adopter of Microsoft Team System in France, he has authored several technical articles. He holds Microsoft Certified Solutions Associate (MCSA) and Expert (MCSE) for SQL Server, MCTS, MCITP for SQL Server 2008, and ITIL V3 Foundation certifications. His industry experience covers chemicals and pharma, banking, and financial services.View Author posts

182 posts since April 2011

Leave a Comment

Your email address will not be published. Required fields are marked *