Skip to content

Commit c713add

Browse files
shadab-skhanShadab Khanhkfb
authored
Correct Map3D layer readout alignment (#883)
* Correct Map3D layer readout alignment Changed Icon Fix #829 * Changed icon * Use property value range instead of color range Co-authored-by: Shadab Khan <[email protected]> Co-authored-by: Håvard Bjerke <[email protected]>
1 parent aad6622 commit c713add

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

react/src/lib/components/DeckGLMap/layers/terrain/terrainMapLayer.ts

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import GL from "@luma.gl/constants";
66
import { Texture2D } from "@luma.gl/core";
77
import { DeckGLLayerContext } from "../../components/Map";
88
import { colorTablesArray, rgbValues } from "@emerson-eps/color-tables/";
9+
import { createPropertyData, PropertyDataType } from "../utils/layerTools";
910

1011
const DEFAULT_TEXTURE_PARAMETERS = {
1112
[GL.TEXTURE_MIN_FILTER]: GL.LINEAR_MIPMAP_LINEAR,
@@ -177,27 +178,41 @@ export default class TerrainMapLayer extends SimpleMeshLayer<
177178
const r = info.color[0] * DECODER.rScaler;
178179
const g = info.color[1] * DECODER.gScaler;
179180
const b = info.color[2] * DECODER.bScaler;
181+
const value = r + g + b;
180182

181-
const floatScaler = 1.0 / (256.0 * 256.0 * 256.0 - 1.0);
183+
let depth = undefined;
184+
const layer_properties: PropertyDataType[] = [];
182185

183-
const isPropertyReadout = !this.props.isReadoutDepth; // Either map properties or map depths are encoded here.
184-
let value = (r + g + b) * (isPropertyReadout ? floatScaler : 1.0);
185-
186-
if (isPropertyReadout) {
187-
// Remap the [0, 1] decoded value to property value range.
188-
const [min, max] = this.props.propertyValueRange;
189-
value = value * (max - min) + min;
190-
}
191-
192-
const valueString =
193-
(isPropertyReadout ? "Property: " : "Depth: ") + value.toFixed(1);
186+
// Either map properties or map depths are encoded here.
187+
if (this.props.isReadoutDepth) depth = value.toFixed(2);
188+
else
189+
layer_properties.push(
190+
getMapProperty(value, this.props.propertyValueRange)
191+
);
194192

195193
return {
196194
...info,
197-
propertyValue: valueString,
195+
properties: layer_properties,
196+
propertyValue: depth,
198197
};
199198
}
200199
}
201200

202201
TerrainMapLayer.layerName = "TerrainMapLayer";
203202
TerrainMapLayer.defaultProps = defaultProps;
203+
204+
//================= Local help functions. ==================
205+
206+
function getMapProperty(
207+
value: number,
208+
value_range: [number, number]
209+
): PropertyDataType {
210+
// Remap the [0, 1] decoded value to property value range.
211+
const [min, max] = value_range;
212+
213+
const floatScaler = 1.0 / (256.0 * 256.0 * 256.0 - 1.0);
214+
const scaled_value = value * floatScaler;
215+
216+
value = scaled_value * (max - min) + min;
217+
return createPropertyData("Property", value);
218+
}

react/src/lib/components/DeckGLMap/redux/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Icon } from "@equinor/eds-core-react";
22
import {
3+
map,
34
well,
45
brush,
56
fault,
@@ -11,6 +12,7 @@ import {
1112

1213
// (this needs only be done once)
1314
Icon.add({
15+
map,
1416
well,
1517
brush,
1618
fault,
@@ -82,7 +84,7 @@ export const LayerIcons = {
8284
ColormapLayer: "surface_layer",
8385
Hillshading2DLayer: "hill_shading",
8486
WellsLayer: "well",
85-
Map3DLayer: "fault",
87+
Map3DLayer: "map",
8688
PieChartLayer: "pie_chart",
8789
GridLayer: "grid_layer",
8890
FaultPolygonsLayer: "fault",

0 commit comments

Comments
 (0)