@webviz/subsurface-viewer 0.0.1-alpha.1 → 0.0.2-alpha.1
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/package.json +5 -2
- package/package.json +6 -3
- 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
|
Binary file
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export default `\
|
|
2
|
-
#version 300 es
|
|
3
|
-
#define SHADER_NAME graph-layer-fragment-shader
|
|
4
|
-
|
|
5
|
-
precision highp float;
|
|
6
|
-
|
|
7
|
-
out vec4 fragColor;
|
|
8
|
-
|
|
9
|
-
uniform sampler2D fontTexture;
|
|
10
|
-
|
|
11
|
-
uniform vec4 uAxisColor;
|
|
12
|
-
uniform vec4 uBackGroundColor;
|
|
13
|
-
|
|
14
|
-
in vec2 _vTexCoord;
|
|
15
|
-
|
|
16
|
-
void main(void) {
|
|
17
|
-
vec4 color = texture(fontTexture, _vTexCoord);
|
|
18
|
-
|
|
19
|
-
float x = 1.0 - (color.r + color.g + color.b) / 3.0; // intensity of text color
|
|
20
|
-
x = smoothstep(0.0, 0.2, x);
|
|
21
|
-
|
|
22
|
-
float text_r = uAxisColor.r;
|
|
23
|
-
float text_g = uAxisColor.g;
|
|
24
|
-
float text_b = uAxisColor.b;
|
|
25
|
-
|
|
26
|
-
float bg_r = uBackGroundColor.r;
|
|
27
|
-
float bg_g = uBackGroundColor.g;
|
|
28
|
-
float bg_b = uBackGroundColor.b;
|
|
29
|
-
|
|
30
|
-
float r = x * text_r + (1.0 - x) * bg_r;
|
|
31
|
-
float g = x * text_g + (1.0 - x) * bg_g;
|
|
32
|
-
float b = x * text_b + (1.0 - x) * bg_b;
|
|
33
|
-
|
|
34
|
-
fragColor = vec4(r, g, b, 1.0);
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
`;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export default `\
|
|
2
|
-
#version 300 es
|
|
3
|
-
#define SHADER_NAME graph-layer-axis-vertex-shader
|
|
4
|
-
|
|
5
|
-
precision highp float;
|
|
6
|
-
|
|
7
|
-
in vec3 positions;
|
|
8
|
-
|
|
9
|
-
in vec2 vTexCoord;
|
|
10
|
-
out vec2 _vTexCoord;
|
|
11
|
-
|
|
12
|
-
uniform mat4 projectionMatrix;
|
|
13
|
-
|
|
14
|
-
void main(void) {
|
|
15
|
-
_vTexCoord = vTexCoord;
|
|
16
|
-
|
|
17
|
-
vec3 position_commonspace = positions; // These positions are in view space.
|
|
18
|
-
gl_Position = projectionMatrix * vec4(position_commonspace, 1.0); // From viewspace to clip
|
|
19
|
-
}
|
|
20
|
-
`;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export default `\
|
|
2
|
-
#version 300 es
|
|
3
|
-
#define SHADER_NAME axes2d-layer-vertex-shader
|
|
4
|
-
|
|
5
|
-
precision highp float;
|
|
6
|
-
|
|
7
|
-
in vec3 positions;
|
|
8
|
-
|
|
9
|
-
void main(void) {
|
|
10
|
-
vec3 position_commonspace = project_position(positions);
|
|
11
|
-
gl_Position = project_common_position_to_clipspace(vec4(position_commonspace, 0.0));
|
|
12
|
-
}
|
|
13
|
-
`;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const fsColormap = `#define SHADER_NAME colormap-shader
|
|
2
|
-
|
|
3
|
-
#ifdef GL_ES
|
|
4
|
-
precision highp float;
|
|
5
|
-
#endif
|
|
6
|
-
|
|
7
|
-
varying vec2 vTexCoord;
|
|
8
|
-
|
|
9
|
-
uniform sampler2D bitmapTexture; // Property map
|
|
10
|
-
uniform sampler2D colormap;
|
|
11
|
-
|
|
12
|
-
uniform float opacity;
|
|
13
|
-
|
|
14
|
-
void main(void) {
|
|
15
|
-
vec4 bitmapColor = texture2D(bitmapTexture, vTexCoord);
|
|
16
|
-
|
|
17
|
-
// If it's a picking pass, we just return the raw property map value.
|
|
18
|
-
if (picking_uActive) {
|
|
19
|
-
gl_FragColor = bitmapColor;
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Decode the RGB value into a float. See decoder.fs.glsl for more details.
|
|
24
|
-
float val = decode_rgb2float(bitmapColor.rgb);
|
|
25
|
-
// The resulting val will be in [0, 1] interval, so we can use it directly as a texture coord
|
|
26
|
-
// to sample from the colormap.
|
|
27
|
-
// 0 => Leftmost color in the colormap, 1 => rightmost color, linearly interpolated in between.
|
|
28
|
-
vec4 color = texture2D(colormap, vec2(val, 0.5));
|
|
29
|
-
|
|
30
|
-
// The final pixel opacity is the combination of the user provided image-wide opacity,
|
|
31
|
-
// the colormap opacity at the sampled pixel and the property map opacity of the sampled pixel.
|
|
32
|
-
gl_FragColor = vec4(color.rgb, color.a * bitmapColor.a * opacity);
|
|
33
|
-
|
|
34
|
-
// Support for existing functionality that comes from the BitmapLayer, such as desaturate, tintColor etc.
|
|
35
|
-
// See https://deck.gl/docs/api-reference/layers/bitmap-layer#render-options for more details.
|
|
36
|
-
geometry.uv = vTexCoord;
|
|
37
|
-
DECKGL_FILTER_COLOR(gl_FragColor, geometry);
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
`;
|
|
41
|
-
|
|
42
|
-
export default fsColormap;
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { BitmapLayer, BitmapLayerProps } from "@deck.gl/layers/typed";
|
|
2
|
-
import { PickingInfo } from "@deck.gl/core/typed";
|
|
3
|
-
import GL from "@luma.gl/constants";
|
|
4
|
-
import { Texture2D } from "@luma.gl/webgl";
|
|
5
|
-
|
|
6
|
-
import { LayerPickInfo } from "../../layers/utils/layerTools";
|
|
7
|
-
import { decoder } from "../shader_modules";
|
|
8
|
-
import { decodeRGB, ValueDecoder } from "../utils/propertyMapTools";
|
|
9
|
-
import { getModelMatrix, colorMapFunctionType } from "../utils/layerTools";
|
|
10
|
-
import fsColormap from "./colormap.fs.glsl";
|
|
11
|
-
import { DeckGLLayerContext } from "../../components/Map";
|
|
12
|
-
import { colorTablesArray } from "@emerson-eps/color-tables/";
|
|
13
|
-
import { getRgbData } from "@emerson-eps/color-tables";
|
|
14
|
-
import { ContinuousLegendDataType } from "../../components/ColorLegend";
|
|
15
|
-
|
|
16
|
-
const DEFAULT_TEXTURE_PARAMETERS = {
|
|
17
|
-
[GL.TEXTURE_MIN_FILTER]: GL.LINEAR_MIPMAP_LINEAR,
|
|
18
|
-
[GL.TEXTURE_MAG_FILTER]: GL.LINEAR,
|
|
19
|
-
[GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
|
|
20
|
-
[GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
function getImageData(
|
|
24
|
-
colorMapName: string,
|
|
25
|
-
colorTables: colorTablesArray,
|
|
26
|
-
colorMapFunction?: colorMapFunctionType
|
|
27
|
-
) {
|
|
28
|
-
const isColorMapFunctionDefined = typeof colorMapFunction !== "undefined";
|
|
29
|
-
|
|
30
|
-
const data = new Uint8Array(256 * 3);
|
|
31
|
-
|
|
32
|
-
for (let i = 0; i < 256; i++) {
|
|
33
|
-
const value = i / 255.0;
|
|
34
|
-
const rgb = isColorMapFunctionDefined
|
|
35
|
-
? (colorMapFunction as colorMapFunctionType)(i / 255)
|
|
36
|
-
: getRgbData(value, colorMapName, colorTables);
|
|
37
|
-
let color: number[] = [];
|
|
38
|
-
if (rgb != undefined) {
|
|
39
|
-
if (Array.isArray(rgb)) {
|
|
40
|
-
color = rgb;
|
|
41
|
-
} else {
|
|
42
|
-
color = [rgb.r, rgb.g, rgb.b];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
data[3 * i + 0] = color[0];
|
|
47
|
-
data[3 * i + 1] = color[1];
|
|
48
|
-
data[3 * i + 2] = color[2];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return data;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Most props are inherited from DeckGL's BitmapLayer. For a full list, see
|
|
55
|
-
// https://deck.gl/docs/api-reference/layers/bitmap-layer
|
|
56
|
-
//
|
|
57
|
-
// The property map is encoded in an image and sent in the `image` prop of the BitmapLayer.
|
|
58
|
-
// The same approach is used in DeckGL's TerrainLayer: https://deck.gl/docs/api-reference/geo-layers/terrain-layer
|
|
59
|
-
//
|
|
60
|
-
// The image format is based on Tizen's terrain format and Mapbox's TerrainRGB:
|
|
61
|
-
// https://github.com/tilezen/joerd/blob/master/docs/formats.md
|
|
62
|
-
// https://docs.mapbox.com/help/troubleshooting/access-elevation-data/
|
|
63
|
-
//
|
|
64
|
-
// The main idea is that property values (floats) are encoded in the R G and B channels of an image.
|
|
65
|
-
// We parametrize decoding, so we can support both Tizen and Mapbox terrains by adapting
|
|
66
|
-
// the valueDecoder for each format.
|
|
67
|
-
// We also support and use by default a format that optimizes for precision.
|
|
68
|
-
// By default, the value decoder will map RGB(0, 0, 0) to the minimum value in valueRange
|
|
69
|
-
// and RGB(255, 255, 255) to the maximum value in valueRange, thus giving us the full
|
|
70
|
-
// > 16mil possible values for any property value range.
|
|
71
|
-
// We also support property maps with an alpha channel. See colormap.fs.glsl for more details.
|
|
72
|
-
export interface ColormapLayerProps extends BitmapLayerProps {
|
|
73
|
-
// Name of color map.
|
|
74
|
-
colorMapName: string;
|
|
75
|
-
|
|
76
|
-
// Optional function property.
|
|
77
|
-
// If defined this function will override the color map.
|
|
78
|
-
// Takes a value in the range [0,1] and returns a color.
|
|
79
|
-
colorMapFunction?: colorMapFunctionType;
|
|
80
|
-
|
|
81
|
-
// Min and max property values.
|
|
82
|
-
valueRange: [number, number];
|
|
83
|
-
|
|
84
|
-
// Use color map in this range.
|
|
85
|
-
colorMapRange: [number, number];
|
|
86
|
-
|
|
87
|
-
// See ValueDecoder in propertyMapTools.ts
|
|
88
|
-
valueDecoder: ValueDecoder;
|
|
89
|
-
|
|
90
|
-
// Rotates image around bounds upper left corner counterclockwise in degrees.
|
|
91
|
-
rotDeg: number;
|
|
92
|
-
|
|
93
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
-
setReportedBoundingBox?: any;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const defaultProps = {
|
|
98
|
-
"@@type": "ColormapLayer",
|
|
99
|
-
name: "Property map",
|
|
100
|
-
id: "colormap-layer",
|
|
101
|
-
pickable: true,
|
|
102
|
-
visible: true,
|
|
103
|
-
valueRange: { type: "array", value: [0, 1] },
|
|
104
|
-
colorMapRange: { type: "array" },
|
|
105
|
-
valueDecoder: {
|
|
106
|
-
rgbScaler: [1, 1, 1],
|
|
107
|
-
// By default, scale the [0, 256*256*256-1] decoded values to [0, 1]
|
|
108
|
-
floatScaler: 1.0 / (256.0 * 256.0 * 256.0 - 1.0),
|
|
109
|
-
offset: 0,
|
|
110
|
-
step: 0,
|
|
111
|
-
},
|
|
112
|
-
rotDeg: 0,
|
|
113
|
-
colorMapName: "Rainbow",
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export default class ColormapLayer extends BitmapLayer<ColormapLayerProps> {
|
|
117
|
-
initializeState(): void {
|
|
118
|
-
this.setState({
|
|
119
|
-
isLoaded: false,
|
|
120
|
-
});
|
|
121
|
-
super.initializeState();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Signature from the base class, eslint doesn't like the any type.
|
|
125
|
-
// eslint-disable-next-line
|
|
126
|
-
draw({ moduleParameters, uniforms, context }: any): void {
|
|
127
|
-
if (!this.state["isLoaded"]) {
|
|
128
|
-
this.setState({
|
|
129
|
-
isLoaded: true,
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
if (typeof this.props.setReportedBoundingBox !== "undefined") {
|
|
133
|
-
const xMin = this.props.bounds[0];
|
|
134
|
-
const yMin = this.props.bounds[1];
|
|
135
|
-
const zMin = 1;
|
|
136
|
-
const xMax = this.props.bounds[2];
|
|
137
|
-
const yMax = this.props.bounds[3];
|
|
138
|
-
const zMax = -1;
|
|
139
|
-
const bbox = [xMin, yMin, zMin, xMax, yMax, zMax];
|
|
140
|
-
|
|
141
|
-
this.props.setReportedBoundingBox(bbox);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const mergedModuleParams = {
|
|
146
|
-
...moduleParameters,
|
|
147
|
-
valueDecoder: {
|
|
148
|
-
// The prop objects are not merged with the defaultProps by default.
|
|
149
|
-
// See https://github.com/facebook/react/issues/2568
|
|
150
|
-
...defaultProps.valueDecoder,
|
|
151
|
-
...moduleParameters.valueDecoder,
|
|
152
|
-
},
|
|
153
|
-
modelMatrix: getModelMatrix(
|
|
154
|
-
this.props.rotDeg,
|
|
155
|
-
this.props.bounds[0] as number, // Rotate around upper left corner of bounds
|
|
156
|
-
this.props.bounds[3] as number
|
|
157
|
-
),
|
|
158
|
-
};
|
|
159
|
-
super.setModuleParameters(mergedModuleParams);
|
|
160
|
-
|
|
161
|
-
const valueRangeMin = this.props.valueRange[0] ?? 0.0;
|
|
162
|
-
const valueRangeMax = this.props.valueRange[1] ?? 1.0;
|
|
163
|
-
|
|
164
|
-
// If specified color map will extend from colorMapRangeMin to colorMapRangeMax.
|
|
165
|
-
// Otherwise it will extend from valueRangeMin to valueRangeMax.
|
|
166
|
-
const colorMapRangeMin = this.props.colorMapRange?.[0] ?? valueRangeMin;
|
|
167
|
-
const colorMapRangeMax = this.props.colorMapRange?.[1] ?? valueRangeMax;
|
|
168
|
-
|
|
169
|
-
super.draw({
|
|
170
|
-
uniforms: {
|
|
171
|
-
...uniforms,
|
|
172
|
-
// Send the colormap texture to the shader.
|
|
173
|
-
colormap: new Texture2D(context.gl, {
|
|
174
|
-
width: 256,
|
|
175
|
-
height: 1,
|
|
176
|
-
format: GL.RGB,
|
|
177
|
-
data: getImageData(
|
|
178
|
-
this.props.colorMapName,
|
|
179
|
-
(this.context as DeckGLLayerContext).userData
|
|
180
|
-
.colorTables,
|
|
181
|
-
this.props.colorMapFunction
|
|
182
|
-
),
|
|
183
|
-
parameters: DEFAULT_TEXTURE_PARAMETERS,
|
|
184
|
-
}),
|
|
185
|
-
valueRangeMin,
|
|
186
|
-
valueRangeMax,
|
|
187
|
-
colorMapRangeMin,
|
|
188
|
-
colorMapRangeMax,
|
|
189
|
-
},
|
|
190
|
-
moduleParameters: mergedModuleParams,
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// Signature from the base class, eslint doesn't like the any type.
|
|
195
|
-
// eslint-disable-next-line
|
|
196
|
-
getShaders(): any {
|
|
197
|
-
const parentShaders = super.getShaders();
|
|
198
|
-
// Overwrite the BitmapLayer's default fragment shader with ours, that does colormapping.
|
|
199
|
-
parentShaders.fs = fsColormap;
|
|
200
|
-
// Add the decoder shader module to our colormap shader, so we can use the decoder function from our shader.
|
|
201
|
-
parentShaders.modules.push(decoder);
|
|
202
|
-
return parentShaders;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
getPickingInfo({ info }: { info: PickingInfo }): LayerPickInfo {
|
|
206
|
-
if (this.state["pickingDisabled"] || !info.color) {
|
|
207
|
-
return info;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const mergedDecoder = {
|
|
211
|
-
...defaultProps.valueDecoder,
|
|
212
|
-
...this.props.valueDecoder,
|
|
213
|
-
};
|
|
214
|
-
// The picked color is the one in raw image, not the one after colormapping.
|
|
215
|
-
// We just need to decode that RGB color into a property float value.
|
|
216
|
-
const val = decodeRGB(info.color, mergedDecoder, this.props.valueRange);
|
|
217
|
-
|
|
218
|
-
return {
|
|
219
|
-
...info,
|
|
220
|
-
// Picking color doesn't represent object index in this layer.
|
|
221
|
-
// For more details, see https://deck.gl/docs/developer-guide/custom-layers/picking
|
|
222
|
-
index: 0,
|
|
223
|
-
propertyValue: val,
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
getLegendData(): ContinuousLegendDataType {
|
|
228
|
-
const valueRangeMin = this.props.valueRange[0] ?? 0.0;
|
|
229
|
-
const valueRangeMax = this.props.valueRange[1] ?? 1.0;
|
|
230
|
-
|
|
231
|
-
// If specified color map will extend from colorMapRangeMin to colorMapRangeMax.
|
|
232
|
-
// Otherwise it will extend from valueRangeMin to valueRangeMax.
|
|
233
|
-
const min = this.props.colorMapRange?.[0] ?? valueRangeMin;
|
|
234
|
-
const max = this.props.colorMapRange?.[1] ?? valueRangeMax;
|
|
235
|
-
|
|
236
|
-
return {
|
|
237
|
-
discrete: false,
|
|
238
|
-
valueRange: [min, max],
|
|
239
|
-
colorName: this.props.colorMapName,
|
|
240
|
-
title: "PropertyMapLayer",
|
|
241
|
-
colorMapFunction: this.props.colorMapFunction,
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
ColormapLayer.layerName = "ColormapLayer";
|
|
247
|
-
ColormapLayer.defaultProps = defaultProps;
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
COORDINATE_SYSTEM,
|
|
3
|
-
Color,
|
|
4
|
-
CompositeLayer,
|
|
5
|
-
PickingInfo,
|
|
6
|
-
LayerContext,
|
|
7
|
-
LayersList,
|
|
8
|
-
} from "@deck.gl/core/typed";
|
|
9
|
-
import { ExtendedLayerProps, LayerPickInfo } from "../utils/layerTools";
|
|
10
|
-
import {
|
|
11
|
-
DrawLineStringMode,
|
|
12
|
-
DrawPointMode,
|
|
13
|
-
DrawPolygonMode,
|
|
14
|
-
EditAction,
|
|
15
|
-
Feature,
|
|
16
|
-
FeatureCollection,
|
|
17
|
-
GeoJsonEditMode,
|
|
18
|
-
ImmutableFeatureCollection,
|
|
19
|
-
ModeProps,
|
|
20
|
-
ModifyMode,
|
|
21
|
-
TransformMode,
|
|
22
|
-
ViewMode,
|
|
23
|
-
} from "@nebula.gl/edit-modes";
|
|
24
|
-
import { EditableGeoJsonLayer } from "@nebula.gl/layers";
|
|
25
|
-
import { DeckGLLayerContext } from "../../components/Map";
|
|
26
|
-
import { area, length } from "../../utils/measurement";
|
|
27
|
-
|
|
28
|
-
// Custom drawing mode that deletes the selected GeoJson feature when releasing the Delete key.
|
|
29
|
-
class CustomModifyMode extends ModifyMode {
|
|
30
|
-
handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>) {
|
|
31
|
-
super.handleKeyUp(event, props);
|
|
32
|
-
|
|
33
|
-
if (event.key === "Delete") {
|
|
34
|
-
const updatedData = new ImmutableFeatureCollection(props.data)
|
|
35
|
-
.deleteFeatures(props.selectedIndexes)
|
|
36
|
-
.getObject();
|
|
37
|
-
|
|
38
|
-
if (updatedData) {
|
|
39
|
-
props.onEdit({
|
|
40
|
-
updatedData,
|
|
41
|
-
editType: "removeFeature",
|
|
42
|
-
editContext: {
|
|
43
|
-
featureIndexes: props.selectedIndexes,
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function deleteEscapeKeyHandler(
|
|
52
|
-
drawMode: GeoJsonEditMode,
|
|
53
|
-
event: KeyboardEvent,
|
|
54
|
-
props: ModeProps<FeatureCollection>
|
|
55
|
-
) {
|
|
56
|
-
if (event.key === "Escape") drawMode.getClickSequence().pop();
|
|
57
|
-
else if (event.key === "Delete") drawMode.resetClickSequence();
|
|
58
|
-
else return;
|
|
59
|
-
|
|
60
|
-
// used to set state so layer can be rerendered
|
|
61
|
-
const updatedData = new ImmutableFeatureCollection(props.data).getObject();
|
|
62
|
-
if (updatedData) {
|
|
63
|
-
props.onEdit({
|
|
64
|
-
updatedData,
|
|
65
|
-
editType: "undoDrawing",
|
|
66
|
-
editContext: {
|
|
67
|
-
featureIndexes: props.selectedIndexes,
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
class CustomDrawLineStringMode extends DrawLineStringMode {
|
|
74
|
-
handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>) {
|
|
75
|
-
super.handleKeyUp(event, props);
|
|
76
|
-
deleteEscapeKeyHandler(this, event, props);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
class CustomDrawPolygonMode extends DrawPolygonMode {
|
|
81
|
-
handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>) {
|
|
82
|
-
super.handleKeyUp(event, props);
|
|
83
|
-
deleteEscapeKeyHandler(this, event, props);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Mapping of mode name to mode class
|
|
88
|
-
const MODE_MAP = {
|
|
89
|
-
view: ViewMode,
|
|
90
|
-
modify: CustomModifyMode,
|
|
91
|
-
transform: TransformMode,
|
|
92
|
-
drawPoint: DrawPointMode,
|
|
93
|
-
drawLineString: CustomDrawLineStringMode,
|
|
94
|
-
drawPolygon: CustomDrawPolygonMode,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const UNSELECTED_LINE_COLOR: Color = [0x50, 0x50, 0x50, 0xcc];
|
|
98
|
-
const SELECTED_LINE_COLOR: Color = [0x0, 0x0, 0x0, 0xff];
|
|
99
|
-
|
|
100
|
-
export interface DrawingLayerProps<D> extends ExtendedLayerProps<D> {
|
|
101
|
-
mode: string; // One of modes in MODE_MAP
|
|
102
|
-
selectedFeatureIndexes: number[];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const defaultProps = {
|
|
106
|
-
"@@type": "DrawingLayer",
|
|
107
|
-
name: "Drawing",
|
|
108
|
-
id: "drawing-layer",
|
|
109
|
-
pickable: true,
|
|
110
|
-
visible: true,
|
|
111
|
-
mode: "drawLineString",
|
|
112
|
-
|
|
113
|
-
// Props used to get/set data in the drawing layer.
|
|
114
|
-
selectedFeatureIndexes: [] as number[],
|
|
115
|
-
data: {
|
|
116
|
-
type: "FeatureCollection",
|
|
117
|
-
features: [],
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
// Composite layer that contains an EditableGeoJsonLayer from nebula.gl
|
|
122
|
-
// See https://nebula.gl/docs/api-reference/layers/editable-geojson-layer
|
|
123
|
-
export default class DrawingLayer extends CompositeLayer<
|
|
124
|
-
DrawingLayerProps<FeatureCollection>
|
|
125
|
-
> {
|
|
126
|
-
initializeState(context: LayerContext): void {
|
|
127
|
-
super.initializeState(context);
|
|
128
|
-
|
|
129
|
-
this.setState({
|
|
130
|
-
data: this.props.data,
|
|
131
|
-
selectedFeatureIndexes: this.props.selectedFeatureIndexes,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Select features when clicking on them if in view or modify modes.
|
|
136
|
-
// The selection is used to set current selected drawing, and
|
|
137
|
-
// is sent to the map component parent via setEditedData.
|
|
138
|
-
onClick(info: PickingInfo): boolean {
|
|
139
|
-
if (this.props.mode === "view" || this.props.mode === "modify") {
|
|
140
|
-
this.setState({
|
|
141
|
-
selectedFeatureIndexes: [info.index],
|
|
142
|
-
});
|
|
143
|
-
(this.context as DeckGLLayerContext).userData.setEditedData({
|
|
144
|
-
selectedFeatureIndexes: [info.index],
|
|
145
|
-
});
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// For now, use `any` for the picking types because this function should
|
|
153
|
-
// recieve PickInfo<FeatureCollection>, but it recieves PickInfo<Feature>.
|
|
154
|
-
getPickingInfo({ info }: { info: PickingInfo }): LayerPickInfo {
|
|
155
|
-
if (!info.object) return info;
|
|
156
|
-
const feature = info.object;
|
|
157
|
-
let measurement;
|
|
158
|
-
if (feature.geometry.type === "LineString") {
|
|
159
|
-
measurement = length(feature);
|
|
160
|
-
} else if (feature.geometry.type === "Polygon") {
|
|
161
|
-
measurement = area(feature);
|
|
162
|
-
} else return info;
|
|
163
|
-
return {
|
|
164
|
-
...info,
|
|
165
|
-
propertyValue: measurement,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Callback for various editing events. Most events will update this component
|
|
170
|
-
// through patches sent to the map parent. See patchLayerPropsin layerTools.ts.
|
|
171
|
-
_onEdit(editAction: EditAction<FeatureCollection>): void {
|
|
172
|
-
switch (editAction.editType) {
|
|
173
|
-
case "addFeature":
|
|
174
|
-
this.setState({
|
|
175
|
-
data: editAction.updatedData,
|
|
176
|
-
selectedFeatureIndexes:
|
|
177
|
-
editAction.editContext.featureIndexes,
|
|
178
|
-
});
|
|
179
|
-
(this.context as DeckGLLayerContext).userData.setEditedData({
|
|
180
|
-
data: editAction.updatedData,
|
|
181
|
-
selectedFeatureIndexes:
|
|
182
|
-
editAction.editContext.featureIndexes,
|
|
183
|
-
});
|
|
184
|
-
break;
|
|
185
|
-
case "removeFeature":
|
|
186
|
-
this.setState({
|
|
187
|
-
data: editAction.updatedData,
|
|
188
|
-
selectedFeatureIndexes: [],
|
|
189
|
-
});
|
|
190
|
-
(this.context as DeckGLLayerContext).userData.setEditedData({
|
|
191
|
-
data: editAction.updatedData,
|
|
192
|
-
selectedFeatureIndexes: [] as number[],
|
|
193
|
-
});
|
|
194
|
-
break;
|
|
195
|
-
case "removePosition":
|
|
196
|
-
case "finishMovePosition":
|
|
197
|
-
this.setState({
|
|
198
|
-
data: editAction.updatedData,
|
|
199
|
-
});
|
|
200
|
-
(this.context as DeckGLLayerContext).userData.setEditedData({
|
|
201
|
-
data: editAction.updatedData,
|
|
202
|
-
});
|
|
203
|
-
break;
|
|
204
|
-
case "movePosition":
|
|
205
|
-
case "undoDrawing":
|
|
206
|
-
// Don't use setEditedData to avoid an expensive roundtrip,
|
|
207
|
-
// since this is done on every mouse move when editing.
|
|
208
|
-
this.setState({ data: editAction.updatedData });
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// Return the line color based on the selection status.
|
|
214
|
-
// The same can be done for other features (polygons, points etc).
|
|
215
|
-
_getLineColor(feature: Feature): Color {
|
|
216
|
-
const is_feature_selected = this.state["selectedFeatureIndexes"].some(
|
|
217
|
-
(i: number) => this.state["data"].features[i] === feature
|
|
218
|
-
);
|
|
219
|
-
if (is_feature_selected) {
|
|
220
|
-
return SELECTED_LINE_COLOR;
|
|
221
|
-
} else {
|
|
222
|
-
return UNSELECTED_LINE_COLOR;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
renderLayers(): LayersList {
|
|
227
|
-
if (this.props.visible == false) {
|
|
228
|
-
return [];
|
|
229
|
-
}
|
|
230
|
-
const sub_layer_props = this.getSubLayerProps({
|
|
231
|
-
data: this.state["data"],
|
|
232
|
-
mode: MODE_MAP[this.props.mode as keyof typeof MODE_MAP],
|
|
233
|
-
modeConfig: {
|
|
234
|
-
viewport: this.context.viewport,
|
|
235
|
-
},
|
|
236
|
-
selectedFeatureIndexes: this.state["selectedFeatureIndexes"],
|
|
237
|
-
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
238
|
-
onEdit: (editAction: EditAction<FeatureCollection>) =>
|
|
239
|
-
this._onEdit(editAction),
|
|
240
|
-
_subLayerProps: {
|
|
241
|
-
geojson: {
|
|
242
|
-
autoHighlight: true,
|
|
243
|
-
getLineColor: (feature: Feature) =>
|
|
244
|
-
this._getLineColor(feature),
|
|
245
|
-
},
|
|
246
|
-
},
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
// @ts-expect-error: EditableGeoJsonLayer from nebula.gl has no typing
|
|
250
|
-
return [new EditableGeoJsonLayer(sub_layer_props)];
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
DrawingLayer.layerName = "DrawingLayer";
|
|
255
|
-
DrawingLayer.defaultProps =
|
|
256
|
-
defaultProps as unknown as DrawingLayerProps<FeatureCollection>;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { COORDINATE_SYSTEM, Color, CompositeLayer } from "@deck.gl/core/typed";
|
|
2
|
-
import { GeoJsonLayer, GeoJsonLayerProps } from "@deck.gl/layers/typed";
|
|
3
|
-
import { Feature } from "geojson";
|
|
4
|
-
import GL from "@luma.gl/constants";
|
|
5
|
-
|
|
6
|
-
const getColor = (d: Feature): Color => {
|
|
7
|
-
const c: Color = d?.properties?.["color"];
|
|
8
|
-
const r = c[0] ?? 0;
|
|
9
|
-
const g = c[1] ?? 0;
|
|
10
|
-
const b = c[2] ?? 0;
|
|
11
|
-
return [r, g, b, 30]; // make fill color transparent
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export interface FaultPolygonsLayerProps extends GeoJsonLayerProps {
|
|
15
|
-
// Enable/disable depth testing when rendering layer. Default true.
|
|
16
|
-
depthTest: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const defaultProps = {
|
|
20
|
-
"@@type": "FaultPolygonsLayer",
|
|
21
|
-
name: "Fault polygons",
|
|
22
|
-
id: "fault-polygons-layer",
|
|
23
|
-
pickable: true,
|
|
24
|
-
visible: true,
|
|
25
|
-
filled: true,
|
|
26
|
-
lineWidthMinPixels: 2,
|
|
27
|
-
depthTest: true,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export default class FaultPolygonsLayer extends CompositeLayer<FaultPolygonsLayerProps> {
|
|
31
|
-
renderLayers(): GeoJsonLayer<Feature>[] {
|
|
32
|
-
const layer = new GeoJsonLayer<Feature>(
|
|
33
|
-
this.getSubLayerProps({
|
|
34
|
-
id: this.props.id,
|
|
35
|
-
data: this.props.data,
|
|
36
|
-
pickable: this.props.pickable,
|
|
37
|
-
visible: this.props.visible,
|
|
38
|
-
filled: this.props.filled,
|
|
39
|
-
lineWidthMinPixels: this.props.lineWidthMinPixels,
|
|
40
|
-
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
41
|
-
getLineColor: (d: Feature) =>
|
|
42
|
-
d?.properties?.["color"] ?? [0, 0, 0, 255],
|
|
43
|
-
getFillColor: getColor,
|
|
44
|
-
parameters: {
|
|
45
|
-
[GL.DEPTH_TEST]: this.props.depthTest,
|
|
46
|
-
},
|
|
47
|
-
})
|
|
48
|
-
);
|
|
49
|
-
return [layer];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
FaultPolygonsLayer.layerName = "FaultPolygonsLayer";
|
|
54
|
-
FaultPolygonsLayer.defaultProps = defaultProps;
|