proximiio-js-library 1.12.78 → 1.12.80
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/lib/components/map/guidanceStepsGenerator.js +3 -0
- package/lib/components/map/main.d.ts +54 -3
- package/lib/components/map/main.js +168 -22
- package/lib/components/map/routing.d.ts +5 -1
- package/lib/components/map/routing.js +53 -9
- package/lib/components/map/sources/routing_source.d.ts +4 -1
- package/lib/components/map/sources/routing_source.js +6 -2
- package/lib/models/feature.d.ts +1 -0
- package/lib/models/feature.js +3 -0
- package/lib/proximiio.js +1 -1
- package/package.json +1 -1
|
@@ -168,6 +168,9 @@ export default class GuidanceStepsGenerator {
|
|
|
168
168
|
if (!nextPoint) {
|
|
169
169
|
return Direction.Finish;
|
|
170
170
|
}
|
|
171
|
+
if (currentPoint.isPoi && nextPoint.isPoi && currentPoint.id === nextPoint.id) {
|
|
172
|
+
return Direction.Finish;
|
|
173
|
+
}
|
|
171
174
|
if (currentPoint.isLevelChanger && nextPoint.properties.level > currentPoint.properties.level) {
|
|
172
175
|
return `${Direction.Up}_${LevelChangerTypes[currentPoint.properties.type]}`;
|
|
173
176
|
}
|
|
@@ -212,6 +212,7 @@ export declare class Map {
|
|
|
212
212
|
private onPoiClickListener;
|
|
213
213
|
private onPersonUpdateListener;
|
|
214
214
|
private onStepSetListener;
|
|
215
|
+
private onStopSetListener;
|
|
215
216
|
private defaultOptions;
|
|
216
217
|
private routeFactory;
|
|
217
218
|
private startPoint?;
|
|
@@ -227,6 +228,7 @@ export declare class Map {
|
|
|
227
228
|
private hoveredPolygon;
|
|
228
229
|
private selectedPolygons;
|
|
229
230
|
private currentStep;
|
|
231
|
+
private currentStop;
|
|
230
232
|
private kioskPopup;
|
|
231
233
|
private mainSourceLoaded;
|
|
232
234
|
private pmTilesInstance;
|
|
@@ -537,11 +539,11 @@ export declare class Map {
|
|
|
537
539
|
*/
|
|
538
540
|
findRouteToNearestFeature(amenityId: string, idFrom?: string, accessibleRoute?: boolean, wayfindingConfig?: WayfindingConfigModel, addToMap?: boolean): void;
|
|
539
541
|
/**
|
|
540
|
-
* This method will generate route
|
|
542
|
+
* This method will generate city route
|
|
541
543
|
* @memberof Map
|
|
542
544
|
* @name findCityRoute
|
|
543
|
-
* @param start {
|
|
544
|
-
* @param destination {
|
|
545
|
+
* @param start {lat: number, lng: number} start coordinates
|
|
546
|
+
* @param destination {lat: number, lng: number} destination coordinates
|
|
545
547
|
* @param autoStart {boolean} default true, if set to false route will not start automatically
|
|
546
548
|
* @example
|
|
547
549
|
* const map = new Proximiio.Map();
|
|
@@ -570,6 +572,30 @@ export declare class Map {
|
|
|
570
572
|
};
|
|
571
573
|
autoStart?: boolean;
|
|
572
574
|
}): void;
|
|
575
|
+
/**
|
|
576
|
+
* This method will generate route based on selected features by their ids
|
|
577
|
+
* @memberof Map
|
|
578
|
+
* @name findMultipointRoute
|
|
579
|
+
* @param start {string} start feature id
|
|
580
|
+
* @param stops [{string}] array of destination feature ids
|
|
581
|
+
* @param wayfindingConfig {WayfindingConfigModel} wayfinding configuration, optional
|
|
582
|
+
* @param autoStart {boolean} default true, if set to false route will not be added to map
|
|
583
|
+
* @example
|
|
584
|
+
* const map = new Proximiio.Map();
|
|
585
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
586
|
+
* console.log('map ready', ready);
|
|
587
|
+
* map.findMultipointRoute({
|
|
588
|
+
* start: 'startId',
|
|
589
|
+
* stops: ['stop1Id', 'stop2Id']
|
|
590
|
+
* });
|
|
591
|
+
* });
|
|
592
|
+
*/
|
|
593
|
+
findMultipointRoute({ start, stops, wayfindingConfig, autoStart, }: {
|
|
594
|
+
start: string;
|
|
595
|
+
stops: string[];
|
|
596
|
+
wayfindingConfig?: WayfindingConfigModel;
|
|
597
|
+
autoStart?: boolean;
|
|
598
|
+
}): void;
|
|
573
599
|
/**
|
|
574
600
|
* This method will cancel generated route
|
|
575
601
|
* @memberof Map
|
|
@@ -607,6 +633,31 @@ export declare class Map {
|
|
|
607
633
|
* });
|
|
608
634
|
*/
|
|
609
635
|
getNavStepSetListener(): CustomSubject<number>;
|
|
636
|
+
/**
|
|
637
|
+
* This method will set the current stop for multipoint route navigation so map can focus on a proper path part
|
|
638
|
+
* @memberof Map
|
|
639
|
+
* @name setStop
|
|
640
|
+
* @param stop { number | 'next' | 'previous' } Number of route part to focus on or string next or previous
|
|
641
|
+
* @returns active stop
|
|
642
|
+
* @example
|
|
643
|
+
* const map = new Proximiio.Map();
|
|
644
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
645
|
+
* console.log('map ready', ready);
|
|
646
|
+
* map.setStop(0);
|
|
647
|
+
* });
|
|
648
|
+
*/
|
|
649
|
+
setStop(stop: number | 'next' | 'previous'): number;
|
|
650
|
+
/**
|
|
651
|
+
* @memberof Map
|
|
652
|
+
* @name getStopSetListener
|
|
653
|
+
* @returns returns stop set listener
|
|
654
|
+
* @example
|
|
655
|
+
* const map = new Proximiio.Map();
|
|
656
|
+
* map.getStopSetListener().subscribe(stop => {
|
|
657
|
+
* console.log('new stop has been set', stop);
|
|
658
|
+
* });
|
|
659
|
+
*/
|
|
660
|
+
getStopSetListener(): CustomSubject<number>;
|
|
610
661
|
/**
|
|
611
662
|
* This method will return turn by turn text navigation object.
|
|
612
663
|
* @memberof Map
|
|
@@ -87,6 +87,7 @@ export class Map {
|
|
|
87
87
|
this.onPoiClickListener = new CustomSubject();
|
|
88
88
|
this.onPersonUpdateListener = new CustomSubject();
|
|
89
89
|
this.onStepSetListener = new CustomSubject();
|
|
90
|
+
this.onStopSetListener = new CustomSubject();
|
|
90
91
|
this.defaultOptions = {
|
|
91
92
|
selector: 'proximiioMap',
|
|
92
93
|
allowNewFeatureModal: false,
|
|
@@ -228,6 +229,7 @@ export class Map {
|
|
|
228
229
|
this.amenityCategories = {};
|
|
229
230
|
this.selectedPolygons = [];
|
|
230
231
|
this.currentStep = 0;
|
|
232
|
+
this.currentStop = 0;
|
|
231
233
|
this.mainSourceLoaded = false;
|
|
232
234
|
this.pointIconMarker = {};
|
|
233
235
|
this.routeStartMarker = {};
|
|
@@ -1648,7 +1650,10 @@ export class Map {
|
|
|
1648
1650
|
this.centerToFeature(destinationFeature.id);
|
|
1649
1651
|
}
|
|
1650
1652
|
if (startFeature && destinationFeature) {
|
|
1651
|
-
this.onRouteUpdate(
|
|
1653
|
+
this.onRouteUpdate({
|
|
1654
|
+
start: startFeature,
|
|
1655
|
+
finish: destinationFeature,
|
|
1656
|
+
});
|
|
1652
1657
|
}
|
|
1653
1658
|
}
|
|
1654
1659
|
featureDialog(e) {
|
|
@@ -2203,6 +2208,8 @@ export class Map {
|
|
|
2203
2208
|
this.map.getSource('main').setData(mainSourceData);
|
|
2204
2209
|
}
|
|
2205
2210
|
onSetHiddenAmenities(amenities) {
|
|
2211
|
+
this.defaultOptions.hiddenAmenities = [...this.defaultOptions.hiddenAmenities, ...amenities];
|
|
2212
|
+
this.defaultOptions.hiddenAmenities = [...new Set(this.defaultOptions.hiddenAmenities)];
|
|
2206
2213
|
// @ts-ignore
|
|
2207
2214
|
const mainSourceData = this.map.getSource('main')._data;
|
|
2208
2215
|
mainSourceData.features = mainSourceData.features.map((f) => {
|
|
@@ -2673,12 +2680,12 @@ export class Map {
|
|
|
2673
2680
|
this.updateCluster();
|
|
2674
2681
|
this.onFloorSelectListener.next(floor);
|
|
2675
2682
|
}
|
|
2676
|
-
onRouteUpdate(start, finish) {
|
|
2683
|
+
onRouteUpdate({ start, finish, stops }) {
|
|
2677
2684
|
this.startPoint = start;
|
|
2678
|
-
this.endPoint = finish;
|
|
2685
|
+
this.endPoint = stops ? stops[stops.length - 1] : finish;
|
|
2679
2686
|
try {
|
|
2680
|
-
if (
|
|
2681
|
-
this.handlePolygonSelection(finish);
|
|
2687
|
+
if (this.defaultOptions.initPolygons) {
|
|
2688
|
+
this.handlePolygonSelection([...stops, finish, start]);
|
|
2682
2689
|
}
|
|
2683
2690
|
if (finish && this.defaultOptions.animatedRoute) {
|
|
2684
2691
|
if (this.defaultOptions.animatedRoute) {
|
|
@@ -2686,17 +2693,20 @@ export class Map {
|
|
|
2686
2693
|
}
|
|
2687
2694
|
cancelAnimationFrame(this.animationFrame);
|
|
2688
2695
|
}
|
|
2689
|
-
this.routingSource.update({ start, finish, language: this.defaultOptions.language });
|
|
2696
|
+
this.routingSource.update({ start, finish, stops, language: this.defaultOptions.language });
|
|
2690
2697
|
}
|
|
2691
2698
|
catch (e) {
|
|
2692
2699
|
console.log('catched', e);
|
|
2693
2700
|
}
|
|
2694
2701
|
this.state = Object.assign(Object.assign({}, this.state), { style: this.state.style });
|
|
2695
2702
|
}
|
|
2696
|
-
onRoutePreview(start, finish) {
|
|
2703
|
+
onRoutePreview({ start, finish, stops }) {
|
|
2697
2704
|
this.startPoint = start;
|
|
2698
|
-
this.endPoint = finish;
|
|
2699
|
-
|
|
2705
|
+
this.endPoint = stops ? stops[stops.length - 1] : finish;
|
|
2706
|
+
if (this.defaultOptions.initPolygons) {
|
|
2707
|
+
this.handlePolygonSelection([...stops, finish, start]);
|
|
2708
|
+
}
|
|
2709
|
+
this.routingSource.update({ start, finish, stops, preview: true, language: this.defaultOptions.language });
|
|
2700
2710
|
}
|
|
2701
2711
|
onRouteCancel() {
|
|
2702
2712
|
this.state = Object.assign(Object.assign({}, this.state), { textNavigation: null });
|
|
@@ -3390,10 +3400,16 @@ export class Map {
|
|
|
3390
3400
|
this.routingSource.setConfig(wayfindingConfig);
|
|
3391
3401
|
}
|
|
3392
3402
|
if (addToMap !== false) {
|
|
3393
|
-
this.onRouteUpdate(
|
|
3403
|
+
this.onRouteUpdate({
|
|
3404
|
+
start: fromFeature,
|
|
3405
|
+
finish: toFeature,
|
|
3406
|
+
});
|
|
3394
3407
|
}
|
|
3395
3408
|
else {
|
|
3396
|
-
this.onRoutePreview(
|
|
3409
|
+
this.onRoutePreview({
|
|
3410
|
+
start: fromFeature,
|
|
3411
|
+
finish: toFeature,
|
|
3412
|
+
});
|
|
3397
3413
|
}
|
|
3398
3414
|
}
|
|
3399
3415
|
/**
|
|
@@ -3422,10 +3438,16 @@ export class Map {
|
|
|
3422
3438
|
this.routingSource.setConfig(wayfindingConfig);
|
|
3423
3439
|
}
|
|
3424
3440
|
if (addToMap !== false) {
|
|
3425
|
-
this.onRouteUpdate(
|
|
3441
|
+
this.onRouteUpdate({
|
|
3442
|
+
start: fromFeature,
|
|
3443
|
+
finish: toFeature,
|
|
3444
|
+
});
|
|
3426
3445
|
}
|
|
3427
3446
|
else {
|
|
3428
|
-
this.onRoutePreview(
|
|
3447
|
+
this.onRoutePreview({
|
|
3448
|
+
start: fromFeature,
|
|
3449
|
+
finish: toFeature,
|
|
3450
|
+
});
|
|
3429
3451
|
}
|
|
3430
3452
|
}
|
|
3431
3453
|
/**
|
|
@@ -3458,10 +3480,16 @@ export class Map {
|
|
|
3458
3480
|
this.routingSource.setConfig(wayfindingConfig);
|
|
3459
3481
|
}
|
|
3460
3482
|
if (addToMap !== false) {
|
|
3461
|
-
this.onRouteUpdate(
|
|
3483
|
+
this.onRouteUpdate({
|
|
3484
|
+
start: fromFeature,
|
|
3485
|
+
finish: toFeature,
|
|
3486
|
+
});
|
|
3462
3487
|
}
|
|
3463
3488
|
else {
|
|
3464
|
-
this.onRoutePreview(
|
|
3489
|
+
this.onRoutePreview({
|
|
3490
|
+
start: fromFeature,
|
|
3491
|
+
finish: toFeature,
|
|
3492
|
+
});
|
|
3465
3493
|
}
|
|
3466
3494
|
}
|
|
3467
3495
|
/**
|
|
@@ -3491,10 +3519,16 @@ export class Map {
|
|
|
3491
3519
|
this.routingSource.setConfig(wayfindingConfig);
|
|
3492
3520
|
}
|
|
3493
3521
|
if (addToMap !== false) {
|
|
3494
|
-
this.onRouteUpdate(
|
|
3522
|
+
this.onRouteUpdate({
|
|
3523
|
+
start: fromFeature,
|
|
3524
|
+
finish: toFeature,
|
|
3525
|
+
});
|
|
3495
3526
|
}
|
|
3496
3527
|
else {
|
|
3497
|
-
this.onRoutePreview(
|
|
3528
|
+
this.onRoutePreview({
|
|
3529
|
+
start: fromFeature,
|
|
3530
|
+
finish: toFeature,
|
|
3531
|
+
});
|
|
3498
3532
|
}
|
|
3499
3533
|
}
|
|
3500
3534
|
else {
|
|
@@ -3502,11 +3536,11 @@ export class Map {
|
|
|
3502
3536
|
}
|
|
3503
3537
|
}
|
|
3504
3538
|
/**
|
|
3505
|
-
* This method will generate route
|
|
3539
|
+
* This method will generate city route
|
|
3506
3540
|
* @memberof Map
|
|
3507
3541
|
* @name findCityRoute
|
|
3508
|
-
* @param start {
|
|
3509
|
-
* @param destination {
|
|
3542
|
+
* @param start {lat: number, lng: number} start coordinates
|
|
3543
|
+
* @param destination {lat: number, lng: number} destination coordinates
|
|
3510
3544
|
* @param autoStart {boolean} default true, if set to false route will not start automatically
|
|
3511
3545
|
* @example
|
|
3512
3546
|
* const map = new Proximiio.Map();
|
|
@@ -3529,10 +3563,57 @@ export class Map {
|
|
|
3529
3563
|
const destinationFeature = feature({ type: 'Point', coordinates: [destination.lng, destination.lat] }, { level: 0 });
|
|
3530
3564
|
this.routingSource.setNavigationType('city');
|
|
3531
3565
|
if (autoStart !== false) {
|
|
3532
|
-
this.onRouteUpdate(
|
|
3566
|
+
this.onRouteUpdate({
|
|
3567
|
+
start: startFeature,
|
|
3568
|
+
finish: destinationFeature,
|
|
3569
|
+
});
|
|
3533
3570
|
}
|
|
3534
3571
|
else {
|
|
3535
|
-
this.onRoutePreview(
|
|
3572
|
+
this.onRoutePreview({
|
|
3573
|
+
start: startFeature,
|
|
3574
|
+
finish: destinationFeature,
|
|
3575
|
+
});
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
/**
|
|
3579
|
+
* This method will generate route based on selected features by their ids
|
|
3580
|
+
* @memberof Map
|
|
3581
|
+
* @name findMultipointRoute
|
|
3582
|
+
* @param start {string} start feature id
|
|
3583
|
+
* @param stops [{string}] array of destination feature ids
|
|
3584
|
+
* @param wayfindingConfig {WayfindingConfigModel} wayfinding configuration, optional
|
|
3585
|
+
* @param autoStart {boolean} default true, if set to false route will not be added to map
|
|
3586
|
+
* @example
|
|
3587
|
+
* const map = new Proximiio.Map();
|
|
3588
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
3589
|
+
* console.log('map ready', ready);
|
|
3590
|
+
* map.findMultipointRoute({
|
|
3591
|
+
* start: 'startId',
|
|
3592
|
+
* stops: ['stop1Id', 'stop2Id']
|
|
3593
|
+
* });
|
|
3594
|
+
* });
|
|
3595
|
+
*/
|
|
3596
|
+
findMultipointRoute({ start, stops, wayfindingConfig, autoStart = true, }) {
|
|
3597
|
+
const fromFeature = start
|
|
3598
|
+
? this.state.allFeatures.features.find((f) => f.id === start || f.properties.id === start)
|
|
3599
|
+
: this.startPoint;
|
|
3600
|
+
const destinationFeatures = stops.map((id) => {
|
|
3601
|
+
return this.state.allFeatures.features.find((f) => f.id === id || f.properties.id === id);
|
|
3602
|
+
});
|
|
3603
|
+
if (wayfindingConfig) {
|
|
3604
|
+
this.routingSource.setConfig(wayfindingConfig);
|
|
3605
|
+
}
|
|
3606
|
+
if (autoStart !== false) {
|
|
3607
|
+
this.onRouteUpdate({
|
|
3608
|
+
start: fromFeature,
|
|
3609
|
+
stops: destinationFeatures,
|
|
3610
|
+
});
|
|
3611
|
+
}
|
|
3612
|
+
else {
|
|
3613
|
+
this.onRoutePreview({
|
|
3614
|
+
start: fromFeature,
|
|
3615
|
+
stops: destinationFeatures,
|
|
3616
|
+
});
|
|
3536
3617
|
}
|
|
3537
3618
|
}
|
|
3538
3619
|
/**
|
|
@@ -3563,6 +3644,7 @@ export class Map {
|
|
|
3563
3644
|
* });
|
|
3564
3645
|
*/
|
|
3565
3646
|
setNavStep(step) {
|
|
3647
|
+
var _a, _b, _c;
|
|
3566
3648
|
let newStep = 0;
|
|
3567
3649
|
if (isNumber(step)) {
|
|
3568
3650
|
newStep = +step;
|
|
@@ -3587,9 +3669,16 @@ export class Map {
|
|
|
3587
3669
|
this.animateRoute();
|
|
3588
3670
|
}
|
|
3589
3671
|
else {
|
|
3672
|
+
if (this.routingSource.isMultipoint) {
|
|
3673
|
+
this.animateRoute();
|
|
3674
|
+
}
|
|
3590
3675
|
this.centerOnRoute(this.routingSource.route[`path-part-${newStep}`]);
|
|
3591
3676
|
}
|
|
3592
3677
|
this.onStepSetListener.next(this.currentStep);
|
|
3678
|
+
if (isNumber((_a = this.routingSource.route[`path-part-${newStep}`].properties) === null || _a === void 0 ? void 0 : _a.stop) &&
|
|
3679
|
+
((_b = this.routingSource.route[`path-part-${newStep}`].properties) === null || _b === void 0 ? void 0 : _b.stop) >= 0) {
|
|
3680
|
+
this.setStop((_c = this.routingSource.route[`path-part-${newStep}`].properties) === null || _c === void 0 ? void 0 : _c.stop);
|
|
3681
|
+
}
|
|
3593
3682
|
return step;
|
|
3594
3683
|
}
|
|
3595
3684
|
else {
|
|
@@ -3609,6 +3698,63 @@ export class Map {
|
|
|
3609
3698
|
getNavStepSetListener() {
|
|
3610
3699
|
return this.onStepSetListener;
|
|
3611
3700
|
}
|
|
3701
|
+
/**
|
|
3702
|
+
* This method will set the current stop for multipoint route navigation so map can focus on a proper path part
|
|
3703
|
+
* @memberof Map
|
|
3704
|
+
* @name setStop
|
|
3705
|
+
* @param stop { number | 'next' | 'previous' } Number of route part to focus on or string next or previous
|
|
3706
|
+
* @returns active stop
|
|
3707
|
+
* @example
|
|
3708
|
+
* const map = new Proximiio.Map();
|
|
3709
|
+
* map.getMapReadyListener().subscribe(ready => {
|
|
3710
|
+
* console.log('map ready', ready);
|
|
3711
|
+
* map.setStop(0);
|
|
3712
|
+
* });
|
|
3713
|
+
*/
|
|
3714
|
+
setStop(stop) {
|
|
3715
|
+
var _a, _b;
|
|
3716
|
+
let newStop = 0;
|
|
3717
|
+
if (isNumber(stop)) {
|
|
3718
|
+
newStop = +stop;
|
|
3719
|
+
}
|
|
3720
|
+
if (stop === 'next') {
|
|
3721
|
+
newStop = this.currentStop + 1;
|
|
3722
|
+
}
|
|
3723
|
+
if (stop === 'next' && this.routingSource.stops && this.routingSource.stops.length - 1 === this.currentStop) {
|
|
3724
|
+
newStop = 0;
|
|
3725
|
+
}
|
|
3726
|
+
if (stop === 'previous' && this.currentStop > 0) {
|
|
3727
|
+
newStop = this.currentStop - 1;
|
|
3728
|
+
}
|
|
3729
|
+
if (newStop === this.currentStop) {
|
|
3730
|
+
return;
|
|
3731
|
+
}
|
|
3732
|
+
const newStopRoute = (_b = (_a = this.routingSource) === null || _a === void 0 ? void 0 : _a.lines) === null || _b === void 0 ? void 0 : _b.find((i) => i.properties.stop === newStop);
|
|
3733
|
+
if (newStopRoute) {
|
|
3734
|
+
this.currentStop = newStop;
|
|
3735
|
+
this.animateRoute();
|
|
3736
|
+
this.centerOnRoute(newStopRoute);
|
|
3737
|
+
this.onStopSetListener.next(this.currentStop);
|
|
3738
|
+
this.setNavStep(newStopRoute.properties.step);
|
|
3739
|
+
return this.currentStop;
|
|
3740
|
+
}
|
|
3741
|
+
else {
|
|
3742
|
+
console.error(`Route not found`);
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
3745
|
+
/**
|
|
3746
|
+
* @memberof Map
|
|
3747
|
+
* @name getStopSetListener
|
|
3748
|
+
* @returns returns stop set listener
|
|
3749
|
+
* @example
|
|
3750
|
+
* const map = new Proximiio.Map();
|
|
3751
|
+
* map.getStopSetListener().subscribe(stop => {
|
|
3752
|
+
* console.log('new stop has been set', stop);
|
|
3753
|
+
* });
|
|
3754
|
+
*/
|
|
3755
|
+
getStopSetListener() {
|
|
3756
|
+
return this.onStopSetListener;
|
|
3757
|
+
}
|
|
3612
3758
|
/**
|
|
3613
3759
|
* This method will return turn by turn text navigation object.
|
|
3614
3760
|
* @memberof Map
|
|
@@ -9,7 +9,11 @@ export default class Routing {
|
|
|
9
9
|
setData(collection: FeatureCollection): void;
|
|
10
10
|
toggleOnlyAccessible(onlyAccessible: any): void;
|
|
11
11
|
setConfig(config: WayfindingConfigModel): void;
|
|
12
|
-
route(start
|
|
12
|
+
route({ start, finish, stops }: {
|
|
13
|
+
start: Feature;
|
|
14
|
+
finish?: Feature;
|
|
15
|
+
stops?: Feature[];
|
|
16
|
+
}): {
|
|
13
17
|
paths: any;
|
|
14
18
|
points: any;
|
|
15
19
|
route: {};
|
|
@@ -60,19 +60,50 @@ export default class Routing {
|
|
|
60
60
|
setConfig(config) {
|
|
61
61
|
this.wayfinding.setConfiguration(config);
|
|
62
62
|
}
|
|
63
|
-
route(start, finish) {
|
|
63
|
+
route({ start, finish, stops }) {
|
|
64
|
+
const isMultipoint = stops && stops.length > 1;
|
|
64
65
|
let points = null;
|
|
65
66
|
let details = null;
|
|
66
|
-
if (
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
if (isMultipoint) {
|
|
68
|
+
for (const [index, stop] of stops.entries()) {
|
|
69
|
+
const isFirstStop = index === 0;
|
|
70
|
+
if (this.routeWithDetails) {
|
|
71
|
+
const res = this.wayfinding.runAStarWithDetails(isFirstStop ? start : stops[index - 1], stop);
|
|
72
|
+
points = points ? points.concat(res.path) : res.path;
|
|
73
|
+
if (!details) {
|
|
74
|
+
details = {
|
|
75
|
+
distance: res.distance,
|
|
76
|
+
duration: res.duration,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
details.distance += res.distance;
|
|
81
|
+
details.duration.elevator += res.duration.elevator;
|
|
82
|
+
details.duration.escalator += res.duration.escalator;
|
|
83
|
+
details.duration.staircase += res.duration.staircase;
|
|
84
|
+
details.duration.realistic += res.duration.realistic;
|
|
85
|
+
details.duration.shortest += res.duration.shortest;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
points = points
|
|
90
|
+
? points.concat(this.wayfinding.runAStar(start, stop))
|
|
91
|
+
: this.wayfinding.runAStar(isFirstStop ? start : stops[index - 1], stop);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
73
94
|
}
|
|
74
95
|
else {
|
|
75
|
-
|
|
96
|
+
if (this.routeWithDetails) {
|
|
97
|
+
const res = this.wayfinding.runAStarWithDetails(start, finish);
|
|
98
|
+
points = res.path;
|
|
99
|
+
details = {
|
|
100
|
+
distance: res.distance,
|
|
101
|
+
duration: res.duration,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
points = this.wayfinding.runAStar(start, finish);
|
|
106
|
+
}
|
|
76
107
|
}
|
|
77
108
|
if (!points) {
|
|
78
109
|
return null;
|
|
@@ -83,6 +114,7 @@ export default class Routing {
|
|
|
83
114
|
const pathPoints = {};
|
|
84
115
|
let pathPartIndex = 0;
|
|
85
116
|
points.forEach((p, index) => {
|
|
117
|
+
var _a;
|
|
86
118
|
if (this.forceFloorLevel !== null && this.forceFloorLevel !== undefined) {
|
|
87
119
|
if (typeof pathPoints['path-part-'.concat(pathPartIndex)] === 'undefined') {
|
|
88
120
|
pathPoints['path-part-'.concat(pathPartIndex)] = [];
|
|
@@ -100,9 +132,13 @@ export default class Routing {
|
|
|
100
132
|
if (p.isLevelChanger && p.properties.level !== points[index + 1].properties.level) {
|
|
101
133
|
pathPartIndex++;
|
|
102
134
|
}
|
|
135
|
+
else if (p.isPoi && p.id === ((_a = points[index + 1]) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
136
|
+
pathPartIndex++;
|
|
137
|
+
}
|
|
103
138
|
}
|
|
104
139
|
});
|
|
105
140
|
const paths = {};
|
|
141
|
+
let stopIndex = 0;
|
|
106
142
|
for (const [key, pointsList] of Object.entries(pathPoints)) {
|
|
107
143
|
if (this.forceFloorLevel !== null && this.forceFloorLevel !== undefined) {
|
|
108
144
|
// @ts-ignore
|
|
@@ -126,12 +162,20 @@ export default class Routing {
|
|
|
126
162
|
paths[key] = new Feature(point(pointsList[0].geometry.coordinates));
|
|
127
163
|
}
|
|
128
164
|
}
|
|
165
|
+
if (isMultipoint &&
|
|
166
|
+
pointsList[0].isPoi &&
|
|
167
|
+
pointsList[0].id &&
|
|
168
|
+
stops.findIndex((i) => i.id === pointsList[0].id) !== -1) {
|
|
169
|
+
stopIndex++;
|
|
170
|
+
}
|
|
129
171
|
paths[key].id = key;
|
|
130
172
|
// @ts-ignore
|
|
131
173
|
paths[key].properties = {
|
|
132
174
|
// @ts-ignore
|
|
133
175
|
level: pointsList[pointsList.length - 1].properties.level,
|
|
134
176
|
amenity: 'chevron_right',
|
|
177
|
+
step: +key.split('-')[2],
|
|
178
|
+
stop: stopIndex,
|
|
135
179
|
};
|
|
136
180
|
}
|
|
137
181
|
const levelPaths = {};
|
|
@@ -10,6 +10,7 @@ export default class RoutingSource extends DataSource {
|
|
|
10
10
|
isEditable: boolean;
|
|
11
11
|
start?: Feature;
|
|
12
12
|
finish?: Feature;
|
|
13
|
+
stops?: Feature[];
|
|
13
14
|
lines?: Feature[];
|
|
14
15
|
changes: ChangeContainer[];
|
|
15
16
|
route: any;
|
|
@@ -32,13 +33,15 @@ export default class RoutingSource extends DataSource {
|
|
|
32
33
|
language: string;
|
|
33
34
|
navigationType: 'mall' | 'city';
|
|
34
35
|
fullPath?: Feature;
|
|
36
|
+
isMultipoint: boolean;
|
|
35
37
|
constructor();
|
|
36
38
|
toggleAccessible(value: any): void;
|
|
37
39
|
setConfig(config: WayfindingConfigModel): void;
|
|
38
40
|
setNavigationType(type: 'mall' | 'city'): void;
|
|
39
|
-
update({ start, finish, preview, language, }: {
|
|
41
|
+
update({ start, finish, stops, preview, language, }: {
|
|
40
42
|
start?: Feature;
|
|
41
43
|
finish?: Feature;
|
|
44
|
+
stops?: Feature[];
|
|
42
45
|
preview?: boolean;
|
|
43
46
|
language: string;
|
|
44
47
|
}): Promise<void>;
|
|
@@ -15,6 +15,7 @@ export default class RoutingSource extends DataSource {
|
|
|
15
15
|
constructor() {
|
|
16
16
|
super('route');
|
|
17
17
|
this.isEditable = false;
|
|
18
|
+
this.isMultipoint = false;
|
|
18
19
|
this.changes = [];
|
|
19
20
|
this.routing = new Routing();
|
|
20
21
|
this.navigationType = 'mall';
|
|
@@ -28,10 +29,13 @@ export default class RoutingSource extends DataSource {
|
|
|
28
29
|
setNavigationType(type) {
|
|
29
30
|
this.navigationType = type;
|
|
30
31
|
}
|
|
31
|
-
update({ start, finish, preview, language, }) {
|
|
32
|
+
update({ start, finish, stops, preview, language, }) {
|
|
32
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
this.isMultipoint = stops && stops.length > 1;
|
|
35
|
+
finish = this.isMultipoint ? stops[stops.length - 1] : finish;
|
|
33
36
|
this.start = start;
|
|
34
37
|
this.finish = finish;
|
|
38
|
+
this.stops = stops;
|
|
35
39
|
this.preview = preview;
|
|
36
40
|
this.language = language;
|
|
37
41
|
this.data = new FeatureCollection({
|
|
@@ -42,7 +46,7 @@ export default class RoutingSource extends DataSource {
|
|
|
42
46
|
this.notify('loading-start');
|
|
43
47
|
const route = this.navigationType === 'city'
|
|
44
48
|
? yield this.routing.cityRoute({ start, finish, language: this.language })
|
|
45
|
-
: this.routing.route(start, finish);
|
|
49
|
+
: this.routing.route({ start, finish, stops });
|
|
46
50
|
// @ts-ignore
|
|
47
51
|
const paths = route === null || route === void 0 ? void 0 : route.paths;
|
|
48
52
|
// @ts-ignore
|
package/lib/models/feature.d.ts
CHANGED
package/lib/models/feature.js
CHANGED
|
@@ -91,6 +91,9 @@ export default class Feature extends BaseModel {
|
|
|
91
91
|
get isLevelChanger() {
|
|
92
92
|
return this.isElevator || this.isEscalator || this.isStairCase || this.isRamp;
|
|
93
93
|
}
|
|
94
|
+
get isPoi() {
|
|
95
|
+
return this.properties.type === POI_TYPE.POI;
|
|
96
|
+
}
|
|
94
97
|
get isText() {
|
|
95
98
|
return this.properties.type === 'text';
|
|
96
99
|
}
|