开发者

How can we find out if a point with a certain lat and long is located on road graph?

I am writing a Windows application in C# which should find the nearest path (road) between two points in the city. I needed to access the road data, like the coordinates of the beginning and end of the roads, maybe a complete database.

I did not know how I can access such an information or file.开发者_StackOverflow So for simplicity I assumed some certain vertices and the edges (the connection between the vertices). Now I have a point (coordinates of a specific location). I want to see on which edge this point is located. I see by just having information about start and end of vertices and the connection between them (edges=roads) I cannot locate a position of a point on the roads. I need to know if there is any way to find out if a point with a specific coordinates is located on a specific road. I also want to know what kind of information do usually map data contain--is it just the coordinates of two ends of roads, or more info about roads?


You need to calculate the distances between the position and road, then you look at the distance and determine if it's close enough. For the distance from point a to line b you need to calculate point c on b where c to a is perpendicular to b.

To actually calculate these distances you need to do quite some math (take in the rounding of the earth) so I hope you got some skills there. Explanation on how to calculate distances between coordinates and between a line and a point.

I wrote a GPS application where the distance to a point had to be 25 meters for the current postion to be on the point. This extra space it quite important because GPS is 10 meters inaccurate by design, so if you get your data from GPS and you must be 1 meter close to your target, chances are you will never reach it, even if your standing next to it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜