@abi-software/flatmap-viewer 2.4.2-b.3 → 2.4.2-b.4

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 CHANGED
@@ -38,7 +38,7 @@ The map server endpoint is specified as ``MAP_ENDPOINT`` in ``src/main.js``. It
38
38
  Package Installation
39
39
  ====================
40
40
 
41
- * ``npm install @abi-software/flatmap-viewer@2.4.2-b.3``
41
+ * ``npm install @abi-software/flatmap-viewer@2.4.2-b.4``
42
42
 
43
43
  Documentation
44
44
  -------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/flatmap-viewer",
3
- "version": "2.4.2-b.3",
3
+ "version": "2.4.2-b.4",
4
4
  "description": "Flatmap viewer using Maplibre GL",
5
5
  "repository": "https://github.com/AnatomicMaps/flatmap-viewer.git",
6
6
  "main": "src/main.js",
@@ -29,7 +29,8 @@ export const displayedProperties = [
29
29
  'fc-class',
30
30
  'fc-kind',
31
31
  'name',
32
- ...indexedProperties
32
+ ...indexedProperties,
33
+ 'featureId'
33
34
  ];
34
35
 
35
36
  //==============================================================================
@@ -247,18 +248,25 @@ export class InfoControl
247
248
  }
248
249
  }
249
250
  });
250
- displayValues.set(feature.id, values);
251
+ if (Object.keys(values).length > 0) {
252
+ displayValues.set(feature.id, values);
253
+ }
251
254
  }
252
255
  }
253
256
 
254
257
  const htmlList = [];
255
- for (const values of displayValues.values()) {
258
+ let lastId = null;
259
+ for (const [id, values] of displayValues.entries()) {
260
+ if (lastId !== null && lastId !== id) {
261
+ htmlList.push(`<span><hr/></span><span></span>`);
262
+ }
256
263
  for (const prop of displayedProperties) {
257
264
  if (prop in values) {
258
265
  htmlList.push(`<span class="info-name">${prop}:</span>`);
259
266
  htmlList.push(`<span class="info-value">${values[prop]}</span>`);
260
267
  }
261
268
  }
269
+ lastId = id;
262
270
  }
263
271
  if (htmlList.length > 0) {
264
272
  html = `<div id="info-control-info">${htmlList.join('\n')}</div>`;
@@ -622,6 +622,12 @@ class FlatMap
622
622
  return (ann && 'models' in ann) ? utils.normaliseId(ann.models) : null;
623
623
  }
624
624
 
625
+ /**
626
+ * Get model terms of all paths connected to a node.
627
+ *
628
+ * @param {number} pathId The local (GeoJSON) identifier of a node
629
+ * @return {set<string>} Model terms of all paths connected to the node
630
+ */
625
631
  nodePathModels(nodeId)
626
632
  //====================
627
633
  {
@@ -630,6 +636,20 @@ class FlatMap
630
636
  }
631
637
  }
632
638
 
639
+ /**
640
+ * Get feature ids of all nodes of a path model.
641
+ *
642
+ * @param {string} pathId The path model identifier
643
+ * @return {set<number>} Local (GeoJSON) identifiers of features on the path
644
+ */
645
+ pathModelNodes(modelId)
646
+ //=====================
647
+ {
648
+ if (this._userInteractions !== null) {
649
+ return this._userInteractions.pathModelNodes(modelId);
650
+ }
651
+ }
652
+
633
653
  get layers()
634
654
  //==========
635
655
  {
@@ -1012,23 +1032,18 @@ class FlatMap
1012
1032
  return false;
1013
1033
  }
1014
1034
 
1015
- /**
1016
- * Generate a callback as a result of some event with a flatmap feature.
1017
- *
1018
- * @param {string} eventType The event type
1019
- * @param {Object} properties Properties associated with the feature
1020
- */
1021
- featureEvent(eventType, properties)
1022
- //=================================
1035
+ __exportedProperties(properties)
1036
+ //==============================
1023
1037
  {
1024
1038
  const data = {};
1025
1039
  const exportedProperties = [
1040
+ 'id',
1041
+ 'featureId',
1026
1042
  'connectivity',
1027
1043
  'dataset',
1028
1044
  'kind',
1029
1045
  'label',
1030
1046
  'models',
1031
- 'nodeId',
1032
1047
  'source',
1033
1048
  'taxons',
1034
1049
  'hyperlinks'
@@ -1042,6 +1057,8 @@ class FlatMap
1042
1057
  if (value !== undefined) {
1043
1058
  if (jsonProperties.includes(property)) {
1044
1059
  data[property] = JSON.parse(properties[property])
1060
+ } else if (property === 'featureId') {
1061
+ data[property] = +properties[property]; // Ensure numeric
1045
1062
  } else {
1046
1063
  data[property] = properties[property];
1047
1064
  }
@@ -1050,12 +1067,41 @@ class FlatMap
1050
1067
  }
1051
1068
  if (Object.keys(data).length > 0) {
1052
1069
  data['type'] = 'feature';
1070
+ }
1071
+ return data;
1072
+ }
1073
+
1074
+ /**
1075
+ * Generate a callback as a result of some event with a flatmap feature.
1076
+ *
1077
+ * @param {string} eventType The event type
1078
+ * @param {Object} properties Properties associated with the feature
1079
+ */
1080
+ featureEvent(eventType, properties)
1081
+ //=================================
1082
+ {
1083
+ const data = this.__exportedProperties(properties);
1084
+
1085
+ if (Object.keys(data).length > 0) {
1053
1086
  this.callback(eventType, data);
1054
1087
  return true;
1055
1088
  }
1056
1089
  return false;
1057
1090
  }
1058
1091
 
1092
+ /**
1093
+ * Return properties associated with a feature.
1094
+ *
1095
+ * @param {number} featureId The feature's internal (GeoJSON) id
1096
+ * @returns {Object} Properties associated with the feature
1097
+ */
1098
+ featureProperties(featureId)
1099
+ //==========================
1100
+ {
1101
+ const properties = this.annotation(featureId);
1102
+ return properties ? this.__exportedProperties(properties) : {};
1103
+ }
1104
+
1059
1105
  /**
1060
1106
  * Generate a callback as a result of some event with a marker.
1061
1107
  *
@@ -1089,7 +1089,7 @@ export class UserInteractions
1089
1089
  }
1090
1090
  }
1091
1091
  if ('nodeId' in feature.properties) {
1092
- for (const featureId of this.__pathManager.nodeFeatureIds(feature.properties.nodeId)) {
1092
+ for (const featureId of this.__pathManager.pathFeatureIds(feature.properties.nodeId)) {
1093
1093
  this.__activateFeature(this.mapFeature(featureId));
1094
1094
  }
1095
1095
  }
@@ -1122,6 +1122,12 @@ export class UserInteractions
1122
1122
  return featureIds;
1123
1123
  }
1124
1124
 
1125
+ pathModelNodes(modelId)
1126
+ //=====================
1127
+ {
1128
+ return this.__pathManager.pathModelNodes(modelId);
1129
+ }
1130
+
1125
1131
  nodePathModels(nodeId)
1126
1132
  //====================
1127
1133
  {
package/src/pathways.js CHANGED
@@ -214,16 +214,6 @@ export class PathManager
214
214
  return featureIds;
215
215
  }
216
216
 
217
- nodeFeatureIds(nodeId)
218
- //===================
219
- {
220
- const featureIds = new Set();
221
- if (nodeId in this._nodePaths) {
222
- this.addPathsToFeatureSet_(this._nodePaths[nodeId], featureIds);
223
- }
224
- return featureIds;
225
- }
226
-
227
217
  pathProperties(feature)
228
218
  //=====================
229
219
  {
@@ -348,6 +338,20 @@ export class PathManager
348
338
  }
349
339
  return modelIds;
350
340
  }
341
+
342
+ pathModelNodes(modelId)
343
+ //=====================
344
+ {
345
+ const nodeIds = new Set();
346
+ if (modelId in this.__pathModelPaths) {
347
+ for (const pathId of this.__pathModelPaths[modelId]) {
348
+ for (const nodeId of this.__paths[pathId].nodes) {
349
+ nodeIds.add(nodeId);
350
+ }
351
+ }
352
+ }
353
+ return nodeIds;
354
+ }
351
355
  }
352
356
 
353
357
  //==============================================================================