@golemio/pid 2.8.9-dev.977094505 → 2.8.9-dev.981491619
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.
|
@@ -40,15 +40,32 @@ let MetroShapePointsFixer = exports.MetroShapePointsFixer = class MetroShapePoin
|
|
|
40
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
41
|
try {
|
|
42
42
|
const clonedData = structuredClone(data);
|
|
43
|
-
clonedData.shapes_anchor_points =
|
|
43
|
+
clonedData.shapes_anchor_points = clonedData.shapes_anchor_points.map((shape) => {
|
|
44
44
|
return Object.assign(Object.assign({}, shape), { at_stop: false, this_stop_sequence: null });
|
|
45
45
|
});
|
|
46
46
|
// load metro obvody
|
|
47
47
|
const metroRailtrackLookup = yield this.cachedMetroRailTrackLookup.getAllByRouteName(MetroRouteHelper_1.MetroRouteHelper.getRouteName(data.trip_id));
|
|
48
|
-
|
|
48
|
+
let lastKnownStopSequence = null;
|
|
49
|
+
const maxStopSequence = clonedData.stop_times.length;
|
|
50
|
+
for (let index = 0; index < clonedData.shapes_anchor_points.length; index++) {
|
|
51
|
+
const shape = clonedData.shapes_anchor_points[index];
|
|
49
52
|
const closestMetroRailtrack = this.getClosestMetroRailtrack(shape, metroRailtrackLookup);
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
const thisStopSequence = this.getSequenceByStopId(closestMetroRailtrack.gtfs_stop_id, clonedData.stop_times);
|
|
54
|
+
if (thisStopSequence) {
|
|
55
|
+
lastKnownStopSequence = thisStopSequence;
|
|
56
|
+
}
|
|
57
|
+
shape.at_stop = closestMetroRailtrack.gtfs_stop_id ? true : false;
|
|
58
|
+
shape.this_stop_sequence = thisStopSequence;
|
|
59
|
+
shape.next_stop_sequence = lastKnownStopSequence ? Math.min(lastKnownStopSequence + 1, maxStopSequence) : 2;
|
|
60
|
+
shape.last_stop_sequence = lastKnownStopSequence && lastKnownStopSequence > 1 ? lastKnownStopSequence - 1 : 1;
|
|
61
|
+
if (shape.at_stop) {
|
|
62
|
+
shape.last_stop_sequence = shape.this_stop_sequence;
|
|
63
|
+
if (!shape.this_stop_sequence) {
|
|
64
|
+
console.log(`Unable to find stop sequence for stop ${closestMetroRailtrack.gtfs_stop_id}`);
|
|
65
|
+
console.log(closestMetroRailtrack);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
52
69
|
return clonedData;
|
|
53
70
|
}
|
|
54
71
|
catch (err) {
|
|
@@ -57,16 +74,32 @@ let MetroShapePointsFixer = exports.MetroShapePointsFixer = class MetroShapePoin
|
|
|
57
74
|
});
|
|
58
75
|
}
|
|
59
76
|
getSequenceByStopId(gtfs_stop_id, stop_times) {
|
|
60
|
-
var _a;
|
|
61
|
-
|
|
77
|
+
var _a, _b, _c;
|
|
78
|
+
const regex = /U(?<node>.*)Z/;
|
|
79
|
+
const node = (_b = (_a = regex.exec(gtfs_stop_id || "")) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.node;
|
|
80
|
+
if (node && node.length > 0) {
|
|
81
|
+
return ((_c = stop_times.find((stop_time) => { var _a, _b; return ((_b = (_a = regex.exec(stop_time.stop_id)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.node) === node; })) === null || _c === void 0 ? void 0 : _c.stop_sequence) || null;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
62
86
|
}
|
|
63
87
|
getClosestMetroRailtrack(shape, metroRailtrackLookup) {
|
|
64
88
|
// find closest metroRailtrack for shape.coordinates
|
|
65
|
-
|
|
89
|
+
const result = metroRailtrackLookup
|
|
66
90
|
.map((metroRailtrack) => {
|
|
67
91
|
return Object.assign(Object.assign({}, metroRailtrack), { distance: this.ruler.distance(shape.coordinates, metroRailtrack.coordinates.coordinates) });
|
|
68
92
|
})
|
|
69
|
-
.sort((a, b) => a.distance - b.distance)
|
|
93
|
+
.sort((a, b) => a.distance - b.distance);
|
|
94
|
+
if (result[0].gtfs_stop_id) {
|
|
95
|
+
return result[0];
|
|
96
|
+
}
|
|
97
|
+
else if (result[1].gtfs_stop_id) {
|
|
98
|
+
return result[1];
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return result[0];
|
|
102
|
+
}
|
|
70
103
|
}
|
|
71
104
|
};
|
|
72
105
|
exports.MetroShapePointsFixer = MetroShapePointsFixer = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetroShapePointsFixer.js","sourceRoot":"","sources":["../../../../../../../src/integration-engine/vehicle-positions/workers/vehicle-positions/helpers/metro/MetroShapePointsFixer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uEAA8E;AAC9E,6EAA+F;AAE/F,iEAAwE;AACxE,8DAAqC;AACrC,mGAAgG;AAEhG,6EAAwE;AAGjE,IAAM,qBAAqB,mCAA3B,MAAM,qBAAqB;IAG9B,YACiE,0BAAsD;QAAtD,+BAA0B,GAA1B,0BAA0B,CAA4B;QAEnH,IAAI,CAAC,KAAK,GAAG,IAAA,qBAAU,EAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAEY,GAAG,CAAC,IAAsB;;YACnC,IAAI;gBACA,MAAM,UAAU,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;gBACzC,UAAU,CAAC,oBAAoB,GAAG,
|
|
1
|
+
{"version":3,"file":"MetroShapePointsFixer.js","sourceRoot":"","sources":["../../../../../../../src/integration-engine/vehicle-positions/workers/vehicle-positions/helpers/metro/MetroShapePointsFixer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uEAA8E;AAC9E,6EAA+F;AAE/F,iEAAwE;AACxE,8DAAqC;AACrC,mGAAgG;AAEhG,6EAAwE;AAGjE,IAAM,qBAAqB,mCAA3B,MAAM,qBAAqB;IAG9B,YACiE,0BAAsD;QAAtD,+BAA0B,GAA1B,0BAA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