Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop shortest distance calc for waypoints and manage their position in the query by route segments #2

Closed
tristen opened this issue Aug 31, 2015 · 9 comments

Comments

@tristen
Copy link
Member

tristen commented Aug 31, 2015

It's otherwise a performance kill calculating the shortest distance between them

@tmcw
Copy link
Contributor

tmcw commented Aug 31, 2015

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

@jfirebaugh
Copy link

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

@tmcw
Copy link
Contributor

tmcw commented Aug 31, 2015

Same

@tristen
Copy link
Member Author

tristen commented Aug 31, 2015

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.

@tmcw
Copy link
Contributor

tmcw commented Aug 31, 2015

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.

@tristen
Copy link
Member Author

tristen commented Aug 31, 2015

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.

@tmcw
Copy link
Contributor

tmcw commented Aug 31, 2015

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.

@tristen
Copy link
Member Author

tristen commented Aug 31, 2015

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

@tristen tristen changed the title Punt & display an error if waypoints exceeds a length of 8 Drop shortest distance calc for waypoints and manage their position in the query by route segments Sep 1, 2015
@tristen
Copy link
Member Author

tristen commented Nov 26, 2015

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

@tristen tristen closed this as completed Nov 26, 2015
nicolas-marien pushed a commit to nicolas-marien/mapbox-gl-directions that referenced this issue May 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants