@wemap/routers 11.0.0-alpha.19 → 11.0.0-alpha.20
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/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/model/Itinerary.ts +2 -2
- package/src/model/Leg.ts +2 -2
- package/src/model/Step.ts +10 -10
package/dist/index.js
CHANGED
|
@@ -96,11 +96,11 @@ function stepToJson(step) {
|
|
|
96
96
|
number: step.number,
|
|
97
97
|
coords: step.coords.toCompressedJson(),
|
|
98
98
|
...step.name !== null && { name: step.name },
|
|
99
|
-
angle: step.angle,
|
|
100
|
-
previousBearing: step.previousBearing,
|
|
101
|
-
nextBearing: step.nextBearing,
|
|
102
|
-
distance: step.distance,
|
|
103
|
-
duration: step.duration,
|
|
99
|
+
angle: Number(step.angle.toFixed(2)),
|
|
100
|
+
previousBearing: Number(step.previousBearing.toFixed(2)),
|
|
101
|
+
nextBearing: Number(step.nextBearing.toFixed(2)),
|
|
102
|
+
distance: Number(step.distance.toFixed(1)),
|
|
103
|
+
duration: Number(step.duration.toFixed(1)),
|
|
104
104
|
...step.levelChange !== null && { levelChange: step.levelChange },
|
|
105
105
|
...step.extras && Object.keys(step.extras).length !== 0 && { extras: step.extras }
|
|
106
106
|
};
|
|
@@ -117,7 +117,7 @@ function jsonToStep(json) {
|
|
|
117
117
|
}
|
|
118
118
|
function stepEquals(step1, step2) {
|
|
119
119
|
var _a, _b, _c, _d, _e, _f;
|
|
120
|
-
return step1.coords.equals(step2.coords) && step1.angle
|
|
120
|
+
return step1.coords.equals(step2.coords) && Math.abs(step1.angle - step2.angle) <= 5e-3 && Math.abs(step1.distance - step2.distance) <= 0.05 && Math.abs(step1.duration - step2.duration) <= 0.05 && step1.firstStep === step2.firstStep && step1.lastStep === step2.lastStep && ((_a = step1.levelChange) == null ? void 0 : _a.difference) === ((_b = step2.levelChange) == null ? void 0 : _b.difference) && ((_c = step1.levelChange) == null ? void 0 : _c.direction) === ((_d = step2.levelChange) == null ? void 0 : _d.direction) && ((_e = step1.levelChange) == null ? void 0 : _e.type) === ((_f = step2.levelChange) == null ? void 0 : _f.type) && step1.name === step2.name && Math.abs(step1.nextBearing - step2.nextBearing) <= 5e-3 && step1.number === step2.number && Math.abs(step1.previousBearing - step2.previousBearing) <= 5e-3;
|
|
121
121
|
}
|
|
122
122
|
class Leg {
|
|
123
123
|
constructor({
|
|
@@ -171,7 +171,7 @@ class Leg {
|
|
|
171
171
|
}
|
|
172
172
|
static equals(obj1, obj2) {
|
|
173
173
|
var _a, _b;
|
|
174
|
-
const intermediate = obj1.mode === obj2.mode && obj1.duration
|
|
174
|
+
const intermediate = obj1.mode === obj2.mode && Math.abs(obj1.duration - obj2.duration) <= 0.05 && obj1.startTime === obj2.startTime && obj1.endTime === obj2.endTime && obj1.from.name === obj2.from.name && obj1.from.coords.equals(obj2.from.coords) && obj1.to.name === obj2.to.name && obj1.to.coords.equals(obj2.to.coords) && obj1.coords.length === obj2.coords.length && (obj1.steps === obj2.steps || ((_a = obj1.steps) == null ? void 0 : _a.length) === ((_b = obj2.steps) == null ? void 0 : _b.length));
|
|
175
175
|
if (!intermediate) {
|
|
176
176
|
return false;
|
|
177
177
|
}
|
|
@@ -210,7 +210,7 @@ class Leg {
|
|
|
210
210
|
coords: this.to.coords.toCompressedJson(),
|
|
211
211
|
...this.to.name && { name: this.to.name }
|
|
212
212
|
},
|
|
213
|
-
duration: this.duration,
|
|
213
|
+
duration: Number(this.duration.toFixed(1)),
|
|
214
214
|
coords: this.coords.map((coords) => coords.toCompressedJson()),
|
|
215
215
|
steps: this.steps.map(stepToJson),
|
|
216
216
|
...this.startTime !== null && { startTime: this.startTime },
|
|
@@ -401,7 +401,7 @@ class Itinerary {
|
|
|
401
401
|
return new Itinerary({ from, to, legs: [leg] });
|
|
402
402
|
}
|
|
403
403
|
static equals(obj1, obj2) {
|
|
404
|
-
const intermediate = obj1.from.equals(obj2.from) && obj1.to.equals(obj2.to) && obj1.distance
|
|
404
|
+
const intermediate = obj1.from.equals(obj2.from) && obj1.to.equals(obj2.to) && Math.abs(obj1.distance - obj2.distance) <= 0.05 && Math.abs(obj1.duration - obj2.duration) <= 0.05 && obj1.startTime === obj2.startTime && obj1.endTime === obj2.endTime && obj1.legs.length === obj2.legs.length;
|
|
405
405
|
if (!intermediate) {
|
|
406
406
|
return false;
|
|
407
407
|
}
|