开发者

Sort/Order Locations

I have a map with locations as shown in the image below.

Sort/Order Locations

These locations are held in a C# Dictionary object with both Latitude/Longitude and Cartesian (x, y, z) coordinates. The area is covered by 5 teams, the first of which is in the south west of the area. What I need is to be able to order the points so that the most south westerly point is first - this would be the green '3' marker near Enniski开发者_开发知识库llen on the map. I've been trying different approaches but not getting the result I want.

Can anyone explain an approach that would work?

Mark


Assuming you know the Lat / Long of the South West corner of this map, I would calculate the distance of each point from that corner using the Aviation Formulary. Then you just have to sort based on the distance calculated.


If you want to define "most south westerly" in a way similar to "most southerly", you could order the points (x,y) by x+y. You can think of this as moving a NW-SE line across the map from the SW corner, noting the order that the points are reached. This is equivalent to defining "most southerly" by sorting on y, where you're moving an east-west line up from the south edge and noting the order that you reach each point.


I would use the Haversine formula to determine the distance between some location in the southwest corner of the map and each of the points. Here's a link with some code for both C# and Sql Server to do that very thing.

http://www.storm-consultancy.com/blog/development/code-snippets/the-haversine-formula-in-c-and-sql/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜