@abi-software/flatmap-viewer 2.3.0-a.1 → 2.3.0-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/src/pathways.js CHANGED
@@ -26,18 +26,25 @@ export const PATHWAYS_LAYER = 'pathways';
26
26
 
27
27
  //==============================================================================
28
28
 
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
- };
29
+ const PATH_TYPES = [
30
+ { type: "cns", label: "CNS", colour: "#9B1FC1"},
31
+ { type: "intracardiac", 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", dashed: true},
34
+ { type: "sensory", label: "Sensory (afferent) neuron", colour: "#2A62F6"},
35
+ { type: "motor", label: "Somatic lower motor", colour: "#98561D"},
36
+ { type: "somatic", label: "Somatic lower motor", colour: "#98561D"},
37
+ { type: "symp-pre", label: "Sympathetic pre-ganglionic", colour: "#EA3423"},
38
+ { type: "symp-post", label: "Sympathetic post-ganglionic", colour: "#EA3423", dashed: true},
39
+ { type: "other", label: "Other neuron type", colour: "#888"},
40
+ { type: "arterial", label: "Arterial blood vessel", colour: "#F00"},
41
+ { type: "venous", label: "Venous blood vessel", colour: "#2F6EBA"},
42
+ { type: "centreline", label: "Nerve centrelines", colour: "#CCC", enabled: false},
43
+ { type: "error", label: "Paths with errors or warnings", colour: "#FF0"}
44
+ ];
45
+
46
+ export const PATH_STYLE_RULES =
47
+ PATH_TYPES.flatMap(pathType => [['==', ['get', 'kind'], pathType.type], pathType.colour]);
41
48
 
42
49
  //==============================================================================
43
50
 
@@ -122,27 +129,46 @@ export class Pathways
122
129
  }
123
130
  this._allFeatureIds = featureIds;
124
131
 
132
+ // Construct a list of path types we know about
133
+ const pathTypes = [];
134
+ for (const pathType of PATH_TYPES) {
135
+ pathTypes.push(pathType.type);
136
+ }
125
137
  // Map unknown path types to ``other``
126
138
  this.__typePaths = {};
127
139
  this.__typePaths['other'] = [];
128
- this.__knownPathTypes = [];
129
140
  for (const [pathType, paths] of Object.entries(flatmap.pathways['type-paths'])) {
130
- if (pathType in PATH_TYPES && pathType !== 'other') {
141
+ if (pathTypes.indexOf(pathType) >= 0) {
131
142
  this.__typePaths[pathType] = paths;
132
- this.__knownPathTypes.push({'type': pathType, ...PATH_TYPES[pathType]});
133
143
  } else {
134
144
  this.__typePaths['other'].push(...paths);
135
145
  }
136
146
  }
137
- if ('other' in this.__typePaths) {
138
- this.__knownPathTypes.push({'type': 'other', ...PATH_TYPES['other']});
139
- }
147
+ // Nerve centrelines are a special case with their own controls
148
+ this.__haveCentrelines = false;
140
149
  }
141
150
 
142
- get pathTypes()
143
- //=============
151
+ get haveCentrelines()
152
+ //===================
153
+ {
154
+ return this.__haveCentrelines;
155
+ }
156
+
157
+ pathTypes()
158
+ //=========
144
159
  {
145
- return this.__knownPathTypes;
160
+ const pathTypes = [];
161
+ for (const pathType of PATH_TYPES) {
162
+ if (pathType.type in this.__typePaths
163
+ && this.__typePaths[pathType.type].length > 0) {
164
+ if (pathType.type === 'centreline') {
165
+ this.__haveCentrelines = true;
166
+ } else {
167
+ pathTypes.push(pathType);
168
+ }
169
+ }
170
+ }
171
+ return pathTypes;
146
172
  }
147
173
 
148
174
  addPathsToFeatureSet_(paths, featureSet)
package/src/search.js CHANGED
@@ -158,7 +158,10 @@ export class SearchIndex
158
158
 
159
159
  addTerm_(featureId, text)
160
160
  //=======================
161
- { if (text) {
161
+ {
162
+ text = text.replace(new RegExp('<br/>', 'g'), ' ')
163
+ .replace('\n', ' ');
164
+ if (text) {
162
165
  this._searchEngine.add({
163
166
  id: this._featureIds.length,
164
167
  text: text