@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.
- package/dist/assets/index.css +1 -0
- package/dist/index.js +80577 -0
- package/dist/lib/index.d.ts +4 -0
- package/package.json +10 -7
- package/lib/index.ts +0 -10
- package/src/contextmenu.js +0 -97
- package/src/controls/annotation.js +0 -302
- package/src/controls/controls.js +0 -645
- package/src/controls/flightpaths.js +0 -95
- package/src/controls/info.js +0 -291
- package/src/controls/minimap.js +0 -442
- package/src/controls/paths.js +0 -143
- package/src/controls/search.js +0 -113
- package/src/controls/systems.js +0 -75
- package/src/controls/taxons.js +0 -73
- package/src/flatmap-viewer.js +0 -1789
- package/src/images.js +0 -66
- package/src/interactions.js +0 -1569
- package/src/layers/cluster.js +0 -177
- package/src/layers/filter.js +0 -310
- package/src/layers/flightpaths.js +0 -383
- package/src/layers/index.js +0 -478
- package/src/layers/styling.js +0 -1077
- package/src/main.js +0 -272
- package/src/mapserver.js +0 -64
- package/src/mathjax.js +0 -100
- package/src/pathways.js +0 -427
- package/src/search.js +0 -137
- package/src/systems.js +0 -146
- package/src/utils.js +0 -152
- package/static/css/flatmap-viewer.css +0 -238
- package/static/icons/favicon.ico +0 -0
- package/static/images/active.png +0 -0
- package/static/images/inactive.png +0 -0
- package/static/images/reset-map-active.png +0 -0
- package/static/images/reset-map-button.png +0 -0
- package/static/images/rounded-background.png +0 -0
- package/static/images/zoom-in-active.png +0 -0
- package/static/images/zoom-in-button.png +0 -0
- package/static/images/zoom-out-active.png +0 -0
- package/static/images/zoom-out-button.png +0 -0
- package/thirdParty/maplibre-gl-svg/CHANGELOG.md +0 -13
- package/thirdParty/maplibre-gl-svg/LICENSE +0 -21
- package/thirdParty/maplibre-gl-svg/LICENSE.md +0 -21
- package/thirdParty/maplibre-gl-svg/README.md +0 -24
- package/thirdParty/maplibre-gl-svg/assets/Add custom SVG template to template manager.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/All built-in SVG templates as HTML markers.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/All built-in SVG templates as symbols.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/Fill polygon with built-in SVG template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/HTML Marker with Custom SVG Template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/HTML Marker with built-in SVG template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/Line layer with built-in SVG template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/Load SVG from URL.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/SVG template options.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/Smiley_face_changed.svg +0 -37
- package/thirdParty/maplibre-gl-svg/assets/Symbol layer with built-in SVG template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/arrow-up-thin.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/arrow-up.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/car.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/checker-rotated.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/checker.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/circles-spaced.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/circles.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-lines-down.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-lines-up.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-stripes-down.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-stripes-up.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/dots.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/flag-triangle.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/flag.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/grid-lines.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon-rounded-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon-rounded.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-arrow.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-ball-pin.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-circle.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-flat.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square-cluster.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square-rounded-cluster.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square-rounded.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/pin-round.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/pin.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/rotated-grid-lines.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/rotated-grid-stripes.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/rounded-square-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/rounded-square.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle-arrow-left.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle-arrow-up.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/x-fill.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/zig-zag-vertical.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/zig-zag.png +0 -0
- package/thirdParty/maplibre-gl-svg/build/build.js +0 -210
- package/thirdParty/maplibre-gl-svg/dist/maplibre-gl-svg.js +0 -339
- package/thirdParty/maplibre-gl-svg/dist/maplibre-gl-svg.min.js +0 -4
- package/thirdParty/maplibre-gl-svg/docs/docs.md +0 -375
- package/thirdParty/maplibre-gl-svg/examples/Add custom SVG template to template manager.html +0 -101
- package/thirdParty/maplibre-gl-svg/examples/All built-in SVG templates as HTML markers.html +0 -82
- package/thirdParty/maplibre-gl-svg/examples/All built-in SVG templates as symbols.html +0 -124
- package/thirdParty/maplibre-gl-svg/examples/Fill polygon with built-in SVG template.html +0 -94
- package/thirdParty/maplibre-gl-svg/examples/HTML Marker with Custom SVG Template.html +0 -86
- package/thirdParty/maplibre-gl-svg/examples/HTML Marker with built-in SVG template.html +0 -83
- package/thirdParty/maplibre-gl-svg/examples/Line layer with built-in SVG template.html +0 -129
- package/thirdParty/maplibre-gl-svg/examples/Load SVG from URL.html +0 -96
- package/thirdParty/maplibre-gl-svg/examples/SVG template options.html +0 -264
- package/thirdParty/maplibre-gl-svg/examples/Symbol layer with built-in SVG template.html +0 -93
- package/thirdParty/maplibre-gl-svg/index.html +0 -151
- package/thirdParty/maplibre-gl-svg/package-lock.json +0 -5882
- package/thirdParty/maplibre-gl-svg/package.json +0 -49
- package/thirdParty/maplibre-gl-svg/src/SvgManager.ts +0 -186
- package/thirdParty/maplibre-gl-svg/src/SvgTemplateManager.ts +0 -144
- package/thirdParty/maplibre-gl-svg/src/index.ts +0 -4
- package/thirdParty/maplibre-gl-svg/tsconfig.json +0 -31
- package/thirdParty/maplibre-gl-svg/typings/index.d.ts +0 -111
package/src/pathways.js
DELETED
|
@@ -1,427 +0,0 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
|
|
3
|
-
Flatmap viewer and annotation tool
|
|
4
|
-
|
|
5
|
-
Copyright (c) 2020 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
|
-
import {colord} from 'colord'
|
|
24
|
-
|
|
25
|
-
//==============================================================================
|
|
26
|
-
|
|
27
|
-
import { reverseMap } from './utils';
|
|
28
|
-
|
|
29
|
-
export const PATHWAYS_LAYER = 'pathways';
|
|
30
|
-
|
|
31
|
-
//==============================================================================
|
|
32
|
-
|
|
33
|
-
export const APINATOMY_PATH_PREFIX = 'ilxtr:';
|
|
34
|
-
|
|
35
|
-
//==============================================================================
|
|
36
|
-
|
|
37
|
-
const PATH_TYPES = [
|
|
38
|
-
{ type: "cns", label: "CNS", colour: "#9B1FC1"},
|
|
39
|
-
{ type: "intracardiac", label: "Local circuit neuron", colour: "#F19E38"},
|
|
40
|
-
{ type: "para-pre", label: "Parasympathetic pre-ganglionic", colour: "#3F8F4A"},
|
|
41
|
-
{ type: "para-post", label: "Parasympathetic post-ganglionic", colour: "#3F8F4A", dashed: true},
|
|
42
|
-
{ type: "sensory", label: "Sensory (afferent) neuron", colour: "#2A62F6"},
|
|
43
|
-
{ type: "motor", label: "Somatic lower motor", colour: "#98561D"},
|
|
44
|
-
{ type: "somatic", label: "Somatic lower motor", colour: "#98561D"},
|
|
45
|
-
{ type: "symp-pre", label: "Sympathetic pre-ganglionic", colour: "#EA3423"},
|
|
46
|
-
{ type: "symp-post", label: "Sympathetic post-ganglionic", colour: "#EA3423", dashed: true},
|
|
47
|
-
{ type: "other", label: "Other neuron type", colour: "#888"},
|
|
48
|
-
{ type: "arterial", label: "Arterial blood vessel", colour: "#F00", enabled: false},
|
|
49
|
-
{ type: "venous", label: "Venous blood vessel", colour: "#2F6EBA", enabled: false},
|
|
50
|
-
{ type: "centreline", label: "Nerve centrelines", colour: "#CCC", enabled: false},
|
|
51
|
-
{ type: "error", label: "Paths with errors or warnings", colour: "#FF0", enabled: false}
|
|
52
|
-
];
|
|
53
|
-
|
|
54
|
-
const PathTypeMap = new Map(PATH_TYPES.map(t => [t.type, t]))
|
|
55
|
-
|
|
56
|
-
export const PATH_STYLE_RULES =
|
|
57
|
-
PATH_TYPES.flatMap(pathType => [['==', ['get', 'kind'], pathType.type], pathType.colour]);
|
|
58
|
-
|
|
59
|
-
export function pathColourArray(pathType, alpha=255)
|
|
60
|
-
//==================================================
|
|
61
|
-
{
|
|
62
|
-
const rgb = colord(PathTypeMap.has(pathType)
|
|
63
|
-
? PathTypeMap.get(pathType).colour
|
|
64
|
-
: PathTypeMap.get('other').colour).toRgb()
|
|
65
|
-
return [rgb.r, rgb.g, rgb.b, alpha]
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
//==============================================================================
|
|
69
|
-
|
|
70
|
-
export class PathManager
|
|
71
|
-
{
|
|
72
|
-
constructor(flatmap, ui, enabled=true)
|
|
73
|
-
{
|
|
74
|
-
this.__ui = ui;
|
|
75
|
-
this.__connectivityModelPaths = {}; // modelId: [pathIds]
|
|
76
|
-
this.__pathToConnectivityModel = {};
|
|
77
|
-
if ('models' in flatmap.pathways) {
|
|
78
|
-
for (const model of flatmap.pathways.models) {
|
|
79
|
-
this.__connectivityModelPaths[model.id] = model.paths;
|
|
80
|
-
for (const path of model.paths) {
|
|
81
|
-
this.__pathToConnectivityModel[path] = model.id;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
this.__pathModelPaths = {}; // pathModelId: [pathIds]
|
|
86
|
-
this.__pathToPathModel = {}; // pathId: pathModelId
|
|
87
|
-
this.__paths = {}; // pathId: path
|
|
88
|
-
const pathLines = {}; // pathId: [lineIds]
|
|
89
|
-
const pathNerves = {}; // pathId: [nerveIds]
|
|
90
|
-
if ('paths' in flatmap.pathways) {
|
|
91
|
-
for (const [pathId, path] of Object.entries(flatmap.pathways.paths)) {
|
|
92
|
-
pathLines[pathId] = path.lines;
|
|
93
|
-
pathNerves[pathId] = path.nerves;
|
|
94
|
-
this.__paths[pathId] = path;
|
|
95
|
-
this.__paths[pathId].systemCount = 0;
|
|
96
|
-
if ('models' in path) {
|
|
97
|
-
const modelId = path['models'];
|
|
98
|
-
if (!(modelId in this.__pathModelPaths)) {
|
|
99
|
-
this.__pathModelPaths[modelId] = [];
|
|
100
|
-
}
|
|
101
|
-
this.__pathModelPaths[modelId].push(pathId);
|
|
102
|
-
this.__pathToPathModel[pathId] = modelId;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
this.__pathsByLine = reverseMap(pathLines); // lineId: [pathIds]
|
|
107
|
-
this.__pathsByNerve = reverseMap(pathNerves); // nerveId: [pathIds]
|
|
108
|
-
|
|
109
|
-
const nodePaths = flatmap.pathways['node-paths'];
|
|
110
|
-
this._nodePaths = nodePaths; // nodeId: [pathIds]
|
|
111
|
-
const featureIds = new Set();
|
|
112
|
-
for (const paths of Object.values(this._nodePaths)) {
|
|
113
|
-
this.addPathsToFeatureSet_(paths, featureIds);
|
|
114
|
-
}
|
|
115
|
-
this._allFeatureIds = featureIds;
|
|
116
|
-
|
|
117
|
-
// Construct a list of path types we know about
|
|
118
|
-
const pathTypes = {};
|
|
119
|
-
this.__pathtypeEnabled = {};
|
|
120
|
-
for (const pathTypeDefn of PATH_TYPES) {
|
|
121
|
-
pathTypes[pathTypeDefn.type] = pathTypeDefn;
|
|
122
|
-
this.__pathtypeEnabled[pathTypeDefn.type] = !('enabled' in pathTypeDefn) || pathTypeDefn.enabled;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Set path types, mapping unknown path types to ``other``
|
|
126
|
-
this.__pathsByType = {};
|
|
127
|
-
this.__pathsByType['other'] = [];
|
|
128
|
-
for (const [pathType, paths] of Object.entries(flatmap.pathways['type-paths'])) {
|
|
129
|
-
if (pathType in pathTypes) {
|
|
130
|
-
this.__pathsByType[pathType] = paths;
|
|
131
|
-
const pathDefn = pathTypes[pathType];
|
|
132
|
-
} else {
|
|
133
|
-
this.__pathsByType['other'].push(...paths);
|
|
134
|
-
this.__pathtypeEnabled[pathType] = false;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
// Assign types to individual paths
|
|
138
|
-
this.__assignPathTypes();
|
|
139
|
-
|
|
140
|
-
// Nerve centrelines are a special case with their own controls
|
|
141
|
-
this.__haveCentrelines = false;
|
|
142
|
-
this.__enabledCentrelines = false;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
get haveCentrelines()
|
|
146
|
-
//===================
|
|
147
|
-
{
|
|
148
|
-
return this.__haveCentrelines;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
get enabledCentrelines()
|
|
152
|
-
//======================
|
|
153
|
-
{
|
|
154
|
-
return this.__enabledCentrelines;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
__assignPathTypes()
|
|
158
|
-
//=================
|
|
159
|
-
{
|
|
160
|
-
for (const [pathType, paths] of Object.entries(this.__pathsByType)) {
|
|
161
|
-
for (const pathId of paths) {
|
|
162
|
-
this.__paths[pathId].pathType = pathType;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
pathStyles()
|
|
168
|
-
//==========
|
|
169
|
-
{
|
|
170
|
-
const styles = []
|
|
171
|
-
for (const mapType of this.pathTypes()) {
|
|
172
|
-
const defn = PathTypeMap.get(mapType.type)
|
|
173
|
-
styles.push({
|
|
174
|
-
type: defn.type,
|
|
175
|
-
colour: defn.colour,
|
|
176
|
-
dashed: defn.dashed || false
|
|
177
|
-
})
|
|
178
|
-
}
|
|
179
|
-
return styles
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
pathTypes()
|
|
183
|
-
//=========
|
|
184
|
-
{
|
|
185
|
-
const pathTypes = [];
|
|
186
|
-
for (const pathTypeDefn of PATH_TYPES) {
|
|
187
|
-
if (pathTypeDefn.type in this.__pathsByType
|
|
188
|
-
&& this.__pathsByType[pathTypeDefn.type].length > 0) {
|
|
189
|
-
if (pathTypeDefn.type === 'centreline') {
|
|
190
|
-
this.__haveCentrelines = true;
|
|
191
|
-
this.__enabledCentrelines = this.__pathtypeEnabled[pathTypeDefn.type];
|
|
192
|
-
} else {
|
|
193
|
-
pathTypes.push({
|
|
194
|
-
...pathTypeDefn,
|
|
195
|
-
enabled: this.__pathtypeEnabled[pathTypeDefn.type]
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return pathTypes;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
addPathsToFeatureSet_(pathIds, featureSet)
|
|
204
|
-
//======================================
|
|
205
|
-
{
|
|
206
|
-
for (const pathId of pathIds) {
|
|
207
|
-
const path = this.__paths[pathId];
|
|
208
|
-
path.lines.forEach(lineId => featureSet.add(lineId));
|
|
209
|
-
path.nerves.forEach(nerveId => featureSet.add(nerveId));
|
|
210
|
-
path.nodes.forEach(nodeId => featureSet.add(nodeId));
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
allFeatureIds()
|
|
215
|
-
//=============
|
|
216
|
-
{
|
|
217
|
-
return this._allFeatureIds;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
lineFeatureIds(lineIds)
|
|
221
|
-
//=====================
|
|
222
|
-
{
|
|
223
|
-
const featureIds = new Set();
|
|
224
|
-
for (const lineId of lineIds) {
|
|
225
|
-
if (lineId in this.__pathsByLine) {
|
|
226
|
-
this.addPathsToFeatureSet_(this.__pathsByLine[lineId], featureIds);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
return featureIds;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
nerveFeatureIds(nerveId)
|
|
233
|
-
//======================
|
|
234
|
-
{
|
|
235
|
-
const featureIds = new Set();
|
|
236
|
-
if (nerveId in this.__pathsByNerve) {
|
|
237
|
-
this.addPathsToFeatureSet_(this.__pathsByNerve[nerveId], featureIds);
|
|
238
|
-
}
|
|
239
|
-
return featureIds;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
pathProperties(feature)
|
|
243
|
-
//=====================
|
|
244
|
-
{
|
|
245
|
-
const properties = Object.assign({}, feature.properties);
|
|
246
|
-
if (feature.id in this.__pathsByLine) {
|
|
247
|
-
for (const pathId of this.__pathsByLine[feature.id]) {
|
|
248
|
-
// There should only be a single path for a line
|
|
249
|
-
if (pathId in this.__pathToConnectivityModel) {
|
|
250
|
-
properties['connectivity'] = this.__pathToConnectivityModel[pathId];
|
|
251
|
-
}
|
|
252
|
-
if (pathId in this.__pathToPathModel) {
|
|
253
|
-
properties['models'] = this.__pathToPathModel[pathId];
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
/*
|
|
257
|
-
if (!('connectivity' in properties)) {
|
|
258
|
-
for (const pathId of this.__pathsByNerve[feature.id]) {
|
|
259
|
-
if (pathId in this.__pathToConnectivityModel) {
|
|
260
|
-
properties['connectivity'] = this.__pathToConnectivityModel[pathId];
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
*/
|
|
266
|
-
}
|
|
267
|
-
return properties;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
connectivityModelFeatureIds(modelId)
|
|
271
|
-
//==================================
|
|
272
|
-
{
|
|
273
|
-
const featureIds = new Set();
|
|
274
|
-
if (modelId in this.__connectivityModelPaths) {
|
|
275
|
-
this.addPathsToFeatureSet_(this.__connectivityModelPaths[modelId], featureIds);
|
|
276
|
-
}
|
|
277
|
-
return featureIds;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
pathModelFeatureIds(modelId)
|
|
281
|
-
//==========================
|
|
282
|
-
{
|
|
283
|
-
const featureIds = new Set();
|
|
284
|
-
if (modelId in this.__pathModelPaths) {
|
|
285
|
-
this.addPathsToFeatureSet_(this.__pathModelPaths[modelId], featureIds);
|
|
286
|
-
}
|
|
287
|
-
return featureIds;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
isNode(id)
|
|
291
|
-
//========
|
|
292
|
-
{
|
|
293
|
-
return id in this._nodePaths;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
pathFeatureIds(nodeId)
|
|
297
|
-
//====================
|
|
298
|
-
{
|
|
299
|
-
const featureIds = new Set();
|
|
300
|
-
if (nodeId in this._nodePaths) {
|
|
301
|
-
this.addPathsToFeatureSet_(this._nodePaths[nodeId], featureIds);
|
|
302
|
-
}
|
|
303
|
-
return featureIds;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
__typeFeatureIds(pathType)
|
|
307
|
-
//========================
|
|
308
|
-
{
|
|
309
|
-
const featureIds = new Set();
|
|
310
|
-
if (pathType in this.__pathsByType) {
|
|
311
|
-
this.addPathsToFeatureSet_(this.__pathsByType[pathType], featureIds);
|
|
312
|
-
}
|
|
313
|
-
return featureIds;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
enablePathLines(enable, force=false)
|
|
317
|
-
//==================================
|
|
318
|
-
{
|
|
319
|
-
for (const lineId of Object.keys(this.__pathsByLine)) {
|
|
320
|
-
this.__ui.enableFeature(lineId, enable, force)
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
enablePathsBySystem(system, enable, force=false)
|
|
325
|
-
//==============================================
|
|
326
|
-
{
|
|
327
|
-
let changed = false;
|
|
328
|
-
for (const pathId of system.pathIds) {
|
|
329
|
-
const path = this.__paths[pathId];
|
|
330
|
-
if (this.__pathtypeEnabled[path.pathType]
|
|
331
|
-
&& (force
|
|
332
|
-
|| enable && path.systemCount === 0
|
|
333
|
-
|| !enable && path.systemCount == 1)) {
|
|
334
|
-
// and type(pathId) is enabled...
|
|
335
|
-
const featureIds = new Set();
|
|
336
|
-
this.addPathsToFeatureSet_([pathId], featureIds)
|
|
337
|
-
for (const featureId of featureIds) {
|
|
338
|
-
this.__ui.enableFeature(featureId, enable, force);
|
|
339
|
-
}
|
|
340
|
-
changed = true
|
|
341
|
-
}
|
|
342
|
-
path.systemCount += (enable ? 1 : -1);
|
|
343
|
-
if (path.systemCount < 0) {
|
|
344
|
-
path.systemCount = 0;
|
|
345
|
-
}
|
|
346
|
-
// TODO? Show connectors and parent components of these paths??
|
|
347
|
-
}
|
|
348
|
-
if (changed) {
|
|
349
|
-
this.#notifyWatchers()
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
enablePathsByType(pathType, enable, force=false)
|
|
354
|
-
//==============================================
|
|
355
|
-
{
|
|
356
|
-
if (force
|
|
357
|
-
|| enable && !this.__pathtypeEnabled[pathType]
|
|
358
|
-
|| !enable && this.__pathtypeEnabled[pathType]) {
|
|
359
|
-
for (const featureId of this.__typeFeatureIds(pathType)) {
|
|
360
|
-
this.__ui.enableFeature(featureId, enable, force);
|
|
361
|
-
}
|
|
362
|
-
this.__pathtypeEnabled[pathType] = enable;
|
|
363
|
-
this.#notifyWatchers({pathType})
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
pathTypeEnabled(pathType)
|
|
368
|
-
//=======================
|
|
369
|
-
{
|
|
370
|
-
return this.__pathtypeEnabled[pathType] || false
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
nodePathModels(nodeId)
|
|
374
|
-
//====================
|
|
375
|
-
{
|
|
376
|
-
const modelIds = new Set();
|
|
377
|
-
if (nodeId in this._nodePaths) {
|
|
378
|
-
for (const pathId of this._nodePaths[nodeId]) {
|
|
379
|
-
if (pathId in this.__pathToPathModel) {
|
|
380
|
-
modelIds.add(this.__pathToPathModel[pathId]);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
return modelIds;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
pathModelNodes(modelId)
|
|
388
|
-
//=====================
|
|
389
|
-
{
|
|
390
|
-
const nodeIds = new Set();
|
|
391
|
-
if (modelId in this.__pathModelPaths) {
|
|
392
|
-
for (const pathId of this.__pathModelPaths[modelId]) {
|
|
393
|
-
for (const nodeId of this.__paths[pathId].nodes) {
|
|
394
|
-
nodeIds.add(nodeId);
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
return nodeIds;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
#lastWatcherId = 0
|
|
402
|
-
#watcherCallbacks = new Map()
|
|
403
|
-
|
|
404
|
-
addWatcher(callback)
|
|
405
|
-
//==================
|
|
406
|
-
{
|
|
407
|
-
this.#lastWatcherId += 1
|
|
408
|
-
this.#watcherCallbacks.set(this.#lastWatcherId, callback)
|
|
409
|
-
return this.#lastWatcherId
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
removeWatcher(watcherId)
|
|
413
|
-
//======================
|
|
414
|
-
{
|
|
415
|
-
this.#watcherCallbacks.delete(watcherId)
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
#notifyWatchers(changes={})
|
|
419
|
-
//=========================
|
|
420
|
-
{
|
|
421
|
-
for (const callback of this.#watcherCallbacks.values()) {
|
|
422
|
-
callback(changes)
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
//==============================================================================
|
package/src/search.js
DELETED
|
@@ -1,137 +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
|
-
import MiniSearch from 'minisearch';
|
|
26
|
-
|
|
27
|
-
//==============================================================================
|
|
28
|
-
|
|
29
|
-
// The properties of a feature we index and show
|
|
30
|
-
|
|
31
|
-
export const indexedProperties = [
|
|
32
|
-
'label',
|
|
33
|
-
'models',
|
|
34
|
-
'source'
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
//==============================================================================
|
|
38
|
-
|
|
39
|
-
export class SearchIndex
|
|
40
|
-
{
|
|
41
|
-
constructor()
|
|
42
|
-
{
|
|
43
|
-
this._searchEngine = new MiniSearch({
|
|
44
|
-
fields: ['text'],
|
|
45
|
-
storeFields: ['text'],
|
|
46
|
-
tokenize: (string, _fieldName) => string.split(' ')
|
|
47
|
-
});
|
|
48
|
-
this._featureIds = [];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
indexMetadata(featureId, metadata)
|
|
52
|
-
//================================
|
|
53
|
-
{
|
|
54
|
-
const textSeen = [];
|
|
55
|
-
for (const prop of indexedProperties) {
|
|
56
|
-
if (prop in metadata) {
|
|
57
|
-
const text = metadata[prop];
|
|
58
|
-
if (!textSeen.includes(text)) {
|
|
59
|
-
this.indexText(featureId, text);
|
|
60
|
-
textSeen.push(text);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
indexText(featureId, text)
|
|
67
|
-
//========================
|
|
68
|
-
{
|
|
69
|
-
text = text.replace(new RegExp('<br/>', 'g'), ' ')
|
|
70
|
-
.replace(new RegExp('\n', 'g'), ' ')
|
|
71
|
-
;
|
|
72
|
-
if (text) {
|
|
73
|
-
this._searchEngine.add({
|
|
74
|
-
id: this._featureIds.length,
|
|
75
|
-
text: text
|
|
76
|
-
});
|
|
77
|
-
this._featureIds.push(featureId);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
clearResults()
|
|
82
|
-
//============
|
|
83
|
-
{
|
|
84
|
-
this._;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
auto_suggest(text)
|
|
88
|
-
//================
|
|
89
|
-
{
|
|
90
|
-
return this._searchEngine.autoSuggest(text, {prefix: true});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
search(text)
|
|
94
|
-
//==========
|
|
95
|
-
{
|
|
96
|
-
const options = {};
|
|
97
|
-
let results = [];
|
|
98
|
-
text = text.trim()
|
|
99
|
-
if (text.length > 2 && ["'", '"'].includes(text.slice(0, 1))) {
|
|
100
|
-
text = text.replaceAll(text.slice(0, 1), '');
|
|
101
|
-
results = this._searchEngine.search(text, {prefix: true, combineWith: 'AND'});
|
|
102
|
-
} else if (text.length > 1) {
|
|
103
|
-
results = this._searchEngine.search(text, {prefix: true});
|
|
104
|
-
}
|
|
105
|
-
const featureResults = results.map(r => {
|
|
106
|
-
return {
|
|
107
|
-
featureId: this._featureIds[r.id],
|
|
108
|
-
score: r.score,
|
|
109
|
-
terms: r.terms,
|
|
110
|
-
text: r.text
|
|
111
|
-
}});
|
|
112
|
-
return new SearchResults(featureResults);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
//==============================================================================
|
|
117
|
-
|
|
118
|
-
class SearchResults
|
|
119
|
-
{
|
|
120
|
-
constructor(results)
|
|
121
|
-
{
|
|
122
|
-
this.__results = results.sort((a, b) => (b.score - a.score));
|
|
123
|
-
this.__featureIds = results.map(r => r.featureId);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
get featureIds()
|
|
127
|
-
{
|
|
128
|
-
return this.__featureIds;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
get results()
|
|
132
|
-
{
|
|
133
|
-
return this.__results;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
//==============================================================================
|
package/src/systems.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
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
|
-
const FC_KIND = {
|
|
22
|
-
SYSTEM: ['fc:System', 'fc-class:System'],
|
|
23
|
-
ORGAN: ['fc:Organ', 'fc-class:Organ'],
|
|
24
|
-
FTU: ['fc:Ftu', 'fc-class:Ftu']
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
//==============================================================================
|
|
28
|
-
|
|
29
|
-
export class SystemsManager
|
|
30
|
-
{
|
|
31
|
-
constructor(flatmap, ui, enabled=false)
|
|
32
|
-
{
|
|
33
|
-
this.__flatmap = flatmap;
|
|
34
|
-
this.__ui = ui;
|
|
35
|
-
this.__systems = new Map();
|
|
36
|
-
this.__enabledChildren = new Map();
|
|
37
|
-
for (const [_, ann] of flatmap.annotations) {
|
|
38
|
-
if (FC_KIND.SYSTEM.includes(ann['fc-class'])) {
|
|
39
|
-
const systemId = ann.name.replaceAll(' ', '_');
|
|
40
|
-
if (this.__systems.has(systemId)) {
|
|
41
|
-
this.__systems.get(systemId).featureIds.push(ann.featureId)
|
|
42
|
-
} else {
|
|
43
|
-
this.__systems.set(systemId, {
|
|
44
|
-
name: ann.name,
|
|
45
|
-
colour: ann.colour,
|
|
46
|
-
featureIds: [ ann.featureId ],
|
|
47
|
-
enabled: false,
|
|
48
|
-
pathIds: ('path-ids' in ann) ? ann['path-ids'] : [],
|
|
49
|
-
organs: this.__children(ann.children, FC_KIND.ORGAN)
|
|
50
|
-
});
|
|
51
|
-
this.__ui.enableFeature(ann.featureId, false, true);
|
|
52
|
-
}
|
|
53
|
-
for (const childId of ann['children']) {
|
|
54
|
-
this.__enabledChildren.set(childId, 0);
|
|
55
|
-
this.__ui.enableFeatureWithChildren(childId, false, true);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
for (const system of this.__systems.values()) {
|
|
60
|
-
if (enabled) {
|
|
61
|
-
this.__enableSystem(system, true);
|
|
62
|
-
} else {
|
|
63
|
-
// Disable all paths associated with the disabled system
|
|
64
|
-
this.__ui.enablePathsBySystem(system, false, true);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
__children(childFeatureIds, childClass)
|
|
70
|
-
//=====================================
|
|
71
|
-
{
|
|
72
|
-
const children = [];
|
|
73
|
-
for (const childFeatureId of childFeatureIds || []) {
|
|
74
|
-
const childAnnotation = this.__flatmap.annotation(childFeatureId);
|
|
75
|
-
if (childAnnotation !== undefined && childClass.includes(childAnnotation['fc-class'])) {
|
|
76
|
-
const child = {
|
|
77
|
-
label: childAnnotation.label,
|
|
78
|
-
models: childAnnotation.models
|
|
79
|
-
};
|
|
80
|
-
if (childClass === FC_KIND.ORGAN) {
|
|
81
|
-
child.ftus = this.__children(childAnnotation.children, FC_KIND.FTU)
|
|
82
|
-
};
|
|
83
|
-
children.push(child);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return children;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
get systems()
|
|
90
|
-
//===========
|
|
91
|
-
{
|
|
92
|
-
const systems = [];
|
|
93
|
-
for (const [systemId, system] of this.__systems.entries()) {
|
|
94
|
-
systems.push({
|
|
95
|
-
id: systemId,
|
|
96
|
-
name: system.name,
|
|
97
|
-
colour: system.colour,
|
|
98
|
-
enabled: system.enabled,
|
|
99
|
-
organs: system.organs
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
return systems;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
enable(systemId, enable=true)
|
|
106
|
-
//===========================
|
|
107
|
-
{
|
|
108
|
-
const system = this.__systems.get(systemId);
|
|
109
|
-
if (system !== undefined && enable !== system.enabled) {
|
|
110
|
-
this.__enableSystem(system, enable);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
__enableSystem(system, enable=true)
|
|
115
|
-
//=================================
|
|
116
|
-
{
|
|
117
|
-
for (const featureId of system.featureIds) {
|
|
118
|
-
const feature = this.__ui.mapFeature(featureId);
|
|
119
|
-
if (feature !== undefined) {
|
|
120
|
-
this.__ui.enableMapFeature(feature, enable);
|
|
121
|
-
for (const childFeatureId of feature.children) {
|
|
122
|
-
const enabledCount = this.__enabledChildren.get(childFeatureId);
|
|
123
|
-
if (enable && enabledCount === 0 || !enable && enabledCount == 1) {
|
|
124
|
-
this.__ui.enableFeatureWithChildren(childFeatureId, enable);
|
|
125
|
-
}
|
|
126
|
-
this.__enabledChildren.set(childFeatureId, enabledCount + (enable ? 1 : -1));
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Enable/disable all paths associated with the system
|
|
132
|
-
this.__ui.enablePathsBySystem(system, enable);
|
|
133
|
-
|
|
134
|
-
// Save system state
|
|
135
|
-
system.enabled = enable;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
systemEnabled(systemId)
|
|
139
|
-
//=====================
|
|
140
|
-
{
|
|
141
|
-
const system = this.__systems.get(systemId);
|
|
142
|
-
return (system !== undefined && system.enabled);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
//==============================================================================
|