@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.
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/package.json +5 -2
- package/package.json +6 -3
- package/dist/DashSubsurfaceViewer.d.ts +0 -56
- package/dist/DashSubsurfaceViewer.js +0 -160
- package/dist/DashSubsurfaceViewer.js.map +0 -1
- package/src/DashSubsurfaceViewer.tsx +0 -270
- package/src/SubsurfaceViewer.stories.tsx +0 -449
- package/src/SubsurfaceViewer.test.tsx +0 -98
- package/src/SubsurfaceViewer.tsx +0 -356
- package/src/__snapshots__/SubsurfaceViewer.test.tsx.snap +0 -178
- package/src/assets/glTF/north_arrow/scene.bin +0 -0
- package/src/assets/glTF/north_arrow/scene.gltf +0 -315
- package/src/assets/glTF/north_arrow/textures/Arrow5_baseColor.png +0 -0
- package/src/assets/glTF/north_arrow/textures/Arrow5_metallicRoughness.png +0 -0
- package/src/assets/glTF/north_arrow/textures/Arrow5_normal.png +0 -0
- package/src/components/ColorLegend.test.tsx +0 -32
- package/src/components/ColorLegend.tsx +0 -80
- package/src/components/ColorLegends.test.tsx +0 -97
- package/src/components/ColorLegends.tsx +0 -46
- package/src/components/DistanceScale.stories.tsx +0 -28
- package/src/components/DistanceScale.test.tsx +0 -36
- package/src/components/DistanceScale.tsx +0 -84
- package/src/components/InfoCard.test.tsx +0 -110
- package/src/components/InfoCard.tsx +0 -263
- package/src/components/Map.test.tsx +0 -142
- package/src/components/Map.tsx +0 -1435
- package/src/components/StatusIndicator.test.tsx +0 -14
- package/src/components/StatusIndicator.tsx +0 -38
- package/src/components/ViewAnnotation.tsx +0 -16
- package/src/components/ViewFooter.test.tsx +0 -12
- package/src/components/ViewFooter.tsx +0 -30
- package/src/components/__snapshots__/ColorLegends.test.tsx.snap +0 -15
- package/src/components/__snapshots__/DistanceScale.test.tsx.snap +0 -33
- package/src/components/__snapshots__/InfoCard.test.tsx.snap +0 -561
- package/src/components/__snapshots__/Map.test.tsx.snap +0 -119
- package/src/components/__snapshots__/StatusIndicator.test.tsx.snap +0 -3
- package/src/components/__snapshots__/ViewFooter.test.tsx.snap +0 -7
- package/src/components/settings/DrawModeSelector.test.tsx +0 -45
- package/src/components/settings/DrawModeSelector.tsx +0 -58
- package/src/components/settings/DrawModeSelector_performance.test.tsx +0 -35
- package/src/components/settings/LayerProperty.test.tsx +0 -35
- package/src/components/settings/LayerProperty.tsx +0 -153
- package/src/components/settings/LayerProperty_performance.test.tsx +0 -39
- package/src/components/settings/LayerSettingsButton.test.tsx +0 -133
- package/src/components/settings/LayerSettingsButton.tsx +0 -95
- package/src/components/settings/LayersButton.test.tsx +0 -102
- package/src/components/settings/LayersButton.tsx +0 -97
- package/src/components/settings/NumericInput.test.tsx +0 -25
- package/src/components/settings/NumericInput.tsx +0 -67
- package/src/components/settings/Settings.tsx +0 -71
- package/src/components/settings/SliderInput.test.tsx +0 -28
- package/src/components/settings/SliderInput.tsx +0 -71
- package/src/components/settings/ToggleButton.test.tsx +0 -25
- package/src/components/settings/ToggleButton.tsx +0 -53
- package/src/components/settings/__snapshots__/DrawModeSelector.test.tsx.snap +0 -124
- package/src/components/settings/__snapshots__/LayerProperty.test.tsx.snap +0 -124
- package/src/components/settings/__snapshots__/LayerSettingsButton.test.tsx.snap +0 -36
- package/src/components/settings/__snapshots__/LayersButton.test.tsx.snap +0 -83
- package/src/components/settings/__snapshots__/NumericInput.test.tsx.snap +0 -123
- package/src/components/settings/__snapshots__/SliderInput.test.tsx.snap +0 -244
- package/src/components/settings/__snapshots__/ToggleButton.test.tsx.snap +0 -182
- package/src/custom.d.ts +0 -9
- package/src/index.ts +0 -5
- package/src/inputSchema/ColorTables.json +0 -51
- package/src/inputSchema/FaultPolygons.json +0 -80
- package/src/inputSchema/Grid.json +0 -39
- package/src/inputSchema/PieChart.json +0 -72
- package/src/inputSchema/WellLog.json +0 -126
- package/src/inputSchema/WellLogTemplate.json +0 -136
- package/src/inputSchema/WellLogs.json +0 -5
- package/src/inputSchema/Wells.json +0 -106
- package/src/inputSchema/schemaValidationUtil.tsx +0 -55
- package/src/inputSchema/validator.tsx +0 -72
- package/src/inputSchema/wellCompletions.json +0 -108
- package/src/layers/BoxSelectionLayer/boxSelectionLayer.stories.tsx +0 -172
- package/src/layers/BoxSelectionLayer/boxSelectionLayer.tsx +0 -136
- package/src/layers/axes/axes-fragment.glsl.ts +0 -15
- package/src/layers/axes/axesLayer.stories.tsx +0 -87
- package/src/layers/axes/axesLayer.ts +0 -692
- package/src/layers/axes/boxLayer.ts +0 -71
- package/src/layers/axes/grid-vertex.glsl.ts +0 -14
- package/src/layers/axes2d/axes2DLayer.stories.tsx +0 -150
- package/src/layers/axes2d/axes2DLayer.ts +0 -841
- package/src/layers/axes2d/font-atlas.png +0 -0
- package/src/layers/axes2d/label-fragment.glsl.js +0 -37
- package/src/layers/axes2d/label-vertex.glsl.js +0 -20
- package/src/layers/axes2d/line-fragment.glsl.js +0 -14
- package/src/layers/axes2d/line-vertex.glsl.js +0 -13
- package/src/layers/colormap/colormap.fs.glsl.ts +0 -42
- package/src/layers/colormap/colormapLayer.ts +0 -247
- package/src/layers/drawing/drawingLayer.tsx +0 -256
- package/src/layers/fault_polygons/faultPolygonsLayer.ts +0 -54
- package/src/layers/grid3d/fragment.fs.glsl.ts +0 -109
- package/src/layers/grid3d/fragment_lines.glsl.ts +0 -21
- package/src/layers/grid3d/grid3dLayer.stories.tsx +0 -172
- package/src/layers/grid3d/grid3dLayer.ts +0 -248
- package/src/layers/grid3d/privateLayer.ts +0 -292
- package/src/layers/grid3d/vertex.glsl.ts +0 -43
- package/src/layers/grid3d/vertex_lines.glsl.ts +0 -15
- package/src/layers/grid3d/webworker.ts +0 -173
- package/src/layers/hillshading2d/hillshading2d.fs.glsl.ts +0 -62
- package/src/layers/hillshading2d/hillshading2dLayer.ts +0 -172
- package/src/layers/index.ts +0 -35
- package/src/layers/intersection/intersectionView.stories.tsx +0 -294
- package/src/layers/intersection/unfoldedGeoJsonLayer.ts +0 -92
- package/src/layers/map/fragment.fs.glsl.ts +0 -127
- package/src/layers/map/fragment_lines.glsl.ts +0 -21
- package/src/layers/map/mapLayer.stories.tsx +0 -1369
- package/src/layers/map/mapLayer.ts +0 -470
- package/src/layers/map/privateMapLayer.ts +0 -317
- package/src/layers/map/vertex.glsl.ts +0 -45
- package/src/layers/map/vertex_lines.glsl.ts +0 -15
- package/src/layers/map/webworker.ts +0 -479
- package/src/layers/northarrow/northArrow.stories.tsx +0 -108
- package/src/layers/northarrow/northArrow3DLayer.ts +0 -204
- package/src/layers/northarrow/northarrow-fragment.glsl.js +0 -14
- package/src/layers/northarrow/northarrow-vertex.glsl.js +0 -13
- package/src/layers/piechart/fragment.glsl.js +0 -42
- package/src/layers/piechart/pieChartLayer.ts +0 -246
- package/src/layers/piechart/vertex.glsl.js +0 -42
- package/src/layers/points/pointsLayer.stories.tsx +0 -141
- package/src/layers/points/pointsLayer.ts +0 -143
- package/src/layers/polylines/polylinesLayer.stories.tsx +0 -144
- package/src/layers/polylines/polylinesLayer.ts +0 -263
- package/src/layers/selectable_geojson/selectableGeoJsonLayer.ts +0 -25
- package/src/layers/shader_modules/decoder.fs.glsl.ts +0 -41
- package/src/layers/shader_modules/decoder.ts +0 -46
- package/src/layers/shader_modules/index.ts +0 -1
- package/src/layers/terrain/map3DLayer.stories.tsx +0 -340
- package/src/layers/terrain/map3DLayer.ts +0 -556
- package/src/layers/terrain/terrainMapLayer.ts +0 -334
- package/src/layers/terrain/terrainmap.fs.glsl.ts +0 -134
- package/src/layers/triangle/fragment.fs.glsl.ts +0 -126
- package/src/layers/triangle/fragment_lines.glsl.ts +0 -21
- package/src/layers/triangle/privateTriangleLayer.ts +0 -203
- package/src/layers/triangle/test_data/surfacePoints.ts +0 -4344
- package/src/layers/triangle/test_data/surfaceTriangles.ts +0 -7392
- package/src/layers/triangle/triangleLayer.stories.tsx +0 -191
- package/src/layers/triangle/triangleLayer.ts +0 -273
- package/src/layers/triangle/vertex.glsl.ts +0 -35
- package/src/layers/triangle/vertex_lines.glsl.ts +0 -15
- package/src/layers/triangle/webworker.ts +0 -165
- package/src/layers/utils/glsl.d.ts +0 -4
- package/src/layers/utils/layerTools.ts +0 -182
- package/src/layers/utils/propertyMapTools.ts +0 -43
- package/src/layers/wells/utils/spline.ts +0 -318
- package/src/layers/wells/wellsLayer.stories.tsx +0 -625
- package/src/layers/wells/wellsLayer.ts +0 -1377
- package/src/redux/actions.ts +0 -8
- package/src/redux/reducer.ts +0 -43
- package/src/redux/store.ts +0 -15
- package/src/redux/types.ts +0 -114
- package/src/storybook/SubsurfaceViewer.stories.jsx +0 -644
- package/src/storybook/components/InfoCard.stories.jsx +0 -39
- package/src/storybook/components/colorLegends/ContinuousLegend.stories.jsx +0 -32
- package/src/storybook/components/colorLegends/DiscreteLegend.stories.jsx +0 -33
- package/src/storybook/components/colorLegends/IndividualScaleForMap.stories.jsx +0 -99
- package/src/storybook/components/colorLegends/SingleScaleForMap.stories.jsx +0 -120
- package/src/storybook/components/settings/LayerSettingsButton.stories.jsx +0 -34
- package/src/storybook/components/settings/NumericInput.stories.jsx +0 -17
- package/src/storybook/components/settings/ToggleButton.stories.jsx +0 -16
- package/src/storybook/schemaValidation/sampleData.js +0 -177
- package/src/storybook/schemaValidation/schemaValidation.stories.jsx +0 -91
- package/src/test/TestWrapper.tsx +0 -13
- package/src/utils/configuration.ts +0 -61
- package/src/utils/fit-bounds.js +0 -85
- package/src/utils/measurement.ts +0 -61
- package/src/utils/northArrow.ts +0 -4
- package/src/utils/specExtractor.ts +0 -36
- package/src/viewports/index.js +0 -1
- package/src/viewports/intersectionViewport.ts +0 -137
- package/src/views/index.js +0 -1
- package/src/views/intersectionView.ts +0 -38
- package/tsconfig.json +0 -7
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react-hooks/exhaustive-deps */ // remove when ready to fix these.
|
|
2
|
-
|
|
3
|
-
import React from "react";
|
|
4
|
-
import convert, { Unit } from "convert-units";
|
|
5
|
-
|
|
6
|
-
export interface ScaleProps {
|
|
7
|
-
// Needed the zoom value to calculate width in units
|
|
8
|
-
zoom?: number;
|
|
9
|
-
// Scale increment value
|
|
10
|
-
incrementValue?: number | null;
|
|
11
|
-
// Scale bar width in pixels per unit value
|
|
12
|
-
widthPerUnit?: number | null;
|
|
13
|
-
// additional css style to position the component
|
|
14
|
-
style?: Record<string, unknown>;
|
|
15
|
-
// default unit for the scale ruler
|
|
16
|
-
scaleUnit?: Unit;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const roundToStep = function (num: number, step: number) {
|
|
20
|
-
return Math.floor(num / step + 0.5) * step;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const DistanceScale: React.FC<ScaleProps> = ({
|
|
24
|
-
zoom,
|
|
25
|
-
incrementValue,
|
|
26
|
-
widthPerUnit,
|
|
27
|
-
style,
|
|
28
|
-
scaleUnit,
|
|
29
|
-
}: ScaleProps) => {
|
|
30
|
-
if (!zoom || !widthPerUnit || !incrementValue || !scaleUnit) return null;
|
|
31
|
-
|
|
32
|
-
if (!convert().possibilities().includes(scaleUnit)) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const widthInUnits = widthPerUnit / Math.pow(2, zoom);
|
|
37
|
-
|
|
38
|
-
const scaleValue =
|
|
39
|
-
widthInUnits < incrementValue
|
|
40
|
-
? Math.round(widthInUnits)
|
|
41
|
-
: roundToStep(widthInUnits, incrementValue);
|
|
42
|
-
|
|
43
|
-
const convertedUnit = convert(scaleValue)
|
|
44
|
-
.from(scaleUnit as convert.Unit)
|
|
45
|
-
.toBest().unit;
|
|
46
|
-
const convertedValue = convert(scaleValue)
|
|
47
|
-
.from(scaleUnit as convert.Unit)
|
|
48
|
-
.toBest().val;
|
|
49
|
-
|
|
50
|
-
const rulerWidth = scaleValue * Math.pow(2, zoom);
|
|
51
|
-
|
|
52
|
-
const scaleRulerStyle: React.CSSProperties = {
|
|
53
|
-
width: rulerWidth,
|
|
54
|
-
height: "4px",
|
|
55
|
-
border: "2px solid",
|
|
56
|
-
borderTop: "none",
|
|
57
|
-
display: "inline-block",
|
|
58
|
-
marginLeft: "3px",
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<div
|
|
63
|
-
style={{
|
|
64
|
-
position: "absolute",
|
|
65
|
-
...style,
|
|
66
|
-
}}
|
|
67
|
-
>
|
|
68
|
-
<label style={{ ...style }}>
|
|
69
|
-
{convertedValue.toFixed(0)}
|
|
70
|
-
{convertedUnit}
|
|
71
|
-
</label>
|
|
72
|
-
<div style={scaleRulerStyle}></div>
|
|
73
|
-
</div>
|
|
74
|
-
);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
DistanceScale.defaultProps = {
|
|
78
|
-
zoom: -3,
|
|
79
|
-
incrementValue: 100,
|
|
80
|
-
widthPerUnit: 100,
|
|
81
|
-
scaleUnit: "m",
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export default DistanceScale;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
render,
|
|
3
|
-
screen,
|
|
4
|
-
waitForElementToBeRemoved,
|
|
5
|
-
} from "@testing-library/react";
|
|
6
|
-
import "jest-styled-components";
|
|
7
|
-
import "@testing-library/jest-dom";
|
|
8
|
-
import React from "react";
|
|
9
|
-
import InfoCard from "./InfoCard";
|
|
10
|
-
import userEvent from "@testing-library/user-event";
|
|
11
|
-
import { Layer } from "@deck.gl/core/typed";
|
|
12
|
-
import { LayerPickInfo } from "../layers/utils/layerTools";
|
|
13
|
-
|
|
14
|
-
describe("Test Info Card", () => {
|
|
15
|
-
it("snapshot test with no props", () => {
|
|
16
|
-
const { container } = render(
|
|
17
|
-
<InfoCard
|
|
18
|
-
pickInfos={[
|
|
19
|
-
{
|
|
20
|
-
x: 152,
|
|
21
|
-
y: 254,
|
|
22
|
-
radius: 1,
|
|
23
|
-
depth: 638,
|
|
24
|
-
coordinate: [111, 222],
|
|
25
|
-
} as unknown as LayerPickInfo,
|
|
26
|
-
{
|
|
27
|
-
layer: { id: "wells-layer" } as Layer,
|
|
28
|
-
property: [
|
|
29
|
-
{
|
|
30
|
-
name: "Poro WellA",
|
|
31
|
-
value: 123,
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
} as unknown as LayerPickInfo,
|
|
35
|
-
]}
|
|
36
|
-
/>
|
|
37
|
-
);
|
|
38
|
-
expect(container.firstChild).toMatchSnapshot();
|
|
39
|
-
});
|
|
40
|
-
it("collapse infocard", async () => {
|
|
41
|
-
render(
|
|
42
|
-
<InfoCard
|
|
43
|
-
pickInfos={[
|
|
44
|
-
{
|
|
45
|
-
x: 152,
|
|
46
|
-
y: 254,
|
|
47
|
-
radius: 1,
|
|
48
|
-
depth: 638,
|
|
49
|
-
coordinate: [111, 222],
|
|
50
|
-
} as unknown as LayerPickInfo,
|
|
51
|
-
]}
|
|
52
|
-
/>
|
|
53
|
-
);
|
|
54
|
-
const collapse_button = screen.getByRole("button", { name: "" });
|
|
55
|
-
expect(screen.getByText("111.00 m")).toBeVisible();
|
|
56
|
-
userEvent.click(collapse_button);
|
|
57
|
-
await waitForElementToBeRemoved(() => screen.getByText("111.00 m"));
|
|
58
|
-
});
|
|
59
|
-
it("undefined coordinates", async () => {
|
|
60
|
-
const { container } = render(
|
|
61
|
-
<InfoCard
|
|
62
|
-
pickInfos={[
|
|
63
|
-
{
|
|
64
|
-
x: 152,
|
|
65
|
-
y: 254,
|
|
66
|
-
radius: 1,
|
|
67
|
-
depth: 638,
|
|
68
|
-
coordinate: undefined,
|
|
69
|
-
} as unknown as LayerPickInfo,
|
|
70
|
-
]}
|
|
71
|
-
/>
|
|
72
|
-
);
|
|
73
|
-
expect(container.firstChild).toMatchSnapshot();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("snapshot test when property value provided", async () => {
|
|
77
|
-
const { container } = render(
|
|
78
|
-
<InfoCard
|
|
79
|
-
pickInfos={[
|
|
80
|
-
{
|
|
81
|
-
x: 152,
|
|
82
|
-
y: 254,
|
|
83
|
-
radius: 1,
|
|
84
|
-
depth: 638,
|
|
85
|
-
coordinate: [111, 222],
|
|
86
|
-
} as unknown as LayerPickInfo,
|
|
87
|
-
{
|
|
88
|
-
layer: {
|
|
89
|
-
id: "wells-layer",
|
|
90
|
-
props: { name: "Wells layer" },
|
|
91
|
-
},
|
|
92
|
-
properties: [
|
|
93
|
-
{ name: "Poro", value: 123 },
|
|
94
|
-
{ name: "Perm", value: 456 },
|
|
95
|
-
],
|
|
96
|
-
logName: "LogCurve1",
|
|
97
|
-
} as unknown as LayerPickInfo,
|
|
98
|
-
{
|
|
99
|
-
layer: {
|
|
100
|
-
id: "hillshading-layer",
|
|
101
|
-
props: { name: "Hill shading" },
|
|
102
|
-
},
|
|
103
|
-
propertyValue: 3152.02,
|
|
104
|
-
} as unknown as LayerPickInfo,
|
|
105
|
-
]}
|
|
106
|
-
/>
|
|
107
|
-
);
|
|
108
|
-
expect(container.firstChild).toMatchSnapshot();
|
|
109
|
-
});
|
|
110
|
-
});
|
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
Collapse,
|
|
4
|
-
Table,
|
|
5
|
-
TableBody,
|
|
6
|
-
TableCell,
|
|
7
|
-
TableContainer,
|
|
8
|
-
TableRow,
|
|
9
|
-
} from "@mui/material";
|
|
10
|
-
import { Button, Icon } from "@equinor/eds-core-react";
|
|
11
|
-
import { arrow_drop_up, arrow_drop_down } from "@equinor/eds-icons";
|
|
12
|
-
import { styled } from "@mui/system";
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
ExtendedLayerProps,
|
|
16
|
-
LayerPickInfo,
|
|
17
|
-
PropertyDataType,
|
|
18
|
-
} from "../layers/utils/layerTools";
|
|
19
|
-
import { rgb } from "d3-color";
|
|
20
|
-
import { FeatureCollection } from "geojson";
|
|
21
|
-
|
|
22
|
-
Icon.add({ arrow_drop_up, arrow_drop_down });
|
|
23
|
-
|
|
24
|
-
interface InfoCardDataType {
|
|
25
|
-
layerName: string;
|
|
26
|
-
properties?: PropertyDataType[];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface InfoCardProps {
|
|
30
|
-
/**
|
|
31
|
-
* List of JSON object describing picking information of layers
|
|
32
|
-
* that are under the cursor.
|
|
33
|
-
*/
|
|
34
|
-
pickInfos: LayerPickInfo[];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const roundToSignificant = function (num: number) {
|
|
38
|
-
// Returns two significant figures (non-zero) for numbers with an absolute value less
|
|
39
|
-
// than 1, and two decimal places for numbers with an absolute value greater
|
|
40
|
-
// than 1.
|
|
41
|
-
return parseFloat(
|
|
42
|
-
num.toExponential(Math.max(1, 2 + Math.log10(Math.abs(num))))
|
|
43
|
-
);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const StyledTable = styled(Table)({
|
|
47
|
-
"& > *": {
|
|
48
|
-
backgroundColor: "#ffffffcc",
|
|
49
|
-
color: "#000000ff",
|
|
50
|
-
border: "2px solid #ccc",
|
|
51
|
-
padding: "0px",
|
|
52
|
-
borderRadius: "5px",
|
|
53
|
-
position: "absolute",
|
|
54
|
-
bottom: 0,
|
|
55
|
-
left: 0,
|
|
56
|
-
marginLeft: "3px",
|
|
57
|
-
marginBottom: "3px",
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const StyledTableCell = styled(TableCell)({
|
|
62
|
-
border: "none",
|
|
63
|
-
padding: 0,
|
|
64
|
-
width: "20px",
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const StyledTableRow = styled(TableRow)({
|
|
68
|
-
"& > *": {
|
|
69
|
-
padding: 0,
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
function Row(props: { layer_data: InfoCardDataType }) {
|
|
74
|
-
const { layer_data } = props;
|
|
75
|
-
const [open, setOpen] = React.useState(true);
|
|
76
|
-
|
|
77
|
-
if (layer_data.properties?.length == 0) return null;
|
|
78
|
-
return (
|
|
79
|
-
<React.Fragment>
|
|
80
|
-
<StyledTableRow>
|
|
81
|
-
<StyledTableCell>
|
|
82
|
-
<Button
|
|
83
|
-
style={{ padding: 0 }}
|
|
84
|
-
variant="ghost"
|
|
85
|
-
onClick={() => setOpen(!open)}
|
|
86
|
-
>
|
|
87
|
-
{open ? (
|
|
88
|
-
<Icon color="currentColor" name="arrow_drop_up" />
|
|
89
|
-
) : (
|
|
90
|
-
<Icon color="currentColor" name="arrow_drop_down" />
|
|
91
|
-
)}
|
|
92
|
-
</Button>
|
|
93
|
-
</StyledTableCell>
|
|
94
|
-
<TableCell> {layer_data.layerName} </TableCell>
|
|
95
|
-
</StyledTableRow>
|
|
96
|
-
<StyledTableRow>
|
|
97
|
-
<TableCell
|
|
98
|
-
style={{ paddingBottom: 0, paddingTop: 0 }}
|
|
99
|
-
colSpan={2}
|
|
100
|
-
>
|
|
101
|
-
<Collapse in={open} timeout="auto" unmountOnExit>
|
|
102
|
-
<Table size="small" aria-label="properties">
|
|
103
|
-
<TableBody>
|
|
104
|
-
{layer_data.properties?.map((propertyRow) => (
|
|
105
|
-
<StyledTableRow key={propertyRow.name}>
|
|
106
|
-
<TableCell
|
|
107
|
-
style={{
|
|
108
|
-
border: "none",
|
|
109
|
-
paddingLeft: 10,
|
|
110
|
-
paddingRight: 10,
|
|
111
|
-
}}
|
|
112
|
-
>
|
|
113
|
-
{propertyRow.color && (
|
|
114
|
-
<span
|
|
115
|
-
style={{
|
|
116
|
-
color: rgb(
|
|
117
|
-
...(propertyRow.color as [
|
|
118
|
-
number,
|
|
119
|
-
number,
|
|
120
|
-
number,
|
|
121
|
-
number?
|
|
122
|
-
])
|
|
123
|
-
).toString(),
|
|
124
|
-
}}
|
|
125
|
-
>
|
|
126
|
-
{"\u2B24"}
|
|
127
|
-
</span>
|
|
128
|
-
)}
|
|
129
|
-
{propertyRow.name}
|
|
130
|
-
</TableCell>
|
|
131
|
-
<TableCell
|
|
132
|
-
style={{
|
|
133
|
-
border: "none",
|
|
134
|
-
textAlign: "right",
|
|
135
|
-
}}
|
|
136
|
-
>
|
|
137
|
-
{typeof propertyRow.value ==
|
|
138
|
-
"number"
|
|
139
|
-
? roundToSignificant(
|
|
140
|
-
propertyRow.value
|
|
141
|
-
)
|
|
142
|
-
: propertyRow.value}
|
|
143
|
-
</TableCell>
|
|
144
|
-
</StyledTableRow>
|
|
145
|
-
))}
|
|
146
|
-
</TableBody>
|
|
147
|
-
</Table>
|
|
148
|
-
</Collapse>
|
|
149
|
-
</TableCell>
|
|
150
|
-
</StyledTableRow>
|
|
151
|
-
</React.Fragment>
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const InfoCard: React.FC<InfoCardProps> = (props: InfoCardProps) => {
|
|
156
|
-
const [infoCardData, setInfoCardData] = React.useState<
|
|
157
|
-
InfoCardDataType[] | null
|
|
158
|
-
>(null);
|
|
159
|
-
|
|
160
|
-
React.useEffect(() => {
|
|
161
|
-
if (props.pickInfos.length === 0) {
|
|
162
|
-
setInfoCardData(null);
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
const topObject = props.pickInfos[0];
|
|
166
|
-
if (
|
|
167
|
-
topObject.coordinate === undefined ||
|
|
168
|
-
topObject.coordinate.length < 2
|
|
169
|
-
) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const xy_properties: PropertyDataType[] = [];
|
|
174
|
-
xy_properties.push({
|
|
175
|
-
name: "x",
|
|
176
|
-
value: Number(topObject.coordinate[0]).toFixed(2).toString() + " m",
|
|
177
|
-
});
|
|
178
|
-
xy_properties.push({
|
|
179
|
-
name: "y",
|
|
180
|
-
value: Number(topObject.coordinate[1]).toFixed(2).toString() + " m",
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
const info_card_data: InfoCardDataType[] = [];
|
|
184
|
-
info_card_data.push({
|
|
185
|
-
layerName: "Position",
|
|
186
|
-
properties: xy_properties,
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
props.pickInfos.forEach((info) => {
|
|
190
|
-
const layer_properties = info.properties;
|
|
191
|
-
const layer_name = (
|
|
192
|
-
info.layer
|
|
193
|
-
?.props as unknown as ExtendedLayerProps<FeatureCollection>
|
|
194
|
-
)?.name;
|
|
195
|
-
|
|
196
|
-
// pick info can have 2 types of properties that can be displayed on the info card
|
|
197
|
-
// 1. defined as propertyValue, used for general layer info (now using for positional data)
|
|
198
|
-
// 2. Another defined as array of property object described by type PropertyDataType
|
|
199
|
-
|
|
200
|
-
// collecting card data for 1st type
|
|
201
|
-
const zValue = (info as LayerPickInfo).propertyValue;
|
|
202
|
-
if (typeof zValue !== "undefined") {
|
|
203
|
-
const property = xy_properties.find(
|
|
204
|
-
(item) => item.name === layer_name
|
|
205
|
-
);
|
|
206
|
-
if (property) {
|
|
207
|
-
property.value = zValue;
|
|
208
|
-
} else {
|
|
209
|
-
xy_properties.push({
|
|
210
|
-
name: layer_name,
|
|
211
|
-
value: zValue,
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// collecting card data for 2nd type
|
|
217
|
-
const layer = info_card_data.find(
|
|
218
|
-
(item) => item.layerName === layer_name
|
|
219
|
-
);
|
|
220
|
-
if (layer) {
|
|
221
|
-
layer_properties?.forEach((layer_prop) => {
|
|
222
|
-
const property = layer.properties?.find(
|
|
223
|
-
(item) => item.name === layer_prop.name
|
|
224
|
-
);
|
|
225
|
-
if (property) {
|
|
226
|
-
property.value = layer_prop.value;
|
|
227
|
-
} else {
|
|
228
|
-
layer.properties?.push(layer_prop);
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
} else {
|
|
232
|
-
info_card_data.push({
|
|
233
|
-
layerName: layer_name || "unknown-layer",
|
|
234
|
-
properties: layer_properties,
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
setInfoCardData(info_card_data);
|
|
240
|
-
}, [props.pickInfos]);
|
|
241
|
-
|
|
242
|
-
return (
|
|
243
|
-
infoCardData && (
|
|
244
|
-
<TableContainer>
|
|
245
|
-
<StyledTable aria-label="info-card">
|
|
246
|
-
<TableBody>
|
|
247
|
-
{infoCardData.map(
|
|
248
|
-
(card_data) =>
|
|
249
|
-
card_data.properties && (
|
|
250
|
-
<Row
|
|
251
|
-
key={card_data.layerName}
|
|
252
|
-
layer_data={card_data}
|
|
253
|
-
/>
|
|
254
|
-
)
|
|
255
|
-
)}
|
|
256
|
-
</TableBody>
|
|
257
|
-
</StyledTable>
|
|
258
|
-
</TableContainer>
|
|
259
|
-
)
|
|
260
|
-
);
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
export default InfoCard;
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
|
-
import "@testing-library/jest-dom/extend-expect";
|
|
3
|
-
import { render } from "@testing-library/react";
|
|
4
|
-
import "jest-styled-components";
|
|
5
|
-
import "@testing-library/jest-dom";
|
|
6
|
-
import React from "react";
|
|
7
|
-
import { LayersList } from "@deck.gl/core/typed";
|
|
8
|
-
import Map from "./Map";
|
|
9
|
-
import { EmptyWrapper } from "../../SubsurfaceViewer/test/TestWrapper";
|
|
10
|
-
import { colorTables } from "@emerson-eps/color-tables";
|
|
11
|
-
import {
|
|
12
|
-
ColormapLayer,
|
|
13
|
-
DrawingLayer,
|
|
14
|
-
FaultPolygonsLayer,
|
|
15
|
-
Hillshading2DLayer,
|
|
16
|
-
Map3DLayer,
|
|
17
|
-
NorthArrow3DLayer,
|
|
18
|
-
PieChartLayer,
|
|
19
|
-
WellsLayer,
|
|
20
|
-
} from "../layers";
|
|
21
|
-
|
|
22
|
-
import mapData from "../../../../demo/example-data/deckgl-map.json";
|
|
23
|
-
import { Unit } from "convert-units";
|
|
24
|
-
const colorTablesData = colorTables;
|
|
25
|
-
const testBounds = [432205, 6475078, 437720, 6481113] as [
|
|
26
|
-
number,
|
|
27
|
-
number,
|
|
28
|
-
number,
|
|
29
|
-
number
|
|
30
|
-
];
|
|
31
|
-
const valueRange = [2782, 3513] as [number, number];
|
|
32
|
-
|
|
33
|
-
const testLayers = [
|
|
34
|
-
new ColormapLayer({
|
|
35
|
-
image: "propertyMap.png",
|
|
36
|
-
rotDeg: 0,
|
|
37
|
-
bounds: testBounds,
|
|
38
|
-
colorMapName: "Rainbow",
|
|
39
|
-
valueRange: valueRange,
|
|
40
|
-
colorMapRange: valueRange,
|
|
41
|
-
}),
|
|
42
|
-
new Hillshading2DLayer({
|
|
43
|
-
bounds: testBounds,
|
|
44
|
-
valueRange: valueRange,
|
|
45
|
-
rotDeg: 0,
|
|
46
|
-
image: "propertyMap.png",
|
|
47
|
-
}),
|
|
48
|
-
new Map3DLayer({
|
|
49
|
-
bounds: testBounds,
|
|
50
|
-
meshMaxError: 5.0,
|
|
51
|
-
mesh: "hugin_depth_25_m_normalized_margin.png",
|
|
52
|
-
meshValueRange: valueRange,
|
|
53
|
-
propertyTexture: "kh_netmap_25_m_normalized_margin.png",
|
|
54
|
-
propertyValueRange: valueRange,
|
|
55
|
-
rotDeg: 0,
|
|
56
|
-
contours: [0, 50.0],
|
|
57
|
-
isContoursDepth: true,
|
|
58
|
-
colorMapName: "Physics",
|
|
59
|
-
colorMapRange: valueRange,
|
|
60
|
-
visible: false,
|
|
61
|
-
}),
|
|
62
|
-
new WellsLayer({
|
|
63
|
-
data: "volve_wells.json",
|
|
64
|
-
logData: "volve_logs.json",
|
|
65
|
-
logrunName: "BLOCKING",
|
|
66
|
-
logName: "ZONELOG",
|
|
67
|
-
logColor: "Stratigraphy",
|
|
68
|
-
}),
|
|
69
|
-
new FaultPolygonsLayer({
|
|
70
|
-
data: "fault_polygons.geojson",
|
|
71
|
-
}),
|
|
72
|
-
new PieChartLayer({
|
|
73
|
-
data: "piechart.json",
|
|
74
|
-
}),
|
|
75
|
-
new NorthArrow3DLayer({
|
|
76
|
-
visible: true,
|
|
77
|
-
}),
|
|
78
|
-
new DrawingLayer(),
|
|
79
|
-
] as LayersList;
|
|
80
|
-
|
|
81
|
-
describe("Test Map component", () => {
|
|
82
|
-
it("snapshot test", () => {
|
|
83
|
-
const { container } = render(
|
|
84
|
-
EmptyWrapper({
|
|
85
|
-
children: (
|
|
86
|
-
<Map
|
|
87
|
-
id={mapData[0].id}
|
|
88
|
-
resources={mapData[0].resources}
|
|
89
|
-
layers={testLayers}
|
|
90
|
-
bounds={testBounds}
|
|
91
|
-
coords={mapData[0].coords}
|
|
92
|
-
scale={mapData[0].scale}
|
|
93
|
-
coordinateUnit={mapData[0].coordinateUnit as Unit}
|
|
94
|
-
editedData={mapData[0].editedData}
|
|
95
|
-
views={{
|
|
96
|
-
layout: [1, 1],
|
|
97
|
-
viewports: [
|
|
98
|
-
{
|
|
99
|
-
id: "view_1",
|
|
100
|
-
show3D: false,
|
|
101
|
-
layerIds: [],
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
|
-
}}
|
|
105
|
-
colorTables={[colorTablesData[0]]}
|
|
106
|
-
/>
|
|
107
|
-
),
|
|
108
|
-
})
|
|
109
|
-
);
|
|
110
|
-
expect(container.firstChild).toMatchSnapshot();
|
|
111
|
-
});
|
|
112
|
-
it("snapshot test with edited data", () => {
|
|
113
|
-
const { container } = render(
|
|
114
|
-
EmptyWrapper({
|
|
115
|
-
children: (
|
|
116
|
-
<Map
|
|
117
|
-
id={mapData[0].id}
|
|
118
|
-
resources={mapData[0].resources}
|
|
119
|
-
layers={testLayers}
|
|
120
|
-
bounds={testBounds}
|
|
121
|
-
coords={mapData[0].coords}
|
|
122
|
-
scale={mapData[0].scale}
|
|
123
|
-
coordinateUnit={mapData[0].coordinateUnit as Unit}
|
|
124
|
-
editedData={{}}
|
|
125
|
-
views={{
|
|
126
|
-
layout: [1, 1],
|
|
127
|
-
viewports: [
|
|
128
|
-
{
|
|
129
|
-
id: "view_1",
|
|
130
|
-
show3D: false,
|
|
131
|
-
layerIds: [],
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
}}
|
|
135
|
-
colorTables={[colorTablesData[0]]}
|
|
136
|
-
/>
|
|
137
|
-
),
|
|
138
|
-
})
|
|
139
|
-
);
|
|
140
|
-
expect(container.firstChild).toMatchSnapshot();
|
|
141
|
-
});
|
|
142
|
-
});
|