Skip to content

Commit

Permalink
Fixed to select proper log curve from selected logrun (equinor#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadab-skhan authored Jun 25, 2021
1 parent ffc2448 commit 2dc78bb
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions src/lib/components/DeckGLMap/layers/wells/wellsLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,39 @@ const COLOR_MAP: RGBAColor[] = [
[255, 125, 125, 255],
];

function isLogRunSelected(d: LogCurveDataType, logrun_name: string): boolean {
return d.header.name.toLowerCase() === logrun_name.toLowerCase();
}

function getLogPath(d: LogCurveDataType, logrun_name: string): number[] {
if (d?.header?.name?.toLowerCase() === logrun_name?.toLowerCase()) {
if (isLogRunSelected(d, logrun_name)) {
if (d?.data) {
return d.data[0];
}
}
return [];
}

function getLogIDByName(d: LogCurveDataType, log_name: string): number | null {
return d?.curves?.findIndex(
(item) => item.name.toLowerCase() === log_name.toLowerCase()
);
function getLogIDByName(
d: LogCurveDataType,
logrun_name: string,
log_name: string
): number | null {
if (isLogRunSelected(d, logrun_name)) {
return d?.curves?.findIndex(
(item) => item.name.toLowerCase() === log_name.toLowerCase()
);
}
return null;
}

const color_interp = interpolateRgbBasis(["red", "yellow", "green", "blue"]);
function getLogColor(d: LogCurveDataType, log_name: string): RGBAColor[] {
const log_id = getLogIDByName(d, log_name);
function getLogColor(
d: LogCurveDataType,
logrun_name: string,
log_name: string
): RGBAColor[] {
const log_id = getLogIDByName(d, logrun_name, log_name);
if (!log_id || d?.curves[log_id] == undefined) {
return [];
}
Expand All @@ -88,8 +103,12 @@ function getLogColor(d: LogCurveDataType, log_name: string): RGBAColor[] {
return log_color;
}

function getLogWidth(d: LogCurveDataType, log_name: string): number[] | null {
const log_id = getLogIDByName(d, log_name);
function getLogWidth(
d: LogCurveDataType,
logrun_name: string,
log_name: string
): number[] | null {
const log_id = getLogIDByName(d, logrun_name, log_name);
return log_id ? d?.data[log_id] : null;
}

Expand Down Expand Up @@ -224,9 +243,10 @@ export default class WellsLayer extends CompositeLayer<
getPath: (d: LogCurveDataType): number[] =>
getLogPath(d, this.props.logrunName),
getColor: (d: LogCurveDataType): RGBAColor[] =>
getLogColor(d, this.props.logName),
getLogColor(d, this.props.logrunName, this.props.logName),
getWidth: (d: LogCurveDataType): number | number[] | null =>
this.props.logRadius || getLogWidth(d, this.props.logName),
this.props.logRadius ||
getLogWidth(d, this.props.logrunName, this.props.logName),
updateTriggers: {
getColor: [this.props.logName],
getWidth: [this.props.logName, this.props.logRadius],
Expand Down Expand Up @@ -278,6 +298,7 @@ export default class WellsLayer extends CompositeLayer<

const log_id = getLogIDByName(
info.object as LogCurveDataType,
this.props.logrunName,
this.props.logName
);
if (!log_id) return info;
Expand Down

0 comments on commit 2dc78bb

Please sign in to comment.