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

FeatureCollection of multiple LineString features #33

Open benistary opened 6 years ago

benistary commented 6 years ago

Hi, I've found your package and it's really awesome! But, is possible to apply pathFinder function on featureCollection of miltiplne lineStrings ? Because it seems that's not working. I'm working on Indoor Navigation based on QRcodes and I want to create big graph, where can I search shortest way.

perliedman commented 6 years ago

Hi, yes, it should work with a FeatureCollection on multiple LineStrings. In fact, that's exactly the data I use it for.

For example, check out this GeoJSON that we use in the tests: https://raw.githubusercontent.com/perliedman/geojson-path-finder/master/test/network.json

If this causes trouble, please provide some more details about your GeoJSON and the issue you're seeing.

maissenayed commented 5 years ago

Hi, i have the same issue where i tried your test data with , but i always have an error in the turf explode function

untitfeled untitled

perliedman commented 5 years ago

@maissenayed hard to tell without seeing it running, but my guess is that you are using a newer version of the Turf modules, which are written with ES modules in mind. This means that the functions from Turf should now be imported like this:

var explode = require('@turf/explode').default;

Might this be the problem?

maissenayed commented 5 years ago

i tried that but still the same problem , i'm using mapbox-draw-plugin ,where i draw LineStrings, and then use Draw.getall , to get my geojson , and yes using the latest turf.js lib,what can i provide so we can tackle this problem ???

perliedman commented 5 years ago

I would just check in devtools what explode is actually set to, it should be pretty straight forward to debug.

MAbdulHalim commented 5 years ago

@maissenayed hard to tell without seeing it running, but my guess is that you are using a newer version of the Turf modules, which are written with ES modules in mind. This means that the functions from Turf should now be imported like this:

var explode = require('@turf/explode').default;

Might this be the problem?

I had the same issue and .default fixed it