proximiio-js-library 1.11.0 → 1.11.2
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/assets/wayfinding.js +71 -62
- package/lib/assets/wayfinding.js +216 -2034
- package/lib/components/map/guidanceStepsGenerator.js +3 -1
- package/lib/components/map/main.d.ts +14 -13
- package/lib/components/map/main.js +33 -28
- package/lib/components/select/main.d.ts +2 -1
- package/lib/components/select/main.js +3 -3
- package/lib/controllers/auth.d.ts +4 -4
- package/lib/controllers/geo.js +9 -1
- package/lib/customSubject.d.ts +7 -0
- package/lib/customSubject.js +13 -0
- package/lib/index.d.ts +2 -2
- package/lib/proximiio.js +2 -2
- package/lib/proximiio.js.LICENSE.txt +0 -53
- package/package.json +20 -8
- package/assets/tbtnav.js +0 -3
- package/lib/assets/tbtnav.js +0 -12521
- package/lib/components/map/guidanceTextGenerator.d.ts +0 -8
- package/lib/components/map/guidanceTextGenerator.js +0 -22
package/assets/wayfinding.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { featureCollection as TurfFeatureCollection, point as TurfPoint, lineString as TurfLineString } from '@turf/helpers'
|
|
2
|
+
import * as TurfFlatten from '@turf/flatten';
|
|
3
|
+
import * as TurfPolygonToLine from '@turf/polygon-to-line';
|
|
4
|
+
import * as TurfBooleanContains from '@turf/boolean-contains';
|
|
5
|
+
import * as TurfDestination from '@turf/distance';
|
|
6
|
+
import * as TurfLineIntersect from '@turf/line-intersect';
|
|
7
|
+
import * as TurfBearing from '@turf/bearing';
|
|
8
|
+
import * as TurfMidpoint from '@turf/midpoint';
|
|
9
|
+
import * as TurfPointToLineDistance from '@turf/point-to-line-distance';
|
|
10
|
+
import * as TurfDistance from '@turf/distance';
|
|
11
|
+
import * as TurfNearestPointOnLine from '@turf/nearest-point-on-line';
|
|
2
12
|
|
|
3
13
|
export class Wayfinding {
|
|
4
14
|
configuration = {
|
|
@@ -69,7 +79,7 @@ export class Wayfinding {
|
|
|
69
79
|
let floorGeojsonMap = new Map();
|
|
70
80
|
for (let level = minLevel; level <= maxLevel; level++) {
|
|
71
81
|
let floorAreaFeature = routableAreaFeatureList.filter((feature) => feature.properties.level === level);
|
|
72
|
-
floorGeojsonMap.set(level,
|
|
82
|
+
floorGeojsonMap.set(level, TurfFeatureCollection(floorAreaFeature !== undefined ? floorAreaFeature : []));
|
|
73
83
|
}
|
|
74
84
|
this.floorList = floorGeojsonMap;
|
|
75
85
|
|
|
@@ -161,8 +171,7 @@ export class Wayfinding {
|
|
|
161
171
|
|
|
162
172
|
// Floor features == "walkable areas"
|
|
163
173
|
floor.features.forEach((walkableArea) => {
|
|
164
|
-
let wallLineStringList =
|
|
165
|
-
.flatten(turf.polygonToLine(walkableArea))
|
|
174
|
+
let wallLineStringList = TurfFlatten(TurfPolygonToLine(walkableArea))
|
|
166
175
|
.features.map((feature) => feature.geometry);
|
|
167
176
|
// Floor wall lines, we wish to split to individual walls
|
|
168
177
|
wallLineStringList.forEach((wallLineString) => {
|
|
@@ -173,7 +182,7 @@ export class Wayfinding {
|
|
|
173
182
|
for (let index = 0; index < wallLineString.coordinates.length - 1; index++) {
|
|
174
183
|
let point;
|
|
175
184
|
if (index === 0) {
|
|
176
|
-
firstPoint =
|
|
185
|
+
firstPoint = TurfPoint(wallLineString.coordinates[index]);
|
|
177
186
|
firstPoint.properties.level = level;
|
|
178
187
|
firstPoint.properties.neighbours = [];
|
|
179
188
|
firstPoint.properties.walkableAreaId = walkableArea.id;
|
|
@@ -184,7 +193,7 @@ export class Wayfinding {
|
|
|
184
193
|
if (index === wallLineString.coordinates.length - 2) {
|
|
185
194
|
nextPoint = firstPoint;
|
|
186
195
|
} else {
|
|
187
|
-
nextPoint =
|
|
196
|
+
nextPoint = TurfPoint(wallLineString.coordinates[index + 1]);
|
|
188
197
|
nextPoint.properties.level = level;
|
|
189
198
|
nextPoint.properties.neighbours = [];
|
|
190
199
|
nextPoint.properties.walkableAreaId = walkableArea.id;
|
|
@@ -195,7 +204,7 @@ export class Wayfinding {
|
|
|
195
204
|
floorWalls.push([point, nextPoint]);
|
|
196
205
|
}
|
|
197
206
|
});
|
|
198
|
-
floorAreas = floorAreas.concat(
|
|
207
|
+
floorAreas = floorAreas.concat(TurfFlatten(walkableArea).features);
|
|
199
208
|
});
|
|
200
209
|
|
|
201
210
|
floorData.set(level, {
|
|
@@ -203,7 +212,7 @@ export class Wayfinding {
|
|
|
203
212
|
points: floorPoints,
|
|
204
213
|
walls: floorWalls,
|
|
205
214
|
wallFeatures: floorWalls.map((wall) =>
|
|
206
|
-
|
|
215
|
+
TurfLineString([wall[0].geometry.coordinates, wall[1].geometry.coordinates]),
|
|
207
216
|
),
|
|
208
217
|
});
|
|
209
218
|
});
|
|
@@ -215,30 +224,30 @@ export class Wayfinding {
|
|
|
215
224
|
// List of physical POIs on this level that are within area
|
|
216
225
|
let inAreaPoiList = this.accessibilityPoi
|
|
217
226
|
.filter((poi) => floorLevel === poi.properties.level)
|
|
218
|
-
.filter((poi) => floorData.areas.filter((area) =>
|
|
227
|
+
.filter((poi) => floorData.areas.filter((area) => TurfBooleanContains(area, poi)).length > 0);
|
|
219
228
|
|
|
220
229
|
inAreaPoiList.forEach((poi) => {
|
|
221
230
|
// Generate points around POI to allow going around, but only if they are "within area
|
|
222
231
|
let detourPointList = [
|
|
223
|
-
|
|
232
|
+
TurfDestination(poi.geometry.coordinates, poi.properties.radius + this.wallOffsetDistance, 0, {
|
|
224
233
|
units: this.UNIT_TYPE,
|
|
225
234
|
}),
|
|
226
|
-
|
|
235
|
+
TurfDestination(poi.geometry.coordinates, poi.properties.radius + this.wallOffsetDistance, 60, {
|
|
227
236
|
units: this.UNIT_TYPE,
|
|
228
237
|
}),
|
|
229
|
-
|
|
238
|
+
TurfDestination(poi.geometry.coordinates, poi.properties.radius + this.wallOffsetDistance, 120, {
|
|
230
239
|
units: this.UNIT_TYPE,
|
|
231
240
|
}),
|
|
232
|
-
|
|
241
|
+
TurfDestination(poi.geometry.coordinates, poi.properties.radius + this.wallOffsetDistance, 180, {
|
|
233
242
|
units: this.UNIT_TYPE,
|
|
234
243
|
}),
|
|
235
|
-
|
|
244
|
+
TurfDestination(poi.geometry.coordinates, poi.properties.radius + this.wallOffsetDistance, -120, {
|
|
236
245
|
units: this.UNIT_TYPE,
|
|
237
246
|
}),
|
|
238
|
-
|
|
247
|
+
TurfDestination(poi.geometry.coordinates, poi.properties.radius + this.wallOffsetDistance, -60, {
|
|
239
248
|
units: this.UNIT_TYPE,
|
|
240
249
|
}),
|
|
241
|
-
].filter((poi) => floorData.areas.filter((area) =>
|
|
250
|
+
].filter((poi) => floorData.areas.filter((area) => TurfBooleanContains(area, poi)).length > 0);
|
|
242
251
|
detourPointList.forEach((point) => {
|
|
243
252
|
point.properties.level = floorLevel;
|
|
244
253
|
point.properties.isDetourPoint = true;
|
|
@@ -259,11 +268,11 @@ export class Wayfinding {
|
|
|
259
268
|
if (lastPoint != null) {
|
|
260
269
|
pointA = lastPoint;
|
|
261
270
|
} else {
|
|
262
|
-
pointA =
|
|
271
|
+
pointA = TurfPoint(coordinateList[i]);
|
|
263
272
|
pointA.properties.neighbours = [];
|
|
264
273
|
pointA.properties.level = corridor.properties.level;
|
|
265
274
|
}
|
|
266
|
-
let pointB =
|
|
275
|
+
let pointB = TurfPoint(coordinateList[i + 1]);
|
|
267
276
|
pointB.properties.level = corridor.properties.level;
|
|
268
277
|
pointB.properties.neighbours = [];
|
|
269
278
|
|
|
@@ -284,7 +293,7 @@ export class Wayfinding {
|
|
|
284
293
|
}
|
|
285
294
|
}
|
|
286
295
|
|
|
287
|
-
let lineFeature =
|
|
296
|
+
let lineFeature = TurfLineString([pointA.geometry.coordinates, pointB.geometry.coordinates]);
|
|
288
297
|
lineFeature.properties.level = corridor.properties.level;
|
|
289
298
|
|
|
290
299
|
// Mark lineFeature accordingly
|
|
@@ -353,7 +362,7 @@ export class Wayfinding {
|
|
|
353
362
|
}
|
|
354
363
|
|
|
355
364
|
let segmentLineStringToTest = corridorLineFeatures[j];
|
|
356
|
-
let intersections =
|
|
365
|
+
let intersections = TurfLineIntersect.default(segmentLineString, segmentLineStringToTest).features;
|
|
357
366
|
if (intersections.length > 0) {
|
|
358
367
|
let intersectingPoint = intersections[0];
|
|
359
368
|
intersectingPoint.properties.level = segment[0].properties.level;
|
|
@@ -434,7 +443,7 @@ export class Wayfinding {
|
|
|
434
443
|
|
|
435
444
|
if (wallFeatures?.length > 0) {
|
|
436
445
|
wallFeatures.forEach((wallFeature, wallIndex) => {
|
|
437
|
-
let intersections =
|
|
446
|
+
let intersections = TurfLineIntersect.default(segmentFeature, wallFeature).features;
|
|
438
447
|
if (intersections.length > 0) {
|
|
439
448
|
let intersectPoint = intersections[0];
|
|
440
449
|
intersectPoint.properties.level = segment[0].properties.level;
|
|
@@ -491,7 +500,7 @@ export class Wayfinding {
|
|
|
491
500
|
});
|
|
492
501
|
|
|
493
502
|
// Inject from last intersection to end of original segment
|
|
494
|
-
let newCorridor =
|
|
503
|
+
let newCorridor = TurfLineString([previousPoint.geometry.coordinates, segment[1].geometry.coordinates]);
|
|
495
504
|
newCorridor.properties.level = previousPoint.properties.level;
|
|
496
505
|
|
|
497
506
|
// connect last intersection point with end point
|
|
@@ -626,7 +635,7 @@ export class Wayfinding {
|
|
|
626
635
|
if (!offsetPoint) {
|
|
627
636
|
return;
|
|
628
637
|
}
|
|
629
|
-
let offsetLine =
|
|
638
|
+
let offsetLine = TurfLineString([point.geometry.coordinates, offsetPoint.geometry.coordinates]);
|
|
630
639
|
offsetLine.properties.level = point.properties.level;
|
|
631
640
|
this.wallOffsetLineList.push(offsetLine);
|
|
632
641
|
});
|
|
@@ -762,8 +771,8 @@ export class Wayfinding {
|
|
|
762
771
|
|
|
763
772
|
let pointA = walls[0][0] === point ? walls[0][1] : walls[0][0];
|
|
764
773
|
let pointB = walls[1][0] === point ? walls[1][1] : walls[1][0];
|
|
765
|
-
let pointABearing =
|
|
766
|
-
let pointBBearing =
|
|
774
|
+
let pointABearing = TurfBearing(point, pointA);
|
|
775
|
+
let pointBBearing = TurfBearing(point, pointB);
|
|
767
776
|
|
|
768
777
|
// b) Get average bearing to points A,B
|
|
769
778
|
let bearing = this._averageBearing(pointABearing, pointBBearing);
|
|
@@ -771,19 +780,19 @@ export class Wayfinding {
|
|
|
771
780
|
// this.wallOffsetLineList.push(turf.lineString([point.geometry.coordinates, offsetPoint.geometry.coordinates]));
|
|
772
781
|
|
|
773
782
|
// c) Generate two points M,N very close to point P
|
|
774
|
-
let pointM =
|
|
783
|
+
let pointM = TurfDestination(point.geometry.coordinates, 0.01, bearing, {
|
|
775
784
|
units: this.UNIT_TYPE,
|
|
776
785
|
});
|
|
777
|
-
let pointN =
|
|
786
|
+
let pointN = TurfDestination(point.geometry.coordinates, 0.01, oppositeBearing, { units: this.UNIT_TYPE });
|
|
778
787
|
|
|
779
788
|
// d) Test which point is contained within accessible area
|
|
780
789
|
let containedPoint = null;
|
|
781
790
|
for (let areaIndex in this.floorData.get(point.properties.level).areas) {
|
|
782
791
|
let area = this.floorData.get(point.properties.level).areas[areaIndex];
|
|
783
|
-
if (
|
|
792
|
+
if (TurfBooleanContains(area, pointM)) {
|
|
784
793
|
containedPoint = pointM;
|
|
785
794
|
break;
|
|
786
|
-
} else if (
|
|
795
|
+
} else if (TurfBooleanContains(area, pointN)) {
|
|
787
796
|
containedPoint = pointN;
|
|
788
797
|
break;
|
|
789
798
|
}
|
|
@@ -794,7 +803,7 @@ export class Wayfinding {
|
|
|
794
803
|
}
|
|
795
804
|
|
|
796
805
|
// e) Generate point F at double the distance of wall offset
|
|
797
|
-
let pointF =
|
|
806
|
+
let pointF = TurfDestination(
|
|
798
807
|
point.geometry.coordinates,
|
|
799
808
|
this.wallOffsetDistance * 2,
|
|
800
809
|
containedPoint === pointM ? bearing : oppositeBearing,
|
|
@@ -802,7 +811,7 @@ export class Wayfinding {
|
|
|
802
811
|
);
|
|
803
812
|
|
|
804
813
|
// f) Test if PF intersects with any wall, update point F and PF to shortest available size
|
|
805
|
-
let linePF =
|
|
814
|
+
let linePF = TurfLineString([point.geometry.coordinates, pointF.geometry.coordinates]);
|
|
806
815
|
this.floorData.get(point.properties.level).walls.forEach((wall, index) => {
|
|
807
816
|
// Do not test walls containing point P, they will intersect of course
|
|
808
817
|
if (walls.includes(wall)) {
|
|
@@ -810,18 +819,18 @@ export class Wayfinding {
|
|
|
810
819
|
}
|
|
811
820
|
let lineWall = this.floorData.get(point.properties.level).wallFeatures[index];
|
|
812
821
|
// Find intersection point, use it to produce new
|
|
813
|
-
let intersections =
|
|
822
|
+
let intersections = TurfLineIntersect.default(linePF, lineWall);
|
|
814
823
|
if (intersections.features.length > 0) {
|
|
815
|
-
pointF =
|
|
816
|
-
linePF =
|
|
824
|
+
pointF = TurfPoint(intersections.features[0].geometry.coordinates);
|
|
825
|
+
linePF = TurfLineString([point.geometry.coordinates, pointF.geometry.coordinates]);
|
|
817
826
|
}
|
|
818
827
|
});
|
|
819
828
|
|
|
820
829
|
// g) Create wall offset point as midpoint between points P,F
|
|
821
|
-
let offsetPoint =
|
|
830
|
+
let offsetPoint = TurfMidpoint.default(point.geometry.coordinates, pointF.geometry.coordinates);
|
|
822
831
|
offsetPoint.properties.level = point.properties.level;
|
|
823
832
|
this.wallOffsets[pointList.indexOf(point)] = offsetPoint;
|
|
824
|
-
let offsetLine =
|
|
833
|
+
let offsetLine = TurfLineString([point.geometry.coordinates, offsetPoint.geometry.coordinates]);
|
|
825
834
|
offsetLine.properties.level = point.properties.level;
|
|
826
835
|
this.wallOffsetLineList.push(offsetLine);
|
|
827
836
|
});
|
|
@@ -926,7 +935,7 @@ export class Wayfinding {
|
|
|
926
935
|
offsetPointList.push(currentOffsetPoint);
|
|
927
936
|
let potentialOffsetPoints;
|
|
928
937
|
do {
|
|
929
|
-
let line =
|
|
938
|
+
let line = TurfLineString([previousPoint.geometry.coordinates, currentOffsetPoint.geometry.coordinates]);
|
|
930
939
|
potentialOffsetPoints = [];
|
|
931
940
|
this.wallOffsetLineList.forEach((wallOffsetLine, index) => {
|
|
932
941
|
// Do not process wall offsets from another floor
|
|
@@ -937,7 +946,7 @@ export class Wayfinding {
|
|
|
937
946
|
if (index === previousPointIndex || index === currentPointIndex) {
|
|
938
947
|
return;
|
|
939
948
|
}
|
|
940
|
-
let intersection =
|
|
949
|
+
let intersection = TurfLineIntersect.default(line, wallOffsetLine);
|
|
941
950
|
if (intersection.features.length > 0) {
|
|
942
951
|
let offsetPoint = this.wallOffsets[index];
|
|
943
952
|
// store distance to previousPoint
|
|
@@ -961,15 +970,15 @@ export class Wayfinding {
|
|
|
961
970
|
if (current === previous || current.properties.level !== previous.properties.level) {
|
|
962
971
|
return [];
|
|
963
972
|
}
|
|
964
|
-
let line =
|
|
973
|
+
let line = TurfLineString([current.geometry.coordinates, previous.geometry.coordinates]);
|
|
965
974
|
let intersectingWallOffsetPoints = [];
|
|
966
975
|
this.wallOffsetLineList.forEach((wallOffsetLine, index) => {
|
|
967
976
|
if (wallOffsetLine.properties.level !== current.properties.level) {
|
|
968
977
|
return;
|
|
969
978
|
}
|
|
970
|
-
if (
|
|
979
|
+
if (TurfLineIntersect.default(line, wallOffsetLine).features.length > 0) {
|
|
971
980
|
let point = this.wallOffsets[index];
|
|
972
|
-
point.properties.distance =
|
|
981
|
+
point.properties.distance = TurfPointToLineDistance.default(current.geometry.coordinates, wallOffsetLine, {
|
|
973
982
|
units: this.UNIT_TYPE,
|
|
974
983
|
});
|
|
975
984
|
intersectingWallOffsetPoints.push(point);
|
|
@@ -1116,7 +1125,7 @@ export class Wayfinding {
|
|
|
1116
1125
|
}
|
|
1117
1126
|
path.forEach((_, key) => {
|
|
1118
1127
|
if (path[key + 1] !== undefined) {
|
|
1119
|
-
distance +=
|
|
1128
|
+
distance += TurfDistance.default(path[key], path[key + 1], {
|
|
1120
1129
|
units: this.UNIT_TYPE,
|
|
1121
1130
|
});
|
|
1122
1131
|
}
|
|
@@ -1233,7 +1242,7 @@ export class Wayfinding {
|
|
|
1233
1242
|
let neighbours = this._getNeighbours(current, fixedStartPoint, fixedEndPoint);
|
|
1234
1243
|
|
|
1235
1244
|
neighbours.forEach((n) =>
|
|
1236
|
-
this.nbLines.push(
|
|
1245
|
+
this.nbLines.push(TurfLineString([current.geometry.coordinates, n.geometry.coordinates])),
|
|
1237
1246
|
);
|
|
1238
1247
|
|
|
1239
1248
|
neighbours.forEach((neighbour) => {
|
|
@@ -1419,12 +1428,12 @@ export class Wayfinding {
|
|
|
1419
1428
|
// Filter out lines that intersect revolving door POIs.
|
|
1420
1429
|
let skip = false;
|
|
1421
1430
|
if (accesibilityType === this.POI_TYPE.REVOLVING_DOOR && this.configuration.avoidRevolvingDoors) {
|
|
1422
|
-
const line =
|
|
1431
|
+
const line = TurfLineString([pointA.geometry.coordinates, pointB.geometry.coordinates]);
|
|
1423
1432
|
const poiList = this.accessibilityPoi.filter(
|
|
1424
1433
|
(poi) => poi.properties.level === level && poi.properties.type === accesibilityType,
|
|
1425
1434
|
);
|
|
1426
1435
|
poiList.forEach((poi) => {
|
|
1427
|
-
const distance =
|
|
1436
|
+
const distance = TurfPointToLineDistance.default(poi.geometry.coordinates, line, { units: this.UNIT_TYPE });
|
|
1428
1437
|
if (distance <= poi.properties.radius) {
|
|
1429
1438
|
skip = true;
|
|
1430
1439
|
}
|
|
@@ -1505,10 +1514,10 @@ export class Wayfinding {
|
|
|
1505
1514
|
|
|
1506
1515
|
if (intersects) {
|
|
1507
1516
|
// if (allowedIntersections >= 1) {
|
|
1508
|
-
let midpoint =
|
|
1517
|
+
let midpoint = TurfMidpoint.default(point.geometry.coordinates, proposedPoint.geometry.coordinates);
|
|
1509
1518
|
for (let polIndex in this.floorData.get(point.properties.level).areas) {
|
|
1510
1519
|
let area = this.floorData.get(point.properties.level).areas[polIndex];
|
|
1511
|
-
if (
|
|
1520
|
+
if (TurfBooleanContains(area, midpoint)) {
|
|
1512
1521
|
neighbours.push(proposedPoint);
|
|
1513
1522
|
break;
|
|
1514
1523
|
}
|
|
@@ -1613,8 +1622,8 @@ export class Wayfinding {
|
|
|
1613
1622
|
intersections++;
|
|
1614
1623
|
}
|
|
1615
1624
|
} else {
|
|
1616
|
-
let intersectPoints =
|
|
1617
|
-
|
|
1625
|
+
let intersectPoints = TurfLineIntersect.default(
|
|
1626
|
+
TurfLineString([fromCoordinates, toCoordinates]),
|
|
1618
1627
|
floorWallFeatures[index],
|
|
1619
1628
|
).features;
|
|
1620
1629
|
if (intersectPoints.length > 0) {
|
|
@@ -1783,7 +1792,7 @@ export class Wayfinding {
|
|
|
1783
1792
|
_distance(pointA, pointB) {
|
|
1784
1793
|
let levelChangePenalty = 0;
|
|
1785
1794
|
if (pointB.properties.level !== pointA.properties.level) levelChangePenalty = 10;
|
|
1786
|
-
return
|
|
1795
|
+
return TurfDistance.default(pointA, pointB, { units: this.UNIT_TYPE }) + levelChangePenalty;
|
|
1787
1796
|
}
|
|
1788
1797
|
|
|
1789
1798
|
/**
|
|
@@ -1815,7 +1824,7 @@ export class Wayfinding {
|
|
|
1815
1824
|
let pointFound = undefined;
|
|
1816
1825
|
if (floorData?.areas.length > 0) {
|
|
1817
1826
|
floorData.areas.forEach((polygon) => {
|
|
1818
|
-
if (
|
|
1827
|
+
if (TurfBooleanContains(polygon, point)) {
|
|
1819
1828
|
pointFound = point;
|
|
1820
1829
|
return;
|
|
1821
1830
|
}
|
|
@@ -1831,7 +1840,7 @@ export class Wayfinding {
|
|
|
1831
1840
|
|
|
1832
1841
|
if (floorData?.wallFeatures.length > 0) {
|
|
1833
1842
|
floorData.wallFeatures.forEach((wall) => {
|
|
1834
|
-
let distance =
|
|
1843
|
+
let distance = TurfPointToLineDistance.default(point.geometry.coordinates, wall, { units: this.UNIT_TYPE });
|
|
1835
1844
|
if (distance <= bestWallDistance) {
|
|
1836
1845
|
bestWall = wall;
|
|
1837
1846
|
bestWallDistance = distance;
|
|
@@ -1846,7 +1855,7 @@ export class Wayfinding {
|
|
|
1846
1855
|
let bestCorridorDistance = Infinity;
|
|
1847
1856
|
levelCorridorFeatures.forEach((corridor) => {
|
|
1848
1857
|
let corridorIndex = this.corridorLineFeatures.indexOf(corridor);
|
|
1849
|
-
let corridorDistance =
|
|
1858
|
+
let corridorDistance = TurfPointToLineDistance.default(point.geometry.coordinates, corridor, { units: this.UNIT_TYPE });
|
|
1850
1859
|
if (corridorDistance < bestCorridorDistance) {
|
|
1851
1860
|
bestCorridorIndex = corridorIndex;
|
|
1852
1861
|
bestCorridorDistance = corridorDistance;
|
|
@@ -1864,7 +1873,7 @@ export class Wayfinding {
|
|
|
1864
1873
|
if (bestCorridorIndex !== undefined && bestCorridorDistance < bestWallDistance) {
|
|
1865
1874
|
// Create fixed point on line itself
|
|
1866
1875
|
let line = this.corridorLineFeatures[bestCorridorIndex];
|
|
1867
|
-
fixedPoint =
|
|
1876
|
+
fixedPoint = TurfNearestPointOnLine.default(line, point);
|
|
1868
1877
|
|
|
1869
1878
|
// Mark this fixed point is on corridor, preset neighbours
|
|
1870
1879
|
fixedPoint.properties.onCorridor = true;
|
|
@@ -1928,9 +1937,9 @@ export class Wayfinding {
|
|
|
1928
1937
|
// Wall is closer
|
|
1929
1938
|
} else if (bestWall !== null) {
|
|
1930
1939
|
// Create fixed point inside area
|
|
1931
|
-
let nearestPoint =
|
|
1932
|
-
let bearing =
|
|
1933
|
-
fixedPoint =
|
|
1940
|
+
let nearestPoint = TurfNearestPointOnLine.default(bestWall, point);
|
|
1941
|
+
let bearing = TurfBearing(point, nearestPoint);
|
|
1942
|
+
fixedPoint = TurfDestination(point.geometry.coordinates, bestWallDistance + 0.05, bearing, {
|
|
1934
1943
|
units: this.UNIT_TYPE,
|
|
1935
1944
|
});
|
|
1936
1945
|
}
|
|
@@ -1948,7 +1957,7 @@ export class Wayfinding {
|
|
|
1948
1957
|
* @return {Feature <Point>}
|
|
1949
1958
|
*/
|
|
1950
1959
|
_copyPoint(pointFeature) {
|
|
1951
|
-
let point =
|
|
1960
|
+
let point = TurfPoint([pointFeature.geometry.coordinates[0], pointFeature.geometry.coordinates[1]]);
|
|
1952
1961
|
if (pointFeature.id !== undefined) point.id = pointFeature.id;
|
|
1953
1962
|
if (pointFeature.properties.id !== undefined) point.properties.id = pointFeature.properties.id;
|
|
1954
1963
|
if (pointFeature.properties.amenity !== undefined) point.properties.amenity = pointFeature.properties.amenity;
|
|
@@ -1984,8 +1993,8 @@ export class Wayfinding {
|
|
|
1984
1993
|
}
|
|
1985
1994
|
|
|
1986
1995
|
_comparePointsByDistanceFromReference(reference, intersectionA, intersectionB) {
|
|
1987
|
-
let dA =
|
|
1988
|
-
let dB =
|
|
1996
|
+
let dA = TurfDistance.default(reference, intersectionA);
|
|
1997
|
+
let dB = TurfDistance.default(reference, intersectionB);
|
|
1989
1998
|
if (dA > dB) return 1;
|
|
1990
1999
|
if (dB > dA) return -1;
|
|
1991
2000
|
return 0;
|
|
@@ -2007,8 +2016,8 @@ export class Wayfinding {
|
|
|
2007
2016
|
return true;
|
|
2008
2017
|
}
|
|
2009
2018
|
const coords = corridor.geometry.coordinates;
|
|
2010
|
-
const corridorBearing =
|
|
2011
|
-
const pathBearing =
|
|
2019
|
+
const corridorBearing = TurfBearing(coords[0], coords[1]);
|
|
2020
|
+
const pathBearing = TurfBearing(start, end);
|
|
2012
2021
|
const delta = parseInt(corridorBearing - pathBearing);
|
|
2013
2022
|
|
|
2014
2023
|
const isSwappedDirection = corridor.properties.swapDirection !== undefined && corridor.properties.swapDirection;
|