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

What am I doing wrong on this simple test? #21

Closed devleaks closed 7 years ago

devleaks commented 7 years ago

Pease have a look at this gist.

I create a 4 x 4 square (4 horizontal lines of length 4, 4 vertical lines of length 4, total 16 squares, 16 intersections, very simple and straightforward square network.)

Then I ask the route between let's say point (0,1) and (2,0). I would expect an answer of the type (0,1) to (1,1); (1,1) to (2,1); (2,1) to (2,0).

I keep getting null as a path, for whatever starting and ending point I supply. Am I missing something? Do I need to enter each individual vertices and line segments, or does your algorithm compute the intersections of horizontal and vertical lines?

Also, is there a direction to the vertices or are they automatically bi-directional?

Could you please give some hint on where you found the code or algorithm (preprocessor, compactVertices, etc.) I understand most of their global purpose, but cannot easily guess how they work. I understand it is based on Dijkstra shortest path, but it is a bit theoretical and not practical.

Thanks.

Pierre

devleaks commented 7 years ago

OK, got it. You have to add each individual vertex. 0,0 to 0,1, 0,1 to 0,2, etc. I was confused by

lines that start and end, or cross, at the same coordinate are joined text in the doc. But still, Id love some more explanation on the algorithm. Thanks. P.

perliedman commented 7 years ago

Ok, yes - the lines have to cross with nodes on or really close to each other. Could make this clearer in the docs!

But this is resolved for you, right?

devleaks commented 7 years ago

Yes it does. But still, can you provide more info on these points:

perliedman commented 7 years ago

Good luck!