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

Can't find route. #5

Closed marvinernst closed 7 years ago

marvinernst commented 7 years ago

Hi, i found your great tool to create a Router on existing geoJSON-Paths. It worked most of the time, but sometimes I get the Error "Cant't find route". I checked the lines for spaces and other errors but i can't find any. Are there any size limits for processing?

I have uploaded my file for testing,: test.zip

perliedman commented 7 years ago

Although the lines cross at the three way intersection roughly in the middle of your network, it appears there are no nodes (coordinates) sufficiently close to each other on the crossing segments.

The topology can only be built if the router can snap coordinates close to each other to a node, to figure out which segments are reachable from each other.

It should be enough to insert new coordinates into the two line strings to make sure they have a coordinate in common.

perliedman commented 7 years ago

You can also work around this without modifying your data by passing the option precision: 1e-4 when you create the network. The result currently looks pretty horrible, though.

new PathFinder(geojson, {precision: 1e-4})
marvinernst commented 7 years ago

Thanks for your help! Editing the precision fixed my problems :)