问题
I have 2750 city centers in Belgium. I need to know the distances between every 2 city centers. But that results in an matrix of 57MB, just to remember those distances (not even the routes), so that scales terribly.
Instead, I am looking at using Highway intersections as hubs. Basically, every city knows it's nearby cities and it's nearby hubs (= highway intersection). All hubs know the distance to each other.
So the distance from 1 city A to another non-nearby city B, can be calculated by the distance of cityA -> hubX -> hubY -> cityB
. Because most cities have typically 3 hubs nearby, I might need to look at all 9 combinations and take the shortest. But in any case it should scale better memory wise.
Now the problem: Can I describe a highway intersection as a single point? Think about it: a highway consist of 2 roads (one in both direction), so a highway intersection center has 4 roads (not even counting the arms).
回答1:
Some ideas:
- you can store those distances off-heap or on-disc via MapDB or GraphHopper its simplistic DataAccess implementations making it RAM-independent
- you can use float which should be only ~30MB or even short and just use the kilometers
- you could try on demand routing, without storing, as it takes only a few ms to calculate a route. Disable instructions and calculating points makes it even twice as fast. You could even disable calculating the distance and just use path.weight - this will give you another good speedup but requires a bit lower level GraphHopper usage and is only recommended if you know what you do.
Now to your question. GraphHopper uses a graph model consisting of nodes (junctions) and edges (streets connecting junctions). Still a roundabout consists of multiple nodes. But in general it should be possible to use such a 'leaving' node as 'hub-id'.
I see two approaches to calculate those nodes:
- either by running the Contraction-Hierarchy and picking the highest 1000 nodes and define them as hubs - this would be similar to what is described in the 'transit node routing' paper
- or you calculate routes from one city to e.g. all other cities (or just 8 geographic directions) and find the last common nodes of two routes to identify some
For both approaches you'll have to digg a bit deeper into GraphHopper and you'll probably need the lower level API.
来源:https://stackoverflow.com/questions/25648425/how-does-graphhopper-handle-a-point-on-a-highway-intersections