proximiio-js-library 1.7.1 → 1.7.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 +118 -113
- package/lib/proximiio.js +1 -1
- package/package.json +1 -1
package/assets/wayfinding.js
CHANGED
|
@@ -466,38 +466,42 @@ export class Wayfinding {
|
|
|
466
466
|
}
|
|
467
467
|
|
|
468
468
|
levelChanger.properties.fixedPointMap = new Map();
|
|
469
|
-
levelChanger.properties.levels
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
if (
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
469
|
+
if (levelChanger.properties.levels) {
|
|
470
|
+
levelChanger.properties.levels.forEach(level => {
|
|
471
|
+
let point = this._copyPoint(levelChanger);
|
|
472
|
+
point.properties.level = level;
|
|
473
|
+
let fixedPoint = this._getFixPointInArea(point);
|
|
474
|
+
if (fixedPoint) {
|
|
475
|
+
fixedPoint.id = levelChanger.id;
|
|
476
|
+
fixedPoint.properties.amenity = levelChanger.properties.amenity;
|
|
477
|
+
fixedPoint.properties.direction = levelChanger.properties.direction;
|
|
478
|
+
fixedPoint.properties.id = levelChanger.properties.id;
|
|
479
|
+
fixedPoint.properties.level = level;
|
|
480
|
+
fixedPoint.properties.type = levelChanger.properties.type;
|
|
481
|
+
if (fixedPoint.properties.neighbours === undefined) fixedPoint.properties.neighbours = [];
|
|
482
|
+
|
|
483
|
+
// Do not fix level changers that are further than 5 meters from any path or area
|
|
484
|
+
if (this._distance(point, fixedPoint) > 5) {
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// Store fixed point into the level changer
|
|
489
|
+
levelChanger.properties.fixedPointMap.set(level, fixedPoint);
|
|
490
|
+
|
|
491
|
+
// Add neighbourhood for corridor
|
|
492
|
+
if (fixedPoint.properties.onCorridor) {
|
|
493
|
+
// fixedPoint.properties.neighbours = [...this.corridorLinePointPairs[fixedPoint.properties.corridorIndex], ...segmentIntersectionPointMap.get(fixedPoint.properties.corridorIndex)];
|
|
494
|
+
if (fixedPoint.properties.neighboursLeadingTo !== undefined) {
|
|
495
|
+
fixedPoint.properties.neighboursLeadingTo.forEach(neighbour => {
|
|
496
|
+
if (neighbour.properties.neighbours === undefined) neighbour.properties.neighbours = [];
|
|
497
|
+
neighbour.properties.neighbours.push(fixedPoint);
|
|
498
|
+
});
|
|
499
|
+
this.corridorLineFeatures[fixedPoint.properties.corridorIndex].properties.intersectionPointList.push(fixedPoint);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
498
502
|
}
|
|
499
|
-
}
|
|
500
|
-
}
|
|
503
|
+
});
|
|
504
|
+
}
|
|
501
505
|
});
|
|
502
506
|
|
|
503
507
|
levelChangerGroupMap.forEach( (lcList, groupId) => {
|
|
@@ -1447,100 +1451,101 @@ export class Wayfinding {
|
|
|
1447
1451
|
|
|
1448
1452
|
_getFixPointInArea(point) {
|
|
1449
1453
|
let floorData = this.floorData.get(point.properties.level);
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1454
|
+
if (floorData) {
|
|
1455
|
+
// If point is located without accessible area, do nothing
|
|
1456
|
+
let areaList = floorData.areas;
|
|
1457
|
+
for (let index in areaList) {
|
|
1458
|
+
let polygon = areaList[index];
|
|
1459
|
+
if (turf.booleanContains(polygon, point)) {
|
|
1460
|
+
return point;
|
|
1461
|
+
}
|
|
1457
1462
|
}
|
|
1458
|
-
}
|
|
1459
1463
|
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1464
|
+
// Find nearest wall to stick to
|
|
1465
|
+
let bestWall = null;
|
|
1466
|
+
let bestWallDistance = Infinity;
|
|
1467
|
+
floorData.wallFeatures.forEach(wall => {
|
|
1468
|
+
let distance = turf.pointToLineDistance(point.geometry.coordinates, wall, {units: 'meters'});
|
|
1469
|
+
if (distance < bestWallDistance) {
|
|
1470
|
+
bestWall = wall;
|
|
1471
|
+
bestWallDistance = distance;
|
|
1472
|
+
}
|
|
1473
|
+
});
|
|
1470
1474
|
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1475
|
+
let levelCorridorFeatures = this.corridorLineFeatures.filter(corridorLine => corridorLine.properties.level === point.properties.level);
|
|
1476
|
+
let bestCorridorIndex = null;
|
|
1477
|
+
let bestCorridorDistance = Infinity;
|
|
1478
|
+
levelCorridorFeatures.forEach(corridor => {
|
|
1479
|
+
let corridorIndex = this.corridorLineFeatures.indexOf(corridor);
|
|
1480
|
+
let corridorDistance = turf.pointToLineDistance(point.geometry.coordinates, corridor, {units: 'meters'});
|
|
1481
|
+
if (corridorDistance < bestCorridorDistance) {
|
|
1482
|
+
bestCorridorIndex = corridorIndex;
|
|
1483
|
+
bestCorridorDistance = corridorDistance;
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1482
1486
|
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1487
|
+
// Test if area or corridor is closer, create appropriate fixed point
|
|
1488
|
+
if (bestWall === null && bestCorridorIndex === null) {
|
|
1489
|
+
// could not find neither close area or corridor
|
|
1490
|
+
return point;
|
|
1491
|
+
} else {
|
|
1492
|
+
let fixedPoint;
|
|
1489
1493
|
|
|
1490
|
-
|
|
1491
|
-
|
|
1494
|
+
// Corridor is closer
|
|
1495
|
+
if (bestCorridorIndex !== undefined && bestCorridorDistance < bestWallDistance) {
|
|
1492
1496
|
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1497
|
+
// Create fixed point on line itself
|
|
1498
|
+
let line = this.corridorLineFeatures[bestCorridorIndex];
|
|
1499
|
+
fixedPoint = turf.nearestPointOnLine(line, point);
|
|
1496
1500
|
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1501
|
+
// Mark this fixed point is on corridor, preset neighbours
|
|
1502
|
+
fixedPoint.properties.onCorridor = true;
|
|
1503
|
+
fixedPoint.properties.corridorIndex = bestCorridorIndex;
|
|
1504
|
+
if (!fixedPoint.properties.neighbours) {
|
|
1505
|
+
fixedPoint.properties.neighbours = [];
|
|
1506
|
+
}
|
|
1507
|
+
if (this.corridorLineFeatures[bestCorridorIndex].properties.bidirectional != false) {
|
|
1508
|
+
fixedPoint.properties.neighbours.push(this.corridorLinePointPairs[bestCorridorIndex][0], this.corridorLinePointPairs[bestCorridorIndex][1]);
|
|
1509
|
+
fixedPoint.properties.neighbours.push(...line.properties.intersectionPointList);
|
|
1510
|
+
fixedPoint.properties.neighboursLeadingTo = [
|
|
1511
|
+
this.corridorLinePointPairs[bestCorridorIndex][0],
|
|
1512
|
+
this.corridorLinePointPairs[bestCorridorIndex][1],
|
|
1513
|
+
...line.properties.intersectionPointList
|
|
1514
|
+
];
|
|
1515
|
+
} else if (this.corridorLineFeatures[bestCorridorIndex].properties.swapDirection != true) {
|
|
1516
|
+
fixedPoint.properties.neighbours.push(this.corridorLinePointPairs[bestCorridorIndex][0]);
|
|
1517
|
+
// include only intersection points after this point
|
|
1518
|
+
let distance = this._distance(fixedPoint, this.corridorLinePointPairs[bestCorridorIndex][0]);
|
|
1519
|
+
let pointsBefore = line.properties.intersectionPointList.filter(point => this._distance(point, this.corridorLinePointPairs[bestCorridorIndex][0]) < distance);
|
|
1520
|
+
let pointsAfter = line.properties.intersectionPointList.filter(point => this._distance(point, this.corridorLinePointPairs[bestCorridorIndex][0]) >= distance);
|
|
1521
|
+
fixedPoint.properties.neighbours.push(...pointsAfter);
|
|
1522
|
+
fixedPoint.properties.neighboursLeadingTo = pointsBefore;
|
|
1523
|
+
} else {
|
|
1524
|
+
fixedPoint.properties.neighbours.push(this.corridorLinePointPairs[bestCorridorIndex][1]);
|
|
1525
|
+
// include only intersection points before this point
|
|
1526
|
+
let distance = this._distance(fixedPoint, this.corridorLinePointPairs[bestCorridorIndex][0]);
|
|
1527
|
+
let pointsBefore = line.properties.intersectionPointList.filter(point => this._distance(point, this.corridorLinePointPairs[bestCorridorIndex][0]) <= distance);
|
|
1528
|
+
let pointsAfter = line.properties.intersectionPointList.filter(point => this._distance(point, this.corridorLinePointPairs[bestCorridorIndex][0]) > distance);
|
|
1529
|
+
fixedPoint.properties.neighbours.push(...pointsBefore);
|
|
1530
|
+
fixedPoint.properties.neighboursLeadingTo = pointsAfter;
|
|
1531
|
+
}
|
|
1528
1532
|
|
|
1529
|
-
|
|
1530
|
-
|
|
1533
|
+
// Wall is closer
|
|
1534
|
+
} else if (bestWall !== null) {
|
|
1531
1535
|
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1536
|
+
// Create fixed point inside area
|
|
1537
|
+
let nearestPoint = turf.nearestPointOnLine(bestWall, point);
|
|
1538
|
+
let bearing = turf.bearing(point, nearestPoint);
|
|
1539
|
+
fixedPoint = turf.destination(point.geometry.coordinates, bestWallDistance + 0.05, bearing, {units: 'meters'});
|
|
1540
|
+
}
|
|
1537
1541
|
|
|
1538
|
-
|
|
1539
|
-
|
|
1542
|
+
// Mark level of fixed point
|
|
1543
|
+
fixedPoint.properties.level = point.properties.level;
|
|
1540
1544
|
|
|
1541
|
-
|
|
1542
|
-
|
|
1545
|
+
// Return created point
|
|
1546
|
+
return fixedPoint;
|
|
1543
1547
|
|
|
1548
|
+
}
|
|
1544
1549
|
}
|
|
1545
1550
|
}
|
|
1546
1551
|
|