perliedman / geojson-path-finder

Find shortest path through a network of GeoJSON
https://www.liedman.net/geojson-path-finder/
ISC License
301 stars 87 forks source link

_createPhatom ? #9

Closed bertrandmd closed 7 years ago

bertrandmd commented 7 years ago

Hi, very impressive by your work !

I'm working on it, and I don't understand how use 'phantom' ?

In my mind this represent a new point in the network to add in graph. But it doesnt work. (maybe you change anything in the code ?)

thks for the reply

perliedman commented 7 years ago

You normally don't have to bother with phantom nodes when you use geojson-path-finder, only if you want to change the internals.

To get descent speeds, geojson-path-finder simplifies the graph topology to only include nodes where there are more than two edges, that is, it removes all nodes that are not forks in the road. This process simplifies most graphs immensely, going from annoyingly slow routing to really quick, at least for my use cases.

When you route, however, it is likely that the start and end points will not be at these forks, but rather at some node that has been removed by the process described above. To handle this, geojson-path-finder temporarily inserts "phantom" nodes, that is nodes that are not really part of the routing graph, but represent the desired start and end points. These phantom nodes are removed again once the route search is complete.

Hope this helps!