Map Routing, a la Google Maps?

前端 未结 9 1270
生来不讨喜
生来不讨喜 2021-02-06 23:59

I\'ve always been intrigued by Map Routing, but I\'ve never found any good introductory (or even advanced!) level tutorials on it. Does anybody have any pointers, hints, etc?

9条回答
  •  孤独总比滥情好
    2021-02-07 00:12

    From my experience of working in this field, A* does the job very well. It is (as mentioned above) faster than Dijkstra's algorithm, but is still simple enough for an ordinarily competent programmer to implement and understand.

    Building the route network is the hardest part, but that can be broken down into a series of simple steps: get all the roads; sort the points into order; make groups of identical points on different roads into intersections (nodes); add arcs in both directions where nodes connect (or in one direction only for a one-way road).

    The A* algorithm itself is well documented on Wikipedia. The key place to optimise is the selection of the best node from the open list, for which you need a high-performance priority queue. If you're using C++ you can use the STL priority_queue adapter.

    Customising the algorithm to route over different parts of the network (e.g., pedestrian, car, public transport, etc.) of favour speed, distance or other criteria is quite easy. You do that by writing filters to control which route segments are available, when building the network, and which weight is assigned to each one.

提交回复
热议问题