perliedman / geojson-path-finder

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

edgeData in both directions? #91

Open pbvahlst opened 11 months ago

pbvahlst commented 11 months ago

Is it possible make so edgeDataReducer or its result can take forward or backward into consideration like the weight function can.

I am creating an algoritm to reconstruct the path parts back to the original geoJson for more detailed path instructions and are storing the ids of the geoJson in an array in the edgeDataReducer (and handles duplicates etc).

The edgeData returned with the path will then look something like [1, 2, [3, 4], 5] and when taking the path in reverse [5, [3, 4], 2, 1] where the nested array is the result of an edge data reduction. The problem is that the reduced edge data does not reflect the direction, so trying to reconstruct the path requires an trial and error approach where all nested arrays are tried in both directions until the correct combination is found.

perliedman commented 10 months ago

It sounds like an oversight in the current design that it does not take direction into account, probably because my requirement for edge datas came up in a separate project from where I needed the differing forward/backward cost for edges.

So, yes, I think this is something that would make sense to implement. Having said that, I don't really plan on working on geojson-path-finder at the moment, so it's not likely I will do it myself for now. Happy to accept PRs though (although I'm apparently very slow to react to communications here... sorry about that).