@digitransit-search-util/digitransit-search-util-is-duplicate 1.0.0 → 2.1.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 +19 -8
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -24,6 +24,18 @@ import truEq from '@digitransit-search-util/digitransit-search-util-tru-eq';
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
const gtfsStopLayers = ['stop', 'station', 'favouriteStop', 'favouriteStation'];
|
|
27
|
+
const vehicleRentalLayers = ['favouriteVehicleRentalStation', 'bikestation'];
|
|
28
|
+
|
|
29
|
+
function labelIdToGid(id) {
|
|
30
|
+
if (!id) {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
const parts = id.split(':');
|
|
34
|
+
if (parts.length === 0) {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
return `citybikes${parts[0]}:bikestation:${parts[1]}`;
|
|
38
|
+
}
|
|
27
39
|
|
|
28
40
|
export default function isDuplicate(item1, item2) {
|
|
29
41
|
const props1 = item1.properties;
|
|
@@ -35,8 +47,8 @@ export default function isDuplicate(item1, item2) {
|
|
|
35
47
|
const o2 = props2.origin;
|
|
36
48
|
const d2 = props2.destination;
|
|
37
49
|
|
|
38
|
-
const name1 = `${o1.name}//${o1.
|
|
39
|
-
const name2 = `${o2.name}//${o2.
|
|
50
|
+
const name1 = `${o1.name}//${o1.localadmin}//${d1.name}//${d1.localadmin}`;
|
|
51
|
+
const name2 = `${o2.name}//${o2.localadmin}//${d2.name}//${d2.localadmin}`;
|
|
40
52
|
|
|
41
53
|
return name1 === name2;
|
|
42
54
|
}
|
|
@@ -44,13 +56,12 @@ export default function isDuplicate(item1, item2) {
|
|
|
44
56
|
return false;
|
|
45
57
|
}
|
|
46
58
|
if (
|
|
47
|
-
(
|
|
48
|
-
|
|
49
|
-
(props2.layer === 'bikeRentalStation' ||
|
|
50
|
-
props2.layer === 'favouriteBikeRentalStation')) ||
|
|
51
|
-
(props1.layer === 'bikestation' && props2.layer === 'bikestation')
|
|
59
|
+
vehicleRentalLayers.includes(props1.layer) &&
|
|
60
|
+
vehicleRentalLayers.includes(props2.layer)
|
|
52
61
|
) {
|
|
53
|
-
|
|
62
|
+
const id1 = props1.gid || labelIdToGid(props1.labelId);
|
|
63
|
+
const id2 = props2.gid || labelIdToGid(props2.labelId);
|
|
64
|
+
return id1 === id2;
|
|
54
65
|
}
|
|
55
66
|
if (props1.gtfsId && props2.gtfsId) {
|
|
56
67
|
return props1.gtfsId === props2.gtfsId;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitransit-search-util/digitransit-search-util-is-duplicate",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "digitransit-search-util is-duplicate module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@digitransit-search-util/digitransit-search-util-tru-eq": "0.0.2"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "37479033b6cc5d8fa3b2b17a46e79c2080ea3b96"
|
|
27
27
|
}
|