@abi-software/flatmap-viewer 2.4.1-b.1 → 2.4.1-b.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/README.rst +1 -1
- package/package.json +1 -1
- package/src/controls/taxons.js +73 -0
- package/src/flatmap-viewer.js +16 -5
- package/src/interactions.js +15 -5
- package/src/styling.js +14 -8
package/README.rst
CHANGED
|
@@ -38,7 +38,7 @@ The map server endpoint is specified as ``MAP_ENDPOINT`` in ``src/main.js``. It
|
|
|
38
38
|
Package Installation
|
|
39
39
|
====================
|
|
40
40
|
|
|
41
|
-
* ``npm install @abi-software/flatmap-viewer@2.4.1-b.
|
|
41
|
+
* ``npm install @abi-software/flatmap-viewer@2.4.1-b.2``
|
|
42
42
|
|
|
43
43
|
Documentation
|
|
44
44
|
-------------
|
package/package.json
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
|
|
3
|
+
Flatmap viewer and annotation tool
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2019 - 2023 David Brooks
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
|
|
19
|
+
**/
|
|
20
|
+
//==============================================================================
|
|
21
|
+
|
|
22
|
+
import { Control } from './controls';
|
|
23
|
+
|
|
24
|
+
//==============================================================================
|
|
25
|
+
|
|
26
|
+
export class TaxonsControl extends Control
|
|
27
|
+
{
|
|
28
|
+
constructor(flatmap)
|
|
29
|
+
{
|
|
30
|
+
super(flatmap, 'taxon', 'taxons');
|
|
31
|
+
this.__taxonIds = flatmap.taxonIdentifiers.sort();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_addControlDetails()
|
|
35
|
+
//==================
|
|
36
|
+
{
|
|
37
|
+
let lines = 0;
|
|
38
|
+
let enabled = 0;
|
|
39
|
+
for (const taxonId of this.__taxonIds) {
|
|
40
|
+
const input = this._addControlLine(`${this.__prefix}${taxonId}`, taxonId);
|
|
41
|
+
input.checked = true;
|
|
42
|
+
enabled += 1;
|
|
43
|
+
lines += 1;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
enabled: enabled,
|
|
47
|
+
total: lines
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_enableAll(enable)
|
|
52
|
+
//================
|
|
53
|
+
{
|
|
54
|
+
for (const taxonId of this.__taxonIds) {
|
|
55
|
+
const checkbox = document.getElementById(`${this.__prefix}${taxonId}`);
|
|
56
|
+
if (checkbox) {
|
|
57
|
+
checkbox.checked = enable;
|
|
58
|
+
this.__flatmap.enableConnectivityByTaxonIds(taxonId, enable);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
__enableControl(id, enable)
|
|
64
|
+
//=========================
|
|
65
|
+
{
|
|
66
|
+
for (const taxonId of this.__taxonIds) {
|
|
67
|
+
if (id === taxonId) {
|
|
68
|
+
this.__flatmap.enableConnectivityByTaxonIds(taxonId, enable);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
}
|
package/src/flatmap-viewer.js
CHANGED
|
@@ -49,6 +49,15 @@ const MAP_MAKER_SEPARATE_LAYERS_VERSION = 1.4;
|
|
|
49
49
|
|
|
50
50
|
//==============================================================================
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* The taxon identifier used when none has been given.
|
|
54
|
+
*
|
|
55
|
+
* @type {string}
|
|
56
|
+
*/
|
|
57
|
+
export const UNCLASSIFIED_TAXON_ID = 'NCBITaxon:2787823'; // unclassified entries
|
|
58
|
+
|
|
59
|
+
//==============================================================================
|
|
60
|
+
|
|
52
61
|
/**
|
|
53
62
|
* Maps are not created directly but instead are created and loaded by
|
|
54
63
|
* :meth:`LoadMap` of :class:`MapManager`.
|
|
@@ -543,18 +552,20 @@ class FlatMap
|
|
|
543
552
|
}
|
|
544
553
|
}
|
|
545
554
|
|
|
546
|
-
__updateFeatureIdMap(property, featureIdMap, annotation)
|
|
547
|
-
|
|
555
|
+
__updateFeatureIdMap(property, featureIdMap, annotation, missingId=null)
|
|
556
|
+
//======================================================================
|
|
548
557
|
{
|
|
549
|
-
if (property in annotation) {
|
|
558
|
+
if (property in annotation && annotation[property].length) {
|
|
550
559
|
const propertyId = annotation[property];
|
|
551
560
|
if (Array.isArray(propertyId)) {
|
|
552
561
|
for (const id of propertyId) {
|
|
553
562
|
this.__updateFeatureIdMapEntry(id, featureIdMap, annotation.featureId);
|
|
554
563
|
}
|
|
555
564
|
} else {
|
|
556
|
-
this.__updateFeatureIdMapEntry(propertyId, featureIdMap, annotation.featureId)
|
|
565
|
+
this.__updateFeatureIdMapEntry(propertyId, featureIdMap, annotation.featureId);
|
|
557
566
|
}
|
|
567
|
+
} else if (missingId !== null) {
|
|
568
|
+
this.__updateFeatureIdMapEntry(missingId, featureIdMap, annotation.featureId);
|
|
558
569
|
}
|
|
559
570
|
}
|
|
560
571
|
|
|
@@ -566,7 +577,7 @@ class FlatMap
|
|
|
566
577
|
this.__updateFeatureIdMap('dataset', this.__datasetToFeatureIds, ann);
|
|
567
578
|
this.__updateFeatureIdMap('models', this.__modelToFeatureIds, ann);
|
|
568
579
|
this.__updateFeatureIdMap('source', this.__mapSourceToFeatureIds, ann);
|
|
569
|
-
this.__updateFeatureIdMap('taxons', this.__taxonToFeatureIds, ann);
|
|
580
|
+
this.__updateFeatureIdMap('taxons', this.__taxonToFeatureIds, ann, UNCLASSIFIED_TAXON_ID);
|
|
570
581
|
this.__annIdToFeatureId.set(ann.id, featureId);
|
|
571
582
|
}
|
|
572
583
|
|
package/src/interactions.js
CHANGED
|
@@ -45,6 +45,7 @@ import {AnnotatedControl, BackgroundControl, LayerControl, NerveControl,
|
|
|
45
45
|
import {PathControl} from './controls/paths';
|
|
46
46
|
import {SearchControl} from './controls/search';
|
|
47
47
|
import {SystemsControl} from './controls/systems';
|
|
48
|
+
import {TaxonsControl} from './controls/taxons';
|
|
48
49
|
|
|
49
50
|
import * as utils from './utils';
|
|
50
51
|
|
|
@@ -159,11 +160,12 @@ export class UserInteractions
|
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
// Note features that are FC systems
|
|
162
|
-
|
|
163
163
|
this.__systemsManager = new SystemsManager(this._flatmap, this, featuresEnabled);
|
|
164
164
|
|
|
165
|
-
//
|
|
165
|
+
// All taxons of connectivity paths are enabled by default
|
|
166
|
+
this.__enabledConnectivityTaxons = new Set(this._flatmap.taxonIdentifiers);
|
|
166
167
|
|
|
168
|
+
// Add various controls when running standalone
|
|
167
169
|
if (flatmap.options.standalone) {
|
|
168
170
|
// Add a control to search annotations if option set
|
|
169
171
|
this._map.addControl(new SearchControl(flatmap));
|
|
@@ -186,11 +188,14 @@ export class UserInteractions
|
|
|
186
188
|
this._map.addControl(new NerveControl(flatmap, this._layerManager, {showCentrelines: false}));
|
|
187
189
|
}
|
|
188
190
|
|
|
189
|
-
// SCKAN path and SYSTEMS controls for FC maps
|
|
190
191
|
if (flatmap.options.style === 'functional') {
|
|
192
|
+
// SCKAN path and SYSTEMS controls for FC maps
|
|
191
193
|
this._map.addControl(new SystemsControl(flatmap, this.__systemsManager.systems));
|
|
192
194
|
this._map.addControl(new SCKANControl(flatmap, flatmap.options.layerOptions));
|
|
193
195
|
this._map.addControl(new AnnotatedControl(this, flatmap.options.layerOptions));
|
|
196
|
+
} else {
|
|
197
|
+
// Connectivity taxon control for AC maps
|
|
198
|
+
this._map.addControl(new TaxonsControl(flatmap));
|
|
194
199
|
}
|
|
195
200
|
}
|
|
196
201
|
|
|
@@ -1136,10 +1141,15 @@ export class UserInteractions
|
|
|
1136
1141
|
//=================================================
|
|
1137
1142
|
{
|
|
1138
1143
|
if (enable) {
|
|
1139
|
-
|
|
1144
|
+
for (const taxonId of taxonIds) {
|
|
1145
|
+
this.__enabledConnectivityTaxons.add(taxonId);
|
|
1146
|
+
}
|
|
1140
1147
|
} else {
|
|
1141
|
-
|
|
1148
|
+
for (const taxonId of taxonIds) {
|
|
1149
|
+
this.__enabledConnectivityTaxons.delete(taxonId);
|
|
1150
|
+
}
|
|
1142
1151
|
}
|
|
1152
|
+
this._layerManager.setFilter({taxons: [...this.__enabledConnectivityTaxons.values()]});
|
|
1143
1153
|
}
|
|
1144
1154
|
|
|
1145
1155
|
excludeAnnotated(exclude=false)
|
package/src/styling.js
CHANGED
|
@@ -26,7 +26,8 @@ export const VECTOR_TILES_SOURCE = 'vector-tiles';
|
|
|
26
26
|
|
|
27
27
|
//==============================================================================
|
|
28
28
|
|
|
29
|
-
import {
|
|
29
|
+
import {UNCLASSIFIED_TAXON_ID} from './flatmap-viewer';
|
|
30
|
+
import {PATH_STYLE_RULES} from './pathways';
|
|
30
31
|
|
|
31
32
|
//==============================================================================
|
|
32
33
|
|
|
@@ -482,14 +483,19 @@ export class PathLineLayer extends VectorStyleLayer
|
|
|
482
483
|
const sckan_filter = sckanFilter(options);
|
|
483
484
|
let taxonFilter = [];
|
|
484
485
|
if ('taxons' in options) {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
486
|
+
if (options.taxons.length) {
|
|
487
|
+
taxonFilter.push('any');
|
|
488
|
+
for (const taxon of options.taxons) {
|
|
489
|
+
if (taxon !== UNCLASSIFIED_TAXON_ID) {
|
|
490
|
+
taxonFilter.push(['in', taxon, ['get', 'taxons']]);
|
|
491
|
+
} else {
|
|
492
|
+
taxonFilter.push(['case', ['has', 'taxons'], false, true]);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
taxonFilter = [taxonFilter];
|
|
496
|
+
} else {
|
|
497
|
+
taxonFilter.push(false);
|
|
490
498
|
}
|
|
491
|
-
taxonFilter.push(filterList);
|
|
492
|
-
taxonFilter = [taxonFilter];
|
|
493
499
|
}
|
|
494
500
|
|
|
495
501
|
return this.__dashed ? [
|