开发者

SQL 2008 Spatial ordering of objects

开发者 https://www.devze.com 2023-01-05 11:25 出处:网络
I have a dataset containing the start and end points (both OSGB36 and corresponding WGS84 coordinates) of sections of a road network.I am able to import this data in SQL and create geometry and geogra

I have a dataset containing the start and end points (both OSGB36 and corresponding WGS84 coordinates) of sections of a road network. I am able to import this data in SQL and create geometry and geography data types for the start and end points and for the entire object (LINESTRING etc).

Viewing the coordinates in SQL query window enables me to see the spatial results for this coordinates and viewing the geometry of the entire object displays the entire road network visually in the spatial results.

However, if I was wishing to return the road objects as a linear representation - in other words as a standard result set and order them on geographic position e.g. north to south, east to开发者_开发百科 west etc - what would be the best method. I am currently assuming that calculating a distance from the start point would be the best approach - but I would appreciate some Spatial SQL 2008 expertise.


You could get the bounding box of each shape w/ .STEnvelope(), and then sort by one of the corners using .STPointN().STX and .STY. That wouldn't be too expensive.

0

精彩评论

暂无评论...
验证码 换一张
取 消