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

Add vertex keys to edges of calculated route #84

Open nickw1 opened 1 year ago

nickw1 commented 1 year ago

This is a small change to index.ts to add the vertex keys to the edgeDatas of each edge of the calculated route.

Why is this useful? It allows an approximate calculation of the distance of each edge on the route. For my use case (an augmented-reality walking app), I wish to calculate what proportion of the route is on footpaths (trails), and reject the route if the proportion is below a certain value. Adding the vertex keys to each edge allows this.

Tested (on my own app, https://github.com/nickw1/hikar.js) and it works, I also displayed each edgeData on the console, and it shows up as expected.