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

Start point for round trip should be first coordinate #1939

Closed
DEHWall opened this issue Jan 29, 2016 · 9 comments
Closed

Start point for round trip should be first coordinate #1939

DEHWall opened this issue Jan 29, 2016 · 9 comments
Assignees
Milestone

Comments

@DEHWall
Copy link

DEHWall commented Jan 29, 2016

Am I right in assuming that the first and last via_points should be the Start and End (being the same) points of a requested \trip url as follows.

Is there a known issue / fix available?

It also affects the order of the route_instructions.

http://osrm:5000/trip?loc=**51.853842,-3.129779**&loc=51.75983,-3.36673&loc=51.63623,-3.95339&loc=51.64771,-4.03711&loc=51.5827,-3.00176&loc=51.48148,-2.52805&loc=51.37876,-2.43739&loc=51.43524,-2.6002&loc=51.56916,-1.80141&loc=51.5523,-1.7864&loc=51.63753,-1.83719&loc=51.90335,-2.07979&loc=**51.853842,-3.129779**
{
"status_message": "Found trips",
"status": 200,
"trips": [
....
"via_points": [
[
51.636239,-3.953348],[
51.582627,-3.001746],[
51.481475,-2.528061],[
51.435281,-2.600249],[
51.37858,-2.437094],[
51.552301,-1.7864],[
51.569181,-1.801448],[
51.63735,-1.837459],[
51.903344,-2.079795],[
* 51.854382,-3.12917],[ <-------
51.854382,-3.12917],[ <-----
*
51.759672,-3.366476],[
51.647716,-4.037114],[
51.636239,-3.953348]],
"permutation": [
2,4,5,7,6,9,8,10,11,0,12,1,3],

Many thanks
Dave

@TheMarex
Copy link
Member

@DEHWall omit the last location entry, all trips are planned as round-trips automatically.

@DEHWall
Copy link
Author

DEHWall commented Feb 1, 2016

Still does not do as expected - am I misunderstanding the functionality here?

Given that the starting point is 51.853842,-3.129779

SelectedStops:
0 51.853842,-3.129779
1 51.78524,-3.87921
2 51.66592,-3.30539
3 51.78099,-3.24361
4 51.6192,-3.93939

http://osrm:5000/trip?loc=51.853842,-3.129779&loc=51.78524,-3.87921&loc=51.66592,-3.30539&loc=51.78099,-3.24361&loc=51.6192,-3.93939

Nearest (replot points osrm/nearest)
0 51.854382,-3.12917
1 51.785243,-3.879195
2 51.665925,-3.305397
3 51.780753,-3.243968
4 51.61924,-3.939364

{
"status_message": "Found trips",
"status": 200,
"trips": [
....
"via_points": [
[
51.61924,-3.939364],[ <--- this is not the first parameter
51.785243,-3.879195],[
51.854382,-3.12917],[ <--- would expect this to be first in permutation and First and last in via_points
51.780753,-3.243968],[
51.665925,-3.305397],[
51.61924,-3.939364]], <--- this is not the first parameter
"permutation": [
4,1,0,3,2], <--- and the permutation to be 0,3,2,4,1

@daniel-j-h
Copy link
Member

/cc @chaupow

@TheMarex
Copy link
Member

TheMarex commented Feb 1, 2016

@DEHWall yeah the lack of normalization here might be a problem. As a work around just start reading the permutation array at the position of 0 and read with wrap-around (yielding your array). You can feed the result again in viaroute to get a round trip starting at 0.

@TheMarex TheMarex changed the title \trip request - via_points not in order as expected Start point for round trip should be first coordinate Feb 1, 2016
@TheMarex TheMarex added this to the 5.0 milestone Feb 1, 2016
@DEHWall
Copy link
Author

DEHWall commented Feb 2, 2016

Moving the required Start / End point to the end of the parameter list rather than the first gives a more desired result:

http://osrm:5000/trip?loc=52.45773,-1.87&loc=52.47613,-1.89509&loc=52.58671,-2.00438&loc=52.4785,-1.96992&loc=52.55478,-2.02305&loc=52.45475,-1.87742&loc=52.5158,-1.90405&loc=51.853842,-3.129779

Nearest
52.457734,-1.869988
52.47649,-1.895337
52.586557,-2.004423
52.478502,-1.96994
52.554781,-2.02304
52.454753,-1.877445
52.515769,-1.904067
51.854382,-3.12917 <--- Start and End
{
"status_message": "Found trips",
"status": 200,
"trips": [
...
"via_points": [
[
51.854382,-3.12917],[ <--- Start
52.554781,-2.02304],[
52.586557,-2.004423],[
52.515769,-1.904067],[
52.47649,-1.895337],[
52.457734,-1.869988],[
52.454753,-1.877445],[
52.478502,-1.96994],[
51.854382,-3.12917]], <--- Same as End
"permutation": [ 7,4,2,6,1,0,5,3], <--- In the right sequence

@DEHWall DEHWall closed this as completed Feb 2, 2016
@TheMarex
Copy link
Member

TheMarex commented Feb 2, 2016

The actual problem is not fixed: Trip should start at first coordinate.

@TheMarex TheMarex reopened this Feb 2, 2016
@TheMarex TheMarex modified the milestones: 5.1.0, 5.0 Mar 9, 2016
@TheMarex TheMarex modified the milestones: 5.2.0, 5.1.0 Apr 28, 2016
@TheMarex TheMarex modified the milestones: 5.3.0, 5.2.0 May 11, 2016
@TheMarex TheMarex modified the milestones: 6.0, 5.3.0 Jun 22, 2016
@chaupow
Copy link
Member

chaupow commented Feb 6, 2017

@DEHWall sorry for being late in the convo and thanks for flagging this :) working on it

@chaupow
Copy link
Member

chaupow commented Feb 8, 2017

@DEHWall just to keep you updated, it was implemented in #3660
and is now waiting for #3408 to get merged into master

edit:
in case you need it earlier, these two lines in src/engine/plugins/trip.cpp are what you want:

auto start_index = std::find(scc_route.begin(), scc_route.end(), 0);
std::rotate(scc_route.begin(), start_index, scc_route.end());

@daniel-j-h
Copy link
Member

This landed by now in both the backend and in the node bindings.

You can now request a roundtrip or not (return to the start or not) and fix start and end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants