Giter VIP home page Giter VIP logo

Comments (9)

tmcw avatar tmcw commented on May 22, 2024

Why does this calculate client-side anyway? We just launched an API for this.

from mapbox-gl-directions.

jfirebaugh avatar jfirebaugh commented on May 22, 2024

I'm confused as to why this is necessary at all. mapbox-directions.js doesn't need it.

from mapbox-gl-directions.

tmcw avatar tmcw commented on May 22, 2024

Same

from mapbox-gl-directions.

tristen avatar tristen commented on May 22, 2024

It's calculated to derive the URL query. Given a url like:

/v4/directions/mapbox.driving/
-74.5597381591797,40.12139809056774;
-74.69306607374473,40.031006417727895;
-75.05781808872085,40.11136049688241;
-74.9486688115121,39.92301383728193;
-75.14762445604451,40.02994849538351.json?

It sorts the coordinates between the first(origin) + last(destination). If it's not sorted, the route is returned with the coordinates in the order that they were sent and not - as I could tell - sorted by the most optimized path.

from mapbox-gl-directions.

tmcw avatar tmcw commented on May 22, 2024

Yes, and the user inputs waypoints in order, and gets directions in order. This is a directions API, not a traveling-salesman API, and the assumption is that you would want to go to things in the order you type them, rather than an 'optimal' order - people do not plan, for example, roadtrips, based on algorithms.

from mapbox-gl-directions.

tristen avatar tristen commented on May 22, 2024

Let me be a little more specific. Say I have a route planned with a single waypoint:

screen shot 2015-08-31 at 5 40 59 pm

Origin = A
Waypoint = C
Destination = B

If I wanted to add another waypoint (D) before the first waypoint I, (as the user) would expect the route to order in this sequence: A -> D -> C -> B.

If I don't sort the order the sequence looks like this: A -> C -> D -> B. which is not the result I would expect.

from mapbox-gl-directions.

tmcw avatar tmcw commented on May 22, 2024

You create new waypoints when someone clicks a segment. You would check which segment they clicked to create the waypoint, and place the new waypoint in between its end points.

from mapbox-gl-directions.

tristen avatar tristen commented on May 22, 2024

Ah that makes sense. I'm creating the directions route as a single LineString when it should be broken into segments.

from mapbox-gl-directions.

tristen avatar tristen commented on May 22, 2024

💀 going to avoid doing anything weird with waypoint ordering all together.

from mapbox-gl-directions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.