Open bulutkartal opened 6 years ago
Gday @bulutkartal
Yeah unfortunantly the shortest-path module is still very days. @stebogit might be able to provide more comment as to what he's struggling with...
It is a great start :) Just needs some improvements.
Hi @bulutkartal, I agree with you this module should perform better. Currently it uses the A* algorithm (see here for some more details), which was a quick (because already implemented) first solution, but it actually operate on a gridded plane so that's why introduces unnecessary points to the path. In https://github.com/Turfjs/turf/issues/788 @rowanwins and @dhivehi reported a couple of much better alternatives, for which though I haven't found a javascript implementation yet.
I believe the minDistance feature could/should be implemented just applying a buffer to each obstacle and run the shortest path with them.
Unfortunately right now I don't have enough time to dedicate to this project. 😞
I started looking at a visibility graph to power our astar algorithm, this will do away with the need for the gridded approach, still a little while away though, I'll try and post a link to a public repo tomorrow
Here is my WIP repo for constructing a visibility graph from geojson. It's surprising but I can't find any js implementations for constructing visibility graphs. My work is based porting this python lib. I'm still getting my head around the algorithm so it's not working yet but hopefully it's not too far off
Pyvisgraph is a great example. I wish he would do it in c# :(
I found this research about Deriving an Obstacle-Avoiding Shortest Path in Continuous Space
Vector-based approach looks a lot better than raster-based approach :)
Hi @bulutkartal
Thanks for that link, looks like a very helpful paper in understanding shortest path considerations.
I've made reasonable progress on porting pyvisgraph to js - see this demo, there are just some structure things in the API that I want to tidy up to make it more useful.
For example once you have a graph of countries you should be able to reuse that (rather than having to recalcuate it everytime), but you also need the flexibility to add new points (your start and end points) and calculate their visibility.
So my intent is to convert the graph into the ngraph.graph lib which has support for saving graphs, and then use the associated path library for calcuating the shortest path.
So still got some work to do but making progress
Hi @rowanwins , Just found this repository on Github. Could be very helpful for you.
Hi, hope this sample will reduce your work on this. https://fribbels.github.io/shortestpath/visgraph.html
Algorithm creates extra waypoints and makes the route/path longer than it supposed to be. Also minimum distance option is not working.
Example Fiddle based on documentation test.
Until the first wp under the polygon it created 6 unnecessary waypoints. Also did the same thing when clear from polygon as well.
Also if you zoom in, you will see the path is going over polygon as well.