I've just started playing with the Geo spatial data types in SQL Server Express.
The first thing I wanted to do was draw a circle. How difficult could it be?
I could not find an example on the interweb - so I put one together.
-- Draw Circle
declare @RecCount float = 360
declare @count int = 0
declare @size int = 1
declare @tmpTable table ( geo geometry)
while(@count < @RecCount)
begin
insert into @tmpTable
SELECT geometry::STGeomFromText('POINT('
+ cast(SIN(RADIANS((CAST(@count AS FLOAT)
/CAST(@RecCount AS FLOAT))
* 360)) * @size as varchar)
+ ' '
+ cast(COS(RADIANS((CAST(@count AS FLOAT)
/CAST(@RecCount AS FLOAT))
* 360)) * @size as varchar)
+ ')',4326) AS Posn
set @count = @count + 1
end
select geo from @tmpTable
Now choose the 'Spatial Results' tab - you might have never seen this before. It only appears if the results set has a geospatial data type in it.
The observant of you might notice, it's not actually a circle.
Happy Coding...!!!
The first thing I wanted to do was draw a circle. How difficult could it be?
I could not find an example on the interweb - so I put one together.
-- Draw Circle
declare @RecCount float = 360
declare @count int = 0
declare @size int = 1
declare @tmpTable table ( geo geometry)
while(@count < @RecCount)
begin
insert into @tmpTable
SELECT geometry::STGeomFromText('POINT('
+ cast(SIN(RADIANS((CAST(@count AS FLOAT)
/CAST(@RecCount AS FLOAT))
* 360)) * @size as varchar)
+ ' '
+ cast(COS(RADIANS((CAST(@count AS FLOAT)
/CAST(@RecCount AS FLOAT))
* 360)) * @size as varchar)
+ ')',4326) AS Posn
set @count = @count + 1
end
select geo from @tmpTable
Now choose the 'Spatial Results' tab - you might have never seen this before. It only appears if the results set has a geospatial data type in it.
Draw a Circle |
The observant of you might notice, it's not actually a circle.
Happy Coding...!!!
No comments:
Post a Comment