@abi-software/flatmap-viewer 2.3.0-b.2 → 2.3.2-b.1
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/README.rst +1 -1
- package/package.json +1 -1
- package/src/annotation.js +137 -17
- package/src/controls/controls.js +133 -229
- package/src/controls/info.js +2 -0
- package/src/controls/paths.js +143 -0
- package/src/controls/systems.js +18 -9
- package/src/flatmap-viewer.js +14 -25
- package/src/interactions.js +150 -165
- package/src/layers.js +2 -2
- package/src/pathways.js +110 -93
- package/src/styling.js +71 -48
- package/src/systems.js +54 -31
- package/src/utils.js +18 -0
- package/static/css/flatmap-viewer.css +12 -0
- package/src/controls/newcontrols.js +0 -617
- package/src/editor.js +0 -198
package/src/interactions.js
CHANGED
|
@@ -35,17 +35,17 @@ import polylabel from 'polylabel';
|
|
|
35
35
|
|
|
36
36
|
import {Annotator} from './annotation';
|
|
37
37
|
import {LayerManager} from './layers';
|
|
38
|
-
import {PATHWAYS_LAYER,
|
|
39
|
-
import {
|
|
38
|
+
import {PATHWAYS_LAYER, PathManager} from './pathways';
|
|
39
|
+
import {VECTOR_TILES_SOURCE} from './styling';
|
|
40
40
|
import {SystemsManager} from './systems';
|
|
41
41
|
|
|
42
42
|
import {displayedProperties, InfoControl} from './controls/info';
|
|
43
43
|
import {BackgroundControl, LayerControl, NerveControl,
|
|
44
|
-
|
|
44
|
+
SCKANControl} from './controls/controls';
|
|
45
|
+
import {PathControl} from './controls/paths';
|
|
45
46
|
import {SearchControl} from './controls/search';
|
|
46
47
|
import {SystemsControl} from './controls/systems';
|
|
47
48
|
|
|
48
|
-
import * as pathways from './pathways';
|
|
49
49
|
import * as utils from './utils';
|
|
50
50
|
|
|
51
51
|
//==============================================================================
|
|
@@ -104,8 +104,6 @@ export class UserInteractions
|
|
|
104
104
|
this._infoControl = null;
|
|
105
105
|
this._tooltip = null;
|
|
106
106
|
|
|
107
|
-
this._disabledPathFeatures = false;
|
|
108
|
-
|
|
109
107
|
this._inQuery = false;
|
|
110
108
|
this._modal = false;
|
|
111
109
|
|
|
@@ -132,18 +130,21 @@ export class UserInteractions
|
|
|
132
130
|
|
|
133
131
|
this._layerManager = new LayerManager(flatmap);
|
|
134
132
|
|
|
133
|
+
this.__featureEnabledCount = new Map(Array.from(this._flatmap.annotations.keys()).map(k => [+k, 0]));
|
|
134
|
+
|
|
135
|
+
const featuresEnabled = flatmap.options.style !== 'functional';
|
|
136
|
+
|
|
135
137
|
// Path visibility is either controlled externally or by a local control
|
|
138
|
+
// FC path visiblitity is determined by system visiblity
|
|
136
139
|
|
|
137
|
-
this.
|
|
140
|
+
this.__pathManager = new PathManager(flatmap, this, featuresEnabled);
|
|
138
141
|
|
|
139
142
|
// The path types in this map
|
|
140
|
-
const mapPathTypes = this.
|
|
143
|
+
const mapPathTypes = this.__pathManager.pathTypes();
|
|
141
144
|
|
|
142
|
-
//
|
|
145
|
+
// Set initial enabled state of paths
|
|
143
146
|
for (const path of mapPathTypes) {
|
|
144
|
-
|
|
145
|
-
this.enablePath(path.type, false);
|
|
146
|
-
}
|
|
147
|
+
this.__pathManager.enablePathsByType(path.type, path.enabled, true);
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
// Add annotation capability
|
|
@@ -155,7 +156,7 @@ export class UserInteractions
|
|
|
155
156
|
|
|
156
157
|
// Note features that are FC systems
|
|
157
158
|
|
|
158
|
-
this.__systemsManager = new SystemsManager(this._flatmap, this);
|
|
159
|
+
this.__systemsManager = new SystemsManager(this._flatmap, this, featuresEnabled);
|
|
159
160
|
|
|
160
161
|
// Add various controls when running standalone
|
|
161
162
|
|
|
@@ -177,9 +178,9 @@ export class UserInteractions
|
|
|
177
178
|
this._map.addControl(new LayerControl(flatmap, this._layerManager));
|
|
178
179
|
|
|
179
180
|
// Add a control for nerve centrelines if they are present
|
|
180
|
-
if (this.
|
|
181
|
+
if (this.__pathManager.haveCentrelines) {
|
|
181
182
|
this._map.addControl(new NerveControl(flatmap, this._layerManager, {showCentrelines: false}));
|
|
182
|
-
this.enableCentrelines(false);
|
|
183
|
+
this.enableCentrelines(false, true);
|
|
183
184
|
}
|
|
184
185
|
|
|
185
186
|
// SCKAN path and SYSTEMS controls for FC maps
|
|
@@ -203,10 +204,10 @@ export class UserInteractions
|
|
|
203
204
|
this.__pan_zoom_enabled = false;
|
|
204
205
|
}
|
|
205
206
|
|
|
206
|
-
get
|
|
207
|
-
|
|
207
|
+
get pathManager()
|
|
208
|
+
//===============
|
|
208
209
|
{
|
|
209
|
-
return this.
|
|
210
|
+
return this.__pathManager;
|
|
210
211
|
}
|
|
211
212
|
|
|
212
213
|
getState()
|
|
@@ -247,7 +248,7 @@ export class UserInteractions
|
|
|
247
248
|
{
|
|
248
249
|
// Add annotation capability
|
|
249
250
|
|
|
250
|
-
this.__annotator = new Annotator(this._flatmap);
|
|
251
|
+
this.__annotator = new Annotator(this._flatmap, this);
|
|
251
252
|
const annotated_features = await this.__annotator.annotated_features();
|
|
252
253
|
|
|
253
254
|
// Flag features that have annotations
|
|
@@ -302,32 +303,64 @@ export class UserInteractions
|
|
|
302
303
|
return this.__systemsManager.systems;
|
|
303
304
|
}
|
|
304
305
|
|
|
305
|
-
enableSystem(
|
|
306
|
-
|
|
306
|
+
enableSystem(systemId, enable=true)
|
|
307
|
+
//=================================
|
|
307
308
|
{
|
|
308
|
-
this.__systemsManager.enable(
|
|
309
|
+
this.__systemsManager.enable(systemId, enable);
|
|
309
310
|
}
|
|
310
311
|
|
|
311
|
-
|
|
312
|
-
|
|
312
|
+
mapFeature(featureId)
|
|
313
|
+
//===================
|
|
314
|
+
{
|
|
315
|
+
const ann = this._flatmap.annotation(featureId);
|
|
316
|
+
if (ann !== undefined) {
|
|
317
|
+
return {
|
|
318
|
+
id: featureId,
|
|
319
|
+
source: VECTOR_TILES_SOURCE,
|
|
320
|
+
sourceLayer: (this._flatmap.options.separateLayers
|
|
321
|
+
? `${ann['layer']}_${ann['tile-layer']}`
|
|
322
|
+
: ann['tile-layer']).replaceAll('/', '_'),
|
|
323
|
+
children: ann.children || []
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
return undefined;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
enableMapFeature(feature, enable=true)
|
|
330
|
+
//====================================
|
|
313
331
|
{
|
|
314
|
-
const feature = this.mapFeature(featureId);
|
|
315
332
|
if (feature !== undefined) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
333
|
+
if (enable) {
|
|
334
|
+
this._map.removeFeatureState(feature, 'hidden');
|
|
335
|
+
} else {
|
|
336
|
+
this._map.setFeatureState(feature, { 'hidden': true });
|
|
319
337
|
}
|
|
338
|
+
this.__enableFeatureMarker(feature.id, enable);
|
|
320
339
|
}
|
|
321
340
|
}
|
|
322
341
|
|
|
323
|
-
|
|
342
|
+
enableFeature(featureId, enable=true, force=false)
|
|
324
343
|
//================================================
|
|
344
|
+
{
|
|
345
|
+
const enabledCount = this.__featureEnabledCount.get(+featureId)
|
|
346
|
+
if (force || enable && enabledCount === 0 || !enable && enabledCount == 1) {
|
|
347
|
+
this.enableMapFeature(this.mapFeature(featureId), enable)
|
|
348
|
+
}
|
|
349
|
+
if (force) {
|
|
350
|
+
this.__featureEnabledCount.set(+featureId, enable ? 1 : 0);
|
|
351
|
+
} else {
|
|
352
|
+
this.__featureEnabledCount.set(+featureId, enabledCount + (enable ? 1 : -1));
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
enableFeatureWithChildren(featureId, enable=true, force=false)
|
|
357
|
+
//============================================================
|
|
325
358
|
{
|
|
326
359
|
const feature = this.mapFeature(featureId);
|
|
327
360
|
if (feature !== undefined) {
|
|
328
|
-
this.enableFeature(
|
|
329
|
-
for (const childFeatureId of feature.
|
|
330
|
-
this.
|
|
361
|
+
this.enableFeature(featureId, enable, force);
|
|
362
|
+
for (const childFeatureId of feature.children) {
|
|
363
|
+
this.enableFeatureWithChildren(childFeatureId, enable, force);
|
|
331
364
|
}
|
|
332
365
|
}
|
|
333
366
|
}
|
|
@@ -344,34 +377,12 @@ export class UserInteractions
|
|
|
344
377
|
}
|
|
345
378
|
}
|
|
346
379
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
{
|
|
350
|
-
if (feature !== undefined) {
|
|
351
|
-
if (enable) {
|
|
352
|
-
this._map.removeFeatureState(feature, 'hidden');
|
|
353
|
-
} else {
|
|
354
|
-
this._map.setFeatureState(feature, { 'hidden': true });
|
|
355
|
-
}
|
|
356
|
-
this.__enableFeatureMarker(feature.id, enable);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
mapFeature(featureId)
|
|
361
|
-
//===================
|
|
380
|
+
__featureEnabled(feature)
|
|
381
|
+
//=======================
|
|
362
382
|
{
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
id: featureId,
|
|
367
|
-
source: VECTOR_TILES_SOURCE,
|
|
368
|
-
sourceLayer: (this._flatmap.options.separateLayers
|
|
369
|
-
? `${ann['layer']}_${ann['tile-layer']}`
|
|
370
|
-
: ann['tile-layer']).replaceAll('/', '_'),
|
|
371
|
-
children: ann.children || []
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
return undefined;
|
|
383
|
+
const state = this._map.getFeatureState(feature);
|
|
384
|
+
return (state !== undefined
|
|
385
|
+
&& (!('hidden' in state) || !state.hidden));
|
|
375
386
|
}
|
|
376
387
|
|
|
377
388
|
featureSelected_(featureId)
|
|
@@ -380,8 +391,8 @@ export class UserInteractions
|
|
|
380
391
|
return this._selectedFeatureIds.has(+featureId);
|
|
381
392
|
}
|
|
382
393
|
|
|
383
|
-
|
|
384
|
-
|
|
394
|
+
selectFeature(featureId, dim=true)
|
|
395
|
+
//================================
|
|
385
396
|
{
|
|
386
397
|
featureId = +featureId; // Ensure numeric
|
|
387
398
|
if (this._selectedFeatureIds.size === 0) {
|
|
@@ -398,8 +409,8 @@ export class UserInteractions
|
|
|
398
409
|
}
|
|
399
410
|
}
|
|
400
411
|
|
|
401
|
-
|
|
402
|
-
|
|
412
|
+
unselectFeature(featureId)
|
|
413
|
+
//========================
|
|
403
414
|
{
|
|
404
415
|
featureId = +featureId; // Ensure numeric
|
|
405
416
|
if (this._selectedFeatureIds.has(featureId)) {
|
|
@@ -419,8 +430,8 @@ export class UserInteractions
|
|
|
419
430
|
}
|
|
420
431
|
}
|
|
421
432
|
|
|
422
|
-
|
|
423
|
-
|
|
433
|
+
unselectFeatures()
|
|
434
|
+
//================
|
|
424
435
|
{
|
|
425
436
|
for (const featureId of this._selectedFeatureIds.keys()) {
|
|
426
437
|
const feature = this.mapFeature(featureId);
|
|
@@ -433,7 +444,7 @@ export class UserInteractions
|
|
|
433
444
|
}
|
|
434
445
|
|
|
435
446
|
__activateFeature(feature)
|
|
436
|
-
|
|
447
|
+
//========================
|
|
437
448
|
{
|
|
438
449
|
if (feature !== undefined) {
|
|
439
450
|
this._map.setFeatureState(feature, { active: true });
|
|
@@ -499,16 +510,15 @@ export class UserInteractions
|
|
|
499
510
|
//=====
|
|
500
511
|
{
|
|
501
512
|
this.__clearModal();
|
|
502
|
-
this.
|
|
503
|
-
this.
|
|
504
|
-
this.
|
|
505
|
-
this._disabledPathFeatures = false;
|
|
513
|
+
this.__clearActiveMarker();
|
|
514
|
+
this.unselectFeatures();
|
|
515
|
+
this.__enablePathFeatures(this.__pathManager.allFeatureIds(), true);
|
|
506
516
|
}
|
|
507
517
|
|
|
508
518
|
clearSearchResults(reset=true)
|
|
509
519
|
//============================
|
|
510
520
|
{
|
|
511
|
-
this.
|
|
521
|
+
this.unselectFeatures();
|
|
512
522
|
}
|
|
513
523
|
|
|
514
524
|
/**
|
|
@@ -526,7 +536,7 @@ export class UserInteractions
|
|
|
526
536
|
if (annotation) {
|
|
527
537
|
this.highlightFeature_(featureId);
|
|
528
538
|
if ('type' in annotation && annotation.type.startsWith('line')) {
|
|
529
|
-
for (const pathFeatureId of this.
|
|
539
|
+
for (const pathFeatureId of this.__pathManager.lineFeatureIds([featureId])) {
|
|
530
540
|
this.highlightFeature_(pathFeatureId);
|
|
531
541
|
}
|
|
532
542
|
}
|
|
@@ -544,14 +554,14 @@ export class UserInteractions
|
|
|
544
554
|
//========================
|
|
545
555
|
{
|
|
546
556
|
if (featureIds.length) {
|
|
547
|
-
this.
|
|
557
|
+
this.unselectFeatures();
|
|
548
558
|
for (const featureId of featureIds) {
|
|
549
559
|
const annotation = this._flatmap.annotation(featureId);
|
|
550
560
|
if (annotation) {
|
|
551
|
-
this.
|
|
561
|
+
this.selectFeature(featureId);
|
|
552
562
|
if ('type' in annotation && annotation.type.startsWith('line')) {
|
|
553
|
-
for (const pathFeatureId of this.
|
|
554
|
-
this.
|
|
563
|
+
for (const pathFeatureId of this.__pathManager.lineFeatureIds([featureId])) {
|
|
564
|
+
this.selectFeature(pathFeatureId);
|
|
555
565
|
}
|
|
556
566
|
}
|
|
557
567
|
}
|
|
@@ -588,7 +598,7 @@ export class UserInteractions
|
|
|
588
598
|
const highlight = (options.highlight === true);
|
|
589
599
|
if (featureIds.length) {
|
|
590
600
|
this.unhighlightFeatures_();
|
|
591
|
-
if (select) this.
|
|
601
|
+
if (select) this.unselectFeatures();
|
|
592
602
|
let bbox = null;
|
|
593
603
|
if (options.noZoomIn) {
|
|
594
604
|
const bounds = this._map.getBounds().toArray();
|
|
@@ -598,15 +608,15 @@ export class UserInteractions
|
|
|
598
608
|
const annotation = this._flatmap.annotation(featureId);
|
|
599
609
|
if (annotation) {
|
|
600
610
|
if (select) {
|
|
601
|
-
this.
|
|
611
|
+
this.selectFeature(featureId);
|
|
602
612
|
} else if (highlight) {
|
|
603
613
|
this.highlightFeature_(featureId);
|
|
604
614
|
}
|
|
605
615
|
bbox = expandBounds(bbox, annotation.bounds);
|
|
606
616
|
if ('type' in annotation && annotation.type.startsWith('line')) {
|
|
607
|
-
for (const pathFeatureId of this.
|
|
617
|
+
for (const pathFeatureId of this.__pathManager.lineFeatureIds([featureId])) {
|
|
608
618
|
if (select) {
|
|
609
|
-
this.
|
|
619
|
+
this.selectFeature(pathFeatureId);
|
|
610
620
|
} else if (highlight) {
|
|
611
621
|
this.highlightFeature_(pathFeatureId);
|
|
612
622
|
}
|
|
@@ -639,8 +649,8 @@ export class UserInteractions
|
|
|
639
649
|
|
|
640
650
|
// Highlight the feature
|
|
641
651
|
|
|
642
|
-
this.
|
|
643
|
-
this.
|
|
652
|
+
this.unselectFeatures();
|
|
653
|
+
this.selectFeature(featureId);
|
|
644
654
|
|
|
645
655
|
// Find the pop-up's postion
|
|
646
656
|
|
|
@@ -675,7 +685,7 @@ export class UserInteractions
|
|
|
675
685
|
//============
|
|
676
686
|
{
|
|
677
687
|
this.__clearModal();
|
|
678
|
-
this.
|
|
688
|
+
this.unselectFeatures();
|
|
679
689
|
}
|
|
680
690
|
|
|
681
691
|
removeTooltip_()
|
|
@@ -746,7 +756,7 @@ export class UserInteractions
|
|
|
746
756
|
{
|
|
747
757
|
if (feature.sourceLayer === PATHWAYS_LAYER) { // I suspect this is never true as source layer
|
|
748
758
|
// names are like `neural_routes_pathways`
|
|
749
|
-
return this._flatmap.featureEvent(type, this.
|
|
759
|
+
return this._flatmap.featureEvent(type, this.__pathManager.pathProperties(feature));
|
|
750
760
|
} else if ('properties' in feature) {
|
|
751
761
|
return this._flatmap.featureEvent(type, feature.properties);
|
|
752
762
|
}
|
|
@@ -785,7 +795,7 @@ export class UserInteractions
|
|
|
785
795
|
|
|
786
796
|
// Get all the features at the current point
|
|
787
797
|
const features = this._map.queryRenderedFeatures(event.point)
|
|
788
|
-
.filter(feature => this.
|
|
798
|
+
.filter(feature => this.__featureEnabled(feature));
|
|
789
799
|
if (features.length === 0) {
|
|
790
800
|
this._lastFeatureMouseEntered = null;
|
|
791
801
|
this._lastFeatureModelsMouse = null;
|
|
@@ -821,13 +831,15 @@ export class UserInteractions
|
|
|
821
831
|
const lineFeatures = features.filter(feature => ('centreline' in feature.properties
|
|
822
832
|
|| ('type' in feature.properties
|
|
823
833
|
&& feature.properties.type.startsWith('line')) ));
|
|
834
|
+
let tooltipFeature = null;
|
|
824
835
|
if (lineFeatures.length > 0) {
|
|
825
836
|
tooltip = this.lineTooltip_(lineFeatures);
|
|
837
|
+
tooltipFeature = lineFeatures[0];
|
|
826
838
|
for (const lineFeature of lineFeatures) {
|
|
827
839
|
const lineFeatureId = +lineFeature.properties.featureId; // Ensure numeric
|
|
828
840
|
this.__activateFeature(lineFeature);
|
|
829
841
|
const lineIds = new Set(lineFeatures.map(f => f.properties.featureId));
|
|
830
|
-
for (const featureId of this.
|
|
842
|
+
for (const featureId of this.__pathManager.lineFeatureIds(lineIds)) {
|
|
831
843
|
if (+featureId !== lineFeatureId) {
|
|
832
844
|
this.__activateFeature(this.mapFeature(featureId));
|
|
833
845
|
}
|
|
@@ -850,6 +862,7 @@ export class UserInteractions
|
|
|
850
862
|
}
|
|
851
863
|
const feature = labelledFeatures[0];
|
|
852
864
|
tooltip = this.tooltipHtml_(feature.properties);
|
|
865
|
+
tooltipFeature = feature;
|
|
853
866
|
if (this._flatmap.options.debug) { // Do this when Info on and not debug??
|
|
854
867
|
const debugProperties = [
|
|
855
868
|
'featureId',
|
|
@@ -888,11 +901,11 @@ export class UserInteractions
|
|
|
888
901
|
if (displayInfo || this._flatmap.options.debug) {
|
|
889
902
|
this._infoControl.show(info);
|
|
890
903
|
}
|
|
891
|
-
this.__showToolTip(tooltip, event.lngLat);
|
|
904
|
+
this.__showToolTip(tooltip, event.lngLat, tooltipFeature);
|
|
892
905
|
}
|
|
893
906
|
|
|
894
|
-
__showToolTip(html, lngLat)
|
|
895
|
-
|
|
907
|
+
__showToolTip(html, lngLat, feature=null)
|
|
908
|
+
//=======================================
|
|
896
909
|
{
|
|
897
910
|
// Show a tooltip
|
|
898
911
|
if (html !== '') {
|
|
@@ -906,7 +919,10 @@ export class UserInteractions
|
|
|
906
919
|
const pt = turf.point(lngLat.toArray());
|
|
907
920
|
const gps = turfProjection.toMercator(pt);
|
|
908
921
|
const coords = gps.geometry.coordinates;
|
|
909
|
-
|
|
922
|
+
const header = (feature === null)
|
|
923
|
+
? JSON.stringify(coords)
|
|
924
|
+
: `${JSON.stringify(coords)} (${feature.id} ${feature.properties['id']})`;
|
|
925
|
+
html = `<span>${header}</span><br/>${html}`;
|
|
910
926
|
}
|
|
911
927
|
this._tooltip
|
|
912
928
|
.setLngLat(lngLat)
|
|
@@ -931,27 +947,27 @@ export class UserInteractions
|
|
|
931
947
|
break;
|
|
932
948
|
}
|
|
933
949
|
}
|
|
934
|
-
this.
|
|
950
|
+
this.unselectFeatures();
|
|
935
951
|
if (selecting) {
|
|
936
952
|
for (const feature of this._activeFeatures) {
|
|
937
|
-
this.
|
|
953
|
+
this.selectFeature(feature.id, dim);
|
|
938
954
|
}
|
|
939
955
|
}
|
|
940
956
|
} else {
|
|
941
957
|
const clickedSelected = this.featureSelected_(clickedFeatureId);
|
|
942
958
|
for (const feature of this._activeFeatures) {
|
|
943
959
|
if (clickedSelected) {
|
|
944
|
-
this.
|
|
960
|
+
this.unselectFeature(feature.id);
|
|
945
961
|
} else {
|
|
946
|
-
this.
|
|
962
|
+
this.selectFeature(feature.id, dim);
|
|
947
963
|
}
|
|
948
964
|
}
|
|
949
965
|
}
|
|
950
966
|
}
|
|
951
967
|
}
|
|
952
968
|
|
|
953
|
-
__annotationEvent(
|
|
954
|
-
|
|
969
|
+
__annotationEvent(features)
|
|
970
|
+
//=========================
|
|
955
971
|
{
|
|
956
972
|
if (!this.__annotator) {
|
|
957
973
|
return;
|
|
@@ -962,15 +978,12 @@ export class UserInteractions
|
|
|
962
978
|
// Remove any tooltip
|
|
963
979
|
this.removeTooltip_();
|
|
964
980
|
|
|
965
|
-
// Select the feature
|
|
966
|
-
this.selectFeature_(feature.id);
|
|
967
|
-
|
|
968
981
|
// Don't respond to mouse events while the dialog is open
|
|
969
982
|
this.setModal_();
|
|
970
983
|
|
|
971
984
|
// The annotation dialog...
|
|
972
|
-
this.__annotator.annotate(
|
|
973
|
-
this.
|
|
985
|
+
this.__annotator.annotate(features, () => {
|
|
986
|
+
this.unselectFeatures();
|
|
974
987
|
this.__clearModal();
|
|
975
988
|
});
|
|
976
989
|
}
|
|
@@ -982,25 +995,25 @@ export class UserInteractions
|
|
|
982
995
|
return;
|
|
983
996
|
}
|
|
984
997
|
|
|
985
|
-
this.
|
|
998
|
+
this.__clearActiveMarker();
|
|
986
999
|
const clickedFeatures = this._map.queryRenderedFeatures(event.point)
|
|
987
|
-
.filter(feature => this.
|
|
1000
|
+
.filter(feature => this.__featureEnabled(feature));
|
|
988
1001
|
if (clickedFeatures.length == 0){
|
|
989
|
-
this.
|
|
1002
|
+
this.unselectFeatures();
|
|
990
1003
|
return;
|
|
991
1004
|
}
|
|
992
|
-
const clickedFeature = clickedFeatures[0];
|
|
993
1005
|
const originalEvent = event.originalEvent;
|
|
994
1006
|
if (originalEvent.altKey) {
|
|
995
|
-
this.__annotationEvent(
|
|
1007
|
+
this.__annotationEvent(clickedFeatures);
|
|
996
1008
|
return;
|
|
997
1009
|
}
|
|
998
1010
|
|
|
1011
|
+
const clickedFeature = clickedFeatures[0];
|
|
999
1012
|
this.selectionEvent_(originalEvent, clickedFeature);
|
|
1000
1013
|
if (this._modal) {
|
|
1001
1014
|
// Remove tooltip, reset active features, etc
|
|
1002
1015
|
this.__resetFeatureDisplay();
|
|
1003
|
-
this.
|
|
1016
|
+
this.unselectFeatures();
|
|
1004
1017
|
this.__clearModal();
|
|
1005
1018
|
} else if (clickedFeature !== undefined) {
|
|
1006
1019
|
this.__lastClickLngLat = event.lngLat;
|
|
@@ -1015,93 +1028,65 @@ export class UserInteractions
|
|
|
1015
1028
|
//================================
|
|
1016
1029
|
{
|
|
1017
1030
|
if ('nerveId' in feature.properties) {
|
|
1018
|
-
|
|
1031
|
+
const nerveId = feature.properties.nerveId;
|
|
1032
|
+
if (nerveId !== feature.id) {
|
|
1033
|
+
this.__activateFeature(this.mapFeature(nerveId));
|
|
1034
|
+
}
|
|
1035
|
+
for (const featureId of this.__pathManager.nerveFeatureIds(nerveId)) {
|
|
1019
1036
|
this.__activateFeature(this.mapFeature(featureId));
|
|
1020
1037
|
}
|
|
1021
1038
|
}
|
|
1022
1039
|
if ('nodeId' in feature.properties) {
|
|
1023
|
-
for (const featureId of this.
|
|
1040
|
+
for (const featureId of this.__pathManager.nodeFeatureIds(feature.properties.nodeId)) {
|
|
1024
1041
|
this.__activateFeature(this.mapFeature(featureId));
|
|
1025
1042
|
}
|
|
1026
1043
|
}
|
|
1027
1044
|
}
|
|
1028
1045
|
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
{
|
|
1032
|
-
const state = this._map.getFeatureState(feature);
|
|
1033
|
-
return (state !== undefined
|
|
1034
|
-
&& (!('hidden' in state) || !state.hidden));
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
enablePaths_(enable, event)
|
|
1038
|
-
//=========================
|
|
1039
|
-
{
|
|
1040
|
-
const nodeId = event.target.getAttribute('featureId');
|
|
1041
|
-
this.enablePathFeatures_(enable, this._pathways.pathFeatureIds(nodeId));
|
|
1042
|
-
this.__clearModal();
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
enablePathFeatures_(enable, featureIds)
|
|
1046
|
-
//=====================================
|
|
1046
|
+
enablePath(pathId, enable=true)
|
|
1047
|
+
//=============================
|
|
1047
1048
|
{
|
|
1048
|
-
|
|
1049
|
-
const feature = this.mapFeature(featureId);
|
|
1050
|
-
if (feature !== undefined) {
|
|
1051
|
-
if (enable) {
|
|
1052
|
-
this._map.removeFeatureState(feature, 'hidden');
|
|
1053
|
-
} else {
|
|
1054
|
-
this._map.setFeatureState(feature, { 'hidden': true });
|
|
1055
|
-
this._disabledPathFeatures = true;
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1049
|
+
this.__pathManager.enablePath(pathId, enable);
|
|
1059
1050
|
}
|
|
1060
1051
|
|
|
1061
|
-
|
|
1062
|
-
|
|
1052
|
+
enablePathsBySystem(system, enable=true, force=false)
|
|
1053
|
+
//===================================================
|
|
1063
1054
|
{
|
|
1064
|
-
|
|
1065
|
-
if (this._disabledPathFeatures){
|
|
1066
|
-
this.enablePathFeatures_(true, this._pathways.allFeatureIds());
|
|
1067
|
-
this._disabledPathFeatures = false;
|
|
1068
|
-
} else {
|
|
1069
|
-
this.enablePathFeatures_(false, this._pathways.allFeatureIds());
|
|
1070
|
-
}
|
|
1055
|
+
this.__pathManager.enablePathsBySystem(system, enable, force);
|
|
1071
1056
|
}
|
|
1072
1057
|
|
|
1073
|
-
|
|
1074
|
-
|
|
1058
|
+
enablePathsByType(pathType, enable=true)
|
|
1059
|
+
//======================================
|
|
1075
1060
|
{
|
|
1076
|
-
this.
|
|
1061
|
+
this.__pathManager.enablePathsByType(pathType, enable);
|
|
1077
1062
|
}
|
|
1078
1063
|
|
|
1079
|
-
|
|
1080
|
-
|
|
1064
|
+
pathFeatureIds(externalIds)
|
|
1065
|
+
//=========================
|
|
1081
1066
|
{
|
|
1082
1067
|
const featureIds = new utils.List();
|
|
1083
|
-
featureIds.extend(this.
|
|
1084
|
-
featureIds.extend(this.
|
|
1068
|
+
featureIds.extend(this.__pathManager.connectivityModelFeatureIds(externalIds));
|
|
1069
|
+
featureIds.extend(this.__pathManager.pathModelFeatureIds(externalIds));
|
|
1085
1070
|
return featureIds;
|
|
1086
1071
|
}
|
|
1087
1072
|
|
|
1088
1073
|
nodePathModels(nodeId)
|
|
1089
1074
|
//====================
|
|
1090
1075
|
{
|
|
1091
|
-
return this.
|
|
1076
|
+
return this.__pathManager.nodePathModels(nodeId);
|
|
1092
1077
|
}
|
|
1093
1078
|
|
|
1094
|
-
enableCentrelines(
|
|
1095
|
-
|
|
1079
|
+
enableCentrelines(enable=true, force=false)
|
|
1080
|
+
//=========================================
|
|
1096
1081
|
{
|
|
1097
|
-
this.
|
|
1098
|
-
this._layerManager.setPaint({showCentrelines:
|
|
1082
|
+
this.__pathManager.enablePathsByType('centreline', enable, force);
|
|
1083
|
+
this._layerManager.setPaint({showCentrelines: enable});
|
|
1099
1084
|
}
|
|
1100
1085
|
|
|
1101
|
-
|
|
1102
|
-
|
|
1086
|
+
enableSckanPaths(sckanState, enable=true)
|
|
1087
|
+
//=======================================
|
|
1103
1088
|
{
|
|
1104
|
-
this._layerManager.
|
|
1089
|
+
this._layerManager.enableSckanPaths(sckanState, enable);
|
|
1105
1090
|
}
|
|
1106
1091
|
|
|
1107
1092
|
//==============================================================================
|
|
@@ -1278,7 +1263,7 @@ export class UserInteractions
|
|
|
1278
1263
|
event.stopPropagation();
|
|
1279
1264
|
}
|
|
1280
1265
|
|
|
1281
|
-
|
|
1266
|
+
__clearActiveMarker()
|
|
1282
1267
|
//==================
|
|
1283
1268
|
{
|
|
1284
1269
|
if (this.__activeMarker !== null) {
|
|
@@ -1292,7 +1277,7 @@ export class UserInteractions
|
|
|
1292
1277
|
{
|
|
1293
1278
|
const marker = this.__activeMarker;
|
|
1294
1279
|
if (markerId !== this.__markerIdByMarker.get(marker)) {
|
|
1295
|
-
this.
|
|
1280
|
+
this.__clearActiveMarker();
|
|
1296
1281
|
return false;
|
|
1297
1282
|
}
|
|
1298
1283
|
|
|
@@ -1311,7 +1296,7 @@ export class UserInteractions
|
|
|
1311
1296
|
element.innerHTML = content;
|
|
1312
1297
|
}
|
|
1313
1298
|
|
|
1314
|
-
element.addEventListener('click', e => this.
|
|
1299
|
+
element.addEventListener('click', e => this.__clearActiveMarker());
|
|
1315
1300
|
|
|
1316
1301
|
this._tooltip = new maplibre.Popup({
|
|
1317
1302
|
closeButton: false,
|
package/src/layers.js
CHANGED
|
@@ -331,8 +331,8 @@ export class LayerManager
|
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
enableSckanPaths(sckanState, enable=true)
|
|
335
|
+
//=======================================
|
|
336
336
|
{
|
|
337
337
|
const currentState = this.__layerOptions.sckan;
|
|
338
338
|
const validEnabled = ['valid', 'all'].indexOf(currentState) >= 0;
|