diff --git a/typescript/packages/subsurface-viewer/src/layers/wells/utils/spline.ts b/typescript/packages/subsurface-viewer/src/layers/wells/utils/spline.ts index b8767e1b0..24a2e7552 100644 --- a/typescript/packages/subsurface-viewer/src/layers/wells/utils/spline.ts +++ b/typescript/packages/subsurface-viewer/src/layers/wells/utils/spline.ts @@ -2,6 +2,7 @@ import type { FeatureCollection, GeometryCollection, LineString, + Point, } from "geojson"; import { cloneDeep } from "lodash"; import type { Position3D } from "../../utils/layerTools"; @@ -66,7 +67,7 @@ export function removeDuplicates(data: FeatureCollection): void { ).coordinates = coords; if (data.features[well_no].properties) { - data.features[well_no].properties!["md"] = mds; // eslint-disable-line + data.features[well_no].properties!["md"] = mds; // eslint-disable-line } } } @@ -133,21 +134,21 @@ export function CatmullRom( const ttt = t * t * t; // disable eslint for some lines due to readability. - 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 - 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 - 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 + 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 + 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 + 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 const t01 = Math.pow(dist_p0_p1, alpha); const t12 = Math.pow(dist_p1_p2, alpha); const t23 = Math.pow(dist_p2_p3, alpha); - const m1_x = (P2[0] - P1[0] + t12 * ((P1[0] - P0[0]) / t01 - (P2[0] - P0[0]) / (t01 + t12))); // eslint-disable-line - const m1_y = (P2[1] - P1[1] + t12 * ((P1[1] - P0[1]) / t01 - (P2[1] - P0[1]) / (t01 + t12))); // eslint-disable-line - const m1_z = (P2[2] - P1[2] + t12 * ((P1[2] - P0[2]) / t01 - (P2[2] - P0[2]) / (t01 + t12))); // eslint-disable-line + const m1_x = (P2[0] - P1[0] + t12 * ((P1[0] - P0[0]) / t01 - (P2[0] - P0[0]) / (t01 + t12))); // eslint-disable-line + const m1_y = (P2[1] - P1[1] + t12 * ((P1[1] - P0[1]) / t01 - (P2[1] - P0[1]) / (t01 + t12))); // eslint-disable-line + const m1_z = (P2[2] - P1[2] + t12 * ((P1[2] - P0[2]) / t01 - (P2[2] - P0[2]) / (t01 + t12))); // eslint-disable-line - const m2_x = (P2[0] - P1[0] + t12 * ((P3[0] - P2[0]) / t23 - (P3[0] - P1[0]) / (t12 + t23))); // eslint-disable-line - const m2_y = (P2[1] - P1[1] + t12 * ((P3[1] - P2[1]) / t23 - (P3[1] - P1[1]) / (t12 + t23))); // eslint-disable-line - const m2_z = (P2[2] - P1[2] + t12 * ((P3[2] - P2[2]) / t23 - (P3[2] - P1[2]) / (t12 + t23))); // eslint-disable-line + const m2_x = (P2[0] - P1[0] + t12 * ((P3[0] - P2[0]) / t23 - (P3[0] - P1[0]) / (t12 + t23))); // eslint-disable-line + const m2_y = (P2[1] - P1[1] + t12 * ((P3[1] - P2[1]) / t23 - (P3[1] - P1[1]) / (t12 + t23))); // eslint-disable-line + const m2_z = (P2[2] - P1[2] + t12 * ((P3[2] - P2[2]) / t23 - (P3[2] - P1[2]) / (t12 + t23))); // eslint-disable-line const a_x = 2 * (P1[0] - P2[0]) + m1_x + m2_x; const a_y = 2 * (P1[1] - P2[1]) + m1_y + m2_y; @@ -298,7 +299,7 @@ export function splineRefine( ).coordinates = newCoordinates; if (data.features[well_no].properties) { - data.features[well_no].properties!["md"] = newMds; // eslint-disable-line + data.features[well_no].properties!["md"] = newMds; // eslint-disable-line } } @@ -387,8 +388,14 @@ export function invertPath(data_in: FeatureCollection): FeatureCollection { for (let well_no = 0; well_no < no_wells; well_no++) { const geometryCollection = data.features[well_no] .geometry as GeometryCollection; + const lineString = geometryCollection?.geometries[1] as LineString; + const wellHead = geometryCollection?.geometries[0] as Point; + if (wellHead.coordinates?.[2]) { + wellHead.coordinates[2] *= -1; + } + if (lineString.coordinates?.length === undefined) { continue; } diff --git a/typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.stories.tsx b/typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.stories.tsx index 3cbdeda97..4f5dbde8f 100644 --- a/typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.stories.tsx +++ b/typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.stories.tsx @@ -29,7 +29,7 @@ const testWellWithDuplicates = { geometries: [ { type: "Point", - coordinates: [0, 0], + coordinates: [0, 0, 0], }, { type: "LineString", @@ -92,6 +92,7 @@ const defaultProps = { { "@@type": "WellsLayer", data: "@@#resources.wellsData", + ZIncreasingDownwards: false, }, ], }; @@ -508,6 +509,7 @@ export const WellsRefine: StoryFn = (args) => { "@@type": "WellsLayer", data: testWell, refine: refineNumber, + ZIncreasingDownwards: false, }, { "@@type": "AxesLayer", @@ -600,10 +602,12 @@ VerticalWellWithDuplicates.args = { layers: [ new WellsLayer({ data: testWellWithDuplicates, + ZIncreasingDownwards: false, }), new AxesLayer({ id: "axes-layer", - bounds: [-100, -100, 0, 100, 100, 500], + bounds: [-100, -100, -500, 100, 100, 0], + ZIncreasingDownwards: false, }), ], @@ -646,6 +650,7 @@ export const SimplifiedRendering: ComponentStory = ( refine: true, outline: true, simplifiedRendering, // If true will cause wellslayer to draw simplified. + ZIncreasingDownwards: false, }), new AxesLayer({ id: "axes-layer", @@ -795,7 +800,7 @@ const discreteData = { const reverseRange = false; //eslint-disable-next-line -const wellLayerTemplate = (args: any) => { +const wellLayerTemplate = (args: any) => { // eslint-disable-next-line react-hooks/rules-of-hooks const [getColorName, setColorName] = React.useState("Rainbow"); // eslint-disable-next-line react-hooks/rules-of-hooks @@ -847,7 +852,7 @@ const wellLayerTemplate = (args: any) => { }; //eslint-disable-next-line -export const LegendWithColorSelector: any = wellLayerTemplate.bind({}); +export const LegendWithColorSelector: any = wellLayerTemplate.bind({}); LegendWithColorSelector.args = { min, diff --git a/typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts b/typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts index eb6bd197c..2573e7c8a 100644 --- a/typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts +++ b/typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts @@ -257,7 +257,7 @@ export default class WellsLayer extends CompositeLayer { initializeState(): void { let data = this.props.data as unknown as FeatureCollection; if (typeof data !== "undefined" && !isEqual(data, [])) { - if (!this.props.ZIncreasingDownwards) { + if (this.props.ZIncreasingDownwards) { data = invertPath(data); } @@ -981,7 +981,7 @@ function getLogColor( logColor: string, colorTables: colorTablesArray, // eslint-disable-next-line - colorMappingFunction: any, + colorMappingFunction: any, isLog: boolean ): Color[] { const log_data = getLogValues(d, logrun_name, log_name); @@ -1014,7 +1014,7 @@ function getLogColor( const logLength = Object.keys(log_attributes).length; // eslint-disable-next-line - const attributesObject: { [key: string]: any } = {}; + const attributesObject: { [key: string]: any } = {}; const categorial = true; Object.keys(log_attributes).forEach((key) => {