Turfjs / Turfjs/turf

ShortestPath & geoJSON

Open
#1,283 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

@turf/shortest-path
Dominant language
TypeScript
Stars
10.5k
Forks
1k
Avg merge
1h 11m
Merged PRs (30d)
4

Description

Do you have any tips on how to use this with a land geojson? I'm trying to plot a course between two points and avoid land masses, which is represented by a GeometryCollection of Polygons.
But, it throws me an invalid obstacles error probably because the geometry is a multipolygon. So, I try to flatten it using turf.flatten but now I'm stuck in a massive loop.

image

You can find the geojson file at:
http://www.luanngo.ca/apps/game/res/land_sm.json
Thanks!

    var start = [-11.777343749999979,40.44694705960049];
    var end = [62.22656250000001,19.97334878611059];
    $.get("http://www.luanngo.ca/apps/game/res/land_sm.json").done(function(data){
        data=turf.flatten(data);
        var options = {
            obstacles: data
        };
        var path = turf.shortestPath(start, end, options);

    });

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the turf.shortestPath entry point and the turf.flatten usage shown in the issue, then inspect how the obstacles option validates GeometryCollection and multipolygon data. Confirm whether the supplied land_sm.json reproduces the invalid-obstacles error or the loop, and document the supported input shape and a working usage pattern.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.