turf icon indicating copy to clipboard operation
turf copied to clipboard

Adding a weighted ShortestPath option

Open kauevestena opened this issue 2 years ago • 2 comments

Hello! First of all, congrats for the amazing project!

I found Turf on searching tools for an attempt to create a routing demo and host at github pages, having the computation running on client-side, I found that there's the function "ShortestPath", which would be an amazing beginning. But for my application I would rather have weighted routes, I even have the weights computed in a field of the geojson file.

So this is my suggestion/request,

Best Regards, Kauê

kauevestena avatar Jan 09 '24 14:01 kauevestena

Thanks for your suggestion @kauevestena. Do you think it needs to be an entirely new module? Or would it make sense to add some optional weighting parameters to the existing shortestPath call? For example, weight: number and the function uses that to compare if it exists?

smallsaucepan avatar Jan 10 '24 12:01 smallsaucepan

I think that the best option would be an optional argument (default null) in the function call.

It could be either an string referring to a precomputed field (less flexible), or to a function that could also calculate weights on-the-fly (could be less optimized).

kauevestena avatar Jan 10 '24 13:01 kauevestena