Skip to content

Commit

Permalink
fix: [NGRM] - For wells the property "ZIncreasingDownwards" does not …
Browse files Browse the repository at this point in the history
…honor… (#1886)
  • Loading branch information
nilscb authored Jan 22, 2024
1 parent abb2e2f commit a88f3c3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
FeatureCollection,
GeometryCollection,
LineString,
Point,
} from "geojson";
import { cloneDeep } from "lodash";
import type { Position3D } from "../../utils/layerTools";
Expand Down Expand Up @@ -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
}
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const testWellWithDuplicates = {
geometries: [
{
type: "Point",
coordinates: [0, 0],
coordinates: [0, 0, 0],
},
{
type: "LineString",
Expand Down Expand Up @@ -92,6 +92,7 @@ const defaultProps = {
{
"@@type": "WellsLayer",
data: "@@#resources.wellsData",
ZIncreasingDownwards: false,
},
],
};
Expand Down Expand Up @@ -508,6 +509,7 @@ export const WellsRefine: StoryFn<typeof SubsurfaceViewer> = (args) => {
"@@type": "WellsLayer",
data: testWell,
refine: refineNumber,
ZIncreasingDownwards: false,
},
{
"@@type": "AxesLayer",
Expand Down Expand Up @@ -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,
}),
],

Expand Down Expand Up @@ -646,6 +650,7 @@ export const SimplifiedRendering: ComponentStory<typeof SubsurfaceViewer> = (
refine: true,
outline: true,
simplifiedRendering, // If true will cause wellslayer to draw simplified.
ZIncreasingDownwards: false,
}),
new AxesLayer({
id: "axes-layer",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export default class WellsLayer extends CompositeLayer<WellsLayerProps> {
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);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit a88f3c3

Please sign in to comment.