@equinor/esv-intersection 3.0.8 → 3.0.10
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/components/axis.d.ts +1 -2
- package/dist/components/axis.d.ts.map +1 -1
- package/dist/control/ExtendedCurveInterpolator.d.ts.map +1 -1
- package/dist/control/IntersectionReferenceSystem.d.ts +2 -6
- package/dist/control/IntersectionReferenceSystem.d.ts.map +1 -1
- package/dist/control/LayerManager.d.ts +2 -2
- package/dist/control/LayerManager.d.ts.map +1 -1
- package/dist/control/MainController.d.ts +3 -3
- package/dist/control/MainController.d.ts.map +1 -1
- package/dist/control/ZoomPanHandler.d.ts +5 -4
- package/dist/control/ZoomPanHandler.d.ts.map +1 -1
- package/dist/control/interfaces.d.ts +3 -4
- package/dist/control/interfaces.d.ts.map +1 -1
- package/dist/control/overlay.d.ts +3 -3
- package/dist/control/overlay.d.ts.map +1 -1
- package/dist/datautils/colortable.d.ts +1 -1
- package/dist/datautils/colortable.d.ts.map +1 -1
- package/dist/datautils/findsample.d.ts.map +1 -1
- package/dist/datautils/schematicShapeGenerator.d.ts +3 -3
- package/dist/datautils/schematicShapeGenerator.d.ts.map +1 -1
- package/dist/datautils/seismicimage.d.ts.map +1 -1
- package/dist/datautils/trajectory.d.ts +1 -1
- package/dist/datautils/trajectory.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1373 -1272
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/interfaces.d.ts +1 -2
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/layers/CalloutCanvasLayer.d.ts +2 -2
- package/dist/layers/CalloutCanvasLayer.d.ts.map +1 -1
- package/dist/layers/CustomDisplayObjects/ComplexRopeGeometry.d.ts.map +1 -1
- package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.d.ts.map +1 -1
- package/dist/layers/GeomodelCanvasLayer.d.ts +1 -1
- package/dist/layers/GeomodelCanvasLayer.d.ts.map +1 -1
- package/dist/layers/GeomodelLabelsLayer.d.ts +4 -4
- package/dist/layers/GeomodelLabelsLayer.d.ts.map +1 -1
- package/dist/layers/GeomodelLayerV2.d.ts.map +1 -1
- package/dist/layers/GridLayer.d.ts.map +1 -1
- package/dist/layers/ImageCanvasLayer.d.ts +1 -1
- package/dist/layers/ImageCanvasLayer.d.ts.map +1 -1
- package/dist/layers/ReferenceLineLayer.d.ts +1 -2
- package/dist/layers/ReferenceLineLayer.d.ts.map +1 -1
- package/dist/layers/SchematicLayer.d.ts.map +1 -1
- package/dist/layers/WellborePathLayer.d.ts +1 -1
- package/dist/layers/WellborePathLayer.d.ts.map +1 -1
- package/dist/layers/base/CanvasLayer.d.ts +3 -3
- package/dist/layers/base/CanvasLayer.d.ts.map +1 -1
- package/dist/layers/base/HTMLLayer.d.ts +1 -1
- package/dist/layers/base/HTMLLayer.d.ts.map +1 -1
- package/dist/layers/base/Layer.d.ts +10 -10
- package/dist/layers/base/Layer.d.ts.map +1 -1
- package/dist/layers/base/PixiLayer.d.ts +4 -4
- package/dist/layers/base/PixiLayer.d.ts.map +1 -1
- package/dist/layers/base/SVGLayer.d.ts +1 -1
- package/dist/layers/base/SVGLayer.d.ts.map +1 -1
- package/dist/utils/arc-length.d.ts.map +1 -1
- package/dist/utils/color.d.ts.map +1 -1
- package/dist/utils/root-finder.d.ts +1 -1
- package/dist/utils/root-finder.d.ts.map +1 -1
- package/dist/utils/text.d.ts +2 -2
- package/dist/utils/text.d.ts.map +1 -1
- package/dist/utils/vectorUtils.d.ts.map +1 -1
- package/dist/vendor/pixi-dashed-line/index.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/components/axis.ts +23 -30
- package/src/control/ExtendedCurveInterpolator.ts +7 -7
- package/src/control/IntersectionReferenceSystem.ts +33 -41
- package/src/control/LayerManager.ts +33 -31
- package/src/control/MainController.ts +5 -7
- package/src/control/ZoomPanHandler.ts +50 -45
- package/src/control/interfaces.ts +3 -3
- package/src/control/overlay.ts +20 -16
- package/src/datautils/colortable.ts +4 -4
- package/src/datautils/findsample.ts +8 -7
- package/src/datautils/picks.ts +13 -13
- package/src/datautils/schematicShapeGenerator.ts +47 -17
- package/src/datautils/seismicimage.ts +12 -13
- package/src/datautils/surfacedata.ts +27 -26
- package/src/datautils/trajectory.ts +34 -32
- package/src/interfaces.ts +1 -1
- package/src/layers/CalloutCanvasLayer.ts +55 -58
- package/src/layers/CustomDisplayObjects/ComplexRopeGeometry.ts +23 -20
- package/src/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.ts +9 -10
- package/src/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.ts +13 -13
- package/src/layers/GeomodelCanvasLayer.ts +43 -36
- package/src/layers/GeomodelLabelsLayer.ts +99 -96
- package/src/layers/GeomodelLayerV2.ts +11 -11
- package/src/layers/GridLayer.ts +25 -21
- package/src/layers/ImageCanvasLayer.ts +17 -11
- package/src/layers/ReferenceLineLayer.ts +53 -45
- package/src/layers/SchematicLayer.ts +78 -75
- package/src/layers/WellborePathLayer.ts +48 -46
- package/src/layers/base/CanvasLayer.ts +18 -18
- package/src/layers/base/HTMLLayer.ts +5 -5
- package/src/layers/base/Layer.ts +18 -18
- package/src/layers/base/PixiLayer.ts +24 -20
- package/src/layers/base/SVGLayer.ts +5 -5
- package/src/utils/arc-length.ts +3 -10
- package/src/utils/binary-search.ts +2 -2
- package/src/utils/color.ts +9 -5
- package/src/utils/root-finder.ts +4 -4
- package/src/utils/text.ts +5 -5
- package/src/utils/vectorUtils.ts +13 -6
- package/src/vendor/pixi-dashed-line/index.ts +3 -2
|
@@ -12,20 +12,19 @@ export type RescaleFunction = (event: OnRescaleEvent) => void;
|
|
|
12
12
|
* Handle zoom and pan for intersection layers
|
|
13
13
|
*/
|
|
14
14
|
export class ZoomPanHandler {
|
|
15
|
-
zoom
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
options: ZoomAndPanOptions = null;
|
|
15
|
+
zoom!: ZoomBehavior<HTMLElement, unknown>;
|
|
16
|
+
container: Selection<HTMLElement, unknown, null, undefined>;
|
|
17
|
+
onRescale: RescaleFunction;
|
|
18
|
+
options: ZoomAndPanOptions;
|
|
20
19
|
xBounds: [number, number] = [0, 1];
|
|
21
20
|
yBounds: [number, number] = [0, 1];
|
|
22
21
|
translateBoundsX: [number, number] = [0, 1];
|
|
23
22
|
translateBoundsY: [number, number] = [0, 1];
|
|
24
|
-
scaleX: ScaleLinear<number, number
|
|
25
|
-
scaleY: ScaleLinear<number, number
|
|
26
|
-
_zFactor
|
|
27
|
-
_enableTranslateExtent
|
|
28
|
-
currentTransform: ZoomTransform;
|
|
23
|
+
scaleX: ScaleLinear<number, number>;
|
|
24
|
+
scaleY: ScaleLinear<number, number>;
|
|
25
|
+
_zFactor = 1;
|
|
26
|
+
_enableTranslateExtent = false;
|
|
27
|
+
currentTransform: ZoomTransform | undefined;
|
|
29
28
|
|
|
30
29
|
/**
|
|
31
30
|
* Constructor
|
|
@@ -66,7 +65,7 @@ export class ZoomPanHandler {
|
|
|
66
65
|
* @returns width
|
|
67
66
|
*/
|
|
68
67
|
get width(): number {
|
|
69
|
-
return this.scaleX.range()[1];
|
|
68
|
+
return this.scaleX.range()[1] ?? 0;
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
/**
|
|
@@ -74,7 +73,7 @@ export class ZoomPanHandler {
|
|
|
74
73
|
* @returns height
|
|
75
74
|
*/
|
|
76
75
|
get height(): number {
|
|
77
|
-
return this.scaleY.range()[1];
|
|
76
|
+
return this.scaleY.range()[1] ?? 0;
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
/**
|
|
@@ -111,8 +110,8 @@ export class ZoomPanHandler {
|
|
|
111
110
|
* @returns ratio
|
|
112
111
|
*/
|
|
113
112
|
get xRatio(): number {
|
|
114
|
-
const domain
|
|
115
|
-
const ratio
|
|
113
|
+
const domain = this.scaleX.domain() as [number, number];
|
|
114
|
+
const ratio = Math.abs(this.width / (domain[1] - domain[0]));
|
|
116
115
|
return ratio;
|
|
117
116
|
}
|
|
118
117
|
|
|
@@ -121,8 +120,8 @@ export class ZoomPanHandler {
|
|
|
121
120
|
* @returns ratio
|
|
122
121
|
*/
|
|
123
122
|
get yRatio(): number {
|
|
124
|
-
const domain
|
|
125
|
-
const ratio
|
|
123
|
+
const domain = this.scaleY.domain() as [number, number];
|
|
124
|
+
const ratio = Math.abs(this.height / (domain[1] - domain[0]));
|
|
126
125
|
return ratio;
|
|
127
126
|
}
|
|
128
127
|
|
|
@@ -183,10 +182,10 @@ export class ZoomPanHandler {
|
|
|
183
182
|
updateTranslateExtent(): void {
|
|
184
183
|
const { width, xSpan, zFactor, enableTranslateExtent, translateBoundsX, translateBoundsY } = this;
|
|
185
184
|
|
|
186
|
-
let x1
|
|
187
|
-
let y1
|
|
188
|
-
let x2
|
|
189
|
-
let y2
|
|
185
|
+
let x1 = -Infinity;
|
|
186
|
+
let y1 = -Infinity;
|
|
187
|
+
let x2 = +Infinity;
|
|
188
|
+
let y2 = +Infinity;
|
|
190
189
|
|
|
191
190
|
if (enableTranslateExtent) {
|
|
192
191
|
const ppu: number = width / xSpan;
|
|
@@ -237,8 +236,7 @@ export class ZoomPanHandler {
|
|
|
237
236
|
* Initialized handler
|
|
238
237
|
*/
|
|
239
238
|
init(): void {
|
|
240
|
-
this.zoom = zoom().scaleExtent([this.options.minZoomLevel, this.options.maxZoomLevel]).on('zoom', this.onZoom);
|
|
241
|
-
|
|
239
|
+
this.zoom = zoom<HTMLElement, unknown>().scaleExtent([this.options.minZoomLevel, this.options.maxZoomLevel]).on('zoom', this.onZoom);
|
|
242
240
|
this.container.call(this.zoom);
|
|
243
241
|
}
|
|
244
242
|
|
|
@@ -292,19 +290,20 @@ export class ZoomPanHandler {
|
|
|
292
290
|
setViewport(cx?: number, cy?: number, displ?: number, duration?: number): void {
|
|
293
291
|
const { zoom, container, calculateTransform, scaleX, scaleY, isXInverted } = this;
|
|
294
292
|
|
|
295
|
-
if (isNaN(cx) || isNaN(displ)) {
|
|
296
|
-
const xd
|
|
293
|
+
if (cx == null || displ == null || isNaN(cx) || isNaN(displ)) {
|
|
294
|
+
const xd = scaleX.domain() as [number, number];
|
|
297
295
|
const dspan: number = xd[1] - xd[0];
|
|
298
|
-
|
|
296
|
+
|
|
297
|
+
if (cx == null || isNaN(cx)) {
|
|
299
298
|
cx = xd[0] + dspan / 2 || 0;
|
|
300
299
|
}
|
|
301
|
-
if (isNaN(displ)) {
|
|
300
|
+
if (displ == null || isNaN(displ)) {
|
|
302
301
|
displ = Math.abs(dspan) || 1;
|
|
303
302
|
}
|
|
304
303
|
}
|
|
305
304
|
|
|
306
|
-
if (isNaN(cy)) {
|
|
307
|
-
const yd
|
|
305
|
+
if (cy == null || isNaN(cy)) {
|
|
306
|
+
const yd = scaleY.domain() as [number, number];
|
|
308
307
|
cy = yd[0] + (yd[1] - yd[0]) / 2 || 0;
|
|
309
308
|
}
|
|
310
309
|
|
|
@@ -315,7 +314,7 @@ export class ZoomPanHandler {
|
|
|
315
314
|
|
|
316
315
|
const t: ZoomTransform = calculateTransform(dx0, dx1, cy);
|
|
317
316
|
|
|
318
|
-
if (Number.isFinite(duration) && duration > 0) {
|
|
317
|
+
if (duration != null && Number.isFinite(duration) && duration > 0) {
|
|
319
318
|
zoom.transform(container.transition().duration(duration), t);
|
|
320
319
|
} else {
|
|
321
320
|
zoom.transform(container, t);
|
|
@@ -346,19 +345,25 @@ export class ZoomPanHandler {
|
|
|
346
345
|
* Adjust zoom due to changes in size of target
|
|
347
346
|
* @param force - force update even if size did not change
|
|
348
347
|
*/
|
|
349
|
-
adjustToSize(
|
|
348
|
+
adjustToSize(): void;
|
|
349
|
+
adjustToSize(autoAdjust: boolean): void;
|
|
350
|
+
adjustToSize(width: number, height: number, force: boolean): void;
|
|
351
|
+
adjustToSize(widthOrAutoAdjust?: unknown, height?: number, force = false): void {
|
|
350
352
|
const { width: oldWidth, height: oldHeight, scaleX, scaleY, recalculateZoomTransform } = this;
|
|
351
353
|
|
|
352
354
|
let w = 0;
|
|
353
355
|
let h = 0;
|
|
354
356
|
|
|
355
|
-
if (typeof
|
|
356
|
-
const { width: containerWidth, height: containerHeight } = this.container.node().getBoundingClientRect();
|
|
357
|
-
w = containerWidth;
|
|
358
|
-
h = containerHeight;
|
|
359
|
-
} else {
|
|
360
|
-
w = width;
|
|
357
|
+
if (typeof widthOrAutoAdjust === 'number' && typeof height === 'number') {
|
|
361
358
|
h = height;
|
|
359
|
+
w = widthOrAutoAdjust;
|
|
360
|
+
} else {
|
|
361
|
+
const containerEl = this.container.node();
|
|
362
|
+
if (containerEl) {
|
|
363
|
+
const { width: containerWidth, height: containerHeight } = containerEl.getBoundingClientRect();
|
|
364
|
+
w = containerWidth;
|
|
365
|
+
h = containerHeight;
|
|
366
|
+
}
|
|
362
367
|
}
|
|
363
368
|
|
|
364
369
|
const newWidth: number = Math.max(1, w);
|
|
@@ -386,15 +391,15 @@ export class ZoomPanHandler {
|
|
|
386
391
|
calculateTransform(dx0: number, dx1: number, dy: number): ZoomTransform {
|
|
387
392
|
const { scaleX, xSpan, xBounds, yBounds, zFactor, viewportRatio: ratio, isXInverted, isYInverted } = this;
|
|
388
393
|
|
|
389
|
-
const [rx1, rx2] = scaleX.range();
|
|
390
|
-
const displ
|
|
391
|
-
const k
|
|
392
|
-
const unitsPerPixels
|
|
394
|
+
const [rx1, rx2] = scaleX.range() as [number, number];
|
|
395
|
+
const displ = Math.abs(dx1 - dx0);
|
|
396
|
+
const k = xSpan / displ;
|
|
397
|
+
const unitsPerPixels = displ / (rx2 - rx1);
|
|
393
398
|
|
|
394
|
-
const dy0
|
|
399
|
+
const dy0 = dy - (isYInverted ? -displ : displ) / zFactor / ratio / 2;
|
|
395
400
|
|
|
396
|
-
const tx
|
|
397
|
-
const ty
|
|
401
|
+
const tx = (xBounds[0] - dx0) / (isXInverted ? -unitsPerPixels : unitsPerPixels);
|
|
402
|
+
const ty = (yBounds[0] - dy0) / ((isYInverted ? -unitsPerPixels : unitsPerPixels) / zFactor);
|
|
398
403
|
|
|
399
404
|
return zoomIdentity.translate(tx, ty).scale(k);
|
|
400
405
|
}
|
|
@@ -405,8 +410,8 @@ export class ZoomPanHandler {
|
|
|
405
410
|
recalculateZoomTransform(): void {
|
|
406
411
|
const { scaleX, scaleY, container, calculateTransform, updateTranslateExtent } = this;
|
|
407
412
|
|
|
408
|
-
const [dx0, dx1] = scaleX.domain();
|
|
409
|
-
const [dy0, dy1] = scaleY.domain();
|
|
413
|
+
const [dx0, dx1] = scaleX.domain() as [number, number];
|
|
414
|
+
const [dy0, dy1] = scaleY.domain() as [number, number];
|
|
410
415
|
|
|
411
416
|
const dy: number = dy0 + (dy1 - dy0) / 2;
|
|
412
417
|
|
|
@@ -18,8 +18,8 @@ export interface ControllerOptions {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
interface OverlayEvent<T> {
|
|
21
|
-
target
|
|
22
|
-
source: Element;
|
|
21
|
+
target: Element | undefined;
|
|
22
|
+
source: Element | undefined;
|
|
23
23
|
caller: T;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -33,7 +33,7 @@ export interface OverlayMouseMoveEvent<T> extends OverlayEvent<T> {
|
|
|
33
33
|
y: number;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export
|
|
36
|
+
export type OverlayMouseExitEvent<T> = OverlayEvent<T>;
|
|
37
37
|
|
|
38
38
|
export interface OverlayCallbacks<T> {
|
|
39
39
|
onMouseMove?(event: OverlayMouseMoveEvent<T>): void;
|
package/src/control/overlay.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { select, Selection, pointer, ContainerElement } from 'd3-selection';
|
|
|
2
2
|
import { OverlayCallbacks } from './interfaces';
|
|
3
3
|
|
|
4
4
|
export class Overlay<T> {
|
|
5
|
-
elm: Selection<
|
|
6
|
-
source:
|
|
5
|
+
elm: Selection<HTMLDivElement, unknown, null, undefined>;
|
|
6
|
+
source: HTMLDivElement | undefined;
|
|
7
7
|
elements: { [propName: string]: Element } = {};
|
|
8
8
|
listeners: { [propName: string]: OverlayCallbacks<T> } = {};
|
|
9
9
|
enabled = true;
|
|
@@ -11,8 +11,7 @@ export class Overlay<T> {
|
|
|
11
11
|
constructor(caller: T, container: HTMLElement) {
|
|
12
12
|
const con = select(container);
|
|
13
13
|
this.elm = con.append('div').attr('id', 'overlay').style('z-index', '11').style('position', 'absolute');
|
|
14
|
-
|
|
15
|
-
this.source = this.elm.node();
|
|
14
|
+
this.source = this.elm.node() ?? undefined;
|
|
16
15
|
|
|
17
16
|
const { elm } = this;
|
|
18
17
|
elm.on('resize', (event) => {
|
|
@@ -24,11 +23,11 @@ export class Overlay<T> {
|
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
Object.keys(this.listeners).forEach((key: string) => {
|
|
27
|
-
const target = this.elements[key]
|
|
26
|
+
const target = this.elements[key] ?? undefined;
|
|
28
27
|
const ops = this.listeners[key];
|
|
29
28
|
if (ops && ops.onResize) {
|
|
30
29
|
requestAnimationFrame(() =>
|
|
31
|
-
ops.onResize({
|
|
30
|
+
ops.onResize?.({
|
|
32
31
|
target,
|
|
33
32
|
source: this.source,
|
|
34
33
|
caller,
|
|
@@ -47,12 +46,12 @@ export class Overlay<T> {
|
|
|
47
46
|
|
|
48
47
|
const [mx, my] = pointer(event, this.elm.node() as ContainerElement);
|
|
49
48
|
Object.keys(this.listeners).forEach((key: string) => {
|
|
50
|
-
const target = this.elements[key]
|
|
49
|
+
const target = this.elements[key] ?? undefined;
|
|
51
50
|
const ops = this.listeners[key];
|
|
52
51
|
|
|
53
52
|
if (ops && ops.onMouseMove) {
|
|
54
53
|
requestAnimationFrame(() =>
|
|
55
|
-
ops.onMouseMove({
|
|
54
|
+
ops.onMouseMove?.({
|
|
56
55
|
x: mx,
|
|
57
56
|
y: my,
|
|
58
57
|
target,
|
|
@@ -69,11 +68,11 @@ export class Overlay<T> {
|
|
|
69
68
|
return;
|
|
70
69
|
}
|
|
71
70
|
Object.keys(this.listeners).forEach((key: string) => {
|
|
72
|
-
const target = this.elements[key] ||
|
|
71
|
+
const target = this.elements[key] || undefined;
|
|
73
72
|
const ops = this.listeners[key];
|
|
74
73
|
if (ops && ops.onMouseExit) {
|
|
75
74
|
requestAnimationFrame(() =>
|
|
76
|
-
ops.onMouseExit({
|
|
75
|
+
ops.onMouseExit?.({
|
|
77
76
|
target,
|
|
78
77
|
source: this.source,
|
|
79
78
|
caller,
|
|
@@ -84,13 +83,18 @@ export class Overlay<T> {
|
|
|
84
83
|
});
|
|
85
84
|
}
|
|
86
85
|
|
|
87
|
-
create(key: string, callbacks?: OverlayCallbacks<T>): HTMLElement {
|
|
86
|
+
create(key: string, callbacks?: OverlayCallbacks<T>): HTMLElement | undefined {
|
|
88
87
|
const newElm = this.elm.append('div').style('position', 'relative').style('pointer-events', 'none').node();
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
this.
|
|
88
|
+
|
|
89
|
+
if (newElm != null) {
|
|
90
|
+
this.elements[key] = newElm;
|
|
91
|
+
if (callbacks) {
|
|
92
|
+
this.listeners[key] = callbacks;
|
|
93
|
+
}
|
|
94
|
+
return newElm;
|
|
95
|
+
} else {
|
|
96
|
+
return undefined;
|
|
92
97
|
}
|
|
93
|
-
return newElm;
|
|
94
98
|
}
|
|
95
99
|
|
|
96
100
|
register(key: string, callbacks: OverlayCallbacks<T>): void {
|
|
@@ -111,7 +115,7 @@ export class Overlay<T> {
|
|
|
111
115
|
}
|
|
112
116
|
|
|
113
117
|
destroy(): void {
|
|
114
|
-
this.source
|
|
118
|
+
this.source?.remove();
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
121
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { scaleLinear } from 'd3-scale';
|
|
2
2
|
import { color } from 'd3-color';
|
|
3
3
|
|
|
4
|
-
export function createColorTable(colorMap: string[], size: number): number
|
|
4
|
+
export function createColorTable(colorMap: string[], size: number): [number, number, number][] {
|
|
5
5
|
const colorDomain = colorMap.map((_v, i) => (i * size) / colorMap.length);
|
|
6
6
|
const colorScale = scaleLinear<string>().domain(colorDomain).range(colorMap);
|
|
7
7
|
|
|
8
|
-
const table = Array.from(new Array(size).keys()).map((i) => {
|
|
9
|
-
const rgb = color(colorScale(i))
|
|
10
|
-
return [rgb.r, rgb.g, rgb.b];
|
|
8
|
+
const table = Array.from(new Array(size).keys()).map<[number, number, number]>((i) => {
|
|
9
|
+
const rgb = color(colorScale(i))?.rgb();
|
|
10
|
+
return rgb != null ? [rgb.r, rgb.g, rgb.b] : [0, 0, 0];
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
return table;
|
|
@@ -47,15 +47,16 @@ export function findIndexOfSample(data: number[][], pos: number): number {
|
|
|
47
47
|
return index;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export function findSampleAtPos(data: number[][], pos: number, topLimit
|
|
51
|
-
let y
|
|
50
|
+
export function findSampleAtPos(data: number[][], pos: number, topLimit = 0, bottomLimit = 0): number {
|
|
51
|
+
let y = 0;
|
|
52
52
|
const index = findIndexOfSample(data, pos);
|
|
53
53
|
if (index !== -1) {
|
|
54
|
-
const v1 = data[index][1];
|
|
55
|
-
const v2 = data[index + 1][1];
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
54
|
+
const v1 = data[index]?.[1];
|
|
55
|
+
const v2 = data[index + 1]?.[1];
|
|
56
|
+
|
|
57
|
+
if (v1 && v2) {
|
|
58
|
+
const x1 = data[index]?.[0] ?? 0;
|
|
59
|
+
const x2 = data[index + 1]?.[0] ?? 0;
|
|
59
60
|
const span = x2 - x1;
|
|
60
61
|
const d = pos - x1;
|
|
61
62
|
const f = d / span;
|
package/src/datautils/picks.ts
CHANGED
|
@@ -103,7 +103,7 @@ function getFilteredExitPicks(formationPicks: PairedPickAndUnit[]): Annotation[]
|
|
|
103
103
|
|
|
104
104
|
export const getPicksData = (picksData: { unitPicks: PairedPickAndUnit[]; nonUnitPicks: PickWithId[] }): Annotation[] =>
|
|
105
105
|
[...getReferencePicks(picksData.nonUnitPicks), ...getEntryPicks(picksData.unitPicks), ...getFilteredExitPicks(picksData.unitPicks)].sort(
|
|
106
|
-
(a, b) => a.md - b.md
|
|
106
|
+
(a, b) => a.md! - b.md!,
|
|
107
107
|
);
|
|
108
108
|
|
|
109
109
|
/**
|
|
@@ -142,7 +142,7 @@ function findGaps(from: number, to: number, arr: { from: number; to: number; itm
|
|
|
142
142
|
let d = from;
|
|
143
143
|
let i = 0;
|
|
144
144
|
while (d < to && i < arr.length) {
|
|
145
|
-
const itm = arr[i]
|
|
145
|
+
const itm = arr[i]!;
|
|
146
146
|
if (itm.from > d) {
|
|
147
147
|
gaps.push([d, Math.min(itm.from, to)]);
|
|
148
148
|
}
|
|
@@ -171,13 +171,13 @@ function joinPicksAndStratColumn(picks: Pick[], stratColumn: Unit[]): { joined:
|
|
|
171
171
|
const nonUnitPicks: PickWithId[] = [];
|
|
172
172
|
const joined: PickAndUnit[] = [];
|
|
173
173
|
picks.forEach((p: Pick) => {
|
|
174
|
-
const matches = transformed.filter((u: UnitDto) => p.pickIdentifier
|
|
174
|
+
const matches = transformed.filter((u: UnitDto) => p.pickIdentifier?.search(new RegExp(`(${u.topSurface}|${u.baseSurface})`, 'i')) !== -1);
|
|
175
175
|
if (matches.length > 0) {
|
|
176
176
|
matches.forEach((u: UnitDto) =>
|
|
177
177
|
joined.push({
|
|
178
178
|
md: p.md,
|
|
179
179
|
tvd: p.tvd,
|
|
180
|
-
identifier: p.pickIdentifier
|
|
180
|
+
identifier: p.pickIdentifier!,
|
|
181
181
|
confidence: p.confidence,
|
|
182
182
|
mdUnit: p.mdUnit,
|
|
183
183
|
depthReferencePoint: p.depthReferencePoint,
|
|
@@ -185,7 +185,7 @@ function joinPicksAndStratColumn(picks: Pick[], stratColumn: Unit[]): { joined:
|
|
|
185
185
|
}),
|
|
186
186
|
);
|
|
187
187
|
} else {
|
|
188
|
-
nonUnitPicks.push({ identifier: p.pickIdentifier
|
|
188
|
+
nonUnitPicks.push({ identifier: p.pickIdentifier!, ...p });
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
191
|
|
|
@@ -206,7 +206,7 @@ function pairJoinedPicks(joined: PickAndUnit[]): PairedPickAndUnit[] {
|
|
|
206
206
|
.sort((a: PickAndUnit, b: PickAndUnit) => a.unitName.localeCompare(b.unitName) || a.md - b.md || a.ageTop - b.ageTop);
|
|
207
207
|
|
|
208
208
|
while (sorted.length > 0) {
|
|
209
|
-
current = sorted.shift()
|
|
209
|
+
current = sorted.shift()!;
|
|
210
210
|
const name = current.identifier;
|
|
211
211
|
let pairWithName: string;
|
|
212
212
|
|
|
@@ -222,8 +222,8 @@ function pairJoinedPicks(joined: PickAndUnit[]): PairedPickAndUnit[] {
|
|
|
222
222
|
continue;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
let top: PickAndUnit;
|
|
226
|
-
let base: PickAndUnit;
|
|
225
|
+
let top: PickAndUnit | undefined;
|
|
226
|
+
let base: PickAndUnit | undefined;
|
|
227
227
|
|
|
228
228
|
const pairWith = sorted.find((p: PickAndUnit) => p.identifier === pairWithName);
|
|
229
229
|
if (!pairWith) {
|
|
@@ -233,7 +233,7 @@ function pairJoinedPicks(joined: PickAndUnit[]): PairedPickAndUnit[] {
|
|
|
233
233
|
base = joined
|
|
234
234
|
.filter((d: PickAndUnit) => d.level)
|
|
235
235
|
.sort((a: PickAndUnit, b: PickAndUnit) => a.md - b.md)
|
|
236
|
-
.find((p: PickAndUnit) => p.md > top
|
|
236
|
+
.find((p: PickAndUnit) => p.md > top!.md);
|
|
237
237
|
if (base) {
|
|
238
238
|
console.warn(`Using ${base.identifier} as base for ${name}`);
|
|
239
239
|
} else {
|
|
@@ -245,7 +245,7 @@ function pairJoinedPicks(joined: PickAndUnit[]): PairedPickAndUnit[] {
|
|
|
245
245
|
top = joined
|
|
246
246
|
.filter((d: PickAndUnit) => d.level)
|
|
247
247
|
.sort((a: PickAndUnit, b: PickAndUnit) => b.md - a.md)
|
|
248
|
-
.find((p: PickAndUnit) => p.md < base
|
|
248
|
+
.find((p: PickAndUnit) => p.md < base!.md);
|
|
249
249
|
if (top) {
|
|
250
250
|
console.warn(`Using ${top.identifier} as top for ${name}`);
|
|
251
251
|
} else {
|
|
@@ -303,10 +303,10 @@ export function transformFormationData(picks: Pick[], stratColumn: Unit[]): { un
|
|
|
303
303
|
// given presedence over lower levels for overlapping picks.
|
|
304
304
|
const unitPicks = [];
|
|
305
305
|
while (itemstack.length > 0) {
|
|
306
|
-
const first = itemstack.pop()
|
|
306
|
+
const first = itemstack.pop()!;
|
|
307
307
|
const group: PairedPickAndUnit[] = [];
|
|
308
|
-
while (itemstack.length > 0 && itemstack[itemstack.length - 1]
|
|
309
|
-
group.push(itemstack.pop());
|
|
308
|
+
while (itemstack.length > 0 && itemstack[itemstack.length - 1]?.level! > first.level) {
|
|
309
|
+
group.push(itemstack.pop()!);
|
|
310
310
|
}
|
|
311
311
|
group.reverse();
|
|
312
312
|
group.push(first);
|
|
@@ -51,15 +51,15 @@ export interface CasingRenderObject {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export const getEndLines = (
|
|
54
|
-
rightPath: IPoint[],
|
|
55
|
-
leftPath: IPoint[],
|
|
54
|
+
rightPath: [IPoint, IPoint, ...IPoint[]],
|
|
55
|
+
leftPath: [IPoint, IPoint, ...IPoint[]],
|
|
56
56
|
): {
|
|
57
|
-
top: IPoint
|
|
58
|
-
bottom: IPoint
|
|
57
|
+
top: [IPoint, IPoint];
|
|
58
|
+
bottom: [IPoint, IPoint];
|
|
59
59
|
} => {
|
|
60
60
|
return {
|
|
61
61
|
top: [rightPath[0], leftPath[0]],
|
|
62
|
-
bottom: [rightPath[rightPath.length - 1], leftPath[leftPath.length - 1]],
|
|
62
|
+
bottom: [rightPath[rightPath.length - 1] as IPoint, leftPath[leftPath.length - 1] as IPoint],
|
|
63
63
|
};
|
|
64
64
|
};
|
|
65
65
|
|
|
@@ -215,8 +215,8 @@ export const createComplexRopeSegmentsForCement = (
|
|
|
215
215
|
throw new Error(`Invalid cement data, can't find referenced casing/completion string for cement with id '${cement.id}'`);
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
attachedStrings.sort((a
|
|
219
|
-
const bottomOfCement = attachedStrings[attachedStrings.length - 1]
|
|
218
|
+
attachedStrings.sort((a, b) => a.end - b.end); // ascending
|
|
219
|
+
const bottomOfCement = attachedStrings[attachedStrings.length - 1]!.end;
|
|
220
220
|
|
|
221
221
|
const { overlappingOuterStrings, overlappingHoles } = findIntersectingItems(cement.toc, bottomOfCement, nonAttachedStrings, holes);
|
|
222
222
|
|
|
@@ -232,7 +232,7 @@ export const createComplexRopeSegmentsForCement = (
|
|
|
232
232
|
return [];
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
const nextDepth = list[index + 1]
|
|
235
|
+
const nextDepth = list[index + 1]!;
|
|
236
236
|
const diameterAtChangeDepth = findCementOuterDiameterAtDepth(attachedStrings, overlappingOuterStrings, overlappingHoles, depth);
|
|
237
237
|
|
|
238
238
|
return [{ top: depth, bottom: nextDepth, diameter: diameterAtChangeDepth * exaggerationFactor }];
|
|
@@ -258,7 +258,7 @@ const splitByReferencedStrings = (
|
|
|
258
258
|
}
|
|
259
259
|
return { ...acc, nonAttachedStrings: [...acc.nonAttachedStrings, current] };
|
|
260
260
|
},
|
|
261
|
-
{ attachedStrings: [], nonAttachedStrings: [] },
|
|
261
|
+
{ attachedStrings: [] as (Casing | Completion)[], nonAttachedStrings: [] as (Casing | Completion)[] },
|
|
262
262
|
);
|
|
263
263
|
|
|
264
264
|
export const createComplexRopeSegmentsForCementSqueeze = (
|
|
@@ -289,7 +289,7 @@ export const createComplexRopeSegmentsForCementSqueeze = (
|
|
|
289
289
|
return [];
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
const nextDepth = list[index + 1]
|
|
292
|
+
const nextDepth = list[index + 1]!;
|
|
293
293
|
|
|
294
294
|
const diameterAtDepth = findCementOuterDiameterAtDepth(attachedStrings, overlappingOuterStrings, overlappingHoles, depth);
|
|
295
295
|
|
|
@@ -327,7 +327,7 @@ export const createComplexRopeSegmentsForCementPlug = (
|
|
|
327
327
|
return [];
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
const nextDepth = list[index + 1]
|
|
330
|
+
const nextDepth = list[index + 1]!;
|
|
331
331
|
const diameterAtDepth = findCementPlugInnerDiameterAtDepth(attachedStrings, overlappingOuterStrings, overlappingHoles, depth);
|
|
332
332
|
|
|
333
333
|
return [{ top: depth, bottom: nextDepth, diameter: diameterAtDepth * exaggerationFactor }];
|
|
@@ -364,6 +364,10 @@ export const createHoleBaseTexture = ({ firstColor, secondColor }: HoleOptions,
|
|
|
364
364
|
canvas.height = height;
|
|
365
365
|
const canvasCtx = canvas.getContext('2d');
|
|
366
366
|
|
|
367
|
+
if (canvasCtx == null) {
|
|
368
|
+
throw Error('Could not get canvas context!');
|
|
369
|
+
}
|
|
370
|
+
|
|
367
371
|
canvasCtx.fillStyle = createGradientFill(canvas, canvasCtx, firstColor, secondColor, 0);
|
|
368
372
|
canvasCtx.fillRect(0, 0, canvas.width, canvas.height);
|
|
369
373
|
|
|
@@ -376,6 +380,9 @@ export const createScreenTexture = ({ scalingFactor }: ScreenOptions): Texture =
|
|
|
376
380
|
canvas.width = size;
|
|
377
381
|
canvas.height = size;
|
|
378
382
|
const canvasCtx = canvas.getContext('2d');
|
|
383
|
+
if (canvasCtx == null) {
|
|
384
|
+
throw Error('Could not get canvas context!');
|
|
385
|
+
}
|
|
379
386
|
|
|
380
387
|
canvasCtx.fillStyle = 'white';
|
|
381
388
|
canvasCtx.fillRect(0, 0, canvas.width, canvas.height);
|
|
@@ -401,6 +408,10 @@ export const createTubingTexture = ({ innerColor, outerColor, scalingFactor }: T
|
|
|
401
408
|
canvas.width = size;
|
|
402
409
|
canvas.height = size;
|
|
403
410
|
const canvasCtx = canvas.getContext('2d');
|
|
411
|
+
|
|
412
|
+
if (canvasCtx == null) {
|
|
413
|
+
throw Error('Could not get canvas context!');
|
|
414
|
+
}
|
|
404
415
|
const gradient = canvasCtx.createLinearGradient(0, 0, 0, size);
|
|
405
416
|
|
|
406
417
|
const innerColorStart = 0.3;
|
|
@@ -425,6 +436,10 @@ export const createCementTexture = ({ firstColor, secondColor, scalingFactor }:
|
|
|
425
436
|
canvas.height = size;
|
|
426
437
|
const canvasCtx = canvas.getContext('2d');
|
|
427
438
|
|
|
439
|
+
if (canvasCtx == null) {
|
|
440
|
+
throw Error('Could not get canvas context!');
|
|
441
|
+
}
|
|
442
|
+
|
|
428
443
|
canvasCtx.fillStyle = firstColor;
|
|
429
444
|
canvasCtx.fillRect(0, 0, canvas.width, canvas.height);
|
|
430
445
|
canvasCtx.lineWidth = lineWidth;
|
|
@@ -449,6 +464,10 @@ export const createCementPlugTexture = ({ firstColor, secondColor, scalingFactor
|
|
|
449
464
|
canvas.height = size;
|
|
450
465
|
const canvasCtx = canvas.getContext('2d');
|
|
451
466
|
|
|
467
|
+
if (canvasCtx == null) {
|
|
468
|
+
throw Error('Could not get canvas context!');
|
|
469
|
+
}
|
|
470
|
+
|
|
452
471
|
canvasCtx.fillStyle = firstColor;
|
|
453
472
|
canvasCtx.fillRect(0, 0, canvas.width, canvas.height);
|
|
454
473
|
canvasCtx.lineWidth = scalingFactor;
|
|
@@ -475,6 +494,10 @@ export const createCementSqueezeTexture = ({ firstColor, secondColor, scalingFac
|
|
|
475
494
|
canvas.height = size;
|
|
476
495
|
|
|
477
496
|
const canvasCtx = canvas.getContext('2d');
|
|
497
|
+
if (canvasCtx == null) {
|
|
498
|
+
throw Error('Could not get canvas context!');
|
|
499
|
+
}
|
|
500
|
+
|
|
478
501
|
canvasCtx.lineWidth = lineWidth;
|
|
479
502
|
canvasCtx.fillStyle = firstColor;
|
|
480
503
|
canvasCtx.strokeStyle = secondColor;
|
|
@@ -535,7 +558,7 @@ export const getCasingIntervalsWithWindows = (casing: Casing): CasingInterval[]
|
|
|
535
558
|
? createCasingInterval(nextLastBottom, casing.end)
|
|
536
559
|
: null;
|
|
537
560
|
|
|
538
|
-
const newIntervals: CasingInterval[] = [startCasingInterval, windowInterval, endCasingInterval].filter((i) => i);
|
|
561
|
+
const newIntervals: CasingInterval[] = [startCasingInterval, windowInterval, endCasingInterval].filter((i): i is CasingInterval => i != null);
|
|
539
562
|
|
|
540
563
|
return { intervals: [...intervals, ...newIntervals], lastBottom: nextLastBottom };
|
|
541
564
|
},
|
|
@@ -599,7 +622,7 @@ export const createComplexRopeSegmentsForPerforation = (
|
|
|
599
622
|
return [];
|
|
600
623
|
}
|
|
601
624
|
|
|
602
|
-
const nextDepth = list[index + 1]
|
|
625
|
+
const nextDepth = list[index + 1]!;
|
|
603
626
|
|
|
604
627
|
const diameterAtDepth = findPerforationOuterDiameterAtDepth(overlappingOuterStrings, overlappingHoles, depth, perforation.subKind);
|
|
605
628
|
|
|
@@ -769,14 +792,17 @@ const errorTexture = (errorMessage = 'Error!', existingContext?: { canvas: HTMLC
|
|
|
769
792
|
const xy: [number, number] = [0, 0];
|
|
770
793
|
const wh: [number, number] = [canvas.width, canvas.height];
|
|
771
794
|
|
|
795
|
+
if (canvasCtx == null) {
|
|
796
|
+
throw Error('Could not get canvas context!');
|
|
797
|
+
}
|
|
772
798
|
canvasCtx.fillStyle = '#ff00ff';
|
|
773
799
|
canvasCtx.fillRect(...xy, ...wh);
|
|
774
800
|
|
|
775
801
|
const texture = new Texture(
|
|
776
802
|
Texture.from(canvas, { wrapMode: WRAP_MODES.CLAMP }).baseTexture,
|
|
777
|
-
|
|
803
|
+
undefined,
|
|
778
804
|
new Rectangle(0, 0, canvas.width, canvas.height),
|
|
779
|
-
|
|
805
|
+
undefined,
|
|
780
806
|
groupD8.MIRROR_HORIZONTAL,
|
|
781
807
|
);
|
|
782
808
|
return texture;
|
|
@@ -793,15 +819,19 @@ const createPerforationCanvas = (
|
|
|
793
819
|
canvas.height = size;
|
|
794
820
|
const ctx = canvas.getContext('2d');
|
|
795
821
|
|
|
822
|
+
if (ctx == null) {
|
|
823
|
+
throw Error('Could not get canvas context!');
|
|
824
|
+
}
|
|
825
|
+
|
|
796
826
|
return { canvas, ctx };
|
|
797
827
|
};
|
|
798
828
|
|
|
799
829
|
const createPerforationTexture = (canvas: HTMLCanvasElement) => {
|
|
800
830
|
const texture = new Texture(
|
|
801
831
|
Texture.from(canvas, { wrapMode: WRAP_MODES.CLAMP }).baseTexture,
|
|
802
|
-
|
|
832
|
+
undefined,
|
|
803
833
|
new Rectangle(0, 0, canvas.width, canvas.height),
|
|
804
|
-
|
|
834
|
+
undefined,
|
|
805
835
|
groupD8.MIRROR_HORIZONTAL,
|
|
806
836
|
);
|
|
807
837
|
return texture;
|