@webviz/subsurface-viewer 0.0.1-alpha.1 → 0.0.2-alpha.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.
Files changed (177) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +0 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/package.json +5 -2
  5. package/package.json +6 -3
  6. package/dist/DashSubsurfaceViewer.d.ts +0 -56
  7. package/dist/DashSubsurfaceViewer.js +0 -160
  8. package/dist/DashSubsurfaceViewer.js.map +0 -1
  9. package/src/DashSubsurfaceViewer.tsx +0 -270
  10. package/src/SubsurfaceViewer.stories.tsx +0 -449
  11. package/src/SubsurfaceViewer.test.tsx +0 -98
  12. package/src/SubsurfaceViewer.tsx +0 -356
  13. package/src/__snapshots__/SubsurfaceViewer.test.tsx.snap +0 -178
  14. package/src/assets/glTF/north_arrow/scene.bin +0 -0
  15. package/src/assets/glTF/north_arrow/scene.gltf +0 -315
  16. package/src/assets/glTF/north_arrow/textures/Arrow5_baseColor.png +0 -0
  17. package/src/assets/glTF/north_arrow/textures/Arrow5_metallicRoughness.png +0 -0
  18. package/src/assets/glTF/north_arrow/textures/Arrow5_normal.png +0 -0
  19. package/src/components/ColorLegend.test.tsx +0 -32
  20. package/src/components/ColorLegend.tsx +0 -80
  21. package/src/components/ColorLegends.test.tsx +0 -97
  22. package/src/components/ColorLegends.tsx +0 -46
  23. package/src/components/DistanceScale.stories.tsx +0 -28
  24. package/src/components/DistanceScale.test.tsx +0 -36
  25. package/src/components/DistanceScale.tsx +0 -84
  26. package/src/components/InfoCard.test.tsx +0 -110
  27. package/src/components/InfoCard.tsx +0 -263
  28. package/src/components/Map.test.tsx +0 -142
  29. package/src/components/Map.tsx +0 -1435
  30. package/src/components/StatusIndicator.test.tsx +0 -14
  31. package/src/components/StatusIndicator.tsx +0 -38
  32. package/src/components/ViewAnnotation.tsx +0 -16
  33. package/src/components/ViewFooter.test.tsx +0 -12
  34. package/src/components/ViewFooter.tsx +0 -30
  35. package/src/components/__snapshots__/ColorLegends.test.tsx.snap +0 -15
  36. package/src/components/__snapshots__/DistanceScale.test.tsx.snap +0 -33
  37. package/src/components/__snapshots__/InfoCard.test.tsx.snap +0 -561
  38. package/src/components/__snapshots__/Map.test.tsx.snap +0 -119
  39. package/src/components/__snapshots__/StatusIndicator.test.tsx.snap +0 -3
  40. package/src/components/__snapshots__/ViewFooter.test.tsx.snap +0 -7
  41. package/src/components/settings/DrawModeSelector.test.tsx +0 -45
  42. package/src/components/settings/DrawModeSelector.tsx +0 -58
  43. package/src/components/settings/DrawModeSelector_performance.test.tsx +0 -35
  44. package/src/components/settings/LayerProperty.test.tsx +0 -35
  45. package/src/components/settings/LayerProperty.tsx +0 -153
  46. package/src/components/settings/LayerProperty_performance.test.tsx +0 -39
  47. package/src/components/settings/LayerSettingsButton.test.tsx +0 -133
  48. package/src/components/settings/LayerSettingsButton.tsx +0 -95
  49. package/src/components/settings/LayersButton.test.tsx +0 -102
  50. package/src/components/settings/LayersButton.tsx +0 -97
  51. package/src/components/settings/NumericInput.test.tsx +0 -25
  52. package/src/components/settings/NumericInput.tsx +0 -67
  53. package/src/components/settings/Settings.tsx +0 -71
  54. package/src/components/settings/SliderInput.test.tsx +0 -28
  55. package/src/components/settings/SliderInput.tsx +0 -71
  56. package/src/components/settings/ToggleButton.test.tsx +0 -25
  57. package/src/components/settings/ToggleButton.tsx +0 -53
  58. package/src/components/settings/__snapshots__/DrawModeSelector.test.tsx.snap +0 -124
  59. package/src/components/settings/__snapshots__/LayerProperty.test.tsx.snap +0 -124
  60. package/src/components/settings/__snapshots__/LayerSettingsButton.test.tsx.snap +0 -36
  61. package/src/components/settings/__snapshots__/LayersButton.test.tsx.snap +0 -83
  62. package/src/components/settings/__snapshots__/NumericInput.test.tsx.snap +0 -123
  63. package/src/components/settings/__snapshots__/SliderInput.test.tsx.snap +0 -244
  64. package/src/components/settings/__snapshots__/ToggleButton.test.tsx.snap +0 -182
  65. package/src/custom.d.ts +0 -9
  66. package/src/index.ts +0 -5
  67. package/src/inputSchema/ColorTables.json +0 -51
  68. package/src/inputSchema/FaultPolygons.json +0 -80
  69. package/src/inputSchema/Grid.json +0 -39
  70. package/src/inputSchema/PieChart.json +0 -72
  71. package/src/inputSchema/WellLog.json +0 -126
  72. package/src/inputSchema/WellLogTemplate.json +0 -136
  73. package/src/inputSchema/WellLogs.json +0 -5
  74. package/src/inputSchema/Wells.json +0 -106
  75. package/src/inputSchema/schemaValidationUtil.tsx +0 -55
  76. package/src/inputSchema/validator.tsx +0 -72
  77. package/src/inputSchema/wellCompletions.json +0 -108
  78. package/src/layers/BoxSelectionLayer/boxSelectionLayer.stories.tsx +0 -172
  79. package/src/layers/BoxSelectionLayer/boxSelectionLayer.tsx +0 -136
  80. package/src/layers/axes/axes-fragment.glsl.ts +0 -15
  81. package/src/layers/axes/axesLayer.stories.tsx +0 -87
  82. package/src/layers/axes/axesLayer.ts +0 -692
  83. package/src/layers/axes/boxLayer.ts +0 -71
  84. package/src/layers/axes/grid-vertex.glsl.ts +0 -14
  85. package/src/layers/axes2d/axes2DLayer.stories.tsx +0 -150
  86. package/src/layers/axes2d/axes2DLayer.ts +0 -841
  87. package/src/layers/axes2d/font-atlas.png +0 -0
  88. package/src/layers/axes2d/label-fragment.glsl.js +0 -37
  89. package/src/layers/axes2d/label-vertex.glsl.js +0 -20
  90. package/src/layers/axes2d/line-fragment.glsl.js +0 -14
  91. package/src/layers/axes2d/line-vertex.glsl.js +0 -13
  92. package/src/layers/colormap/colormap.fs.glsl.ts +0 -42
  93. package/src/layers/colormap/colormapLayer.ts +0 -247
  94. package/src/layers/drawing/drawingLayer.tsx +0 -256
  95. package/src/layers/fault_polygons/faultPolygonsLayer.ts +0 -54
  96. package/src/layers/grid3d/fragment.fs.glsl.ts +0 -109
  97. package/src/layers/grid3d/fragment_lines.glsl.ts +0 -21
  98. package/src/layers/grid3d/grid3dLayer.stories.tsx +0 -172
  99. package/src/layers/grid3d/grid3dLayer.ts +0 -248
  100. package/src/layers/grid3d/privateLayer.ts +0 -292
  101. package/src/layers/grid3d/vertex.glsl.ts +0 -43
  102. package/src/layers/grid3d/vertex_lines.glsl.ts +0 -15
  103. package/src/layers/grid3d/webworker.ts +0 -173
  104. package/src/layers/hillshading2d/hillshading2d.fs.glsl.ts +0 -62
  105. package/src/layers/hillshading2d/hillshading2dLayer.ts +0 -172
  106. package/src/layers/index.ts +0 -35
  107. package/src/layers/intersection/intersectionView.stories.tsx +0 -294
  108. package/src/layers/intersection/unfoldedGeoJsonLayer.ts +0 -92
  109. package/src/layers/map/fragment.fs.glsl.ts +0 -127
  110. package/src/layers/map/fragment_lines.glsl.ts +0 -21
  111. package/src/layers/map/mapLayer.stories.tsx +0 -1369
  112. package/src/layers/map/mapLayer.ts +0 -470
  113. package/src/layers/map/privateMapLayer.ts +0 -317
  114. package/src/layers/map/vertex.glsl.ts +0 -45
  115. package/src/layers/map/vertex_lines.glsl.ts +0 -15
  116. package/src/layers/map/webworker.ts +0 -479
  117. package/src/layers/northarrow/northArrow.stories.tsx +0 -108
  118. package/src/layers/northarrow/northArrow3DLayer.ts +0 -204
  119. package/src/layers/northarrow/northarrow-fragment.glsl.js +0 -14
  120. package/src/layers/northarrow/northarrow-vertex.glsl.js +0 -13
  121. package/src/layers/piechart/fragment.glsl.js +0 -42
  122. package/src/layers/piechart/pieChartLayer.ts +0 -246
  123. package/src/layers/piechart/vertex.glsl.js +0 -42
  124. package/src/layers/points/pointsLayer.stories.tsx +0 -141
  125. package/src/layers/points/pointsLayer.ts +0 -143
  126. package/src/layers/polylines/polylinesLayer.stories.tsx +0 -144
  127. package/src/layers/polylines/polylinesLayer.ts +0 -263
  128. package/src/layers/selectable_geojson/selectableGeoJsonLayer.ts +0 -25
  129. package/src/layers/shader_modules/decoder.fs.glsl.ts +0 -41
  130. package/src/layers/shader_modules/decoder.ts +0 -46
  131. package/src/layers/shader_modules/index.ts +0 -1
  132. package/src/layers/terrain/map3DLayer.stories.tsx +0 -340
  133. package/src/layers/terrain/map3DLayer.ts +0 -556
  134. package/src/layers/terrain/terrainMapLayer.ts +0 -334
  135. package/src/layers/terrain/terrainmap.fs.glsl.ts +0 -134
  136. package/src/layers/triangle/fragment.fs.glsl.ts +0 -126
  137. package/src/layers/triangle/fragment_lines.glsl.ts +0 -21
  138. package/src/layers/triangle/privateTriangleLayer.ts +0 -203
  139. package/src/layers/triangle/test_data/surfacePoints.ts +0 -4344
  140. package/src/layers/triangle/test_data/surfaceTriangles.ts +0 -7392
  141. package/src/layers/triangle/triangleLayer.stories.tsx +0 -191
  142. package/src/layers/triangle/triangleLayer.ts +0 -273
  143. package/src/layers/triangle/vertex.glsl.ts +0 -35
  144. package/src/layers/triangle/vertex_lines.glsl.ts +0 -15
  145. package/src/layers/triangle/webworker.ts +0 -165
  146. package/src/layers/utils/glsl.d.ts +0 -4
  147. package/src/layers/utils/layerTools.ts +0 -182
  148. package/src/layers/utils/propertyMapTools.ts +0 -43
  149. package/src/layers/wells/utils/spline.ts +0 -318
  150. package/src/layers/wells/wellsLayer.stories.tsx +0 -625
  151. package/src/layers/wells/wellsLayer.ts +0 -1377
  152. package/src/redux/actions.ts +0 -8
  153. package/src/redux/reducer.ts +0 -43
  154. package/src/redux/store.ts +0 -15
  155. package/src/redux/types.ts +0 -114
  156. package/src/storybook/SubsurfaceViewer.stories.jsx +0 -644
  157. package/src/storybook/components/InfoCard.stories.jsx +0 -39
  158. package/src/storybook/components/colorLegends/ContinuousLegend.stories.jsx +0 -32
  159. package/src/storybook/components/colorLegends/DiscreteLegend.stories.jsx +0 -33
  160. package/src/storybook/components/colorLegends/IndividualScaleForMap.stories.jsx +0 -99
  161. package/src/storybook/components/colorLegends/SingleScaleForMap.stories.jsx +0 -120
  162. package/src/storybook/components/settings/LayerSettingsButton.stories.jsx +0 -34
  163. package/src/storybook/components/settings/NumericInput.stories.jsx +0 -17
  164. package/src/storybook/components/settings/ToggleButton.stories.jsx +0 -16
  165. package/src/storybook/schemaValidation/sampleData.js +0 -177
  166. package/src/storybook/schemaValidation/schemaValidation.stories.jsx +0 -91
  167. package/src/test/TestWrapper.tsx +0 -13
  168. package/src/utils/configuration.ts +0 -61
  169. package/src/utils/fit-bounds.js +0 -85
  170. package/src/utils/measurement.ts +0 -61
  171. package/src/utils/northArrow.ts +0 -4
  172. package/src/utils/specExtractor.ts +0 -36
  173. package/src/viewports/index.js +0 -1
  174. package/src/viewports/intersectionViewport.ts +0 -137
  175. package/src/views/index.js +0 -1
  176. package/src/views/intersectionView.ts +0 -38
  177. package/tsconfig.json +0 -7
@@ -1,182 +0,0 @@
1
- import { PickingInfo } from "@deck.gl/core/typed";
2
- import { Color } from "@deck.gl/core/typed";
3
- import {
4
- Layer,
5
- LayersList,
6
- LayerManager,
7
- CompositeLayerProps,
8
- } from "@deck.gl/core/typed";
9
- import { Matrix4 } from "math.gl";
10
- import {
11
- ContinuousLegendDataType,
12
- DiscreteLegendDataType,
13
- } from "../../components/ColorLegend";
14
- import DrawingLayer from "../drawing/drawingLayer";
15
-
16
- export type Position3D = [number, number, number];
17
-
18
- // Return a color given a number in the [0,1] range.
19
- export type colorMapFunctionType = (x: number) => [number, number, number];
20
-
21
- export interface ExtendedLayerProps<D> extends CompositeLayerProps<D> {
22
- "@@type"?: string;
23
- name: string;
24
- }
25
-
26
- export interface ExtendedLayer<D> extends Layer<D> {
27
- getLegendData?: () => DiscreteLegendDataType | ContinuousLegendDataType;
28
- }
29
-
30
- export interface PropertyDataType {
31
- name: string;
32
- value: string | number;
33
- color?: Color;
34
- }
35
-
36
- // Layer pick info can have multiple properties
37
- export interface LayerPickInfo extends PickingInfo {
38
- propertyValue?: number; // for single property
39
- properties?: PropertyDataType[]; // for multiple properties
40
- }
41
-
42
- // Creates property object which will be used to display layer property
43
- // in the info card.
44
- export function createPropertyData(
45
- name: string,
46
- value: string | number,
47
- color?: Color
48
- ): PropertyDataType {
49
- return {
50
- name: name,
51
- value: value,
52
- color: color,
53
- };
54
- }
55
-
56
- // Return a model matrix representing a rotation of "deg" degrees around the point x, y
57
- export function getModelMatrix(deg: number, x: number, y: number): Matrix4 {
58
- const rad = deg * 0.017453;
59
- const IDENTITY = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
60
-
61
- const m1 = new Matrix4(IDENTITY).translate([-x, -y, 0, 1]); // translate to origin
62
- const mRot = new Matrix4(IDENTITY).rotateZ(rad); // rotate
63
- const m2 = new Matrix4(IDENTITY).translate([x, y, 0, 1]); // translate back
64
-
65
- // Make m2*mRot*m1
66
- mRot.multiplyRight(m1);
67
- const m2mRotm1 = m2.multiplyRight(mRot);
68
-
69
- return m2mRotm1;
70
- }
71
-
72
- // Return a model matrix representing a rotation of "deg" degrees around the point x, y
73
- export function getModelMatrixScale(scaleZ: number): Matrix4 {
74
- const IDENTITY = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
75
- const mScaleZ = new Matrix4(IDENTITY).scale([1, 1, scaleZ]);
76
- return mScaleZ;
77
- }
78
-
79
- export function getLayersInViewport(
80
- layers: Record<string, unknown>[] | LayersList,
81
- layerIds: string[] | undefined
82
- ): Record<string, unknown>[] | LayersList {
83
- if (layerIds && layerIds.length > 0 && layers) {
84
- const layers_in_view = (layers as never[]).filter((layer) =>
85
- layerIds.includes(layer["id"] as string)
86
- );
87
- return layers_in_view;
88
- } else {
89
- return layers;
90
- }
91
- }
92
-
93
- export function getLayersByType(layers: LayersList, type: string): LayersList {
94
- if (!layers) return [];
95
- return layers.filter((l) => l?.constructor.name === type);
96
- }
97
-
98
- export type NewLayersList = LayersList & {
99
- id: string;
100
- props: prop;
101
- };
102
-
103
- type prop = {
104
- data: wellData;
105
- visible: boolean;
106
- };
107
-
108
- type wellData = {
109
- features: feature[];
110
- type: string;
111
- unit?: string;
112
- };
113
-
114
- type feature = {
115
- properties: {
116
- name: string;
117
- };
118
- };
119
-
120
- export function getWellLayerByTypeAndSelectedWells(
121
- layers: LayersList,
122
- type: string,
123
- selectedWell: string
124
- ): LayersList {
125
- if (!layers) return [];
126
- return layers.filter((l) => {
127
- return (
128
- l?.constructor.name === type &&
129
- (l as NewLayersList).props.data.features.find(
130
- (item) => item.properties.name === selectedWell
131
- )
132
- );
133
- });
134
- }
135
-
136
- export function getLayersById(layers: LayersList, id: string): LayersList {
137
- if (!layers) return [];
138
- return layers.filter((l) => (l as Layer).id === id);
139
- }
140
-
141
- export function isDrawingEnabled(layer_manager: LayerManager): boolean {
142
- const drawing_layer = layer_manager.getLayers({
143
- layerIds: ["drawing-layer"],
144
- })?.[0] as DrawingLayer;
145
- return (
146
- drawing_layer &&
147
- drawing_layer.props.visible &&
148
- drawing_layer.props.mode != "view"
149
- );
150
- }
151
-
152
- export function invertZCoordinate(dataArray: Float32Array): void {
153
- for (let i = 2; i < dataArray.length; i += 3) {
154
- dataArray[i] *= -1;
155
- }
156
- }
157
-
158
- export function defineBoundingBox(
159
- dataArray: Float32Array
160
- ): [number, number, number, number, number, number] {
161
- const length = dataArray.length;
162
- let minX = Number.POSITIVE_INFINITY;
163
- let minY = Number.POSITIVE_INFINITY;
164
- let minZ = Number.POSITIVE_INFINITY;
165
- let maxX = Number.NEGATIVE_INFINITY;
166
- let maxY = Number.NEGATIVE_INFINITY;
167
- let maxZ = Number.NEGATIVE_INFINITY;
168
-
169
- for (let i = 0; i < length; i += 3) {
170
- const x = dataArray[i];
171
- const y = dataArray[i + 1];
172
- const z = dataArray[i + 2];
173
- minX = x < minX ? x : minX;
174
- minY = y < minY ? y : minY;
175
- minZ = z < minZ ? z : minZ;
176
-
177
- maxX = x > maxX ? x : maxX;
178
- maxY = y > maxY ? y : maxY;
179
- maxZ = z > maxZ ? z : maxZ;
180
- }
181
- return [minX, minY, minZ, maxX, maxY, maxZ];
182
- }
@@ -1,43 +0,0 @@
1
- import { Color } from "@deck.gl/core/typed";
2
-
3
- // Parameters used to decode a float value from RGB pixels.
4
- export interface ValueDecoder {
5
- // r, g and b multipliers
6
- rgbScaler: [number, number, number];
7
- // value multiplier
8
- floatScaler: number;
9
- // translation of the r, g, b sum
10
- offset: number;
11
- // discretize the value in a number of steps
12
- step: number;
13
- }
14
-
15
- // Decode an RGB pixel to a float value. Same operation the one performed in decoder.fs.glsl,
16
- // but this time performed in the js world.
17
- // Optionally, this function can also remap an [0, 1] value to a different range, [min, max].
18
- export function decodeRGB(
19
- [r, g, b]: Color,
20
- decoder: ValueDecoder,
21
- remapToRange?: [number, number]
22
- ): number {
23
- const { rgbScaler, floatScaler, offset, step } = decoder;
24
- const [rScale, gScale, bScale] = rgbScaler;
25
-
26
- r *= rScale * 256.0 * 256.0;
27
- g *= gScale * 256.0;
28
- b *= bScale;
29
-
30
- let decodedValue = (r + g + b + offset) * floatScaler;
31
-
32
- if (step > 0) {
33
- decodedValue = Math.floor(decodedValue / step + 0.5) * step;
34
- }
35
-
36
- if (remapToRange) {
37
- const [min, max] = remapToRange;
38
- // If we know the min and max values, remap the [0, 1] decoded value to [min, max]
39
- decodedValue = decodedValue * (max - min) + min;
40
- }
41
-
42
- return decodedValue;
43
- }
@@ -1,318 +0,0 @@
1
- import { FeatureCollection, GeometryCollection, LineString } from "geojson";
2
- import { cloneDeep } from "lodash";
3
- import { Position3D } from "../../utils/layerTools";
4
-
5
- /**
6
- * Given four points P0, P1, P2, P4 and a argument t in the interval [0,1].
7
- * returns function value at t. t == 0 corresponds to P1 and t == 1 corrsponds to P2
8
- *
9
- * See https://qroph.github.io/2018/07/30/smooth-paths-using-catmull-rom-splines.html
10
- */
11
- export function CatmullRom1D(
12
- P0: number,
13
- P1: number,
14
- P2: number,
15
- P3: number,
16
- t: number
17
- ): number {
18
- const alpha = 0.5;
19
- const tt = t * t;
20
- const ttt = t * t * t;
21
-
22
- const dist_p0_p1 = Math.sqrt(
23
- (P1 - P0) * (P1 - P0) + (P1 - P0) * (P1 - P0) + (P1 - P0) * (P1 - P0)
24
- );
25
- const dist_p1_p2 = Math.sqrt(
26
- (P1 - P2) * (P1 - P2) + (P1 - P2) * (P1 - P2) + (P1 - P2) * (P1 - P2)
27
- );
28
- const dist_p2_p3 = Math.sqrt(
29
- (P3 - P2) * (P3 - P2) + (P3 - P2) * (P3 - P2) + (P3 - P2) * (P3 - P2)
30
- );
31
-
32
- const t01 = Math.pow(dist_p0_p1, alpha);
33
- const t12 = Math.pow(dist_p1_p2, alpha);
34
- const t23 = Math.pow(dist_p2_p3, alpha);
35
-
36
- const m1 = P2 - P1 + t12 * ((P1 - P0) / t01 - (P2 - P0) / (t01 + t12));
37
- const m2 = P2 - P1 + t12 * ((P3 - P2) / t23 - (P3 - P1) / (t12 + t23));
38
-
39
- const a_x = 2 * (P1 - P2) + m1 + m2;
40
- const b_x = -3 * (P1 - P2) - m1 - m1 - m2;
41
- const c_x = m1;
42
- const d_x = P1;
43
-
44
- const x = a_x * ttt + b_x * tt + c_x * t + d_x;
45
-
46
- return x;
47
- }
48
-
49
- /**
50
- * Given four 3D points P0, P1, P2, P4 and a scalar argument t in the interval [0,1].
51
- * returns function value (3D) at t. t == 0 corresponds to P1 and t == 1 corrsponds to P2
52
- *
53
- * See https://qroph.github.io/2018/07/30/smooth-paths-using-catmull-rom-splines.html
54
- */
55
- export function CatmullRom(
56
- P0: Position3D,
57
- P1: Position3D,
58
- P2: Position3D,
59
- P3: Position3D,
60
- t: number
61
- ): Position3D {
62
- const alpha = 0.5;
63
- const tt = t * t;
64
- const ttt = t * t * t;
65
-
66
- // disable eslint for some lines due to readability.
67
- const dist_p0_p1 = Math.sqrt((P1[0]-P0[0])*(P1[0]-P0[0]) + (P1[1]-P0[1])*(P1[1]-P0[1]) + (P1[2]-P0[2])*(P1[2]-P0[2]) ); // eslint-disable-line
68
- const dist_p1_p2 = Math.sqrt((P1[0]-P2[0])*(P1[0]-P2[0]) + (P1[1]-P2[1])*(P1[1]-P2[1]) + (P1[2]-P2[2])*(P1[2]-P2[2]) ); // eslint-disable-line
69
- const dist_p2_p3 = Math.sqrt((P3[0]-P2[0])*(P3[0]-P2[0]) + (P3[1]-P2[1])*(P3[1]-P2[1]) + (P3[2]-P2[2])*(P3[2]-P2[2]) ); // eslint-disable-line
70
-
71
- const t01 = Math.pow(dist_p0_p1, alpha);
72
- const t12 = Math.pow(dist_p1_p2, alpha);
73
- const t23 = Math.pow(dist_p2_p3, alpha);
74
-
75
- const m1_x = (P2[0] - P1[0] + t12 * ((P1[0] - P0[0]) / t01 - (P2[0] - P0[0]) / (t01 + t12))); // eslint-disable-line
76
- const m1_y = (P2[1] - P1[1] + t12 * ((P1[1] - P0[1]) / t01 - (P2[1] - P0[1]) / (t01 + t12))); // eslint-disable-line
77
- const m1_z = (P2[2] - P1[2] + t12 * ((P1[2] - P0[2]) / t01 - (P2[2] - P0[2]) / (t01 + t12))); // eslint-disable-line
78
-
79
- const m2_x = (P2[0] - P1[0] + t12 * ((P3[0] - P2[0]) / t23 - (P3[0] - P1[0]) / (t12 + t23))); // eslint-disable-line
80
- const m2_y = (P2[1] - P1[1] + t12 * ((P3[1] - P2[1]) / t23 - (P3[1] - P1[1]) / (t12 + t23))); // eslint-disable-line
81
- const m2_z = (P2[2] - P1[2] + t12 * ((P3[2] - P2[2]) / t23 - (P3[2] - P1[2]) / (t12 + t23))); // eslint-disable-line
82
-
83
- const a_x = 2 * (P1[0] - P2[0]) + m1_x + m2_x;
84
- const a_y = 2 * (P1[1] - P2[1]) + m1_y + m2_y;
85
- const a_z = 2 * (P1[2] - P2[2]) + m1_z + m2_z;
86
-
87
- const b_x = -3 * (P1[0] - P2[0]) - m1_x - m1_x - m2_x;
88
- const b_y = -3 * (P1[1] - P2[1]) - m1_y - m1_y - m2_y;
89
- const b_z = -3 * (P1[2] - P2[2]) - m1_z - m1_z - m2_z;
90
-
91
- const c_x = m1_x;
92
- const c_y = m1_y;
93
- const c_z = m1_z;
94
-
95
- const d_x = P1[0];
96
- const d_y = P1[1];
97
- const d_z = P1[2];
98
-
99
- const x = a_x * ttt + b_x * tt + c_x * t + d_x;
100
- const y = a_y * ttt + b_y * tt + c_y * t + d_y;
101
- const z = a_z * ttt + b_z * tt + c_z * t + d_z;
102
-
103
- return [x, y, z] as Position3D;
104
- }
105
-
106
- /**
107
- * Will interpolate and refine wellpaths using spline interploation resulting
108
- * in smoother curves with more points.
109
- * Assumes 3D data.
110
- */
111
- export function splineRefine(data_in: FeatureCollection): FeatureCollection {
112
- const data = cloneDeep(data_in);
113
-
114
- const no_wells = data.features.length;
115
- for (let well_no = 0; well_no < no_wells; well_no++) {
116
- const mds = data.features[well_no].properties?.["md"];
117
- if (mds === undefined) {
118
- continue;
119
- }
120
- const geometryCollection = data.features[well_no]
121
- .geometry as GeometryCollection;
122
- const lineString = geometryCollection?.geometries[1] as LineString;
123
-
124
- if (lineString.coordinates?.length === undefined) {
125
- continue;
126
- }
127
-
128
- const coords = lineString.coordinates as Position3D[];
129
-
130
- const n = coords.length;
131
- const ts = n > 3 ? [0.2, 0.4, 0.6, 0.8] : [];
132
-
133
- // Point before first.
134
- const x0 = coords[0][0] - coords[1][0] + coords[0][0];
135
- const y0 = coords[0][1] - coords[1][1] + coords[0][1];
136
- const z0 = coords[0][2] - coords[1][2] + coords[0][2];
137
- const P_first: Position3D = [x0, y0, z0];
138
-
139
- const md_first = mds[0][0] - mds[0][1] + mds[0][0];
140
-
141
- // Point after last.
142
- const xn = coords[n - 1][0] - coords[n - 2][0] + coords[n - 1][0];
143
- const yn = coords[n - 1][1] - coords[n - 2][1] + coords[n - 1][1];
144
- const zn = coords[n - 1][2] - coords[n - 2][2] + coords[n - 1][2];
145
- const P_n: Position3D = [xn, yn, zn];
146
-
147
- const md_n = mds[0][n - 1] - mds[0][n - 2] + mds[0][n - 1];
148
-
149
- const newCoordinates: Position3D[] = [];
150
- const newMds: number[][] = [];
151
- newMds.push([]);
152
-
153
- for (let i = 0; i < n - 1; i += 1) {
154
- let P0: Position3D, P1: Position3D, P2: Position3D, P3: Position3D;
155
- let md0: number, md1: number, md2: number, md3: number;
156
-
157
- if (i === 0) {
158
- P0 = P_first;
159
- P1 = coords[i + 0];
160
- P2 = coords[i + 1];
161
- P3 = coords[i + 2];
162
-
163
- md0 = md_first;
164
- md1 = mds[0][i + 0];
165
- md2 = mds[0][i + 1];
166
- md3 = mds[0][i + 2];
167
- } else if (i === n - 2) {
168
- P0 = coords[n - 3];
169
- P1 = coords[n - 2];
170
- P2 = coords[n - 1];
171
- P3 = P_n;
172
-
173
- md0 = mds[0][n - 3];
174
- md1 = mds[0][n - 2];
175
- md2 = mds[0][n - 1];
176
- md3 = md_n;
177
- } else {
178
- P0 = coords[i - 1];
179
- P1 = coords[i - 0];
180
- P2 = coords[i + 1];
181
- P3 = coords[i + 2];
182
-
183
- md0 = mds[0][i - 1];
184
- md1 = mds[0][i - 0];
185
- md2 = mds[0][i + 1];
186
- md3 = mds[0][i + 2];
187
- }
188
-
189
- newCoordinates.push(P1);
190
- newMds[0].push(md1);
191
-
192
- // Skip first leg from platform to first survey point.
193
- if (i > 1) {
194
- for (let t_i = 0; t_i < ts.length; t_i += 1) {
195
- const t = ts[t_i];
196
- const [x, y, z] = CatmullRom(P0, P1, P2, P3, t);
197
- const md = CatmullRom1D(md0, md1, md2, md3, t);
198
-
199
- newCoordinates.push([x, y, z] as Position3D);
200
- newMds[0].push(md);
201
- }
202
- }
203
- }
204
-
205
- newCoordinates.push(coords[n - 1]);
206
- newMds[0].push(mds[0][n - 1]);
207
-
208
- (
209
- (data.features[well_no].geometry as GeometryCollection)
210
- .geometries[1] as LineString
211
- ).coordinates = newCoordinates;
212
-
213
- if (data.features[well_no].properties) {
214
- data.features[well_no].properties!["md"] = newMds; // eslint-disable-line
215
- }
216
- }
217
-
218
- return data;
219
- }
220
-
221
- export function flattenPath(data_in: FeatureCollection): FeatureCollection {
222
- const data = cloneDeep(data_in);
223
-
224
- const no_wells = data.features.length;
225
- for (let well_no = 0; well_no < no_wells; well_no++) {
226
- const geometryCollection = data.features[well_no]
227
- .geometry as GeometryCollection;
228
- const lineString = geometryCollection?.geometries[1] as LineString;
229
-
230
- if (lineString.coordinates?.length === undefined) {
231
- continue;
232
- }
233
-
234
- const coords = lineString.coordinates as Position3D[];
235
-
236
- // flatten by setting z value constant.
237
- const coords_flat: Position3D[] = coords.map((e: Position3D) => {
238
- return [e[0], e[1], 0.0];
239
- });
240
-
241
- (
242
- (data.features[well_no].geometry as GeometryCollection)
243
- .geometries[1] as LineString
244
- ).coordinates = coords_flat;
245
- }
246
-
247
- return data;
248
- }
249
-
250
- export function invertPath(data_in: FeatureCollection): FeatureCollection {
251
- const data = cloneDeep(data_in);
252
-
253
- const no_wells = data.features.length;
254
- for (let well_no = 0; well_no < no_wells; well_no++) {
255
- const geometryCollection = data.features[well_no]
256
- .geometry as GeometryCollection;
257
- const lineString = geometryCollection?.geometries[1] as LineString;
258
-
259
- if (lineString.coordinates?.length === undefined) {
260
- continue;
261
- }
262
-
263
- const coords = lineString.coordinates as Position3D[];
264
-
265
- // Invert path by multiplying depth with -1.
266
- const coords_inverted: Position3D[] = coords.map((e: Position3D) => {
267
- return [e[0], e[1], -e[2]];
268
- });
269
-
270
- (
271
- (data.features[well_no].geometry as GeometryCollection)
272
- .geometries[1] as LineString
273
- ).coordinates = coords_inverted;
274
- }
275
-
276
- return data;
277
- }
278
-
279
- /**
280
- * Calculates bounding box of all wells.
281
- */
282
- export function GetBoundingBox(
283
- data: FeatureCollection
284
- ): [number, number, number, number, number, number] {
285
- let xMin = 9999999999;
286
- let yMin = 9999999999;
287
- let zMin = 9999999999;
288
- let xMax = -9999999999;
289
- let yMax = -9999999999;
290
- let zMax = -9999999999;
291
-
292
- const no_wells = data.features.length;
293
- for (let well_no = 0; well_no < no_wells; well_no++) {
294
- const geometryCollection = data.features[well_no]
295
- .geometry as GeometryCollection;
296
- const lineString = geometryCollection?.geometries[1] as LineString;
297
-
298
- if (lineString.coordinates?.length === undefined) {
299
- continue;
300
- }
301
-
302
- const coords = lineString.coordinates as Position3D[];
303
- const n = coords.length;
304
- for (let i = 0; i < n; i++) {
305
- const xyz = coords[i];
306
-
307
- xMin = xyz[0] < xMin ? xyz[0] : xMin;
308
- yMin = xyz[1] < yMin ? xyz[1] : yMin;
309
- zMin = xyz[2] < zMin ? xyz[2] : zMin;
310
-
311
- xMax = xyz[0] > xMax ? xyz[0] : xMax;
312
- yMax = xyz[1] > yMax ? xyz[1] : yMax;
313
- zMax = xyz[2] > zMax ? xyz[2] : zMax;
314
- }
315
- }
316
-
317
- return [xMin, yMin, zMin, xMax, yMax, zMax];
318
- }