@abi-software/flatmap-viewer 2.2.10-devel.2 → 2.2.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/flatmap-viewer",
3
- "version": "2.2.10-devel.2",
3
+ "version": "2.2.10",
4
4
  "description": "Flatmap viewer using Maplibre GL",
5
5
  "repository": "https://github.com/AnatomicMaps/flatmap-viewer.git",
6
6
  "main": "src/main.js",
package/src/controls.js CHANGED
@@ -22,7 +22,6 @@ limitations under the License.
22
22
 
23
23
  //==============================================================================
24
24
 
25
- import * as pathways from './pathways.js';
26
25
 
27
26
  //==============================================================================
28
27
 
@@ -91,10 +90,11 @@ export class NavigationControl
91
90
 
92
91
  export class PathControl
93
92
  {
94
- constructor(flatmap)
93
+ constructor(flatmap, pathTypes)
95
94
  {
96
95
  this._flatmap = flatmap;
97
96
  this._map = undefined;
97
+ this.__pathTypes = pathTypes;
98
98
  }
99
99
 
100
100
  getDefaultPosition()
@@ -117,11 +117,11 @@ export class PathControl
117
117
 
118
118
  const innerHTML = [];
119
119
  innerHTML.push(`<label for="path-all-paths">ALL PATHS:</label><div class="nerve-line"></div><input id="path-all-paths" type="checkbox" checked/>`);
120
- for (const path of pathways.PATH_TYPES) {
120
+ for (const path of this.__pathTypes) {
121
121
  innerHTML.push(`<label for="path-${path.type}">${path.label}</label><div class="nerve-line nerve-${path.type}"></div><input id="path-${path.type}" type="checkbox" checked/>`);
122
122
  }
123
123
  this._legend.innerHTML = innerHTML.join('\n');
124
- this.__checkedCount = pathways.PATH_TYPES.length;
124
+ this.__checkedCount = this.__pathTypes.length;
125
125
  this.__halfCount = Math.trunc(this.__checkedCount/2);
126
126
 
127
127
  this._button = document.createElement('button');
@@ -164,11 +164,11 @@ export class PathControl
164
164
  event.target.indeterminate = false;
165
165
  }
166
166
  if (event.target.checked) {
167
- this.__checkedCount = pathways.PATH_TYPES.length;
167
+ this.__checkedCount = this.__pathTypes.length;
168
168
  } else {
169
169
  this.__checkedCount = 0;
170
170
  }
171
- for (const path of pathways.PATH_TYPES) {
171
+ for (const path of this.__pathTypes) {
172
172
  const pathCheckbox = document.getElementById(`path-${path.type}`);
173
173
  if (pathCheckbox) {
174
174
  pathCheckbox.checked = event.target.checked;
@@ -187,7 +187,7 @@ export class PathControl
187
187
  if (this.__checkedCount === 0) {
188
188
  allPathsCheckbox.checked = false;
189
189
  allPathsCheckbox.indeterminate = false;
190
- } else if (this.__checkedCount === pathways.PATH_TYPES.length) {
190
+ } else if (this.__checkedCount === this.__pathTypes.length) {
191
191
  allPathsCheckbox.checked = true;
192
192
  allPathsCheckbox.indeterminate = false;
193
193
  } else {
@@ -37,7 +37,7 @@ import {ContextMenu} from './contextmenu.js';
37
37
  import {displayedProperties} from './info.js';
38
38
  import {InfoControl} from './info.js';
39
39
  import {LayerManager} from './layers.js';
40
- import {PATHWAYS_LAYER, Pathways} from './pathways.js';
40
+ import {PATH_TYPES, PATHWAYS_LAYER, Pathways} from './pathways.js';
41
41
  import {BackgroundControl, LayerControl, PathControl} from './controls.js';
42
42
  import {SearchControl} from './search.js';
43
43
  import {VECTOR_TILES_SOURCE} from './styling.js';
@@ -163,7 +163,8 @@ export class UserInteractions
163
163
  // Add a control to manage our pathways
164
164
 
165
165
  if (flatmap.options.pathControls) {
166
- this._map.addControl(new PathControl(flatmap));
166
+ // Restrict to path types that are on the map...
167
+ this._map.addControl(new PathControl(flatmap, this._pathways.pathTypes));
167
168
  }
168
169
 
169
170
  // Add a control to manage our layers
@@ -672,9 +673,9 @@ export class UserInteractions
672
673
  : '';
673
674
  if ('hyperlink' in properties) {
674
675
  if (label === '') {
675
- return `<div class='flatmap-feature-label'><a href='{properties.hyperlink}'>${properties.hyperlink}</a></div>`;
676
+ return `<div class='flatmap-feature-label'><a href='${properties.hyperlink}'>${properties.hyperlink}</a></div>`;
676
677
  } else {
677
- return `<div class='flatmap-feature-label'><a href='{properties.hyperlink}'>${properties.hyperlink}</a><br/>${label}</div>`;
678
+ return `<div class='flatmap-feature-label'><a href='${properties.hyperlink}'>${label}</a></div>`;
678
679
  }
679
680
  } else {
680
681
  return `<div class='flatmap-feature-label'>${label}</div>`;
package/src/pathways.js CHANGED
@@ -38,6 +38,9 @@ export const PATH_TYPES = [
38
38
  { type: "other", label: "Other neuron type", colour: "#888"}
39
39
  ];
40
40
 
41
+ export const PATH_STYLE_RULES =
42
+ PATH_TYPES.flatMap(pathType => [['==', ['get', 'kind'], pathType.type], pathType.colour]);
43
+
41
44
  //==============================================================================
42
45
 
43
46
  function reverseMap(mapping)
@@ -138,6 +141,19 @@ export class Pathways
138
141
  }
139
142
  }
140
143
 
144
+ get pathTypes()
145
+ //=============
146
+ {
147
+ const pathTypes = [];
148
+ for (const pathType of PATH_TYPES) {
149
+ if (pathType.type in this.__typePaths
150
+ && this.__typePaths[pathType.type].length > 0) {
151
+ pathTypes.push(pathType);
152
+ }
153
+ }
154
+ return pathTypes;
155
+ }
156
+
141
157
  addPathsToFeatureSet_(paths, featureSet)
142
158
  //======================================
143
159
  {
package/src/styling.js CHANGED
@@ -26,6 +26,10 @@ export const VECTOR_TILES_SOURCE = 'vector-tiles';
26
26
 
27
27
  //==============================================================================
28
28
 
29
+ import {PATH_STYLE_RULES} from './pathways.js';
30
+
31
+ //==============================================================================
32
+
29
33
  class VectorStyleLayer
30
34
  {
31
35
  constructor(id, suffix, sourceLayer)
@@ -370,24 +374,17 @@ export class PathLineLayer extends VectorStyleLayer
370
374
  ['==', ['get', 'type'], 'bezier'], 'red',
371
375
  ['==', ['get', 'kind'], 'error'], '#FFFE0E',
372
376
  ['==', ['get', 'kind'], 'unknown'], '#888',
373
- ['==', ['get', 'kind'], 'cns'], '#9B1FC1',
374
- ['==', ['get', 'kind'], 'lcn'], '#F19E38',
375
- ['==', ['get', 'kind'], 'para-post'], '#3F8F4A',
376
- ['==', ['get', 'kind'], 'para-pre'], '#3F8F4A',
377
- ['==', ['get', 'kind'], 'somatic'], '#98561D',
378
- ['==', ['get', 'kind'], 'sensory'], '#2A62F6',
379
- ['==', ['get', 'kind'], 'symp-post'], '#EA3423',
380
- ['==', ['get', 'kind'], 'symp-pre'], '#EA3423',
377
+ ...PATH_STYLE_RULES,
381
378
  '#888'
382
379
  ],
383
380
  'line-opacity': [
384
381
  'case',
385
- ['boolean', ['feature-state', 'hidden'], false], 0.1,
382
+ ['boolean', ['feature-state', 'hidden'], false], 0.05,
386
383
  ['==', ['get', 'type'], 'bezier'], 1.0,
387
384
  ['boolean', ['get', 'invisible'], false], 0.001,
388
385
  ['boolean', ['feature-state', 'selected'], false], 1.0,
389
- ['boolean', ['feature-state', 'active'], false], 0.8,
390
- dimmed ? 0.1 : 0.5
386
+ ['boolean', ['feature-state', 'active'], false], 1.0,
387
+ dimmed ? 0.1 : 0.8
391
388
  ],
392
389
  'line-width': [
393
390
  'let',
@@ -398,7 +395,7 @@ export class PathLineLayer extends VectorStyleLayer
398
395
  ['==', ['get', 'kind'], 'unknown'], 1,
399
396
  ['boolean', ['get', 'invisible'], false], 0.1,
400
397
  ['boolean', ['feature-state', 'selected'], false], 1.2,
401
- ['boolean', ['feature-state', 'active'], false], 0.9,
398
+ ['boolean', ['feature-state', 'active'], false], 1.2,
402
399
  0.8
403
400
  ], [
404
401
  'interpolate',
@@ -570,14 +567,7 @@ export class NervePolygonFill extends VectorStyleLayer
570
567
  'case',
571
568
  ['==', ['get', 'kind'], 'bezier-end'], 'red',
572
569
  ['==', ['get', 'kind'], 'bezier-control'], 'green',
573
- ['==', ['get', 'kind'], 'cns'], '#9B1FC1',
574
- ['==', ['get', 'kind'], 'lcn'], '#F19E38',
575
- ['==', ['get', 'kind'], 'para-post'], '#3F8F4A',
576
- ['==', ['get', 'kind'], 'para-pre'], '#3F8F4A',
577
- ['==', ['get', 'kind'], 'somatic'], '#98561D',
578
- ['==', ['get', 'kind'], 'sensory'], '#2A62F6',
579
- ['==', ['get', 'kind'], 'symp-post'], '#EA3423',
580
- ['==', ['get', 'kind'], 'symp-pre'], '#EA3423',
570
+ ...PATH_STYLE_RULES,
581
571
  'white'
582
572
  ],
583
573
  'fill-opacity': [