A quick set of SQLCLR spatial decomposition functions

Saw a request on the SQL Server spatial forum this morning for routines that would decompose a geography type to a set of Lat/Longs. A while ago, I was experiemnting with spatial decomposition, and happened to cruft up a couple of SQLCLR table-valued functions to accomplish this. Although the same functions could be written in T-SQL, it's better to use SQLCLR for this, just for speed's sake. Although these function aren't likely production quality (and I think I only tested these on polygons), I figured it would be better to post them here now than to wait until I had time, and answer each forum query with "write me mail" in the meantime. I did send these out a few times privitely and almost a year ago, and Matt Jones did port the code to use Geometry rather than Geography and did send me the changes (thanks Matt). I've enclosed these files (these are the WClassX.cs files) as well, although they're not hooked up to the project. Suffixed each TVF with "Geom" so they do have some rather odd names. If you do make any changes or enhancements to these in future, please send them back.

Enjoy!

@bobbeauch

SpatialDecomposition.zip (21.23 kb)

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.