Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@turf/shortest-path is not giving the shortest path & minDistance option is not working #1211

Open
bulutkartal opened this issue Jan 3, 2018 · 12 comments

Comments

@bulutkartal
Copy link

bulutkartal commented Jan 3, 2018

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.

@rowanwins
Copy link
Member

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...

@bulutkartal
Copy link
Author

It is a great start :) Just needs some improvements.

@bulutkartal bulutkartal changed the title @turf/shortest-path not giving the shortest path & minDistance option not working @turf/shortest-path is not giving the shortest path & minDistance option is not working Jan 3, 2018
@stebogit
Copy link
Collaborator

stebogit commented Jan 4, 2018

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 #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. 😞

@rowanwins
Copy link
Member

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

@rowanwins
Copy link
Member

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

@bulutkartal
Copy link
Author

Pyvisgraph is a great example. I wish he would do it in c# :(

@rowanwins
Copy link
Member

https://github.com/atil/visibilitygraph is c#

@bulutkartal
Copy link
Author

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 :)

@rowanwins
Copy link
Member

rowanwins commented Feb 1, 2018

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

@bulutkartal
Copy link
Author

Hi @rowanwins ,
Just found this repository on Github. Could be very helpful for you.

@dhivehi
Copy link
Collaborator

dhivehi commented Jul 21, 2018

Hi, hope this sample will reduce your work on this.
https://fribbels.github.io/shortestpath/visgraph.html

@ineeve
Copy link

ineeve commented Oct 27, 2021

An implementation of the shortest path using the visgraph approach described above would be much appreciated.
The current approach has weird behaviours, i.e. fiddle - if you look closely at the end of the red path, it overshoots and then comes back.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants