@abi-software/flatmap-viewer 2.2.8 → 2.3.0-a.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/flatmap-viewer",
3
- "version": "2.2.8",
3
+ "version": "2.3.0-a.1",
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
 
@@ -77,10 +76,11 @@ export class NavigationControl
77
76
 
78
77
  export class PathControl
79
78
  {
80
- constructor(flatmap)
79
+ constructor(flatmap, pathways)
81
80
  {
82
81
  this._flatmap = flatmap;
83
82
  this._map = undefined;
83
+ this.__pathTypes = pathways.pathTypes;
84
84
  }
85
85
 
86
86
  getDefaultPosition()
@@ -103,11 +103,11 @@ export class PathControl
103
103
 
104
104
  const innerHTML = [];
105
105
  innerHTML.push(`<label for="path-all-paths">ALL PATHS:</label><input id="path-all-paths" type="checkbox" checked/><div class="nerve-line"></div>`);
106
- for (const path of pathways.PATH_TYPES) {
106
+ for (const path of this.__pathTypes) {
107
107
  innerHTML.push(`<label for="path-${path.type}">${path.label}</label><input id="path-${path.type}" type="checkbox" checked/><div class="nerve-line nerve-${path.type}"></div>`);
108
108
  }
109
109
  this._legend.innerHTML = innerHTML.join('\n');
110
- this.__checkedCount = pathways.PATH_TYPES.length;
110
+ this.__checkedCount = this.__pathTypes.length;
111
111
  this.__halfCount = Math.trunc(this.__checkedCount/2);
112
112
 
113
113
  this._button = document.createElement('button');
@@ -150,11 +150,11 @@ export class PathControl
150
150
  event.target.indeterminate = false;
151
151
  }
152
152
  if (event.target.checked) {
153
- this.__checkedCount = pathways.PATH_TYPES.length;
153
+ this.__checkedCount = this.__pathTypes.length;
154
154
  } else {
155
155
  this.__checkedCount = 0;
156
156
  }
157
- for (const path of pathways.PATH_TYPES) {
157
+ for (const path of this.__pathTypes) {
158
158
  const pathCheckbox = document.getElementById(`path-${path.type}`);
159
159
  if (pathCheckbox) {
160
160
  pathCheckbox.checked = event.target.checked;
@@ -173,7 +173,7 @@ export class PathControl
173
173
  if (this.__checkedCount === 0) {
174
174
  allPathsCheckbox.checked = false;
175
175
  allPathsCheckbox.indeterminate = false;
176
- } else if (this.__checkedCount === pathways.PATH_TYPES.length) {
176
+ } else if (this.__checkedCount === this.__pathTypes.length) {
177
177
  allPathsCheckbox.checked = true;
178
178
  allPathsCheckbox.indeterminate = false;
179
179
  } else {
@@ -281,7 +281,9 @@ class FlatMap
281
281
  pathTypes()
282
282
  //=========
283
283
  {
284
- return pathways.PATH_TYPES;
284
+ if (this._userInteractions !== null) {
285
+ return this._userInteractions.pathTypes();
286
+ }
285
287
  }
286
288
 
287
289
  /**
@@ -151,8 +151,7 @@ export class UserInteractions
151
151
 
152
152
  if (flatmap.options.pathControls) {
153
153
  // Add controls to manage our pathways
154
-
155
- this._map.addControl(new PathControl(flatmap));
154
+ this._map.addControl(new PathControl(flatmap, this._pathways));
156
155
  }
157
156
 
158
157
  // Manage our layers
@@ -966,6 +965,12 @@ export class UserInteractions
966
965
  }
967
966
  }
968
967
 
968
+ pathTypes()
969
+ //=========
970
+ {
971
+ return this._pathways.pathTypes;
972
+ }
973
+
969
974
  enablePath(pathType, enable=true)
970
975
  //===============================
971
976
  {
package/src/pathways.js CHANGED
@@ -26,17 +26,18 @@ export const PATHWAYS_LAYER = 'pathways';
26
26
 
27
27
  //==============================================================================
28
28
 
29
- export const PATH_TYPES = [
30
- { type: "cns", label: "CNS", colour: "#9B1FC1"},
31
- { type: "lcn", label: "Local circuit neuron", colour: "#F19E38"},
32
- { type: "para-pre", label: "Parasympathetic pre-ganglionic", colour: "#3F8F4A"},
33
- { type: "para-post", label: "Parasympathetic post-ganglionic", colour: "#3F8F4A"},
34
- { type: "sensory", label: "Sensory (afferent) neuron", colour: "#2A62F6"},
35
- { type: "somatic", label: "Somatic lower motor", colour: "#98561D"},
36
- { type: "symp-pre", label: "Sympathetic pre-ganglionic", colour: "#EA3423"},
37
- { type: "symp-post", label: "Sympathetic post-ganglionic", colour: "#EA3423"},
38
- { type: "other", label: "Other neuron type", colour: "#888"}
39
- ];
29
+ const PATH_TYPES = {
30
+ "cns": {label: "CNS", colour: "#9B1FC1"},
31
+ "lcn": {label: "Local circuit neuron", colour: "#F19E38"},
32
+ "para-pre": {label: "Parasympathetic pre-ganglionic", colour: "#3F8F4A"},
33
+ "para-post": {label: "Parasympathetic post-ganglionic", colour: "#3F8F4A"},
34
+ "sensory": {label: "Sensory (afferent) neuron", colour: "#2A62F6"},
35
+ "somatic": {label: "Somatic lower motor", colour: "#98561D"},
36
+ "symp-pre": {label: "Sympathetic pre-ganglionic", colour: "#EA3423"},
37
+ "symp-post": {label: "Sympathetic post-ganglionic", colour: "#EA3423"},
38
+ "other": {label: "Other neuron type", colour: "#888"},
39
+ "centreline": {label: "Nerve centrelines", colour: "#CC0"}
40
+ };
40
41
 
41
42
  //==============================================================================
42
43
 
@@ -121,21 +122,27 @@ export class Pathways
121
122
  }
122
123
  this._allFeatureIds = featureIds;
123
124
 
124
- // Construct a list of path types we know about
125
- const pathTypes = [];
126
- for (const pathType of PATH_TYPES) {
127
- pathTypes.push(pathType.type);
128
- }
129
125
  // Map unknown path types to ``other``
130
126
  this.__typePaths = {};
131
127
  this.__typePaths['other'] = [];
128
+ this.__knownPathTypes = [];
132
129
  for (const [pathType, paths] of Object.entries(flatmap.pathways['type-paths'])) {
133
- if (pathTypes.indexOf(pathType) >= 0) {
130
+ if (pathType in PATH_TYPES && pathType !== 'other') {
134
131
  this.__typePaths[pathType] = paths;
132
+ this.__knownPathTypes.push({'type': pathType, ...PATH_TYPES[pathType]});
135
133
  } else {
136
134
  this.__typePaths['other'].push(...paths);
137
135
  }
138
136
  }
137
+ if ('other' in this.__typePaths) {
138
+ this.__knownPathTypes.push({'type': 'other', ...PATH_TYPES['other']});
139
+ }
140
+ }
141
+
142
+ get pathTypes()
143
+ //=============
144
+ {
145
+ return this.__knownPathTypes;
139
146
  }
140
147
 
141
148
  addPathsToFeatureSet_(paths, featureSet)
package/src/styling.js CHANGED
@@ -346,7 +346,8 @@ export class PathLineLayer extends VectorStyleLayer
346
346
  [
347
347
  'any',
348
348
  ['==', 'type', 'bezier'],
349
- ['==', 'type', `line`]
349
+ ['==', 'kind', 'centreline'],
350
+ ['==', 'type', 'line']
350
351
  ];
351
352
  this.__dashed = dashed;
352
353
  }
@@ -369,6 +370,7 @@ export class PathLineLayer extends VectorStyleLayer
369
370
  ['==', ['get', 'kind'], 'sensory'], '#2A62F6',
370
371
  ['==', ['get', 'kind'], 'symp-post'], '#EA3423',
371
372
  ['==', ['get', 'kind'], 'symp-pre'], '#EA3423',
373
+ ['==', ['get', 'kind'], 'centreline'], '#CC0',
372
374
  '#888'
373
375
  ],
374
376
  'line-opacity': [
@@ -378,6 +380,7 @@ export class PathLineLayer extends VectorStyleLayer
378
380
  ['boolean', ['get', 'invisible'], false], 0.001,
379
381
  ['boolean', ['feature-state', 'selected'], false], 1.0,
380
382
  ['boolean', ['feature-state', 'active'], false], 0.8,
383
+ ['==', ['get', 'kind'], 'centreline'], 0.2,
381
384
  dimmed ? 0.1 : 0.5
382
385
  ],
383
386
  'line-width': [
@@ -385,6 +388,7 @@ export class PathLineLayer extends VectorStyleLayer
385
388
  'width', [
386
389
  'case',
387
390
  ['==', ['get', 'type'], 'bezier'], 0.1,
391
+ ['==', ['get', 'kind'], 'centreline'], 2,
388
392
  ['==', ['get', 'kind'], 'error'], 1,
389
393
  ['==', ['get', 'kind'], 'unknown'], 1,
390
394
  ['boolean', ['get', 'invisible'], false], 0.1,
@@ -452,6 +456,7 @@ export class FeatureNerveLayer extends VectorStyleLayer
452
456
  'filter': [
453
457
  'all',
454
458
  ['==', '$type', 'LineString'],
459
+ ['!=', 'kind', 'centreline'],
455
460
  ['==', 'type', 'nerve']
456
461
  ],
457
462
  'paint': {
@@ -198,6 +198,9 @@ li.flatmap-contextmenu-item:hover {
198
198
  label[for=path-all-paths] {
199
199
  font-weight: bold;
200
200
  }
201
+ .nerve-centreline {
202
+ background: #CC0;
203
+ }
201
204
  .nerve-cns {
202
205
  background: #9B1FC1;
203
206
  }