@abi-software/flatmap-viewer 2.7.2 → 2.7.3-a.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.
Files changed (120) hide show
  1. package/dist/assets/index.css +1 -0
  2. package/dist/index.js +80577 -0
  3. package/dist/lib/index.d.ts +4 -0
  4. package/package.json +10 -7
  5. package/lib/index.ts +0 -10
  6. package/src/contextmenu.js +0 -97
  7. package/src/controls/annotation.js +0 -302
  8. package/src/controls/controls.js +0 -645
  9. package/src/controls/flightpaths.js +0 -95
  10. package/src/controls/info.js +0 -291
  11. package/src/controls/minimap.js +0 -442
  12. package/src/controls/paths.js +0 -143
  13. package/src/controls/search.js +0 -113
  14. package/src/controls/systems.js +0 -75
  15. package/src/controls/taxons.js +0 -73
  16. package/src/flatmap-viewer.js +0 -1789
  17. package/src/images.js +0 -66
  18. package/src/interactions.js +0 -1569
  19. package/src/layers/cluster.js +0 -177
  20. package/src/layers/filter.js +0 -310
  21. package/src/layers/flightpaths.js +0 -383
  22. package/src/layers/index.js +0 -478
  23. package/src/layers/styling.js +0 -1077
  24. package/src/main.js +0 -272
  25. package/src/mapserver.js +0 -64
  26. package/src/mathjax.js +0 -100
  27. package/src/pathways.js +0 -427
  28. package/src/search.js +0 -137
  29. package/src/systems.js +0 -146
  30. package/src/utils.js +0 -152
  31. package/static/css/flatmap-viewer.css +0 -238
  32. package/static/icons/favicon.ico +0 -0
  33. package/static/images/active.png +0 -0
  34. package/static/images/inactive.png +0 -0
  35. package/static/images/reset-map-active.png +0 -0
  36. package/static/images/reset-map-button.png +0 -0
  37. package/static/images/rounded-background.png +0 -0
  38. package/static/images/zoom-in-active.png +0 -0
  39. package/static/images/zoom-in-button.png +0 -0
  40. package/static/images/zoom-out-active.png +0 -0
  41. package/static/images/zoom-out-button.png +0 -0
  42. package/thirdParty/maplibre-gl-svg/CHANGELOG.md +0 -13
  43. package/thirdParty/maplibre-gl-svg/LICENSE +0 -21
  44. package/thirdParty/maplibre-gl-svg/LICENSE.md +0 -21
  45. package/thirdParty/maplibre-gl-svg/README.md +0 -24
  46. package/thirdParty/maplibre-gl-svg/assets/Add custom SVG template to template manager.jpg +0 -0
  47. package/thirdParty/maplibre-gl-svg/assets/All built-in SVG templates as HTML markers.jpg +0 -0
  48. package/thirdParty/maplibre-gl-svg/assets/All built-in SVG templates as symbols.jpg +0 -0
  49. package/thirdParty/maplibre-gl-svg/assets/Fill polygon with built-in SVG template.jpg +0 -0
  50. package/thirdParty/maplibre-gl-svg/assets/HTML Marker with Custom SVG Template.jpg +0 -0
  51. package/thirdParty/maplibre-gl-svg/assets/HTML Marker with built-in SVG template.jpg +0 -0
  52. package/thirdParty/maplibre-gl-svg/assets/Line layer with built-in SVG template.jpg +0 -0
  53. package/thirdParty/maplibre-gl-svg/assets/Load SVG from URL.jpg +0 -0
  54. package/thirdParty/maplibre-gl-svg/assets/SVG template options.jpg +0 -0
  55. package/thirdParty/maplibre-gl-svg/assets/Smiley_face_changed.svg +0 -37
  56. package/thirdParty/maplibre-gl-svg/assets/Symbol layer with built-in SVG template.jpg +0 -0
  57. package/thirdParty/maplibre-gl-svg/assets/image-templates/arrow-up-thin.png +0 -0
  58. package/thirdParty/maplibre-gl-svg/assets/image-templates/arrow-up.png +0 -0
  59. package/thirdParty/maplibre-gl-svg/assets/image-templates/car.png +0 -0
  60. package/thirdParty/maplibre-gl-svg/assets/image-templates/checker-rotated.png +0 -0
  61. package/thirdParty/maplibre-gl-svg/assets/image-templates/checker.png +0 -0
  62. package/thirdParty/maplibre-gl-svg/assets/image-templates/circles-spaced.png +0 -0
  63. package/thirdParty/maplibre-gl-svg/assets/image-templates/circles.png +0 -0
  64. package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-lines-down.png +0 -0
  65. package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-lines-up.png +0 -0
  66. package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-stripes-down.png +0 -0
  67. package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-stripes-up.png +0 -0
  68. package/thirdParty/maplibre-gl-svg/assets/image-templates/dots.png +0 -0
  69. package/thirdParty/maplibre-gl-svg/assets/image-templates/flag-triangle.png +0 -0
  70. package/thirdParty/maplibre-gl-svg/assets/image-templates/flag.png +0 -0
  71. package/thirdParty/maplibre-gl-svg/assets/image-templates/grid-lines.png +0 -0
  72. package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon-rounded-thick.png +0 -0
  73. package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon-rounded.png +0 -0
  74. package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon-thick.png +0 -0
  75. package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon.png +0 -0
  76. package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-arrow.png +0 -0
  77. package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-ball-pin.png +0 -0
  78. package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-circle.png +0 -0
  79. package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-flat.png +0 -0
  80. package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square-cluster.png +0 -0
  81. package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square-rounded-cluster.png +0 -0
  82. package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square-rounded.png +0 -0
  83. package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square.png +0 -0
  84. package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-thick.png +0 -0
  85. package/thirdParty/maplibre-gl-svg/assets/image-templates/marker.png +0 -0
  86. package/thirdParty/maplibre-gl-svg/assets/image-templates/pin-round.png +0 -0
  87. package/thirdParty/maplibre-gl-svg/assets/image-templates/pin.png +0 -0
  88. package/thirdParty/maplibre-gl-svg/assets/image-templates/rotated-grid-lines.png +0 -0
  89. package/thirdParty/maplibre-gl-svg/assets/image-templates/rotated-grid-stripes.png +0 -0
  90. package/thirdParty/maplibre-gl-svg/assets/image-templates/rounded-square-thick.png +0 -0
  91. package/thirdParty/maplibre-gl-svg/assets/image-templates/rounded-square.png +0 -0
  92. package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle-arrow-left.png +0 -0
  93. package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle-arrow-up.png +0 -0
  94. package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle-thick.png +0 -0
  95. package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle.png +0 -0
  96. package/thirdParty/maplibre-gl-svg/assets/image-templates/x-fill.png +0 -0
  97. package/thirdParty/maplibre-gl-svg/assets/image-templates/zig-zag-vertical.png +0 -0
  98. package/thirdParty/maplibre-gl-svg/assets/image-templates/zig-zag.png +0 -0
  99. package/thirdParty/maplibre-gl-svg/build/build.js +0 -210
  100. package/thirdParty/maplibre-gl-svg/dist/maplibre-gl-svg.js +0 -339
  101. package/thirdParty/maplibre-gl-svg/dist/maplibre-gl-svg.min.js +0 -4
  102. package/thirdParty/maplibre-gl-svg/docs/docs.md +0 -375
  103. package/thirdParty/maplibre-gl-svg/examples/Add custom SVG template to template manager.html +0 -101
  104. package/thirdParty/maplibre-gl-svg/examples/All built-in SVG templates as HTML markers.html +0 -82
  105. package/thirdParty/maplibre-gl-svg/examples/All built-in SVG templates as symbols.html +0 -124
  106. package/thirdParty/maplibre-gl-svg/examples/Fill polygon with built-in SVG template.html +0 -94
  107. package/thirdParty/maplibre-gl-svg/examples/HTML Marker with Custom SVG Template.html +0 -86
  108. package/thirdParty/maplibre-gl-svg/examples/HTML Marker with built-in SVG template.html +0 -83
  109. package/thirdParty/maplibre-gl-svg/examples/Line layer with built-in SVG template.html +0 -129
  110. package/thirdParty/maplibre-gl-svg/examples/Load SVG from URL.html +0 -96
  111. package/thirdParty/maplibre-gl-svg/examples/SVG template options.html +0 -264
  112. package/thirdParty/maplibre-gl-svg/examples/Symbol layer with built-in SVG template.html +0 -93
  113. package/thirdParty/maplibre-gl-svg/index.html +0 -151
  114. package/thirdParty/maplibre-gl-svg/package-lock.json +0 -5882
  115. package/thirdParty/maplibre-gl-svg/package.json +0 -49
  116. package/thirdParty/maplibre-gl-svg/src/SvgManager.ts +0 -186
  117. package/thirdParty/maplibre-gl-svg/src/SvgTemplateManager.ts +0 -144
  118. package/thirdParty/maplibre-gl-svg/src/index.ts +0 -4
  119. package/thirdParty/maplibre-gl-svg/tsconfig.json +0 -31
  120. package/thirdParty/maplibre-gl-svg/typings/index.d.ts +0 -111
@@ -1,1077 +0,0 @@
1
- /******************************************************************************
2
-
3
- Flatmap viewer and annotation tool
4
-
5
- Copyright (c) 2019 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
- 'use strict';
22
-
23
- //==============================================================================
24
-
25
- export const VECTOR_TILES_SOURCE = 'vector-tiles';
26
-
27
- //==============================================================================
28
-
29
- import {UNCLASSIFIED_TAXON_ID} from '../flatmap-viewer';
30
- import {PATH_STYLE_RULES} from '../pathways';
31
-
32
- //==============================================================================
33
-
34
- const COLOUR_ACTIVE = 'blue';
35
- const COLOUR_ANNOTATED = '#C8F';
36
- const COLOUR_SELECTED = '#0F0';
37
- const COLOUR_HIDDEN = '#D8D8D8';
38
-
39
- const CENTRELINE_ACTIVE = '#888';
40
- const CENTRELINE_COLOUR = '#CCC';
41
-
42
- const FEATURE_SELECTED_BORDER = 'black';
43
-
44
- const NERVE_ACTIVE = '#222';
45
- const NERVE_SELECTED = 'red';
46
-
47
- //==============================================================================
48
-
49
- const STROKE_INTERPOLATION = [
50
- 'interpolate',
51
- ['exponential', 2],
52
- ['zoom'],
53
- 2, ["*", ['var', 'width'], ["^", 2, -0.5]],
54
- 7, ["*", ['var', 'width'], ["^", 2, 2.5]],
55
- 9, ["*", ['var', 'width'], ["^", 2, 3.0]]
56
- ];
57
-
58
- //==============================================================================
59
-
60
- class VectorStyleLayer
61
- {
62
- constructor(id, suffix, sourceLayer)
63
- {
64
- this.__id = `${id}_${suffix}`;
65
- this.__sourceLayer = sourceLayer;
66
- this.__lastPaintStyle = {};
67
- }
68
-
69
- get id()
70
- {
71
- return this.__id;
72
- }
73
-
74
- makeFilter(options)
75
- {
76
- return null;
77
- }
78
-
79
- paintStyle(options, changes=false)
80
- {
81
- return {};
82
- }
83
-
84
- __paintChanges(newPaintStyle)
85
- {
86
- const paintChanges = {};
87
- for (const [property, value] of Object.entries(newPaintStyle)) {
88
- if (!(property in this.__lastPaintStyle)
89
- || JSON.stringify(value) !== JSON.stringify(this.__lastPaintStyle[property])) {
90
- paintChanges[property] = value;
91
- }
92
- }
93
- return paintChanges;
94
- }
95
-
96
- changedPaintStyle(newPaintStyle, changes=false)
97
- {
98
- const paintStyle = changes ? this.__paintChanges(newPaintStyle) : newPaintStyle;
99
- this.__lastPaintStyle = newPaintStyle;
100
- return paintStyle;
101
- }
102
-
103
- style()
104
- {
105
- return {
106
- 'id': this.__id,
107
- 'source': VECTOR_TILES_SOURCE,
108
- 'source-layer': this.__sourceLayer
109
- };
110
- }
111
- }
112
-
113
- //==============================================================================
114
-
115
- export class BodyLayer extends VectorStyleLayer
116
- {
117
- constructor(id, sourceLayer)
118
- {
119
- super(id, 'body', sourceLayer);
120
- }
121
-
122
- style(options)
123
- {
124
- return {
125
- ...super.style(),
126
- 'type': 'fill',
127
- 'filter': [
128
- 'all',
129
- ['==', '$type', 'Polygon'],
130
- ['==', 'models', 'UBERON:0013702']
131
- ],
132
- 'paint': {
133
- 'fill-color': '#CCC',
134
- 'fill-opacity': 0.1
135
- }
136
- };
137
- }
138
- }
139
-
140
- //==============================================================================
141
-
142
- export class FeatureFillLayer extends VectorStyleLayer
143
- {
144
- constructor(id, sourceLayer)
145
- {
146
- super(id, 'fill', sourceLayer);
147
- }
148
-
149
- paintStyle(options, changes=false)
150
- {
151
- const coloured = !('colour' in options) || options.colour;
152
- const dimmed = 'dimmed' in options && options.dimmed;
153
- const paintStyle = {
154
- 'fill-color': [
155
- 'case',
156
- ['boolean', ['feature-state', 'selected'], false], COLOUR_SELECTED,
157
- ['boolean', ['feature-state', 'hidden'], false], COLOUR_HIDDEN,
158
- ['has', 'colour'], ['get', 'colour'],
159
- ['boolean', ['feature-state', 'active'], false], coloured ? '#D88' : '#CCC',
160
- 'white' // background colour? body colour ??
161
- ],
162
- 'fill-opacity': [
163
- 'case',
164
- ['boolean', ['feature-state', 'hidden'], false], 0.1,
165
- ['boolean', ['feature-state', 'selected'], false], 0.2,
166
- ['has', 'opacity'], ['get', 'opacity'],
167
- ['has', 'colour'], 1.0,
168
- ['boolean', ['feature-state', 'active'], false], 0.7,
169
- (coloured && !dimmed) ? 0.01 : 0.1
170
- ]
171
- };
172
- return super.changedPaintStyle(paintStyle, changes);
173
- }
174
-
175
- style(options)
176
- {
177
- return {
178
- ...super.style(),
179
- 'type': 'fill',
180
- 'filter': [
181
- 'all',
182
- ['==', '$type', 'Polygon'],
183
- ['!=', 'models', 'UBERON:0013702'],
184
- ['!has', 'node']
185
- ],
186
- 'layout': {
187
- 'fill-sort-key': ['get', 'scale']
188
- },
189
- 'paint': this.paintStyle(options)
190
- };
191
- }
192
- }
193
-
194
- //==============================================================================
195
-
196
- export class FeatureBorderLayer extends VectorStyleLayer
197
- {
198
- constructor(id, sourceLayer)
199
- {
200
- super(id, 'border', sourceLayer);
201
- }
202
-
203
- paintStyle(options, changes=false)
204
- {
205
- const coloured = !('colour' in options) || options.colour;
206
- const outlined = !('outline' in options) || options.outline;
207
- const dimmed = 'dimmed' in options && options.dimmed;
208
- const activeRasterLayer = 'activeRasterLayer' in options && options.activeRasterLayer;
209
- const lineColour = ['case'];
210
- lineColour.push(['boolean', ['feature-state', 'hidden'], false], COLOUR_HIDDEN);
211
- lineColour.push(['boolean', ['feature-state', 'selected'], false], FEATURE_SELECTED_BORDER);
212
- if (coloured && outlined) {
213
- lineColour.push(['boolean', ['feature-state', 'active'], false], COLOUR_ACTIVE);
214
- }
215
- lineColour.push(['boolean', ['feature-state', 'annotated'], false], COLOUR_ANNOTATED);
216
- lineColour.push(['has', 'colour'], ['get', 'colour']);
217
- lineColour.push('#444');
218
-
219
- const lineOpacity = ['case'];
220
- lineOpacity.push(['boolean', ['feature-state', 'hidden'], false], 0.05);
221
- if (coloured && outlined) {
222
- lineOpacity.push(['boolean', ['feature-state', 'active'], false], 0.9);
223
- }
224
- lineOpacity.push(['boolean', ['feature-state', 'selected'], false], 0.9);
225
- lineOpacity.push(['boolean', ['feature-state', 'annotated'], false], 0.9);
226
- if (activeRasterLayer) {
227
- lineOpacity.push((outlined && !dimmed) ? 0.3 : 0.1);
228
- } else {
229
- lineOpacity.push(0.5);
230
- }
231
-
232
- const lineWidth = ['case'];
233
- lineWidth.push(['boolean', ['get', 'invisible'], false], 0.2);
234
- lineWidth.push(['boolean', ['feature-state', 'selected'], false], 1.5);
235
- if (coloured && outlined) {
236
- lineWidth.push(['boolean', ['feature-state', 'active'], false], 1.5);
237
- }
238
- lineWidth.push(['boolean', ['feature-state', 'annotated'], false], 3.5);
239
- lineWidth.push(['has', 'colour'], 0.7);
240
- lineWidth.push((coloured && outlined) ? 0.5 : 0.1);
241
-
242
- return super.changedPaintStyle({
243
- 'line-color': lineColour,
244
- 'line-opacity': lineOpacity,
245
- 'line-width': lineWidth
246
- }, changes);
247
- }
248
-
249
- style(options)
250
- {
251
- return {
252
- ...super.style(),
253
- 'type': 'line',
254
- 'filter': [
255
- 'all',
256
- ['==', '$type', 'Polygon'],
257
- ['!has', 'node']
258
- ],
259
- 'paint': this.paintStyle(options)
260
- };
261
- }
262
- }
263
-
264
- //==============================================================================
265
-
266
- export class FeatureLineLayer extends VectorStyleLayer
267
- {
268
- constructor(id, sourceLayer, options={})
269
- {
270
- const dashed = ('dashed' in options && options.dashed);
271
- super(id, `feature-${dashed ? 'line-dash' : 'line'}`, sourceLayer);
272
- this.__dashed = dashed;
273
- }
274
-
275
- makeFilter(options={})
276
- {
277
- return this.__dashed ? [
278
- 'all',
279
- ['==', '$type', 'LineString'],
280
- ['==', 'type', 'line-dash']
281
- ] : [
282
- 'all',
283
- ['==', '$type', 'LineString'],
284
- [
285
- 'any',
286
- ['==', 'type', 'bezier'],
287
- ['==', 'type', 'line']
288
- ]
289
- ];
290
- }
291
-
292
- paintStyle(options, changes=false)
293
- {
294
- const coloured = !('colour' in options) || options.colour;
295
- const paintStyle = {
296
- 'line-color': [
297
- 'case',
298
- ['boolean', ['feature-state', 'hidden'], false], COLOUR_HIDDEN,
299
- ['boolean', ['feature-state', 'selected'], false], COLOUR_SELECTED,
300
- ['boolean', ['feature-state', 'active'], false], coloured ? '#888' : '#CCC',
301
- ['has', 'colour'], ['get', 'colour'],
302
- ['==', ['get', 'type'], 'network'], '#AFA202',
303
- options.authoring ? '#C44' : '#444'
304
- ],
305
- 'line-opacity': [
306
- 'case',
307
- ['boolean', ['feature-state', 'hidden'], false], 0.01,
308
- ['boolean', ['feature-state', 'selected'], false], 1.0,
309
- ['has', 'colour'], 1.0,
310
- ['boolean', ['feature-state', 'active'], false], 1.0,
311
- 0.3
312
- ],
313
- 'line-width': [
314
- 'let',
315
- 'width', [
316
- '*',
317
- ['case',
318
- ['has', 'stroke-width'], ['get', 'stroke-width'],
319
- 1.0
320
- ],
321
- ['case',
322
- ['boolean', ['feature-state', 'selected'], false], 1.2,
323
- ['boolean', ['feature-state', 'active'], false], 1.2,
324
- options.authoring ? 0.7 : 0.5
325
- ]
326
- ],
327
- STROKE_INTERPOLATION
328
- ]
329
- // Need to vary width based on zoom??
330
- // Or opacity??
331
- };
332
- if (this.__dashed) {
333
- paintStyle['line-dasharray'] = [3, 2];
334
- }
335
- return super.changedPaintStyle(paintStyle, changes);
336
- }
337
-
338
- style(options)
339
- {
340
- return {
341
- ...super.style(),
342
- 'type': 'line',
343
- 'filter': this.makeFilter(options),
344
- 'paint': this.paintStyle(options)
345
- };
346
- }
347
- }
348
-
349
- //==============================================================================
350
-
351
- export class FeatureDashLineLayer extends FeatureLineLayer
352
- {
353
- constructor(id, sourceLayer)
354
- {
355
- super(id, sourceLayer, {dashed: true});
356
- }
357
- }
358
-
359
- //==============================================================================
360
-
361
- function sckanFilter(options)
362
- {
363
- const sckanState = !'sckan' in options ? 'all'
364
- : options.sckan.toLowerCase();
365
- const sckanFilter =
366
- sckanState == 'none' ? [
367
- ['!', ['has', 'sckan']]
368
- ] :
369
- sckanState == 'valid' ? [[
370
- 'any',
371
- ['!', ['has', 'sckan']],
372
- [
373
- 'all',
374
- ['has', 'sckan'],
375
- ['==', ['get', 'sckan'], true]
376
- ]
377
- ]] :
378
- sckanState == 'invalid' ? [[
379
- 'any',
380
- ['!', ['has', 'sckan']],
381
- [
382
- 'all',
383
- ['has', 'sckan'],
384
- ['!=', ['get', 'sckan'], true]
385
- ]
386
- ]] :
387
- [ ];
388
- return sckanFilter;
389
- }
390
-
391
- //==============================================================================
392
-
393
- export class AnnotatedPathLayer extends VectorStyleLayer
394
- {
395
- constructor(id, sourceLayer)
396
- {
397
- super(id, 'annotated-path', sourceLayer);
398
- }
399
-
400
- makeFilter(options={})
401
- {
402
- return [
403
- 'all',
404
- ...sckanFilter(options)
405
- ];
406
- }
407
-
408
- paintStyle(options={}, changes=false)
409
- {
410
- const dimmed = 'dimmed' in options && options.dimmed;
411
- const exclude = 'excludeAnnotated' in options && options.excludeAnnotated;
412
- const paintStyle = {
413
- 'line-color': COLOUR_ANNOTATED,
414
- 'line-dasharray': [5, 0.5, 3, 0.5],
415
- 'line-opacity': [
416
- 'case',
417
- ['boolean', ['feature-state', 'active'], false], 0.8,
418
- ['boolean', ['feature-state', 'selected'], false], 0.8,
419
- ['boolean', ['feature-state', 'hidden'], false], 0.05,
420
- ['boolean', ['feature-state', 'annotated'], false],
421
- ((exclude || dimmed) ? 0.05 : 0.8),
422
- 0.6
423
- ],
424
- 'line-width': [
425
- 'let',
426
- 'width',
427
- ['case',
428
- ['boolean', ['feature-state', 'hidden'], false], 0.0,
429
- ['boolean', ['feature-state', 'annotated'], false],
430
- exclude ? 0.0 : (['*', 1.1, ['case',
431
- ['has', 'stroke-width'], ['get', 'stroke-width'],
432
- ['boolean', ['feature-state', 'active'], false], 1.1,
433
- ['boolean', ['feature-state', 'active'], false], 1.1,
434
- 1.0]]),
435
- 0.0
436
- ],
437
- STROKE_INTERPOLATION
438
- ]
439
- };
440
- return super.changedPaintStyle(paintStyle, changes);
441
- }
442
-
443
- style(options)
444
- {
445
- return {
446
- ...super.style(),
447
- 'type': 'line',
448
- 'filter': this.makeFilter(options),
449
- 'paint': this.paintStyle(options),
450
- 'layout': {
451
- 'line-cap': 'square'
452
- }
453
- };
454
- }
455
- }
456
-
457
- //==============================================================================
458
-
459
- export class PathLineLayer extends VectorStyleLayer
460
- {
461
- constructor(id, sourceLayer, options={})
462
- {
463
- const dashed = ('dashed' in options && options.dashed);
464
- const highlight = ('highlight' in options && options.highlight);
465
- super(id, `path${highlight ? '-highlight' : ''}-${dashed ? 'line-dash' : 'line'}`, sourceLayer);
466
- this.__dashed = dashed;
467
- this.__highlight = highlight;
468
- }
469
-
470
- makeFilter(options={})
471
- {
472
- const sckan_filter = sckanFilter(options);
473
- let taxonFilter = [];
474
- if ('taxons' in options) {
475
- if (options.taxons.length) {
476
- taxonFilter.push('any');
477
- for (const taxon of options.taxons) {
478
- if (taxon !== UNCLASSIFIED_TAXON_ID) {
479
- taxonFilter.push(['in', taxon, ['get', 'taxons']]);
480
- } else {
481
- taxonFilter.push(['case', ['has', 'taxons'], false, true]);
482
- }
483
- }
484
- taxonFilter = [taxonFilter];
485
- } else {
486
- taxonFilter.push(false);
487
- }
488
- }
489
-
490
- return this.__dashed ? [
491
- 'all',
492
- ['==', ['get', 'type'], 'line-dash'],
493
- ...sckan_filter,
494
- ...taxonFilter
495
- ] : [
496
- 'all',
497
- [
498
- 'any',
499
- ['==', ['get', 'type'], 'bezier'],
500
- [
501
- 'all',
502
- ['==', ['get', 'type'], 'line'],
503
- ...sckan_filter,
504
- ...taxonFilter
505
- ]
506
- ]
507
- ];
508
- }
509
-
510
- paintStyle(options={}, changes=false)
511
- {
512
- const dimmed = 'dimmed' in options && options.dimmed;
513
- const exclude = 'excludeAnnotated' in options && options.excludeAnnotated;
514
- const paintStyle = {
515
- 'line-color': [
516
- 'let', 'active', ['to-number', ['feature-state', 'active'], 0],
517
- [ 'case',
518
- ['boolean', ['feature-state', 'hidden'], false], COLOUR_HIDDEN,
519
- ['==', ['get', 'type'], 'bezier'], 'red',
520
- ...PATH_STYLE_RULES,
521
- '#888'
522
- ]
523
- ],
524
- 'line-opacity': this.__highlight ? [
525
- 'case',
526
- ['boolean', ['feature-state', 'hidden'], false], 0.0,
527
- ['boolean', ['get', 'invisible'], false], 0.0,
528
- ['boolean', ['feature-state', 'selected'], false], 1.0,
529
- ['boolean', ['feature-state', 'active'], false], 1.0,
530
- 0.0
531
- ] : [
532
- 'case',
533
- ['boolean', ['feature-state', 'hidden'], false], 0.01,
534
- ['==', ['get', 'type'], 'bezier'], 1.0,
535
- ['==', ['get', 'kind'], 'error'], 1.0,
536
- ['boolean', ['get', 'invisible'], false], 0.001,
537
- ['boolean', ['feature-state', 'selected'], false], 0.0,
538
- ['boolean', ['feature-state', 'active'], false], 0.0,
539
- dimmed ? 0.1 : 0.8
540
- ],
541
- 'line-width': [
542
- 'let',
543
- 'width', [
544
- "*",
545
- this.__highlight ? ['case',
546
- ['boolean', ['get', 'invisible'], false], 0.1,
547
- ['boolean', ['feature-state', 'selected'], false], [
548
- 'case', ['boolean', ['feature-state', 'active'], false], 1.2,
549
- 0.9],
550
- ['boolean', ['feature-state', 'active'], false], 0.9,
551
- 0.0
552
- ] : [
553
- 'case',
554
- ['==', ['get', 'type'], 'bezier'], 0.1,
555
- ['==', ['get', 'kind'], 'error'], 1,
556
- ['==', ['get', 'kind'], 'unknown'], 1,
557
- ['boolean', ['get', 'invisible'], false], 0.1,
558
- ['boolean', ['feature-state', 'selected'], false], 0.0,
559
- ['boolean', ['feature-state', 'active'], false], 0.0,
560
- 0.6
561
- ],
562
- ['case', ['boolean', ['feature-state', 'annotated'], false], (exclude ? 0.0 : 1.0), 1.0],
563
- ['case', ['has', 'stroke-width'], ['get', 'stroke-width'], 1.0]
564
- ],
565
- STROKE_INTERPOLATION
566
- ]
567
- };
568
- if (this.__dashed) {
569
- paintStyle['line-dasharray'] = [1, 1];
570
- }
571
- return super.changedPaintStyle(paintStyle, changes);
572
- }
573
-
574
- style(options={})
575
- {
576
- return {
577
- ...super.style(),
578
- 'type': 'line',
579
- 'filter': this.makeFilter(options),
580
- 'layout': {
581
- 'line-cap': 'butt'
582
- },
583
- 'paint': this.paintStyle(options)
584
- };
585
- }
586
- }
587
-
588
- //==============================================================================
589
-
590
- export class PathDashlineLayer extends PathLineLayer
591
- {
592
- constructor(id, sourceLayer)
593
- {
594
- super(id, sourceLayer, {dashed: true});
595
- }
596
- }
597
-
598
- //==============================================================================
599
-
600
- export class PathHighlightLayer extends PathLineLayer
601
- {
602
- constructor(id, sourceLayer)
603
- {
604
- super(id, sourceLayer, {highlight: true});
605
- }
606
- }
607
-
608
- export class PathDashHighlightLayer extends PathLineLayer
609
- {
610
- constructor(id, sourceLayer)
611
- {
612
- super(id, sourceLayer, {dashed: true, highlight: true});
613
- }
614
- }
615
-
616
- //==============================================================================
617
-
618
- class CentrelineLayer extends VectorStyleLayer
619
- {
620
- constructor(id, type, sourceLayer)
621
- {
622
- super(id, `centreline-${type}`, sourceLayer);
623
- this.__type = type;
624
- }
625
-
626
- paintStyle(options, changes=false)
627
- {
628
- const coloured = !('colour' in options) || options.colour;
629
- const paintStyle = {
630
- 'line-color': (this.__type == 'edge') ? '#000' : [
631
- 'case',
632
- ['boolean', ['feature-state', 'selected'], false], COLOUR_SELECTED,
633
- ['boolean', ['feature-state', 'active'], false], CENTRELINE_ACTIVE,
634
- CENTRELINE_COLOUR
635
- ],
636
- 'line-opacity': [
637
- 'case',
638
- ['boolean', ['feature-state', 'hidden'], false], 0,
639
- ['boolean', ['feature-state', 'selected'], false], 1.0,
640
- ['boolean', ['feature-state', 'active'], false], 1.0,
641
- (this.__type == 'edge') ? 0.4 : 0.8
642
- ],
643
- 'line-width': [
644
- 'let',
645
- 'width',
646
- (this.__type == 'edge') ? 1.6 : 1.2,
647
- STROKE_INTERPOLATION
648
- ]
649
- // Need to vary width based on zoom??
650
- // Or opacity??
651
- };
652
- return super.changedPaintStyle(paintStyle, changes);
653
- }
654
-
655
- style(options)
656
- {
657
- return {
658
- ...super.style(),
659
- 'type': 'line',
660
- 'filter': [
661
- 'all',
662
- ['==', '$type', 'LineString'],
663
- ['==', 'kind', 'centreline'],
664
- ['has', 'label']
665
- ],
666
- 'paint': this.paintStyle(options),
667
- 'layout': {
668
- 'line-cap': 'round',
669
- 'line-join': 'bevel'
670
- }
671
- };
672
- }
673
- }
674
-
675
-
676
- export class CentrelineEdgeLayer extends CentrelineLayer
677
- {
678
- constructor(id, sourceLayer)
679
- {
680
- super(id, 'edge', sourceLayer);
681
- }
682
-
683
- }
684
-
685
- export class CentrelineTrackLayer extends CentrelineLayer
686
- {
687
- constructor(id, sourceLayer)
688
- {
689
- super(id, 'track', sourceLayer);
690
- }
691
-
692
-
693
- }
694
-
695
- //==============================================================================
696
-
697
- export class CentrelineNodeFillLayer extends VectorStyleLayer
698
- {
699
- constructor(id, sourceLayer)
700
- {
701
- super(id, 'node-fill', sourceLayer);
702
- }
703
-
704
- paintStyle(options={}, changes=false)
705
- {
706
- const showNodes = options.showCentrelines || false;
707
- const paintStyle = {
708
- 'fill-color': [
709
- 'case',
710
- ['boolean', ['feature-state', 'selected'], false], COLOUR_SELECTED,
711
- ['boolean', ['feature-state', 'active'], false], CENTRELINE_ACTIVE,
712
- CENTRELINE_COLOUR
713
- ],
714
- 'fill-opacity': showNodes ? 0.8 : 0.01
715
- }
716
- return super.changedPaintStyle(paintStyle, changes);
717
- }
718
-
719
- style(options)
720
- {
721
- return {
722
- ...super.style(),
723
- 'type': 'fill',
724
- 'filter': [
725
- 'all',
726
- ['==', '$type', 'Polygon'],
727
- ['has', 'node']
728
- ],
729
- 'layout': {
730
- 'fill-sort-key': ['get', 'scale']
731
- },
732
- 'paint': this.paintStyle(options)
733
- };
734
- }
735
- }
736
-
737
- export class CentrelineNodeBorderLayer extends VectorStyleLayer
738
- {
739
- constructor(id, sourceLayer)
740
- {
741
- super(id, 'node-border', sourceLayer);
742
- }
743
-
744
- paintStyle(options={}, changes=false)
745
- {
746
- const showNodes = options.showCentrelines || false;
747
- const paintStyle = {
748
- 'line-color': '#000',
749
- 'line-opacity': showNodes ? 0.1 : 0.01,
750
- 'line-width': [
751
- 'let',
752
- 'width',
753
- 0.2,
754
- STROKE_INTERPOLATION
755
- ]
756
- }
757
- return super.changedPaintStyle(paintStyle, changes);
758
- }
759
-
760
- style(options)
761
- {
762
- return {
763
- ...super.style(),
764
- 'type': 'line',
765
- 'filter': [
766
- 'all',
767
- ['==', '$type', 'Polygon'],
768
- ['has', 'node']
769
- ],
770
- 'paint': this.paintStyle(options)
771
- };
772
- }
773
- }
774
-
775
- //==============================================================================
776
-
777
- export class FeatureNerveLayer extends VectorStyleLayer
778
- {
779
- constructor(id, sourceLayer)
780
- {
781
- super(id, 'nerve-path', sourceLayer);
782
- }
783
-
784
- style(options)
785
- {
786
- return {
787
- ...super.style(),
788
- 'type': 'line',
789
- 'filter': [
790
- 'all',
791
- ['==', '$type', 'LineString'],
792
- ['!=', 'kind', 'centreline'],
793
- ['==', 'type', 'nerve']
794
- ],
795
- 'paint': {
796
- 'line-color': [
797
- 'case',
798
- ['boolean', ['feature-state', 'hidden'], false], COLOUR_HIDDEN,
799
- ['boolean', ['feature-state', 'selected'], false], NERVE_SELECTED,
800
- ['boolean', ['feature-state', 'active'], false], NERVE_ACTIVE,
801
- '#888'
802
- ],
803
- 'line-opacity': [
804
- 'case',
805
- ['boolean', ['feature-state', 'hidden'], false], 0.3,
806
- ['boolean', ['get', 'invisible'], false], 0.001,
807
- ['boolean', ['feature-state', 'active'], false], 0.9,
808
- ['boolean', ['feature-state', 'selected'], false], 0.9,
809
- 0.9
810
- ],
811
- 'line-dasharray': [2, 1],
812
- 'line-width': [
813
- 'let', 'width', ['case',
814
- ['boolean', ['feature-state', 'active'], false], 0.8,
815
- ['boolean', ['feature-state', 'selected'], false], 1.2,
816
- 0.6],
817
- [ 'interpolate',
818
- ['exponential', 2],
819
- ['zoom'],
820
- 2, ["*", ['var', 'width'], ["^", 2, -1]],
821
- 10, ["*", ['var', 'width'], ["^", 2, 6]]
822
- ]
823
- ]
824
- }
825
- };
826
- }
827
- }
828
-
829
- //==============================================================================
830
-
831
- export class NervePolygonBorder extends VectorStyleLayer
832
- {
833
- constructor(id, sourceLayer)
834
- {
835
- super(id, 'nerve-border', sourceLayer);
836
- }
837
-
838
- style(options)
839
- {
840
- return {
841
- ...super.style(),
842
- 'type': 'line',
843
- 'filter': [
844
- 'all',
845
- ['==', '$type', 'Polygon'],
846
- ['==', 'type', 'nerve-section']
847
- ],
848
- 'paint': {
849
- 'line-color': [
850
- 'case',
851
- ['boolean', ['feature-state', 'active'], false], COLOUR_ACTIVE,
852
- ['boolean', ['feature-state', 'selected'], false], 'red',
853
- '#444'
854
- ],
855
- 'line-opacity': [
856
- 'case',
857
- ['boolean', ['get', 'invisible'], false], 0.05,
858
- ['boolean', ['feature-state', 'active'], false], 0.9,
859
- ['boolean', ['feature-state', 'selected'], false], 0.9,
860
- 0.3
861
- ],
862
- 'line-width': [
863
- 'case',
864
- ['boolean', ['get', 'invisible'], false], 0.5,
865
- ['boolean', ['feature-state', 'selected'], false], 6,
866
- 2
867
- ]
868
- }
869
- };
870
- }
871
- }
872
-
873
- //==============================================================================
874
-
875
- export class NervePolygonFill extends VectorStyleLayer
876
- {
877
- constructor(id, sourceLayer)
878
- {
879
- super(id, 'nerve-fill', sourceLayer);
880
- }
881
-
882
- paintStyle(options={}, changes=false)
883
- {
884
- const dimmed = 'dimmed' in options && options.dimmed;
885
- const paintStyle = {
886
- 'fill-color': [
887
- 'let', 'active', ['to-number', ['feature-state', 'active'], 0],
888
- [ 'case',
889
- ['all',
890
- ['==', ['var', 'active'], 0],
891
- ['==', ['get', 'type'], 'arrow'],
892
- ['boolean', ['feature-state', 'selected'], false]
893
- ], COLOUR_SELECTED,
894
- ['==', ['get', 'kind'], 'bezier-end'], 'red',
895
- ['==', ['get', 'kind'], 'bezier-control'], 'green',
896
- ...PATH_STYLE_RULES,
897
- 'white'
898
- ]
899
- ],
900
- 'fill-opacity': [
901
- 'case',
902
- ['boolean', ['feature-state', 'hidden'], false], 0.01,
903
- ['boolean', ['feature-state', 'selected'], false], 0.8,
904
- ['boolean', ['feature-state', 'active'], false], 0.9,
905
- ['==', ['get', 'type'], 'bezier'], 0.9,
906
- ['any',
907
- ['==', ['get', 'type'], 'arrow'],
908
- ['==', ['get', 'type'], 'junction']
909
- ], dimmed ? 0.1 : 0.5,
910
- 0.01
911
- ]
912
- };
913
- return super.changedPaintStyle(paintStyle, changes);
914
- }
915
-
916
- style(options={})
917
- {
918
- return {
919
- ...super.style(),
920
- 'type': 'fill',
921
- 'filter': [
922
- 'all',
923
- ['==', '$type', 'Polygon'],
924
- ['any',
925
- ['==', 'type', 'arrow'],
926
- ['==', 'type', 'bezier'],
927
- ['==', 'type', 'junction'],
928
- ['==', 'type', 'nerve'],
929
- ['==', 'type', 'nerve-section']
930
- ]
931
- ],
932
- 'paint': this.paintStyle(options)
933
- };
934
- }
935
- }
936
-
937
- //==============================================================================
938
-
939
- export class FeatureLargeSymbolLayer extends VectorStyleLayer
940
- {
941
- constructor(id, sourceLayer)
942
- {
943
- super(id, 'large-symbol', sourceLayer);
944
- }
945
-
946
- style(options)
947
- {
948
- return {
949
- ...super.style(),
950
- 'type': 'symbol',
951
- 'minzoom': 3,
952
- //'maxzoom': 7,
953
- 'filter': [
954
- 'all',
955
- ['has', 'labelled'],
956
- ['has', 'label']
957
- ],
958
- 'layout': {
959
- 'visibility': 'visible',
960
- 'icon-allow-overlap': true,
961
- 'icon-image': 'label-background',
962
- 'text-allow-overlap': true,
963
- 'text-field': '{label}',
964
- 'text-font': ['Open Sans Regular'],
965
- 'text-line-height': 1,
966
- 'text-max-width': 5,
967
- 'text-size': 16,
968
- 'icon-text-fit': 'both'
969
- },
970
- 'paint': {
971
- 'text-color': [
972
- 'case',
973
- ['boolean', ['feature-state', 'active'], false], '#8300bf',
974
- '#000'
975
- ]
976
- }
977
- };
978
- }
979
- }
980
-
981
- //==============================================================================
982
-
983
- export class FeatureSmallSymbolLayer extends VectorStyleLayer
984
- {
985
- constructor(id, sourceLayer)
986
- {
987
- super(id, 'small-symbol', sourceLayer);
988
- }
989
-
990
- style(options)
991
- {
992
- return {
993
- ...super.style(),
994
- 'type': 'symbol',
995
- 'minzoom': 6,
996
- 'filter': [
997
- 'all',
998
- ['has', 'label'],
999
- ['>', 'scale', 5]
1000
- ],
1001
- 'layout': {
1002
- 'visibility': 'visible',
1003
- 'icon-allow-overlap': true,
1004
- 'icon-image': 'label-background',
1005
- 'text-allow-overlap': true,
1006
- 'text-field': '{label}',
1007
- 'text-font': ['Open Sans Regular'],
1008
- 'text-line-height': 1,
1009
- 'text-max-width': 5,
1010
- 'text-size': {'stops': [[5, 8], [7, 12], [9, 20]]},
1011
- 'icon-text-fit': 'both'
1012
- },
1013
- 'paint': {
1014
- 'text-color': [
1015
- 'case',
1016
- ['boolean', ['feature-state', 'active'], false], '#8300bf',
1017
- '#000'
1018
- ]
1019
- }
1020
- };
1021
- }
1022
- }
1023
-
1024
- //==============================================================================
1025
-
1026
- export class BackgroundLayer
1027
- {
1028
- constructor()
1029
- {
1030
- this.__id = 'background';
1031
- }
1032
-
1033
- get id()
1034
- {
1035
- return this.__id;
1036
- }
1037
-
1038
- style(backgroundColour, opacity=1.0)
1039
- {
1040
- return {
1041
- 'id': this.__id,
1042
- 'type': 'background',
1043
- 'paint': {
1044
- 'background-color': backgroundColour,
1045
- 'background-opacity': opacity
1046
- }
1047
- };
1048
- }
1049
- }
1050
-
1051
- //==============================================================================
1052
-
1053
- export class RasterLayer
1054
- {
1055
- constructor(id)
1056
- {
1057
- this.__id = id;
1058
- }
1059
-
1060
- get id()
1061
- {
1062
- return this.__id;
1063
- }
1064
-
1065
- style(options)
1066
- {
1067
- const coloured = !('colour' in options) || options.colour;
1068
- return {
1069
- 'id': this.__id,
1070
- 'source': this.__id,
1071
- 'type': 'raster',
1072
- 'visibility': coloured ? 'visible' : 'none'
1073
- };
1074
- }
1075
- }
1076
-
1077
- //==============================================================================