@abi-software/flatmap-viewer 2.2.11-devel.1 → 2.2.12-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 +2 -2
- package/src/controls.js +101 -37
- package/src/flatmap-viewer.js +79 -49
- package/src/info.js +5 -5
- package/src/interactions.js +129 -134
- package/src/layers.js +105 -53
- package/src/main.js +1 -7
- package/src/minimap.js +1 -1
- package/src/pathways.js +21 -8
- package/src/search.js +0 -1
- package/src/styling.js +239 -44
- package/static/flatmap-viewer.css +3 -30
- package/src/editor.js +0 -198
- package/src/newcontrols.js +0 -617
package/src/layers.js
CHANGED
|
@@ -20,9 +20,6 @@ limitations under the License.
|
|
|
20
20
|
|
|
21
21
|
'use strict';
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
// See https://stevage.github.io/map-gl-utils/ for layering ideas...
|
|
25
|
-
|
|
26
23
|
//==============================================================================
|
|
27
24
|
|
|
28
25
|
import {PATHWAYS_LAYER} from './pathways.js';
|
|
@@ -38,12 +35,13 @@ const RASTER_LAYERS_ID = 'background-image-layer';
|
|
|
38
35
|
|
|
39
36
|
class MapStylingLayers
|
|
40
37
|
{
|
|
41
|
-
constructor(flatmap,
|
|
38
|
+
constructor(flatmap, layer, options)
|
|
42
39
|
{
|
|
43
40
|
this.__map = flatmap.map;
|
|
44
|
-
this.__id =
|
|
45
|
-
this.
|
|
41
|
+
this.__id = layer.id;
|
|
42
|
+
this.__description = layer.description;
|
|
46
43
|
this.__active = true;
|
|
44
|
+
this.__layers = [];
|
|
47
45
|
this.__layerOptions = options;
|
|
48
46
|
this.__separateLayers = flatmap.options.separateLayers;
|
|
49
47
|
}
|
|
@@ -54,6 +52,12 @@ class MapStylingLayers
|
|
|
54
52
|
return this.__id;
|
|
55
53
|
}
|
|
56
54
|
|
|
55
|
+
get description()
|
|
56
|
+
//===============
|
|
57
|
+
{
|
|
58
|
+
return this.__description;
|
|
59
|
+
}
|
|
60
|
+
|
|
57
61
|
get active()
|
|
58
62
|
//==========
|
|
59
63
|
{
|
|
@@ -88,6 +92,14 @@ class MapStylingLayers
|
|
|
88
92
|
return this.__separateLayers ? `${this.__id}_${sourceLayer}`
|
|
89
93
|
: sourceLayer;
|
|
90
94
|
}
|
|
95
|
+
|
|
96
|
+
setPaint(options)
|
|
97
|
+
{
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
setFilter(options)
|
|
101
|
+
{
|
|
102
|
+
}
|
|
91
103
|
}
|
|
92
104
|
|
|
93
105
|
//==============================================================================
|
|
@@ -96,7 +108,7 @@ class MapFeatureLayers extends MapStylingLayers
|
|
|
96
108
|
{
|
|
97
109
|
constructor(flatmap, layer, options)
|
|
98
110
|
{
|
|
99
|
-
super(flatmap, layer
|
|
111
|
+
super(flatmap, layer, options);
|
|
100
112
|
const vectorTileSource = this.__map.getSource('vector-tiles');
|
|
101
113
|
const haveVectorLayers = (typeof vectorTileSource !== 'undefined');
|
|
102
114
|
|
|
@@ -110,8 +122,10 @@ class MapFeatureLayers extends MapStylingLayers
|
|
|
110
122
|
this.__addStyleLayer(style.FeatureDashLineLayer);
|
|
111
123
|
this.__addStyleLayer(style.FeatureLineLayer);
|
|
112
124
|
this.__addStyleLayer(style.FeatureBorderLayer);
|
|
125
|
+
this.__addStyleLayer(style.CentrelineNodeFillLayer);
|
|
126
|
+
this.__addStyleLayer(style.CentrelineNodeBorderLayer);
|
|
113
127
|
}
|
|
114
|
-
this.__addPathwayStyleLayers(
|
|
128
|
+
this.__addPathwayStyleLayers();
|
|
115
129
|
if (vectorFeatures) {
|
|
116
130
|
this.__addStyleLayer(style.FeatureLargeSymbolLayer);
|
|
117
131
|
if (!flatmap.options.tooltips) {
|
|
@@ -120,9 +134,9 @@ class MapFeatureLayers extends MapStylingLayers
|
|
|
120
134
|
}
|
|
121
135
|
}
|
|
122
136
|
|
|
123
|
-
// Make sure our
|
|
137
|
+
// Make sure our paint options are set properly, in particular raster layer visibility
|
|
124
138
|
|
|
125
|
-
this.
|
|
139
|
+
this.setPaint(this.__layerOptions);
|
|
126
140
|
}
|
|
127
141
|
|
|
128
142
|
__addStyleLayer(styleClass, sourceLayer=FEATURES_LAYER)
|
|
@@ -141,16 +155,20 @@ class MapFeatureLayers extends MapStylingLayers
|
|
|
141
155
|
if (this.__map.getSource('vector-tiles')
|
|
142
156
|
.vectorLayerIds
|
|
143
157
|
.indexOf(pathwaysVectorSource) >= 0) {
|
|
158
|
+
this.__addStyleLayer(style.CentrelineEdgeLayer, PATHWAYS_LAYER);
|
|
159
|
+
this.__addStyleLayer(style.CentrelineTrackLayer, PATHWAYS_LAYER);
|
|
160
|
+
|
|
144
161
|
this.__addStyleLayer(style.PathLineLayer, PATHWAYS_LAYER);
|
|
145
162
|
this.__addStyleLayer(style.PathDashlineLayer, PATHWAYS_LAYER);
|
|
163
|
+
|
|
146
164
|
this.__addStyleLayer(style.NervePolygonBorder, PATHWAYS_LAYER);
|
|
147
165
|
this.__addStyleLayer(style.NervePolygonFill, PATHWAYS_LAYER);
|
|
148
166
|
this.__addStyleLayer(style.FeatureNerveLayer, PATHWAYS_LAYER);
|
|
149
167
|
}
|
|
150
168
|
}
|
|
151
169
|
|
|
152
|
-
|
|
153
|
-
|
|
170
|
+
setPaint(options)
|
|
171
|
+
//===============
|
|
154
172
|
{
|
|
155
173
|
for (const layer of this.__layers) {
|
|
156
174
|
const paintStyle = layer.paintStyle(options, true);
|
|
@@ -159,6 +177,17 @@ class MapFeatureLayers extends MapStylingLayers
|
|
|
159
177
|
}
|
|
160
178
|
}
|
|
161
179
|
}
|
|
180
|
+
|
|
181
|
+
setFilter(options)
|
|
182
|
+
//================
|
|
183
|
+
{
|
|
184
|
+
for (const layer of this.__layers) {
|
|
185
|
+
const filter = layer.makeFilter(options);
|
|
186
|
+
if (filter !== null) {
|
|
187
|
+
this.__map.setFilter(layer.id, filter, {validate: true});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
162
191
|
}
|
|
163
192
|
|
|
164
193
|
//==============================================================================
|
|
@@ -167,7 +196,11 @@ class MapRasterLayers extends MapStylingLayers
|
|
|
167
196
|
{
|
|
168
197
|
constructor(flatmap, options, bodyLayerId=null)
|
|
169
198
|
{
|
|
170
|
-
|
|
199
|
+
const rasterLayer = {
|
|
200
|
+
id: RASTER_LAYERS_ID,
|
|
201
|
+
description: RASTER_LAYERS_NAME
|
|
202
|
+
};
|
|
203
|
+
super(flatmap, rasterLayer, options);
|
|
171
204
|
if (bodyLayerId !== null) {
|
|
172
205
|
const layerId = `${bodyLayerId}_${FEATURES_LAYER}`;
|
|
173
206
|
const source = flatmap.options.separateLayers ? layerId : FEATURES_LAYER;
|
|
@@ -175,8 +208,8 @@ class MapRasterLayers extends MapStylingLayers
|
|
|
175
208
|
this.__map.addLayer(styleLayer.style(this.__layerOptions));
|
|
176
209
|
this.__layers.push(styleLayer);
|
|
177
210
|
}
|
|
178
|
-
// Make sure our
|
|
179
|
-
this.
|
|
211
|
+
// Make sure our paint options are set properly, in particular raster layer visibility
|
|
212
|
+
this.setPaint(this.__layerOptions);
|
|
180
213
|
}
|
|
181
214
|
|
|
182
215
|
addLayer(layer)
|
|
@@ -187,12 +220,12 @@ class MapRasterLayers extends MapStylingLayers
|
|
|
187
220
|
this.__map.addLayer(rasterLayer.style(this.__layerOptions));
|
|
188
221
|
this.__layers.push(rasterLayer);
|
|
189
222
|
}
|
|
190
|
-
// Make sure our
|
|
191
|
-
this.
|
|
223
|
+
// Make sure our paint options are set properly, in particular raster layer visibility
|
|
224
|
+
this.setPaint(this.__layerOptions);
|
|
192
225
|
}
|
|
193
226
|
|
|
194
|
-
|
|
195
|
-
|
|
227
|
+
setPaint(options)
|
|
228
|
+
//===============
|
|
196
229
|
{
|
|
197
230
|
const coloured = !('colour' in options) || options.colour;
|
|
198
231
|
for (const layer of this.__layers) {
|
|
@@ -212,12 +245,12 @@ export class LayerManager
|
|
|
212
245
|
{
|
|
213
246
|
this.__flatmap = flatmap;
|
|
214
247
|
this.__map = flatmap.map;
|
|
215
|
-
this.__layers = new Map;
|
|
216
248
|
this.__mapLayers = new Map;
|
|
217
249
|
this.__layerOptions = utils.setDefaults(flatmap.options.layerOptions, {
|
|
218
250
|
colour: true,
|
|
219
|
-
outline: true
|
|
220
|
-
|
|
251
|
+
outline: true,
|
|
252
|
+
sckan: 'valid'
|
|
253
|
+
});
|
|
221
254
|
const backgroundLayer = new style.BackgroundLayer();
|
|
222
255
|
if ('background' in flatmap.options) {
|
|
223
256
|
this.__map.addLayer(backgroundLayer.style(flatmap.options.background));
|
|
@@ -237,44 +270,29 @@ export class LayerManager
|
|
|
237
270
|
for (const layer of flatmap.layers) {
|
|
238
271
|
rasterLayers.addLayer(layer);
|
|
239
272
|
}
|
|
240
|
-
this.__layers.set(RASTER_LAYERS_ID, {
|
|
241
|
-
id: RASTER_LAYERS_ID,
|
|
242
|
-
description: RASTER_LAYERS_NAME
|
|
243
|
-
});
|
|
244
273
|
this.__mapLayers.set(RASTER_LAYERS_ID, rasterLayers);
|
|
245
274
|
} else {
|
|
246
275
|
this.__layerOptions.activeRasterLayer = false;
|
|
247
276
|
}
|
|
248
277
|
for (const layer of flatmap.layers) {
|
|
249
|
-
|
|
278
|
+
this.__mapLayers.set(layer.id, new MapFeatureLayers(this.__flatmap,
|
|
279
|
+
layer,
|
|
280
|
+
this.__layerOptions));
|
|
250
281
|
}
|
|
251
282
|
}
|
|
252
283
|
|
|
253
|
-
get activeLayerNames()
|
|
254
|
-
//====================
|
|
255
|
-
{
|
|
256
|
-
const activeNames = [];
|
|
257
|
-
for (const mapLayer of this.__mapLayers.values()) {
|
|
258
|
-
if (mapLayer.active) {
|
|
259
|
-
activeNames.push(mapLayer.id);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
return activeNames;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
__addFeatureLayer(layer)
|
|
266
|
-
//======================
|
|
267
|
-
{
|
|
268
|
-
this.__layers.set(layer.id, layer);
|
|
269
|
-
this.__mapLayers.set(layer.id, new MapFeatureLayers(this.__flatmap,
|
|
270
|
-
layer,
|
|
271
|
-
this.__layerOptions));
|
|
272
|
-
}
|
|
273
|
-
|
|
274
284
|
get layers()
|
|
275
285
|
//==========
|
|
276
286
|
{
|
|
277
|
-
|
|
287
|
+
const layers = [];
|
|
288
|
+
for (const mapLayer of this.__mapLayers.values()) {
|
|
289
|
+
layers.push({
|
|
290
|
+
id: mapLayer.id,
|
|
291
|
+
description: mapLayer.description,
|
|
292
|
+
enabled: mapLayer.active
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
return layers;
|
|
278
296
|
}
|
|
279
297
|
|
|
280
298
|
activate(layerId, enable=true)
|
|
@@ -287,19 +305,53 @@ export class LayerManager
|
|
|
287
305
|
this.__layerOptions.activeRasterLayer = enable;
|
|
288
306
|
for (const mapLayer of this.__mapLayers.values()) {
|
|
289
307
|
if (mapLayer.id !== RASTER_LAYERS_ID) {
|
|
290
|
-
mapLayer.
|
|
308
|
+
mapLayer.setPaint(this.__layerOptions);
|
|
291
309
|
}
|
|
292
310
|
}
|
|
293
311
|
}
|
|
294
312
|
}
|
|
295
313
|
}
|
|
296
314
|
|
|
297
|
-
|
|
298
|
-
|
|
315
|
+
setPaint(options={})
|
|
316
|
+
//==================
|
|
317
|
+
{
|
|
318
|
+
this.__layerOptions = utils.setDefaults(options, this.__layerOptions);
|
|
319
|
+
for (const mapLayer of this.__mapLayers.values()) {
|
|
320
|
+
mapLayer.setPaint(this.__layerOptions);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
setFilter(options={})
|
|
325
|
+
//===================
|
|
299
326
|
{
|
|
300
327
|
this.__layerOptions = utils.setDefaults(options, this.__layerOptions);
|
|
301
328
|
for (const mapLayer of this.__mapLayers.values()) {
|
|
302
|
-
mapLayer.
|
|
329
|
+
mapLayer.setFilter(this.__layerOptions);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
enableSckanPath(sckanState, enable=true)
|
|
334
|
+
//======================================
|
|
335
|
+
{
|
|
336
|
+
const currentState = this.__layerOptions.sckan;
|
|
337
|
+
const validEnabled = ['valid', 'all'].indexOf(currentState) >= 0;
|
|
338
|
+
const invalidEnabled = ['invalid', 'all'].indexOf(currentState) >= 0;
|
|
339
|
+
let newState = sckanState.toLowerCase();
|
|
340
|
+
if (newState === 'valid') {
|
|
341
|
+
if (enable && !validEnabled) {
|
|
342
|
+
newState = invalidEnabled ? 'all' : 'valid';
|
|
343
|
+
} else if (!enable && validEnabled) {
|
|
344
|
+
newState = invalidEnabled ? 'invalid' : 'none';
|
|
345
|
+
}
|
|
346
|
+
} else if (newState === 'invalid') {
|
|
347
|
+
if (enable && !invalidEnabled) {
|
|
348
|
+
newState = validEnabled ? 'all' : 'invalid';
|
|
349
|
+
} else if (!enable && invalidEnabled) {
|
|
350
|
+
newState = validEnabled ? 'valid' : 'none';
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (newState !== this.__layerOptions.sckan) {
|
|
354
|
+
this.setFilter({sckan: newState});
|
|
303
355
|
}
|
|
304
356
|
}
|
|
305
357
|
}
|
package/src/main.js
CHANGED
|
@@ -57,14 +57,10 @@ export async function standaloneViewer(map_endpoint=null, options={})
|
|
|
57
57
|
const mapOptions = Object.assign({
|
|
58
58
|
tooltips: true,
|
|
59
59
|
background: defaultBackground,
|
|
60
|
-
backgroundControl: true,
|
|
61
60
|
debug: false,
|
|
62
61
|
minimap: false,
|
|
63
|
-
searchable: true,
|
|
64
|
-
featureInfo: true,
|
|
65
62
|
showPosition: false,
|
|
66
|
-
|
|
67
|
-
layerControl: true
|
|
63
|
+
standalone: true
|
|
68
64
|
}, options);
|
|
69
65
|
|
|
70
66
|
function loadMap(id, taxon, sex)
|
|
@@ -92,8 +88,6 @@ export async function standaloneViewer(map_endpoint=null, options={})
|
|
|
92
88
|
mapManager.loadMap(id, 'map-canvas', (eventType, ...args) => {
|
|
93
89
|
if (args[0].type === 'control' && args[0].control === 'background') {
|
|
94
90
|
mapOptions.background = args[0].value;
|
|
95
|
-
} else if (eventType === 'click') {
|
|
96
|
-
console.log(args);
|
|
97
91
|
}
|
|
98
92
|
}, mapOptions)
|
|
99
93
|
.then(map => {
|
package/src/minimap.js
CHANGED
package/src/pathways.js
CHANGED
|
@@ -26,19 +26,20 @@ export const PATHWAYS_LAYER = 'pathways';
|
|
|
26
26
|
|
|
27
27
|
//==============================================================================
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
const PATH_TYPES = [
|
|
30
30
|
{ type: "cns", label: "CNS", colour: "#9B1FC1"},
|
|
31
31
|
{ type: "intracardiac", label: "Local circuit neuron", colour: "#F19E38"},
|
|
32
|
-
{ type: "lcn", label: "Local circuit neuron", colour: "#F19E38"},
|
|
33
32
|
{ type: "para-pre", label: "Parasympathetic pre-ganglionic", colour: "#3F8F4A"},
|
|
34
|
-
{ type: "para-post", label: "Parasympathetic post-ganglionic", colour: "#3F8F4A"},
|
|
33
|
+
{ type: "para-post", label: "Parasympathetic post-ganglionic", colour: "#3F8F4A", dashed: true},
|
|
35
34
|
{ type: "sensory", label: "Sensory (afferent) neuron", colour: "#2A62F6"},
|
|
36
35
|
{ type: "somatic", label: "Somatic lower motor", colour: "#98561D"},
|
|
37
36
|
{ type: "symp-pre", label: "Sympathetic pre-ganglionic", colour: "#EA3423"},
|
|
38
|
-
{ type: "symp-post", label: "Sympathetic post-ganglionic", colour: "#EA3423"},
|
|
37
|
+
{ type: "symp-post", label: "Sympathetic post-ganglionic", colour: "#EA3423", dashed: true},
|
|
39
38
|
{ type: "other", label: "Other neuron type", colour: "#888"},
|
|
40
39
|
{ type: "arterial", label: "Arterial blood vessel", colour: "#F00"},
|
|
41
|
-
{ type: "venous", label: "Venous blood vessel", colour: "#2F6EBA"}
|
|
40
|
+
{ type: "venous", label: "Venous blood vessel", colour: "#2F6EBA"},
|
|
41
|
+
{ type: "centreline", label: "Nerve centrelines", colour: "#CCC", enabled: false},
|
|
42
|
+
{ type: "error", label: "Paths with errors or warnings", colour: "#FF0"}
|
|
42
43
|
];
|
|
43
44
|
|
|
44
45
|
export const PATH_STYLE_RULES =
|
|
@@ -142,16 +143,28 @@ export class Pathways
|
|
|
142
143
|
this.__typePaths['other'].push(...paths);
|
|
143
144
|
}
|
|
144
145
|
}
|
|
146
|
+
// Nerve centrelines are a special case with their own controls
|
|
147
|
+
this.__haveCentrelines = false;
|
|
145
148
|
}
|
|
146
149
|
|
|
147
|
-
get
|
|
148
|
-
|
|
150
|
+
get haveCentrelines()
|
|
151
|
+
//===================
|
|
152
|
+
{
|
|
153
|
+
return this.__haveCentrelines;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
pathTypes()
|
|
157
|
+
//=========
|
|
149
158
|
{
|
|
150
159
|
const pathTypes = [];
|
|
151
160
|
for (const pathType of PATH_TYPES) {
|
|
152
161
|
if (pathType.type in this.__typePaths
|
|
153
162
|
&& this.__typePaths[pathType.type].length > 0) {
|
|
154
|
-
|
|
163
|
+
if (pathType.type === 'centreline') {
|
|
164
|
+
this.__haveCentrelines = true;
|
|
165
|
+
} else {
|
|
166
|
+
pathTypes.push(pathType);
|
|
167
|
+
}
|
|
155
168
|
}
|
|
156
169
|
}
|
|
157
170
|
return pathTypes;
|