perliedman / geojson-path-finder

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

weight to km #19

Closed trandinh135 closed 7 years ago

trandinh135 commented 7 years ago

How can i calculate real distance from weight ?

perliedman commented 7 years ago

Hi,

it depends entirely on how you configured the weights of your graph. By default, GeoJSON Path Finder will use distance as weight (https://github.com/perliedman/geojson-path-finder/blob/master/preprocessor.js#L10), so no calculation is necessary, just take the weight and it will be the total distance.

If you have other weights, it is still quite easy to just loop over the returned path and sum the distance between them.