@digitransit-search-util/digitransit-search-util-execute-search-immidiate 2.0.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +50 -61
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -167,9 +167,12 @@ function getBackSuggestion() {
|
|
|
167
167
|
]);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
function filterFavouriteStops(stopsAndStations, input) {
|
|
171
|
-
return stopsAndStations.then(
|
|
172
|
-
|
|
170
|
+
function filterFavouriteStops(stopsAndStations, input, useStops, useStations) {
|
|
171
|
+
return stopsAndStations.then(stopsStations => {
|
|
172
|
+
const candidates = stopsStations.filter(s =>
|
|
173
|
+
s.type === 'stop' ? useStops : useStations,
|
|
174
|
+
);
|
|
175
|
+
return filterMatchingToInput(candidates, input, [
|
|
173
176
|
'properties.name',
|
|
174
177
|
'properties.name',
|
|
175
178
|
'properties.address',
|
|
@@ -229,9 +232,12 @@ const routeLayers = [
|
|
|
229
232
|
'route-FERRY',
|
|
230
233
|
'route-SUBWAY',
|
|
231
234
|
'route-AIRPLANE',
|
|
235
|
+
'route-FUNICULAR',
|
|
232
236
|
];
|
|
233
|
-
const locationLayers = ['
|
|
237
|
+
const locationLayers = ['venue', 'address', 'street'];
|
|
234
238
|
const parkingLayers = ['carpark', 'bikepark'];
|
|
239
|
+
const stopLayers = ['stop', 'station'];
|
|
240
|
+
|
|
235
241
|
/**
|
|
236
242
|
* Executes the search
|
|
237
243
|
*
|
|
@@ -323,7 +329,7 @@ export function getSearchResults(
|
|
|
323
329
|
}
|
|
324
330
|
|
|
325
331
|
if (allSources || sources.includes('Datasource')) {
|
|
326
|
-
const geocodingLayers = ['
|
|
332
|
+
const geocodingLayers = ['venue', 'address', 'street'];
|
|
327
333
|
const feedis = feedIDs.map(v => `gtfs${v}`);
|
|
328
334
|
const geosources = geocodingSources.concat(feedis).join(',');
|
|
329
335
|
searchComponents.push(
|
|
@@ -341,18 +347,10 @@ export function getSearchResults(
|
|
|
341
347
|
}
|
|
342
348
|
if (allSources || sources.includes('History')) {
|
|
343
349
|
const locationHistory = getOldSearches(context, 'endpoint');
|
|
344
|
-
const dropLayers = [
|
|
345
|
-
|
|
346
|
-
'selectFromMap',
|
|
347
|
-
'futureRoute',
|
|
348
|
-
'ownLocations',
|
|
349
|
-
'vehicleRentalStation',
|
|
350
|
-
'bikepark',
|
|
351
|
-
'carpark',
|
|
352
|
-
'stop',
|
|
353
|
-
'back',
|
|
354
|
-
];
|
|
350
|
+
const dropLayers = ['bikestation'];
|
|
351
|
+
dropLayers.push(...stopLayers);
|
|
355
352
|
dropLayers.push(...routeLayers);
|
|
353
|
+
dropLayers.push(...parkingLayers);
|
|
356
354
|
searchComponents.push(
|
|
357
355
|
filterOldSearches(locationHistory, input, dropLayers),
|
|
358
356
|
);
|
|
@@ -386,25 +384,18 @@ export function getSearchResults(
|
|
|
386
384
|
}
|
|
387
385
|
if (allSources || sources.includes('History')) {
|
|
388
386
|
const history = getOldSearches(context);
|
|
389
|
-
const dropLayers = [
|
|
390
|
-
|
|
391
|
-
'selectFromMap',
|
|
392
|
-
'futureRoute',
|
|
393
|
-
'ownLocations',
|
|
394
|
-
'favouritePlace',
|
|
395
|
-
'bikestation',
|
|
396
|
-
'vehicleRentalStation',
|
|
397
|
-
'back',
|
|
398
|
-
'stop',
|
|
399
|
-
'station',
|
|
400
|
-
];
|
|
387
|
+
const dropLayers = ['bikestation'];
|
|
388
|
+
dropLayers.push(...stopLayers);
|
|
401
389
|
dropLayers.push(...routeLayers);
|
|
402
390
|
dropLayers.push(...locationLayers);
|
|
403
391
|
searchComponents.push(filterOldSearches(history, input, dropLayers));
|
|
404
392
|
}
|
|
405
393
|
}
|
|
406
394
|
|
|
407
|
-
|
|
395
|
+
const useStops = targets.includes('Stops');
|
|
396
|
+
const useStations = targets.includes('Stations');
|
|
397
|
+
|
|
398
|
+
if (allTargets || useStops || useStations) {
|
|
408
399
|
if (sources.includes('Favourite')) {
|
|
409
400
|
const favouriteStops = getFavouriteStops(context);
|
|
410
401
|
let stopsAndStations;
|
|
@@ -430,10 +421,18 @@ export function getSearchResults(
|
|
|
430
421
|
return results;
|
|
431
422
|
});
|
|
432
423
|
}
|
|
433
|
-
searchComponents.push(
|
|
424
|
+
searchComponents.push(
|
|
425
|
+
filterFavouriteStops(stopsAndStations, input, useStops, useStations),
|
|
426
|
+
);
|
|
434
427
|
}
|
|
435
428
|
if (allSources || sources.includes('Datasource')) {
|
|
436
|
-
const geocodingLayers = [
|
|
429
|
+
const geocodingLayers = [];
|
|
430
|
+
if (useStops) {
|
|
431
|
+
geocodingLayers.push('stop');
|
|
432
|
+
}
|
|
433
|
+
if (useStations) {
|
|
434
|
+
geocodingLayers.push('station');
|
|
435
|
+
}
|
|
437
436
|
const searchParams =
|
|
438
437
|
geocodingSize && geocodingSize !== 10 ? { size: geocodingSize } : {};
|
|
439
438
|
if (geocodingSearchParams && geocodingSearchParams['boundary.country']) {
|
|
@@ -471,23 +470,17 @@ export function getSearchResults(
|
|
|
471
470
|
}
|
|
472
471
|
return true;
|
|
473
472
|
});
|
|
474
|
-
const dropLayers = [
|
|
475
|
-
'currentPosition',
|
|
476
|
-
'selectFromMap',
|
|
477
|
-
'futureRoute',
|
|
478
|
-
'ownLocations',
|
|
479
|
-
'favouritePlace',
|
|
480
|
-
'vehicleRentalStation',
|
|
481
|
-
'back',
|
|
482
|
-
];
|
|
473
|
+
const dropLayers = ['bikestation'];
|
|
483
474
|
dropLayers.push(...routeLayers);
|
|
484
475
|
dropLayers.push(...locationLayers);
|
|
485
476
|
dropLayers.push(...parkingLayers);
|
|
477
|
+
if (!useStops) {
|
|
478
|
+
dropLayers.push('stop');
|
|
479
|
+
}
|
|
480
|
+
if (!useStations) {
|
|
481
|
+
dropLayers.push('station');
|
|
482
|
+
}
|
|
486
483
|
if (transportMode) {
|
|
487
|
-
if (transportMode !== 'route-CITYBIKE') {
|
|
488
|
-
dropLayers.push('vehicleRentalStation');
|
|
489
|
-
dropLayers.push('bikestation');
|
|
490
|
-
}
|
|
491
484
|
searchComponents.push(
|
|
492
485
|
filterOldSearches(stopHistory, input, dropLayers).then(result =>
|
|
493
486
|
filterResults ? filterResults(result, mode) : result,
|
|
@@ -500,7 +493,6 @@ export function getSearchResults(
|
|
|
500
493
|
}
|
|
501
494
|
}
|
|
502
495
|
}
|
|
503
|
-
|
|
504
496
|
if (allTargets || targets.includes('Routes')) {
|
|
505
497
|
if (sources.includes('Favourite')) {
|
|
506
498
|
const favouriteRoutes = getFavouriteRoutes(context);
|
|
@@ -518,26 +510,14 @@ export function getSearchResults(
|
|
|
518
510
|
);
|
|
519
511
|
if (allSources || sources.includes('History')) {
|
|
520
512
|
const routeHistory = getOldSearches(context);
|
|
521
|
-
const dropLayers = [
|
|
522
|
-
'currentPosition',
|
|
523
|
-
'selectFromMap',
|
|
524
|
-
'futureRoute',
|
|
525
|
-
'favouritePlace',
|
|
526
|
-
'stop',
|
|
527
|
-
'station',
|
|
528
|
-
'bikepark',
|
|
529
|
-
'carpark',
|
|
530
|
-
'ownLocations',
|
|
531
|
-
'back',
|
|
532
|
-
];
|
|
513
|
+
const dropLayers = ['bikestation'];
|
|
533
514
|
if (transportMode) {
|
|
534
|
-
if (transportMode !== 'route-CITYBIKE') {
|
|
535
|
-
dropLayers.push('vehicleRentalStation');
|
|
536
|
-
dropLayers.push('bikestation');
|
|
537
|
-
}
|
|
538
515
|
dropLayers.push(...routeLayers.filter(i => !(i === transportMode)));
|
|
539
516
|
}
|
|
517
|
+
dropLayers.push(...stopLayers);
|
|
540
518
|
dropLayers.push(...locationLayers);
|
|
519
|
+
dropLayers.push(...parkingLayers);
|
|
520
|
+
|
|
541
521
|
searchComponents.push(
|
|
542
522
|
filterOldSearches(routeHistory, input, dropLayers).then(results =>
|
|
543
523
|
filterResults ? filterResults(results, mode, 'Routes') : results,
|
|
@@ -578,6 +558,15 @@ export function getSearchResults(
|
|
|
578
558
|
}),
|
|
579
559
|
);
|
|
580
560
|
}
|
|
561
|
+
if (allSources || sources.includes('History')) {
|
|
562
|
+
const history = getOldSearches(context);
|
|
563
|
+
const dropLayers = [...stopLayers];
|
|
564
|
+
dropLayers.push(...routeLayers);
|
|
565
|
+
dropLayers.push(...locationLayers);
|
|
566
|
+
dropLayers.push(...parkingLayers);
|
|
567
|
+
|
|
568
|
+
searchComponents.push(filterOldSearches(history, input, dropLayers));
|
|
569
|
+
}
|
|
581
570
|
}
|
|
582
571
|
|
|
583
572
|
const searchResultsPromise = Promise.all(searchComponents)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitransit-search-util/digitransit-search-util-execute-search-immidiate",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "digitransit-search-util execute-search-immidiate module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"@digitransit-search-util/digitransit-search-util-helpers": "2.0.0",
|
|
28
28
|
"lodash": "4.17.21"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "f4f89d869a32e89ee2212589c8f1f286d20f34e4"
|
|
31
31
|
}
|