Skip to content

Commit 53c52c1

Browse files
authored
Simplify use lane (#70)
- use lane always has the straight modifier and indication, so use these only - automatically-generate fixtures
1 parent 596564a commit 53c52c1

40 files changed

+574
-517
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. For change
77
- Run tests per language via LANGUAGE=de npm test
88
- Shorter merge instructions (Merge slightly left -> Merge left)
99
- Numeric ordinals (1st, 2nd) instead of word ordinals (first, second)
10+
- use lane only has straight as modifier, so simplify instructions.json and tests
1011

1112
# 0.0.5 2016-10-26
1213

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ module.exports = function(version, language) {
9696
laneInstruction = this.instructions[version].constants.lanes[this.laneConfig(step)];
9797

9898
if (!laneInstruction) {
99-
// If the lane combination is not found, default to continue
99+
// If the lane combination is not found, default to continue straight
100100
instructionObject = this.instructions[version]['use lane'].no_lanes;
101101
}
102102
break;

instructions/de.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -390,19 +390,7 @@
390390
"default": "Geradeaus weiterfahren"
391391
},
392392
"default": {
393-
"default": "{lane_instruction} um {modifier} abzubiegen"
394-
},
395-
"straight": {
396393
"default": "{lane_instruction}"
397-
},
398-
"left": {
399-
"default": "{lane_instruction} um links abzubiegen"
400-
},
401-
"right": {
402-
"default": "{lane_instruction} um rechts abzubiegen"
403-
},
404-
"uturn": {
405-
"default": "{lane_instruction} für eine 180°-Wendung"
406394
}
407395
}
408396
}

instructions/en.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -390,16 +390,7 @@
390390
"default": "Continue straight"
391391
},
392392
"default": {
393-
"default": "{lane_instruction} to make a {modifier}"
394-
},
395-
"straight": {
396393
"default": "{lane_instruction}"
397-
},
398-
"left": {
399-
"default": "{lane_instruction} to turn left"
400-
},
401-
"right": {
402-
"default": "{lane_instruction} to turn right"
403394
}
404395
}
405396
}

scripts/generate_fixtures.js

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function writeVariations(baseStep, basePath) {
5151
};
5252

5353
function execute() {
54-
var basePath = path.join(__dirname, '..', 'test', 'fixtures', 'v5', type);
54+
var basePath = path.join(__dirname, '..', 'test', 'fixtures', 'v5', underscorify(type));
5555

5656
switch (type) {
5757
case 'modes':
@@ -237,14 +237,77 @@ function execute() {
237237
basePath = path.join(__dirname, '..', 'test', 'fixtures', 'v5', 'roundabout', 'exit');
238238
baseStep = {
239239
maneuver: {
240-
modifier: 'left', // roundaboouts don't care about modifiers
240+
modifier: 'left', // roundabouts don't care about modifiers
241241
type: 'roundabout',
242242
exit: 1
243243
},
244244
name: '',
245245
};
246246
writeVariations(baseStep, basePath);
247247
break;
248+
case 'use lane':
249+
function lanesFromConfig(config) {
250+
var lanes = [];
251+
config.split('').forEach((c) => {
252+
switch (c) {
253+
case 'x':
254+
lanes.push({
255+
indications: ["straight"],
256+
valid: false
257+
});
258+
break;
259+
case 'o':
260+
lanes.push({
261+
indications: ["straight"],
262+
valid: true
263+
});
264+
break;
265+
default:
266+
throw 'Invalid config ' + c
267+
}
268+
});
269+
return lanes;
270+
}
271+
function writeLaneConfig(config) {
272+
var step = Object.assign(clone(baseStep));
273+
step.intersections[0].lanes = lanesFromConfig(config);
274+
write(step, `${basePath}/${config}`);
275+
}
276+
277+
var baseStep = {
278+
maneuver: {
279+
modifier: 'straight',
280+
type: 'use lane'
281+
},
282+
intersections: [
283+
{
284+
location: [ 13.39677,52.54366 ],
285+
in: 1,
286+
out: 2,
287+
bearings: [ 10, 20 ],
288+
entry: [ true, false ]
289+
}
290+
],
291+
name: '',
292+
};
293+
294+
// lane combinations
295+
[
296+
'o',
297+
'ooo',
298+
'oox',
299+
'xoo',
300+
'xox',
301+
'oxo',
302+
'xxoo',
303+
'ooxx',
304+
'xxoxo',
305+
'xxooxx',
306+
'oooxxo'
307+
].forEach((c) => {
308+
writeLaneConfig(c);
309+
});
310+
break;
248311
default:
249312
console.error('Need to provide a type as first argument. Supported values:' + types.join(' ,'));
250313
process.exit(1);

test/fixtures/v5/use_lane/all_lanes.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

test/fixtures/v5/use_lane/all_lanes_no_name.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

test/fixtures/v5/use_lane/left.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

test/fixtures/v5/use_lane/left_lane.json

Lines changed: 0 additions & 34 deletions
This file was deleted.

test/fixtures/v5/use_lane/left_lane_no_name.json

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)