Skip to content

Commit a5157e6

Browse files
save
1 parent 71d919b commit a5157e6

File tree

6 files changed

+26
-107
lines changed

6 files changed

+26
-107
lines changed

features/car/startpoint.feature

Lines changed: 1 addition & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,6 @@ Feature: Car - Allowed start/end modes
44
Background:
55
Given the profile "car"
66

7-
Scenario: Car - Don't start/stop on ferries
8-
Given the node map
9-
"""
10-
a 1 b 2 c
11-
"""
12-
13-
And the ways
14-
| nodes | highway | route | bicycle |
15-
| ab | primary | | |
16-
| bc | | ferry | yes |
17-
18-
When I route I should get
19-
| from | to | route | modes |
20-
| 1 | 2 | ab,ab | driving,driving |
21-
| 2 | 1 | ab,ab | driving,driving |
22-
23-
Scenario: Car - Don't start/stop on trains
24-
Given the node map
25-
"""
26-
a 1 b 2 c
27-
"""
28-
29-
And the ways
30-
| nodes | highway | railway | bicycle |
31-
| ab | primary | | |
32-
| bc | | train | yes |
33-
34-
When I route I should get
35-
| from | to | route | modes |
36-
| 1 | 2 | ab,ab | driving,driving |
37-
| 2 | 1 | ab,ab | driving,driving |
38-
39-
Scenario: Car - URL override of non-startpoints
40-
Given the node map
41-
"""
42-
a 1 b c 2 d
43-
"""
44-
45-
Given the query options
46-
| snapping | any |
47-
48-
And the ways
49-
| nodes | highway | access |
50-
| ab | service | private |
51-
| bc | primary | |
52-
| cd | service | private |
53-
54-
When I request a travel time matrix I should get
55-
| | 2 | c |
56-
| 1 | 59.1 | 35.2 |
57-
| b | 35 | 11.1 |
58-
59-
When I route I should get
60-
| from | to | route |
61-
| 1 | 2 | ab,bc,cd |
62-
| 2 | 1 | cd,bc,ab |
63-
647
Scenario: Car - URL override of non-startpoints
658
Given the node map
669
"""
@@ -82,44 +25,4 @@ Feature: Car - Allowed start/end modes
8225
| 1 | 2 | ab,bc,cd |
8326
| 2 | 1 | cd,bc,ab |
8427

85-
Scenario: Car - URL override of non-startpoints
86-
Given the node map
87-
"""
88-
a 1 b c 2 d
89-
"""
90-
91-
Given the query options
92-
| snapping | any |
93-
| radiuses | 100;unlimited |
94-
95-
And the ways
96-
| nodes | highway | access |
97-
| ab | service | private |
98-
| bc | primary | |
99-
| cd | service | private |
100-
101-
When I route I should get
102-
| from | to | route |
103-
| 1 | 2 | ab,bc,cd |
104-
| 2 | 1 | cd,bc,ab |
105-
106-
Scenario: Car - URL override of non-startpoints
107-
Given the node map
108-
"""
109-
a 1 b c 2 d
110-
"""
111-
112-
Given the query options
113-
| snapping | any |
114-
| bearings | 90,180;0,180;; |
115-
116-
And the ways
117-
| nodes | highway | access |
118-
| ab | service | private |
119-
| bc | primary | |
120-
| cd | service | private |
121-
122-
When I request a travel time matrix I should get
123-
| | 2 | c |
124-
| 1 | 59.1 | 35.2 |
125-
| b | 35 | 11.1 |
28+

features/support/shared_steps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = function () {
3737
let destinations, exits, pronunciations, instructions, refs, bearings, turns, modes, times, classes,
3838
distances, summary, intersections, lanes, locations, annotation, weight_name, weights, approaches,
3939
driving_sides;
40-
40+
console.log(body);
4141
let json = JSON.parse(body);
4242

4343
got.code = json.code;

routed-js/ServiceHandler.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ class ServiceHandler {
5050
});
5151
}
5252
if (query.bearings) {
53-
options.bearings = query.bearings;
53+
options.bearings = query.bearings.map((bearingWithRange) => {
54+
if (bearingWithRange.length == 0) {
55+
return null;
56+
}
57+
return bearingWithRange;
58+
});
5459
}
5560
if (query.hints) {
5661
options.hints = query.hints;

routed-js/ServiceHandler.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ export abstract class ServiceHandler {
6767
}
6868

6969
if (query.bearings) {
70-
options.bearings = query.bearings;
70+
options.bearings = query.bearings.map((bearingWithRange: number[]) => {
71+
if (bearingWithRange.length == 0) {
72+
return null;
73+
}
74+
return bearingWithRange;
75+
});
7176
}
7277

7378
if (query.hints) {

routed-js/schema.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const queryStringJsonSchemaGeneral = {
3131
type: 'array',
3232
items: {
3333
type: 'array',
34-
// TODO: check [min;max] + numbers of elements should be exactly 2
34+
// TODO: check [min;max]
3535
items: {
3636
type: 'number'
3737
}
@@ -40,8 +40,9 @@ const queryStringJsonSchemaGeneral = {
4040
radiuses: {
4141
type: 'array',
4242
items: {
43+
type: ['number', 'string'],
4344
oneOf: [
44-
{ type: 'number', exclusiveMinimum: 0 },
45+
{ exclusiveMinimum: 0 },
4546
{ enum: ['unlimited'] }
4647
]
4748
}
@@ -267,8 +268,10 @@ function parseArray(listString, separator) {
267268
}
268269
function parseQueryString(queryString) {
269270
const parsed = querystring.parse(queryString, '&', '=', {
271+
// 0 means "infinity"
270272
maxKeys: 0
271273
});
274+
// TODO: copy-paste
272275
if ('timestamps' in parsed) {
273276
parsed['timestamps'] = parseArray(parsed['timestamps'], ';');
274277
}
@@ -291,7 +294,7 @@ function parseQueryString(queryString) {
291294
parsed['exclude'] = parseArray(parsed['exclude'], ',');
292295
}
293296
if ('bearings' in parsed) {
294-
parsed['bearings'] = parseArray(parsed['bearings'], ';').map(bearingWithRange => { parseArray(bearingWithRange, ','); });
297+
parsed['bearings'] = parseArray(parsed['bearings'], ';').map(bearingWithRange => parseArray(bearingWithRange, ',').filter(bearing => bearing !== ''));
295298
}
296299
if ('annotations' in parsed) {
297300
if (!['true', 'false'].includes(parsed['annotations'])) {

routed-js/schema.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const queryStringJsonSchemaGeneral = {
2727
type: 'array',
2828
items: {
2929
type: 'array',
30-
// TODO: check [min;max] + numbers of elements should be exactly 2
30+
// TODO: check [min;max]
3131
items: {
3232
type: 'number'
3333
}
@@ -36,8 +36,9 @@ const queryStringJsonSchemaGeneral = {
3636
radiuses: {
3737
type: 'array',
3838
items: {
39+
type: ['number', 'string'],
3940
oneOf: [
40-
{ type: 'number', exclusiveMinimum: 0 },
41+
{ exclusiveMinimum: 0 },
4142
{ enum: ['unlimited'] }
4243
]
4344
}
@@ -285,8 +286,10 @@ function parseArray(listString: string | string[], separator: string): string[]
285286

286287
export function parseQueryString(queryString: string): any {
287288
const parsed = querystring.parse(queryString, '&', '=', {
289+
// 0 means "infinity"
288290
maxKeys: 0
289291
});
292+
// TODO: copy-paste
290293
if ('timestamps' in parsed) {
291294
parsed['timestamps'] = parseArray(parsed['timestamps'], ';');
292295
}
@@ -309,7 +312,7 @@ export function parseQueryString(queryString: string): any {
309312
parsed['exclude'] = parseArray(parsed['exclude'], ',');
310313
}
311314
if ('bearings' in parsed) {
312-
parsed['bearings'] = parseArray(parsed['bearings'], ';').map(bearingWithRange => { parseArray(bearingWithRange, ',') });
315+
parsed['bearings'] = parseArray(parsed['bearings'], ';').map(bearingWithRange => parseArray(bearingWithRange, ',').filter(bearing => bearing !== ''));
313316
}
314317
if ('annotations' in parsed) {
315318
if (!['true', 'false'].includes(parsed['annotations'])) {

0 commit comments

Comments
 (0)