@webviz/subsurface-viewer 1.10.3 → 1.10.5

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 (32) hide show
  1. package/dist/hooks/useMultiViewPicking/MultiViewPickingInfoAssembler.d.ts +4 -2
  2. package/dist/hooks/useMultiViewPicking/MultiViewPickingInfoAssembler.js +58 -37
  3. package/dist/hooks/useMultiViewPicking/MultiViewPickingInfoAssembler.js.map +1 -1
  4. package/dist/layers/grid3d/fragment_lines.glsl.d.ts +1 -1
  5. package/dist/layers/grid3d/fragment_lines.glsl.js +1 -0
  6. package/dist/layers/grid3d/fragment_lines.glsl.js.map +1 -1
  7. package/dist/layers/map/fragment_lines.glsl.d.ts +1 -1
  8. package/dist/layers/map/fragment_lines.glsl.js +1 -0
  9. package/dist/layers/map/fragment_lines.glsl.js.map +1 -1
  10. package/dist/layers/map/privateMapLayer.js +1 -1
  11. package/dist/layers/map/privateMapLayer.js.map +1 -1
  12. package/dist/layers/types.d.ts +1 -1
  13. package/dist/layers/utils/layerTools.d.ts +4 -4
  14. package/dist/layers/utils/layerTools.js.map +1 -1
  15. package/dist/layers/wells/layers/wellLabelLayer.d.ts +7 -6
  16. package/dist/layers/wells/layers/wellLabelLayer.js +1 -2
  17. package/dist/layers/wells/layers/wellLabelLayer.js.map +1 -1
  18. package/dist/layers/wells/types.d.ts +42 -0
  19. package/dist/layers/wells/types.js +2 -0
  20. package/dist/layers/wells/types.js.map +1 -0
  21. package/dist/layers/wells/utils/abscissaTransform.d.ts +1 -1
  22. package/dist/layers/wells/utils/abscissaTransform.js.map +1 -1
  23. package/dist/layers/wells/utils/spline.d.ts +2 -2
  24. package/dist/layers/wells/utils/spline.js +1 -0
  25. package/dist/layers/wells/utils/spline.js.map +1 -1
  26. package/dist/layers/wells/utils/trajectory.d.ts +5 -4
  27. package/dist/layers/wells/utils/trajectory.js +5 -4
  28. package/dist/layers/wells/utils/trajectory.js.map +1 -1
  29. package/dist/layers/wells/wellsLayer.d.ts +35 -39
  30. package/dist/layers/wells/wellsLayer.js +138 -127
  31. package/dist/layers/wells/wellsLayer.js.map +1 -1
  32. package/package.json +1 -1
@@ -12,12 +12,17 @@ import { WellLabelLayer } from "./layers/wellLabelLayer";
12
12
  import { abscissaTransform } from "./utils/abscissaTransform";
13
13
  import { GetBoundingBox, checkWells, coarsenWells, invertPath, splineRefine, } from "./utils/spline";
14
14
  import { getColor, getTrajectory } from "./utils/trajectory";
15
- function onDataLoad(data, context) {
16
- const bbox = GetBoundingBox(data);
17
- if (typeof context.layer.props.reportBoundingBox !== "undefined") {
18
- context.layer.props.reportBoundingBox({ layerBoundingBox: bbox });
19
- }
20
- }
15
+ export var SubLayerId;
16
+ (function (SubLayerId) {
17
+ SubLayerId["COLORS"] = "colors";
18
+ SubLayerId["SIMPLE"] = "simple";
19
+ SubLayerId["OUTLINE"] = "outline";
20
+ SubLayerId["HIGHLIGHT"] = "highlight";
21
+ SubLayerId["HIGHLIGHT_2"] = "highlight2";
22
+ SubLayerId["LOG_CURVE"] = "log_curve";
23
+ SubLayerId["SELECTION"] = "selection";
24
+ SubLayerId["LABELS"] = "labels";
25
+ })(SubLayerId || (SubLayerId = {}));
21
26
  const defaultProps = {
22
27
  "@@type": "WellsLayer",
23
28
  name: "Wells",
@@ -42,40 +47,11 @@ const defaultProps = {
42
47
  wellNameColor: [0, 0, 0, 255],
43
48
  wellNameSize: 10,
44
49
  };
45
- function multiply(pair, factor) {
46
- return [pair[0] * factor, pair[1] * factor];
47
- }
48
50
  const LINE = "line";
49
51
  const POINT = "point";
50
52
  const DEFAULT_POINT_SIZE = 8;
51
53
  const DEFAULT_LINE_WIDTH = 5;
52
54
  const DEFAULT_DASH = [5, 5];
53
- function getDashFactor(accessor, width_accessor, offset = 0) {
54
- return (object, objectInfo) => {
55
- let width = DEFAULT_LINE_WIDTH;
56
- if (typeof width_accessor == "function") {
57
- width = width_accessor(object);
58
- }
59
- else if (width_accessor) {
60
- width = width_accessor;
61
- }
62
- const factor = width / (width + offset);
63
- let dash = [0, 0];
64
- if (typeof accessor == "function") {
65
- dash = accessor(object, objectInfo);
66
- }
67
- else if (accessor)
68
- dash = accessor;
69
- else if (accessor)
70
- dash = DEFAULT_DASH;
71
- if (dash.length == 2) {
72
- return multiply(dash, factor);
73
- }
74
- else {
75
- return multiply(DEFAULT_DASH, factor);
76
- }
77
- };
78
- }
79
55
  export function getSize(type, accessor, offset = 0) {
80
56
  if (typeof accessor == "function") {
81
57
  return (object) => {
@@ -93,24 +69,28 @@ export function getSize(type, accessor, offset = 0) {
93
69
  return 0;
94
70
  }
95
71
  export default class WellsLayer extends CompositeLayer {
96
- initializeState() {
97
- let data = this.props.data;
72
+ recomputeDataState() {
73
+ const data = this.props.data;
98
74
  const refine = this.props.refine;
99
- if (!data || isEmpty(data)) {
75
+ const doRefine = typeof refine === "number" ? refine > 1 : refine;
76
+ const stepCount = typeof refine === "number" ? refine : 5;
77
+ if (!dataIsReady(data)) {
100
78
  return;
101
79
  }
80
+ let transformedData = data;
102
81
  if (this.props.ZIncreasingDownwards) {
103
- data = invertPath(data);
82
+ transformedData = invertPath(transformedData);
104
83
  }
105
84
  if (this.props.section) {
106
- data = abscissaTransform(data);
85
+ transformedData = abscissaTransform(transformedData);
107
86
  }
108
- checkWells(data);
87
+ // Mutate data to remove duplicates
88
+ checkWells(transformedData);
109
89
  // Conditionally apply spline interpolation to refine the well path.
110
- const doRefine = typeof refine === "number" ? refine > 1 : refine;
111
- const stepCount = typeof refine === "number" ? refine : 5;
112
- data = doRefine ? splineRefine(data, stepCount) : data;
113
- this.setState(Object.assign(Object.assign({}, this.state), { data }));
90
+ if (doRefine) {
91
+ transformedData = splineRefine(transformedData, stepCount);
92
+ }
93
+ this.setState({ data: transformedData });
114
94
  }
115
95
  shouldUpdateState({ changeFlags }) {
116
96
  return (changeFlags.viewportChanged ||
@@ -122,10 +102,9 @@ export default class WellsLayer extends CompositeLayer {
122
102
  !isEqual(props.ZIncreasingDownwards, oldProps.ZIncreasingDownwards) ||
123
103
  !isEqual(props.refine, oldProps.refine);
124
104
  if (needs_reload) {
125
- this.initializeState();
105
+ this.recomputeDataState();
126
106
  }
127
107
  }
128
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
129
108
  onClick(info) {
130
109
  var _a;
131
110
  // Make selection only when drawing is disabled
@@ -134,7 +113,7 @@ export default class WellsLayer extends CompositeLayer {
134
113
  }
135
114
  else {
136
115
  this.context.userData.setEditedData({
137
- selectedWell: (_a = info.object.properties) === null || _a === void 0 ? void 0 : _a["name"],
116
+ selectedWell: (_a = info.object) === null || _a === void 0 ? void 0 : _a.properties.name,
138
117
  });
139
118
  return false; // do not return true to allow DeckGL props.onClick to be called
140
119
  }
@@ -154,6 +133,9 @@ export default class WellsLayer extends CompositeLayer {
154
133
  });
155
134
  }
156
135
  }
136
+ getWellDataState() {
137
+ return this.state.data;
138
+ }
157
139
  getLegendData(value) {
158
140
  return getLegendData(value, "", this.props.logName, this.props.logColor);
159
141
  }
@@ -213,7 +195,7 @@ export default class WellsLayer extends CompositeLayer {
213
195
  [GL.POLYGON_OFFSET_FILL]: true,
214
196
  };
215
197
  const fastDrawing = this.props.simplifiedRendering;
216
- const wellLabelProps = this.getSubLayerProps(Object.assign(Object.assign({}, this.props.wellLabel), { data,
198
+ const wellLabelProps = this.getSubLayerProps(Object.assign(Object.assign({}, this.props.wellLabel), { id: SubLayerId.LABELS, data,
217
199
  // Z is always increasing upwards at this stage
218
200
  zIncreasingDownwards: false, getPositionAlongPath: this.getWellLabelPosition(), getColor: (_b = (_a = this.props.wellLabel) === null || _a === void 0 ? void 0 : _a.getColor) !== null && _b !== void 0 ? _b : this.props.wellNameColor, getAnchor: "start", getSize: (_d = (_c = this.props.wellLabel) === null || _c === void 0 ? void 0 : _c.getSize) !== null && _d !== void 0 ? _d : this.props.wellNameSize, parameters, visible: !fastDrawing, background: ((_e = this.props.wellLabel) === null || _e === void 0 ? void 0 : _e.background) ||
219
201
  this.props.hideOverlappingWellNames }));
@@ -221,12 +203,12 @@ export default class WellsLayer extends CompositeLayer {
221
203
  }
222
204
  renderLayers() {
223
205
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
224
- if (!this.props.data.features) {
225
- return [];
226
- }
227
- const data = this.state["data"];
206
+ const data = this.getWellDataState();
228
207
  const positionFormat = "XYZ";
229
208
  const isDashed = !!((_a = this.props.lineStyle) === null || _a === void 0 ? void 0 : _a.dash);
209
+ if (!data || !(data === null || data === void 0 ? void 0 : data.features.length)) {
210
+ return [];
211
+ }
230
212
  const extensions = [
231
213
  new PathStyleExtension({
232
214
  dash: isDashed,
@@ -255,11 +237,11 @@ export default class WellsLayer extends CompositeLayer {
255
237
  parameters,
256
238
  visible: fastDrawing,
257
239
  };
258
- const colorsLayerProps = this.getSubLayerProps(Object.assign(Object.assign({}, defaultLayerProps), { id: "colors", pickable: true, extensions, getDashArray: getDashFactor((_d = this.props.lineStyle) === null || _d === void 0 ? void 0 : _d.dash, getSize(LINE, (_e = this.props.lineStyle) === null || _e === void 0 ? void 0 : _e.width), -1), visible: !fastDrawing, getLineColor: getColor((_f = this.props.lineStyle) === null || _f === void 0 ? void 0 : _f.color), getFillColor: getColor((_g = this.props.wellHeadStyle) === null || _g === void 0 ? void 0 : _g.color) }));
259
- const fastLayerProps = this.getSubLayerProps(Object.assign(Object.assign({}, defaultLayerProps), { id: "simple", positionFormat, getLineColor: getColor((_h = this.props.lineStyle) === null || _h === void 0 ? void 0 : _h.color), getFillColor: getColor((_j = this.props.wellHeadStyle) === null || _j === void 0 ? void 0 : _j.color) }));
260
- const outlineLayerProps = this.getSubLayerProps(Object.assign(Object.assign({}, defaultLayerProps), { id: "outline", getLineWidth: getSize(LINE, (_k = this.props.lineStyle) === null || _k === void 0 ? void 0 : _k.width), getPointRadius: getSize(POINT, (_l = this.props.wellHeadStyle) === null || _l === void 0 ? void 0 : _l.size), extensions, getDashArray: getDashFactor((_m = this.props.lineStyle) === null || _m === void 0 ? void 0 : _m.dash), visible: this.props.outline && !fastDrawing, parameters: Object.assign(Object.assign({}, parameters), { [GL.POLYGON_OFFSET_FACTOR]: 1, [GL.POLYGON_OFFSET_UNITS]: 1 }) }));
261
- const highlightLayerProps = this.getSubLayerProps(Object.assign(Object.assign({}, defaultLayerProps), { id: "highlight", data: getWellObjectByName(data.features, this.props.selectedWell), getLineWidth: getSize(LINE, (_o = this.props.lineStyle) === null || _o === void 0 ? void 0 : _o.width, 2), getPointRadius: getSize(POINT, (_p = this.props.wellHeadStyle) === null || _p === void 0 ? void 0 : _p.size, 2), getLineColor: getColor((_q = this.props.lineStyle) === null || _q === void 0 ? void 0 : _q.color), getFillColor: getColor((_r = this.props.wellHeadStyle) === null || _r === void 0 ? void 0 : _r.color), visible: this.props.logCurves && !fastDrawing }));
262
- const highlightMultiWellsLayerProps = this.getSubLayerProps(Object.assign(Object.assign({}, defaultLayerProps), { id: "highlight2", data: getWellObjectsByName(data.features, this.state["selectedMultiWells"]), getPointRadius: getSize(POINT, (_s = this.props.wellHeadStyle) === null || _s === void 0 ? void 0 : _s.size, 2), getFillColor: [255, 140, 0], getLineColor: [255, 140, 0], visible: this.props.logCurves && !fastDrawing }));
240
+ const colorsLayerProps = this.getSubLayerProps(Object.assign(Object.assign({}, defaultLayerProps), { id: SubLayerId.COLORS, pickable: true, extensions, getDashArray: getDashFactor((_d = this.props.lineStyle) === null || _d === void 0 ? void 0 : _d.dash, getSize(LINE, (_e = this.props.lineStyle) === null || _e === void 0 ? void 0 : _e.width), -1), visible: !fastDrawing, getLineColor: getColor((_f = this.props.lineStyle) === null || _f === void 0 ? void 0 : _f.color), getFillColor: getColor((_g = this.props.wellHeadStyle) === null || _g === void 0 ? void 0 : _g.color) }));
241
+ const fastLayerProps = this.getSubLayerProps(Object.assign(Object.assign({}, defaultLayerProps), { id: SubLayerId.SIMPLE, positionFormat, getLineColor: getColor((_h = this.props.lineStyle) === null || _h === void 0 ? void 0 : _h.color), getFillColor: getColor((_j = this.props.wellHeadStyle) === null || _j === void 0 ? void 0 : _j.color) }));
242
+ const outlineLayerProps = this.getSubLayerProps(Object.assign(Object.assign({}, defaultLayerProps), { id: SubLayerId.OUTLINE, getLineWidth: getSize(LINE, (_k = this.props.lineStyle) === null || _k === void 0 ? void 0 : _k.width), getPointRadius: getSize(POINT, (_l = this.props.wellHeadStyle) === null || _l === void 0 ? void 0 : _l.size), extensions, getDashArray: getDashFactor((_m = this.props.lineStyle) === null || _m === void 0 ? void 0 : _m.dash), visible: this.props.outline && !fastDrawing, parameters: Object.assign(Object.assign({}, parameters), { [GL.POLYGON_OFFSET_FACTOR]: 1, [GL.POLYGON_OFFSET_UNITS]: 1 }) }));
243
+ const highlightLayerProps = this.getSubLayerProps(Object.assign(Object.assign({}, defaultLayerProps), { id: SubLayerId.HIGHLIGHT, data: getWellObjectByName(data.features, this.props.selectedWell), getLineWidth: getSize(LINE, (_o = this.props.lineStyle) === null || _o === void 0 ? void 0 : _o.width, 2), getPointRadius: getSize(POINT, (_p = this.props.wellHeadStyle) === null || _p === void 0 ? void 0 : _p.size, 2), getLineColor: getColor((_q = this.props.lineStyle) === null || _q === void 0 ? void 0 : _q.color), getFillColor: getColor((_r = this.props.wellHeadStyle) === null || _r === void 0 ? void 0 : _r.color), visible: this.props.logCurves && !fastDrawing }));
244
+ const highlightMultiWellsLayerProps = this.getSubLayerProps(Object.assign(Object.assign({}, defaultLayerProps), { id: SubLayerId.HIGHLIGHT_2, data: getWellObjectsByName(data.features, this.state.selectedMultiWells), getPointRadius: getSize(POINT, (_s = this.props.wellHeadStyle) === null || _s === void 0 ? void 0 : _s.size, 2), getFillColor: [255, 140, 0], getLineColor: [255, 140, 0], visible: this.props.logCurves && !fastDrawing }));
263
245
  const fastLayer = new GeoJsonLayer(fastLayerProps);
264
246
  const outlineLayer = new GeoJsonLayer(outlineLayerProps);
265
247
  const colorsLayer = new GeoJsonLayer(colorsLayerProps);
@@ -268,7 +250,7 @@ export default class WellsLayer extends CompositeLayer {
268
250
  // Highlight the multi selected wells.
269
251
  const highlightMultiWellsLayer = new GeoJsonLayer(highlightMultiWellsLayerProps);
270
252
  const logLayer = new PathLayer(this.getSubLayerProps({
271
- id: "log_curve",
253
+ id: SubLayerId.LOG_CURVE,
272
254
  data: this.props.logData,
273
255
  positionFormat,
274
256
  pickable: true,
@@ -306,7 +288,7 @@ export default class WellsLayer extends CompositeLayer {
306
288
  visible: this.props.logCurves && !fastDrawing,
307
289
  }));
308
290
  const selectionLayer = new PathLayer(this.getSubLayerProps({
309
- id: "selection",
291
+ id: SubLayerId.SELECTION,
310
292
  data: this.props.logData,
311
293
  positionFormat,
312
294
  pickable: false,
@@ -315,16 +297,16 @@ export default class WellsLayer extends CompositeLayer {
315
297
  miterLimit: 100,
316
298
  getPath: (d) => {
317
299
  var _a;
318
- return getLogPath1(data.features, d, this.state["well"], this.state["selection"], this.props.logrunName, (_a = this.props.lineStyle) === null || _a === void 0 ? void 0 : _a.color);
300
+ return getLogPath1(data.features, d, this.state.well, this.state.selection, this.props.logrunName, (_a = this.props.lineStyle) === null || _a === void 0 ? void 0 : _a.color);
319
301
  },
320
- getColor: (d) => getLogColor1(data.features, d, this.state["well"], this.state["selection"], this.props.logrunName),
302
+ getColor: (d) => getLogColor1(data.features, d, this.state.well, this.state.selection, this.props.logrunName),
321
303
  getWidth: (d) => this.props.logRadius * 1.5 ||
322
304
  getLogWidth(d, this.props.logrunName, this.props.logName),
323
305
  updateTriggers: {
324
306
  getColor: [
325
307
  this.props.logrunName,
326
- this.state["well"],
327
- this.state["selection"],
308
+ this.state.well,
309
+ this.state.selection,
328
310
  ],
329
311
  getWidth: [
330
312
  this.props.logrunName,
@@ -334,8 +316,8 @@ export default class WellsLayer extends CompositeLayer {
334
316
  getPath: [
335
317
  positionFormat,
336
318
  this.props.logrunName,
337
- this.state["well"],
338
- this.state["selection"],
319
+ this.state.well,
320
+ this.state.selection,
339
321
  ],
340
322
  },
341
323
  onDataLoad: (value) => {
@@ -360,23 +342,32 @@ export default class WellsLayer extends CompositeLayer {
360
342
  return layers;
361
343
  }
362
344
  getPickingInfo({ info }) {
363
- var _a, _b;
345
+ var _a, _b, _c, _d, _e;
364
346
  if (!info.object)
365
347
  return Object.assign(Object.assign({}, info), { properties: [], logName: "" });
366
- const coordinate = (info.coordinate || [0, 0, 0]);
348
+ const features = (_b = (_a = this.getWellDataState()) === null || _a === void 0 ? void 0 : _a.features) !== null && _b !== void 0 ? _b : [];
349
+ const coordinate = info.coordinate || [0, 0, 0];
367
350
  const zScale = this.props.modelMatrix ? this.props.modelMatrix[10] : 1;
368
351
  if (typeof coordinate[2] !== "undefined") {
369
352
  coordinate[2] /= Math.max(0.001, zScale);
370
353
  }
371
- let md_property = getMdProperty(coordinate, info.object, (_a = this.props.lineStyle) === null || _a === void 0 ? void 0 : _a.color, info.featureType);
372
- if (!md_property) {
373
- md_property = getLogProperty(coordinate, this.props.data.features, info.object, this.props.logrunName, "MD");
354
+ let md_property = null;
355
+ let tvd_property = null;
356
+ let log_property = null;
357
+ // ! This needs to be updated if we ever change the sub-layer id!
358
+ if (((_c = info.sourceLayer) === null || _c === void 0 ? void 0 : _c.id) === `${this.props.id}-${SubLayerId.LOG_CURVE}`) {
359
+ // The user is hovering a well log entry
360
+ const logPick = info;
361
+ md_property = getLogProperty(coordinate, features, logPick.object, this.props.logrunName, "MD");
362
+ tvd_property = getLogProperty(coordinate, features, logPick.object, this.props.logrunName, "TVD");
363
+ log_property = getLogProperty(coordinate, features, info.object, this.props.logrunName, this.props.logName);
374
364
  }
375
- let tvd_property = getTvdProperty(coordinate, info.object, (_b = this.props.lineStyle) === null || _b === void 0 ? void 0 : _b.color, info.featureType);
376
- if (!tvd_property) {
377
- tvd_property = getLogProperty(coordinate, this.props.data.features, info.object, this.props.logrunName, "TVD");
365
+ else {
366
+ // User is hovering a wellbore path
367
+ const wellpickInfo = info;
368
+ md_property = getMdProperty(coordinate, wellpickInfo.object, (_d = this.props.lineStyle) === null || _d === void 0 ? void 0 : _d.color, info.featureType);
369
+ tvd_property = getTvdProperty(coordinate, info.object, (_e = this.props.lineStyle) === null || _e === void 0 ? void 0 : _e.color, info.featureType);
378
370
  }
379
- const log_property = getLogProperty(coordinate, this.props.data.features, info.object, this.props.logrunName, this.props.logName);
380
371
  // Patch for inverting tvd readout to fix issue #830,
381
372
  // should make proper fix when handling z increase direction - issue #842
382
373
  const inverted_tvd_property = tvd_property && Object.assign(Object.assign({}, tvd_property), { value: (tvd_property === null || tvd_property === void 0 ? void 0 : tvd_property.value) * -1 });
@@ -393,6 +384,45 @@ export default class WellsLayer extends CompositeLayer {
393
384
  WellsLayer.layerName = "WellsLayer";
394
385
  WellsLayer.defaultProps = Object.assign(Object.assign({}, defaultProps), { onDataLoad: (data, context) => onDataLoad(data, context) });
395
386
  //================= Local help functions. ==================
387
+ function onDataLoad(data, context) {
388
+ const bbox = GetBoundingBox(data);
389
+ if (typeof context.layer.props.reportBoundingBox !== "undefined") {
390
+ context.layer.props.reportBoundingBox({ layerBoundingBox: bbox });
391
+ }
392
+ }
393
+ function multiply(pair, factor) {
394
+ return [pair[0] * factor, pair[1] * factor];
395
+ }
396
+ function getDashFactor(accessor, width_accessor, offset = 0) {
397
+ return (object, objectInfo) => {
398
+ let width = DEFAULT_LINE_WIDTH;
399
+ if (typeof width_accessor == "function") {
400
+ width = width_accessor(object);
401
+ }
402
+ else if (width_accessor) {
403
+ width = width_accessor;
404
+ }
405
+ const factor = width / (width + offset);
406
+ let dash = [0, 0];
407
+ if (typeof accessor == "function") {
408
+ dash = accessor(object, objectInfo);
409
+ }
410
+ else if (accessor)
411
+ dash = accessor;
412
+ else if (accessor)
413
+ dash = DEFAULT_DASH;
414
+ if (dash.length == 2) {
415
+ return multiply(dash, factor);
416
+ }
417
+ else {
418
+ return multiply(DEFAULT_DASH, factor);
419
+ }
420
+ };
421
+ }
422
+ function dataIsReady(layerData) {
423
+ // Deck.gl always shows prop.data as `[]` while external data is being loaded
424
+ return !!layerData && !isEmpty(layerData);
425
+ }
396
426
  function getColumn(data, col) {
397
427
  const column = [];
398
428
  for (let i = 0; i < data.length; i++) {
@@ -426,33 +456,30 @@ function isSelectedLogRun(d, logrun_name) {
426
456
  return d.header.name.toLowerCase() === logrun_name.toLowerCase();
427
457
  }
428
458
  function getWellObjectByName(wells_data, name) {
429
- return wells_data === null || wells_data === void 0 ? void 0 : wells_data.find((item) => { var _a, _b; return ((_b = (_a = item.properties) === null || _a === void 0 ? void 0 : _a["name"]) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === (name === null || name === void 0 ? void 0 : name.toLowerCase()); });
459
+ return wells_data === null || wells_data === void 0 ? void 0 : wells_data.find((item) => { var _a, _b; return ((_b = (_a = item.properties) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === (name === null || name === void 0 ? void 0 : name.toLowerCase()); });
430
460
  }
431
461
  function getWellObjectsByName(wells_data, name) {
432
462
  const res = [];
433
463
  for (let i = 0; i < (name === null || name === void 0 ? void 0 : name.length); i++) {
434
464
  wells_data === null || wells_data === void 0 ? void 0 : wells_data.find((item) => {
435
465
  var _a, _b, _c;
436
- if (((_b = (_a = item.properties) === null || _a === void 0 ? void 0 : _a["name"]) === null || _b === void 0 ? void 0 : _b.toLowerCase()) ===
437
- ((_c = name[i]) === null || _c === void 0 ? void 0 : _c.toLowerCase())) {
466
+ if (((_b = (_a = item.properties) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === ((_c = name[i]) === null || _c === void 0 ? void 0 : _c.toLowerCase()))
438
467
  res.push(item);
439
- }
440
468
  });
441
469
  }
442
470
  return res;
443
471
  }
444
472
  function getPointGeometry(well_object) {
445
- var _a;
446
- return (_a = well_object.geometry) === null || _a === void 0 ? void 0 : _a.geometries.find((item) => item.type == "Point");
473
+ const geometries = well_object.geometry.geometries;
474
+ return geometries.find((item) => item.type === "Point");
447
475
  }
448
476
  // Return well head position from Point Geometry
449
477
  function getWellHeadPosition(well_object) {
450
- var _a;
451
- return (_a = getPointGeometry(well_object)) === null || _a === void 0 ? void 0 : _a.coordinates;
478
+ var _a, _b;
479
+ return (_b = (_a = getPointGeometry(well_object)) === null || _a === void 0 ? void 0 : _a.coordinates) !== null && _b !== void 0 ? _b : [-1, -1, -1];
452
480
  }
453
481
  function getWellMds(well_object) {
454
- var _a;
455
- return (_a = well_object.properties) === null || _a === void 0 ? void 0 : _a["md"][0];
482
+ return well_object.properties.md[0];
456
483
  }
457
484
  function getNeighboringMdIndices(mds, md) {
458
485
  const idx = mds.findIndex((x) => x >= md);
@@ -495,9 +522,7 @@ function getLogIndexByNames(d, names) {
495
522
  }
496
523
  return -1;
497
524
  }
498
- function getLogColor(d, logrun_name, log_name, logColor, colorTables,
499
- // eslint-disable-next-line
500
- colorMappingFunction, isLog) {
525
+ function getLogColor(d, logrun_name, log_name, logColor, colorTables, colorMappingFunction, isLog) {
501
526
  var _a;
502
527
  const log_data = getLogValues(d, logrun_name, log_name);
503
528
  const log_info = getLogInfo(d, logrun_name, log_name);
@@ -509,17 +534,12 @@ colorMappingFunction, isLog) {
509
534
  const max = Math.max(...log_data);
510
535
  const max_delta = max - min;
511
536
  log_data.forEach((value) => {
537
+ const adjustedVal = (value - min) / max_delta;
512
538
  const rgb = colorMappingFunction
513
- ? colorMappingFunction((value - min) / max_delta)
514
- : rgbValues((value - min) / max_delta, logColor, colorTables);
515
- rgbValues(value - min / max_delta, logColor, colorTables, isLog);
539
+ ? colorMappingFunction(adjustedVal)
540
+ : rgbValues(adjustedVal, logColor, colorTables, isLog);
516
541
  if (rgb) {
517
- if (Array.isArray(rgb)) {
518
- log_color.push([rgb[0], rgb[1], rgb[2]]);
519
- }
520
- else {
521
- log_color.push([rgb === null || rgb === void 0 ? void 0 : rgb.r, rgb === null || rgb === void 0 ? void 0 : rgb.g, rgb === null || rgb === void 0 ? void 0 : rgb.b]);
522
- }
542
+ log_color.push([rgb[0], rgb[1], rgb[2]]);
523
543
  }
524
544
  else {
525
545
  log_color.push([0, 0, 0, 0]); // push transparent for null/undefined log values
@@ -530,53 +550,44 @@ colorMappingFunction, isLog) {
530
550
  // well log data set for ex : H1: Array(2)0: (4) [255, 26, 202, 255] 1: 13
531
551
  const log_attributes = (_a = getDiscreteLogMetadata(d, log_name)) === null || _a === void 0 ? void 0 : _a.objects;
532
552
  const logLength = Object.keys(log_attributes).length;
533
- // eslint-disable-next-line
534
553
  const attributesObject = {};
535
- const categorial = true;
554
+ const categorical = true;
536
555
  Object.keys(log_attributes).forEach((key) => {
537
556
  // get the point from log_attributes
538
557
  const point = log_attributes[key][1];
539
- const categorialMin = 0;
540
- const categorialMax = logLength - 1;
558
+ const categoricalMin = 0;
559
+ const categoricalMax = logLength - 1;
541
560
  let rgb;
542
561
  if (colorMappingFunction) {
543
- rgb = colorMappingFunction(point, categorial, categorialMin, categorialMax);
562
+ rgb = colorMappingFunction(point, categorical, categoricalMin, categoricalMax);
544
563
  }
545
564
  else {
546
- // if colormap function is not defined
565
+ // if color-map function is not defined
547
566
  const arrayOfColors = getColors(logColor, colorTables, point);
548
567
  if (!arrayOfColors.length)
549
- console.error("Empty or missed '" + logColor + "' color table");
550
- rgb = arrayOfColors;
568
+ console.error(`Empty or missed '${logColor}' color table`);
569
+ else {
570
+ rgb = arrayOfColors;
571
+ }
551
572
  }
552
573
  if (rgb) {
553
- if (Array.isArray(rgb)) {
554
- if (rgb.length === 3) {
555
- attributesObject[key] = [
556
- [rgb[0], rgb[1], rgb[2]],
557
- point,
558
- ];
559
- }
560
- else {
561
- attributesObject[key] = [
562
- [rgb[1], rgb[2], rgb[3]],
563
- point,
564
- ];
565
- }
574
+ if (rgb.length === 3) {
575
+ attributesObject[key] = [[rgb[0], rgb[1], rgb[2]], point];
566
576
  }
567
577
  else {
568
- attributesObject[key] = [[rgb.r, rgb.g, rgb.b], point];
578
+ // ? What is the point of this? Why do we offset the index in this case, isn't the fourth value the opacity?
579
+ // (@anders2303)
580
+ attributesObject[key] = [[rgb[1], rgb[2], rgb[3]], point];
569
581
  }
570
582
  }
571
583
  });
572
584
  log_data.forEach((log_value) => {
573
585
  var _a;
574
586
  const dl_attrs = (_a = Object.entries(attributesObject).find(([, value]) => value[1] == log_value)) === null || _a === void 0 ? void 0 : _a[1];
575
- // TODO: Fix this the next time the file is edited.
576
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
577
- dl_attrs
578
- ? log_color.push(dl_attrs[0])
579
- : log_color.push([0, 0, 0, 0]); // use transparent for undefined/null log values
587
+ if (dl_attrs)
588
+ log_color.push(dl_attrs[0]);
589
+ else
590
+ log_color.push([0, 0, 0, 0]); // use transparent for undefined/null log values
580
591
  });
581
592
  }
582
593
  return log_color;
@@ -735,13 +746,13 @@ function getMd(coord, feature, accessor) {
735
746
  var _a, _b;
736
747
  if (!((_b = (_a = feature.properties) === null || _a === void 0 ? void 0 : _a["md"]) === null || _b === void 0 ? void 0 : _b[0]) || !feature.geometry)
737
748
  return null;
738
- const measured_depths = feature.properties["md"][0];
749
+ const measured_depths = feature.properties.md[0];
739
750
  const trajectory3D = getTrajectory(feature, accessor);
740
751
  if (trajectory3D == undefined)
741
752
  return null;
742
753
  let trajectory;
743
754
  // In 2D view coord is of type Position2D and in 3D view it's Position3D,
744
- // so use apropriate trajectory for interpolation
755
+ // so use appropriate trajectory for interpolation
745
756
  if (coord.length == 2) {
746
757
  const trajectory2D = trajectory3D.map((v) => {
747
758
  return v.slice(0, 2);
@@ -840,7 +851,7 @@ function getLogProperty(coord, wells_data, log_data, logrun_name, log_name) {
840
851
  else
841
852
  return null;
842
853
  }
843
- // Return data required to build welllayer legend
854
+ // Return data required to build well layer legend
844
855
  function getLegendData(logs, wellName, logName, logColor) {
845
856
  if (!logs)
846
857
  return null;