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

Add support for exits. #116

Merged
merged 2 commits into from
Jul 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,12 @@ module.exports = function(version, _options) {
// Decide which instruction string to use
// Destination takes precedence over name
var instruction;
if (step.destinations && instructionObject.destination) {
if (step.destinations && step.exits && instructionObject.exit_destination) {
instruction = instructionObject.exit_destination;
} else if (step.destinations && instructionObject.destination) {
instruction = instructionObject.destination;
} else if (step.exits && instructionObject.exit) {
instruction = instructionObject.exit;
} else if (wayName && instructionObject.name) {
instruction = instructionObject.name;
} else {
Expand All @@ -169,6 +173,7 @@ module.exports = function(version, _options) {
instruction = instruction
.replace('{way_name}', wayName)
.replace('{destination}', (step.destinations || '').split(',')[0])
.replace('{exit}', (step.exits || '').split(',')[0])
.replace('{exit_number}', this.ordinalize(language, step.maneuver.exit || 1))
.replace('{rotary_name}', step.rotary_name)
.replace('{lane_instruction}', laneInstruction)
Expand Down
30 changes: 22 additions & 8 deletions languages/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,37 +238,51 @@
"default": {
"default": "Take the ramp",
"name": "Take the ramp onto {way_name}",
"destination": "Take the ramp towards {destination}"
"destination": "Take the ramp towards {destination}",
"exit": "Take exit {exit}",
"exit_destination": "Take exit {exit} towards {destination}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't sure about using an _ here style wise. There isn't a precedent for complex/multiple fields.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

},
"left": {
"default": "Take the ramp on the left",
"name": "Take the ramp on the left onto {way_name}",
"destination": "Take the ramp on the left towards {destination}"
"destination": "Take the ramp on the left towards {destination}",
"exit": "Take exit {exit} on the left",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm explicit about "on the left" here because left exits are more unusual.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is only true for right-hand driving countries. Ideally we'd have left-hand/right-hand driving country information here. This is ticketed upstream Project-OSRM/osrm-backend#2269, assuming it would also be exposed in the API responses.

For now, I would remove direction on ramps completely. (Take the ramp on the {left/right} -> Take the ramp)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, but I went in the other direction with 38c6630 and added specific instructions until we have enough information to simplify.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@freenerd just saw your note further down:

Decide on exit directions (i vote for remove left/right)

I learn toward more specificity here because it can be super jarring when there is a left exit and driver really do expect it to be specifically called out.

"exit_destination": "Take exit {exit} on the left towards {destination}"
},
"right": {
"default": "Take the ramp on the right",
"name": "Take the ramp on the right onto {way_name}",
"destination": "Take the ramp on the right towards {destination}"
"destination": "Take the ramp on the right towards {destination}",
"exit": "Take exit {exit}",
"exit_destination": "Take exit {exit} on the right towards {destination}"
},
"sharp left": {
"default": "Take the ramp on the left",
"name": "Take the ramp on the left onto {way_name}",
"destination": "Take the ramp on the left towards {destination}"
"destination": "Take the ramp on the left towards {destination}",
"exit": "Take exit {exit} on the left",
"exit_destination": "Take exit {exit} on the left towards {destination}"
},
"sharp right": {
"default": "Take the ramp on the right",
"name": "Take the ramp on the right onto {way_name}",
"destination": "Take the ramp on the right towards {destination}"
"destination": "Take the ramp on the right towards {destination}",
"exit": "Take exit {exit}",
"exit_destination": "Take exit {exit} on the right towards {destination}"
},
"slight left": {
"default": "Take the ramp on the left",
"name": "Take the ramp on the left onto {way_name}",
"destination": "Take the ramp on the left towards {destination}"
"destination": "Take the ramp on the left towards {destination}",
"exit": "Take exit {exit} on the left",
"exit_destination": "Take exit {exit} on the left towards {destination}"
},
"slight right": {
"default": "Take the ramp on the right",
"name": "Take the ramp on the right onto {way_name}",
"destination": "Take the ramp on the right towards {destination}"
"destination": "Take the ramp on the right towards {destination}",
"exit": "Take exit {exit}",
"exit_destination": "Take exit {exit} on the right towards {destination}"
}
},
"on ramp": {
Expand Down Expand Up @@ -399,4 +413,4 @@
}
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want to add the en.json to transifex, do some translations, then run the transifex script to pull the updated translations down again.

22 changes: 22 additions & 0 deletions test/fixtures/v5/continue/left_exit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "left"
},
"name": "Way Name",
"exits": "4A,4B"
},
"instructions": {
"de": "Links weiterfahren auf Way Name",
"en": "Continue left onto Way Name",
"es": "Continua izquierda en Way Name",
"fr": "Continuer à gauche sur Way Name",
"id": "Terus kiri ke Way Name",
"nl": "Ga links naar Way Name",
"ru": "Двигайтесь налево по Way Name",
"sv": "Fortsätt vänster in på Way Name",
"vi": "Chạy tiếp bên trái trên Way Name",
"zh-Hans": "继续向左,上Way Name"
}
}
23 changes: 23 additions & 0 deletions test/fixtures/v5/continue/left_exit_destination.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "left"
},
"name": "Way Name",
"destinations": "Destination 1,Destination 2",
"exits": "4A,4B"
},
"instructions": {
"de": "Links weiterfahren Richtung Destination 1",
"en": "Continue left towards Destination 1",
"es": "Continua izquierda hacia Destination 1",
"fr": "Continuer à gauche en direction de Destination 1",
"id": "Teruskan kiri menuju Destination 1",
"nl": "Ga links richting Destination 1",
"ru": "Двигайтесь налево в направлении Destination 1",
"sv": "Fortsätt vänster mot Destination 1",
"vi": "Chạy tiếp bên trái đến Destination 1",
"zh-Hans": "继续向左行驶,前往Destination 1"
}
}
22 changes: 22 additions & 0 deletions test/fixtures/v5/continue/right_exit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "right"
},
"name": "Way Name",
"exits": "4A,4B"
},
"instructions": {
"de": "Rechts weiterfahren auf Way Name",
"en": "Continue right onto Way Name",
"es": "Continua derecha en Way Name",
"fr": "Continuer à droite sur Way Name",
"id": "Terus kanan ke Way Name",
"nl": "Ga rechts naar Way Name",
"ru": "Двигайтесь направо по Way Name",
"sv": "Fortsätt höger in på Way Name",
"vi": "Chạy tiếp bên phải trên Way Name",
"zh-Hans": "继续向右,上Way Name"
}
}
23 changes: 23 additions & 0 deletions test/fixtures/v5/continue/right_exit_destination.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "right"
},
"name": "Way Name",
"destinations": "Destination 1,Destination 2",
"exits": "4A,4B"
},
"instructions": {
"de": "Rechts weiterfahren Richtung Destination 1",
"en": "Continue right towards Destination 1",
"es": "Continua derecha hacia Destination 1",
"fr": "Continuer à droite en direction de Destination 1",
"id": "Teruskan kanan menuju Destination 1",
"nl": "Ga rechts richting Destination 1",
"ru": "Двигайтесь направо в направлении Destination 1",
"sv": "Fortsätt höger mot Destination 1",
"vi": "Chạy tiếp bên phải đến Destination 1",
"zh-Hans": "继续向右行驶,前往Destination 1"
}
}
22 changes: 22 additions & 0 deletions test/fixtures/v5/continue/sharp_left_exit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "sharp left"
},
"name": "Way Name",
"exits": "4A,4B"
},
"instructions": {
"de": "Scharf links weiterfahren auf Way Name",
"en": "Continue sharp left onto Way Name",
"es": "Continua cerrada a la izquierda en Way Name",
"fr": "Continuer franchement à gauche sur Way Name",
"id": "Terus tajam kiri ke Way Name",
"nl": "Ga linksaf naar Way Name",
"ru": "Двигайтесь налево по Way Name",
"sv": "Fortsätt skarp vänster in på Way Name",
"vi": "Chạy tiếp bên trái gắt trên Way Name",
"zh-Hans": "继续向左,上Way Name"
}
}
23 changes: 23 additions & 0 deletions test/fixtures/v5/continue/sharp_left_exit_destination.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "sharp left"
},
"name": "Way Name",
"destinations": "Destination 1,Destination 2",
"exits": "4A,4B"
},
"instructions": {
"de": "Scharf links weiterfahren Richtung Destination 1",
"en": "Continue sharp left towards Destination 1",
"es": "Continua cerrada a la izquierda hacia Destination 1",
"fr": "Continuer franchement à gauche en direction de Destination 1",
"id": "Teruskan tajam kiri menuju Destination 1",
"nl": "Ga linksaf richting Destination 1",
"ru": "Двигайтесь налево в направлении Destination 1",
"sv": "Fortsätt skarp vänster mot Destination 1",
"vi": "Chạy tiếp bên trái gắt đến Destination 1",
"zh-Hans": "继续向左行驶,前往Destination 1"
}
}
22 changes: 22 additions & 0 deletions test/fixtures/v5/continue/sharp_right_exit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "sharp right"
},
"name": "Way Name",
"exits": "4A,4B"
},
"instructions": {
"de": "Scharf rechts weiterfahren auf Way Name",
"en": "Continue sharp right onto Way Name",
"es": "Continua cerrada a la derecha en Way Name",
"fr": "Continuer franchement à droite sur Way Name",
"id": "Terus tajam kanan ke Way Name",
"nl": "Ga rechtsaf naar Way Name",
"ru": "Двигайтесь направо по Way Name",
"sv": "Fortsätt skarp höger in på Way Name",
"vi": "Chạy tiếp bên phải gắt trên Way Name",
"zh-Hans": "继续向右,上Way Name"
}
}
23 changes: 23 additions & 0 deletions test/fixtures/v5/continue/sharp_right_exit_destination.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "sharp right"
},
"name": "Way Name",
"destinations": "Destination 1,Destination 2",
"exits": "4A,4B"
},
"instructions": {
"de": "Scharf rechts weiterfahren Richtung Destination 1",
"en": "Continue sharp right towards Destination 1",
"es": "Continua cerrada a la derecha hacia Destination 1",
"fr": "Continuer franchement à droite en direction de Destination 1",
"id": "Teruskan tajam kanan menuju Destination 1",
"nl": "Ga rechtsaf richting Destination 1",
"ru": "Двигайтесь направо в направлении Destination 1",
"sv": "Fortsätt skarp höger mot Destination 1",
"vi": "Chạy tiếp bên phải gắt đến Destination 1",
"zh-Hans": "继续向右行驶,前往Destination 1"
}
}
22 changes: 22 additions & 0 deletions test/fixtures/v5/continue/slight_left_exit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "slight left"
},
"name": "Way Name",
"exits": "4A,4B"
},
"instructions": {
"de": "Leicht links weiter auf Way Name",
"en": "Continue slightly left onto Way Name",
"es": "Continua ligeramente a la izquierda en Way Name",
"fr": "Continuer légèrement à gauche sur Way Name",
"id": "Tetap agak di kiri ke Way Name",
"nl": "Links aanhouden naar Way Name",
"ru": "Плавно поверните налево на Way Name",
"sv": "Fortsätt med lätt vänstersväng in på Way Name",
"vi": "Nghiêng về bên trái vào Way Name",
"zh-Hans": "继续向左,上Way Name"
}
}
23 changes: 23 additions & 0 deletions test/fixtures/v5/continue/slight_left_exit_destination.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "slight left"
},
"name": "Way Name",
"destinations": "Destination 1,Destination 2",
"exits": "4A,4B"
},
"instructions": {
"de": "Leicht links weiter Richtung Destination 1",
"en": "Continue slightly left towards Destination 1",
"es": "Continua ligeramente a la izquierda hacia Destination 1",
"fr": "Continuer légèrement à gauche en direction de Destination 1",
"id": "Tetap agak di kiri menuju Destination 1",
"nl": "Links aanhouden richting Destination 1",
"ru": "Плавно поверните налево в направлении Destination 1",
"sv": "Fortsätt med lätt vänstersväng mot Destination 1",
"vi": "Nghiêng về bên trái đến Destination 1",
"zh-Hans": "继续向左行驶,前往Destination 1"
}
}
22 changes: 22 additions & 0 deletions test/fixtures/v5/continue/slight_right_exit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "slight right"
},
"name": "Way Name",
"exits": "4A,4B"
},
"instructions": {
"de": "Leicht rechts weiter auf Way Name",
"en": "Continue slightly right onto Way Name",
"es": "Continua ligeramente a la derecha en Way Name",
"fr": "Continuer légèrement à droite sur Way Name",
"id": "Tetap agak di kanan ke Way Name",
"nl": "Rechts aanhouden naar Way Name",
"ru": "Плавно поверните направо на Way Name",
"sv": "Fortsätt med lätt högersväng in på Way Name",
"vi": "Nghiêng về bên phải vào Way Name",
"zh-Hans": "继续向右,上Way Name"
}
}
23 changes: 23 additions & 0 deletions test/fixtures/v5/continue/slight_right_exit_destination.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "slight right"
},
"name": "Way Name",
"destinations": "Destination 1,Destination 2",
"exits": "4A,4B"
},
"instructions": {
"de": "Leicht rechts weiter Richtung Destination 1",
"en": "Continue slightly right towards Destination 1",
"es": "Continua ligeramente a la derecha hacia Destination 1",
"fr": "Continuer légèrement à droite en direction de Destination 1",
"id": "Tetap agak di kanan menuju Destination 1",
"nl": "Rechts aanhouden richting Destination 1",
"ru": "Плавно поверните направо в направлении Destination 1",
"sv": "Fortsätt med lätt högersväng mot Destination 1",
"vi": "Nghiêng về bên phải đến Destination 1",
"zh-Hans": "继续向右行驶,前往Destination 1"
}
}
22 changes: 22 additions & 0 deletions test/fixtures/v5/continue/straight_exit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "straight"
},
"name": "Way Name",
"exits": "4A,4B"
},
"instructions": {
"de": "Geradeaus weiterfahren auf Way Name",
"en": "Continue onto Way Name",
"es": "Continua en Way Name",
"fr": "Continuer tout droit sur Way Name",
"id": "Terus ke Way Name",
"nl": "Ga rechtdoor naar Way Name",
"ru": "Продолжите движение по Way Name",
"sv": "Fortsätt in på Way Name",
"vi": "Chạy tiếp trên Way Name",
"zh-Hans": "继续直行,上Way Name"
}
}
Loading