Visualizing the new Denali curve spatial types

I'd been fretting over the lack of a true visualizer for the new circularstring and compoundcurve spatial types in SQL Server Denali. I'd installed SSMS from SQL Server 2008 R2, and although it works just fine for Denali spatial types (even though the binary format has changed since 2008/R2), trying to use it with either of the new "curve" types produces an empty graph pane. Because of this lack of visualization, I also wondered how these types would ever work with map websites/controls that only support Points, LineStrings, and Polygons.

Silly me. When I mentioned this to Ed Katibah (aka Spatial Ed), he pointed out that this was exactly the purpose of STCurveToLine(). I thought this method would only produce LineStrings that had as many vertices as the curve, resulting in a "square" rendition of a circle, for example. But no… this routine "densifies" the linestring, resulting in a linestring with more points, that really looks like a curve/circle. Nice! If this doesn't look circular enough (or is too many points) you can always use CurveToLineWithTolerance() instead of STCurveToLine(). Thanks, Ed! Here's a short example:

declare @g geometry = 'CIRCULARSTRING(0 2, 2 0, 4 2, 2 4, 0 2)' — here's a circle
select @g.STIsValid() — ensure it's valid
select @g.STNumPoints() — 5 points in the definition

— show in the SSMS 2008/R2 "spatial results tab"
select @g.STCurveToLine()
select @g.CurveToLineWithTolerance(0.01,0)

— circle densification
select @g.STCurveToLine().STNumPoints(), — 65 points
         @g.CurveToLineWithTolerance(0.01,0).STNumPoints() — 33 points

@bobbeauch

Other articles

Imagine feeling confident enough to handle whatever your database throws at you.

With training and consulting from SQLskills, you’ll be able to solve big problems, elevate your team’s capacity, and take control of your data career.