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

MultiLineString features #67

Closed Lessad closed 1 year ago

Lessad commented 4 years ago

Hello,

I just wanted to know if this library works with MultiLineString features ? It should be the same as LineString but with extra brackets like so:

MultiLineString [ [ [5.783246085057053,43.12920992982103],[5.78323152868196,43.129224336755215] ] ]

LineString [ [5.783246085057053,43.12920992982103],[5.78323152868196,43.129224336755215] ]

If not maybe there is a way to alter the code and make it compatible ?

Thank you in advance :) Lessad

Edit: Corrected "MultipleLineString" to "MultiLineString"

Lessad commented 4 years ago

Update:

Changed topology.js

Line 30 function isLineString(f) { return true; } You can also replace "LineString" with "MultiLineString"

Line 56 f.geometry.coordinates[0].forEach(function buildLineStringEdges(c, i, cs) {

It made it work for me.

perliedman commented 4 years ago

Hi!

The problem with these changes are that if I understand correctly, it will only work with MultiLineStrings.

It would be reasonable to make the library support MultLineString, but without breaking current support. Happy to merge a PR.

Lessad commented 4 years ago

Hey,

It’s exactly as you say haha I did that because I really needed it to work with that type of feature. But because of my lack of skill and understanding of this library I couldn’t do much.. so I shared it only as a comment.

I hope someone will find a proper and clean way!

perliedman commented 1 year ago

Closing this for now. Adding MultiLineString support is probably not too hard, but not something a lot of people seem to ask for. If anyone is interested in adding this, feel free to open a PR.