@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,143 +0,0 @@
|
|
|
1
|
-
import { CompositeLayer, UpdateParameters } from "@deck.gl/core/typed";
|
|
2
|
-
import { ScatterplotLayer } from "@deck.gl/layers/typed";
|
|
3
|
-
import { isEqual } from "lodash";
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
ExtendedLayerProps,
|
|
7
|
-
invertZCoordinate,
|
|
8
|
-
defineBoundingBox,
|
|
9
|
-
} from "../utils/layerTools";
|
|
10
|
-
|
|
11
|
-
export interface PointsLayerProps<D> extends ExtendedLayerProps<D> {
|
|
12
|
-
/**
|
|
13
|
-
* Point positions as [x, y, z, x, y, z....].
|
|
14
|
-
*/
|
|
15
|
-
pointsData: number[];
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Point color defined as RGB or RGBA array. Each component is in 0-255 range.
|
|
19
|
-
*/
|
|
20
|
-
color: [number, number, number] | [number, number, number, number];
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The units of the point radius, one of `'meters'`, `'common'`, and `'pixels'`.
|
|
24
|
-
*/
|
|
25
|
-
radiusUnits: "meters" | "common" | "pixels";
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Point radius defined in radius units.
|
|
29
|
-
*/
|
|
30
|
-
pointRadius: number;
|
|
31
|
-
|
|
32
|
-
/** If true means that input z values are interpreted as depths.
|
|
33
|
-
* For example depth of z = 1000 corresponds to -1000 on the z axis. Default true.
|
|
34
|
-
*/
|
|
35
|
-
ZIncreasingDownwards: boolean;
|
|
36
|
-
|
|
37
|
-
// Non public properties:
|
|
38
|
-
setReportedBoundingBox?: React.Dispatch<
|
|
39
|
-
React.SetStateAction<[number, number, number, number, number, number]>
|
|
40
|
-
>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const defaultProps = {
|
|
44
|
-
"@@type": "PointsLayer",
|
|
45
|
-
name: "PointsLayer",
|
|
46
|
-
id: "points-layer",
|
|
47
|
-
color: [125, 0, 0, 255],
|
|
48
|
-
radiusUnits: "pixels",
|
|
49
|
-
pointRadius: 5,
|
|
50
|
-
pickable: true,
|
|
51
|
-
visible: true,
|
|
52
|
-
ZIncreasingDownwards: true,
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
interface IDataAttributes {
|
|
56
|
-
length: number;
|
|
57
|
-
attributes: {
|
|
58
|
-
getPosition: {
|
|
59
|
-
value: Float32Array;
|
|
60
|
-
size: number;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export default class PointsLayer extends CompositeLayer<
|
|
66
|
-
PointsLayerProps<unknown>
|
|
67
|
-
> {
|
|
68
|
-
renderLayers(): [ScatterplotLayer?] {
|
|
69
|
-
const layer = new ScatterplotLayer(
|
|
70
|
-
this.getSubLayerProps({
|
|
71
|
-
id: "points-layer",
|
|
72
|
-
pickable: this.props.pickable,
|
|
73
|
-
billboard: true,
|
|
74
|
-
data: this.state["dataAttributes"],
|
|
75
|
-
_pathType: "open",
|
|
76
|
-
getFillColor: () => this.props.color,
|
|
77
|
-
getRadius: () => this.props.pointRadius,
|
|
78
|
-
radiusUnits: this.props.radiusUnits,
|
|
79
|
-
|
|
80
|
-
updateTriggers: {
|
|
81
|
-
getFillColor: [this.props.color],
|
|
82
|
-
getRadius: [this.props.pointRadius],
|
|
83
|
-
},
|
|
84
|
-
})
|
|
85
|
-
);
|
|
86
|
-
return [layer];
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
initializeState(): void {
|
|
90
|
-
const dataAttributes = this.rebuildDataAttributes(true);
|
|
91
|
-
this.setState({ dataAttributes });
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
updateState({ props, oldProps }: UpdateParameters<PointsLayer>): void {
|
|
95
|
-
const needs_reload =
|
|
96
|
-
!isEqual(props.pointsData, oldProps.pointsData) ||
|
|
97
|
-
!isEqual(props.ZIncreasingDownwards, oldProps.ZIncreasingDownwards);
|
|
98
|
-
|
|
99
|
-
if (needs_reload) {
|
|
100
|
-
const dataAttributes = this.rebuildDataAttributes(false);
|
|
101
|
-
this.setState({ dataAttributes });
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
private rebuildDataAttributes(
|
|
106
|
-
reportBoundingBox: boolean
|
|
107
|
-
): IDataAttributes | null {
|
|
108
|
-
const dataArray = this.loadData();
|
|
109
|
-
if (!dataArray) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
if (this.props.ZIncreasingDownwards) {
|
|
113
|
-
invertZCoordinate(dataArray);
|
|
114
|
-
}
|
|
115
|
-
if (
|
|
116
|
-
typeof this.props.setReportedBoundingBox === "function" &&
|
|
117
|
-
reportBoundingBox
|
|
118
|
-
) {
|
|
119
|
-
const boundingBox = defineBoundingBox(dataArray);
|
|
120
|
-
this.props.setReportedBoundingBox(boundingBox);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
length: dataArray.length / 3,
|
|
125
|
-
attributes: {
|
|
126
|
-
getPosition: {
|
|
127
|
-
value: dataArray,
|
|
128
|
-
size: 3,
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
private loadData(): Float32Array | null {
|
|
135
|
-
if (Array.isArray(this.props.pointsData)) {
|
|
136
|
-
return new Float32Array(this.props.pointsData);
|
|
137
|
-
}
|
|
138
|
-
return new Float32Array();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
PointsLayer.layerName = "PointsLayer";
|
|
143
|
-
PointsLayer.defaultProps = defaultProps;
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ComponentStory, ComponentMeta } from "@storybook/react";
|
|
3
|
-
import { create, all } from "mathjs";
|
|
4
|
-
|
|
5
|
-
import SubsurfaceViewer from "../../SubsurfaceViewer";
|
|
6
|
-
import { default as PolylinesLayer } from "./polylinesLayer";
|
|
7
|
-
import { default as AxesLayer } from "../axes/axesLayer";
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
component: SubsurfaceViewer,
|
|
11
|
-
title: "SubsurfaceViewer / Polylines Layer",
|
|
12
|
-
} as ComponentMeta<typeof SubsurfaceViewer>;
|
|
13
|
-
|
|
14
|
-
const defaultParameters = {
|
|
15
|
-
docs: {
|
|
16
|
-
inlineStories: false,
|
|
17
|
-
iframeHeight: 500,
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// Small example using polylinesLayer.
|
|
22
|
-
const smallPolylinesLayer = new PolylinesLayer({
|
|
23
|
-
id: "small_polylines_layer",
|
|
24
|
-
/* eslint-disable */
|
|
25
|
-
polylinePoints: [0, 0, 0,
|
|
26
|
-
10, 0, 0,
|
|
27
|
-
10, 0, 10,
|
|
28
|
-
|
|
29
|
-
-5, -5, 4,
|
|
30
|
-
0, -8, 6,
|
|
31
|
-
5, 10, 8
|
|
32
|
-
|
|
33
|
-
],
|
|
34
|
-
/* eslint-enable */
|
|
35
|
-
startIndices: [0, 3],
|
|
36
|
-
polylinesClosed: [true, false],
|
|
37
|
-
color: [0, 200, 100],
|
|
38
|
-
|
|
39
|
-
widthUnits: "pixels",
|
|
40
|
-
linesWidth: 10,
|
|
41
|
-
ZIncreasingDownwards: true,
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const smallAxesLayer = new AxesLayer({
|
|
45
|
-
id: "small_axes_layer",
|
|
46
|
-
bounds: [-10, -10, 0, 20, 10, 10],
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
export const SmallPolylinesLayer: ComponentStory<typeof SubsurfaceViewer> = (
|
|
50
|
-
args
|
|
51
|
-
) => {
|
|
52
|
-
return <SubsurfaceViewer {...args} />;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
SmallPolylinesLayer.args = {
|
|
56
|
-
id: "map",
|
|
57
|
-
layers: [smallAxesLayer, smallPolylinesLayer],
|
|
58
|
-
bounds: [-10, -10, 17, 10],
|
|
59
|
-
views: {
|
|
60
|
-
layout: [1, 1],
|
|
61
|
-
viewports: [
|
|
62
|
-
{
|
|
63
|
-
id: "view_1",
|
|
64
|
-
show3D: true,
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
SmallPolylinesLayer.parameters = {
|
|
71
|
-
docs: {
|
|
72
|
-
...defaultParameters.docs,
|
|
73
|
-
description: {
|
|
74
|
-
story: "Polyline nodes are given as native javascript array.",
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const sideSize = 10000;
|
|
80
|
-
const pointsCount = 100000;
|
|
81
|
-
|
|
82
|
-
const math = create(all, { randomSeed: "1234" });
|
|
83
|
-
|
|
84
|
-
type TRandomNumberFunc = () => number;
|
|
85
|
-
|
|
86
|
-
const randomFunc = ((): TRandomNumberFunc => {
|
|
87
|
-
if (math.random) {
|
|
88
|
-
return () => {
|
|
89
|
-
const val = math.random?.(sideSize);
|
|
90
|
-
return val ? val : 0.0;
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
return () => Math.random() * sideSize;
|
|
94
|
-
})();
|
|
95
|
-
|
|
96
|
-
const hugePolylinesLayer = new PolylinesLayer({
|
|
97
|
-
id: "huge_polylines-layer",
|
|
98
|
-
|
|
99
|
-
polylinePoints: Array(pointsCount * 3)
|
|
100
|
-
.fill(0)
|
|
101
|
-
.map(() => randomFunc()),
|
|
102
|
-
startIndices: [0],
|
|
103
|
-
color: [0, 100, 100, 40],
|
|
104
|
-
|
|
105
|
-
widthUnits: "pixels",
|
|
106
|
-
linesWidth: 1,
|
|
107
|
-
|
|
108
|
-
ZIncreasingDownwards: true,
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const hugeAxesLayer = new AxesLayer({
|
|
112
|
-
id: "huge_axes_layer",
|
|
113
|
-
bounds: [0, 0, 0, sideSize, sideSize, sideSize],
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
export const HugePolylinesLayer: ComponentStory<typeof SubsurfaceViewer> = (
|
|
117
|
-
args
|
|
118
|
-
) => {
|
|
119
|
-
return <SubsurfaceViewer {...args} />;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
HugePolylinesLayer.args = {
|
|
123
|
-
id: "map",
|
|
124
|
-
layers: [hugeAxesLayer, hugePolylinesLayer],
|
|
125
|
-
bounds: [0, 0, sideSize, sideSize],
|
|
126
|
-
views: {
|
|
127
|
-
layout: [1, 1],
|
|
128
|
-
viewports: [
|
|
129
|
-
{
|
|
130
|
-
id: "view_1",
|
|
131
|
-
show3D: true,
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
},
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
HugePolylinesLayer.parameters = {
|
|
138
|
-
docs: {
|
|
139
|
-
...defaultParameters.docs,
|
|
140
|
-
description: {
|
|
141
|
-
story: "Polyline nodes are randomly generated in runtime and given as native javascript array.",
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
};
|
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import { CompositeLayer, UpdateParameters } from "@deck.gl/core/typed";
|
|
2
|
-
import { PathLayer } from "@deck.gl/layers/typed";
|
|
3
|
-
import { isEqual } from "lodash";
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
ExtendedLayerProps,
|
|
7
|
-
invertZCoordinate,
|
|
8
|
-
defineBoundingBox,
|
|
9
|
-
} from "../utils/layerTools";
|
|
10
|
-
|
|
11
|
-
type IsPolylineClosedFunc = (index: number) => boolean;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* _pathType is Deck.GL PathLayer prop. If all the polylines are "open" or are "loop" some checks are skipped for better performance.
|
|
15
|
-
* If this prop is not set or null PathLayer checks closeness by comparing coordinates and decides how to draw the polylines.
|
|
16
|
-
*/
|
|
17
|
-
type PathType = "open" | "loop" | null;
|
|
18
|
-
|
|
19
|
-
export interface PolylinesLayerProps<D> extends ExtendedLayerProps<D> {
|
|
20
|
-
/**
|
|
21
|
-
* Polyline vertices as [x, y, z, x, y, z....].
|
|
22
|
-
*/
|
|
23
|
-
polylinePoints: number[];
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
Start indices of the polylines counted in vertex indices.
|
|
27
|
-
For example, if there are 3 paths of 2, 3, and 4 vertices each, startIndices should be [0, 2, 5].
|
|
28
|
-
*/
|
|
29
|
-
startIndices: number[];
|
|
30
|
-
|
|
31
|
-
/** Array of boolean flags or a single value indicating whether the polylines are closed.
|
|
32
|
-
* The polylines are considered to be open if not set.
|
|
33
|
-
*/
|
|
34
|
-
polylinesClosed?: boolean | boolean[];
|
|
35
|
-
/**
|
|
36
|
-
* Line color defined as RGB or RGBA array. Each component is in 0-255 range.
|
|
37
|
-
*/
|
|
38
|
-
color: [number, number, number] | [number, number, number, number];
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* The units of the line width, one of `'meters'`, `'common'`, and `'pixels'`.
|
|
42
|
-
*/
|
|
43
|
-
widthUnits: "meters" | "common" | "pixels";
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Line width defined in width units.
|
|
47
|
-
*/
|
|
48
|
-
linesWidth: number;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* If true means that input z values are interpreted as depths.
|
|
52
|
-
* For example depth of z = 1000 corresponds to -1000 on the z axis. Default true.
|
|
53
|
-
*/
|
|
54
|
-
ZIncreasingDownwards: boolean;
|
|
55
|
-
|
|
56
|
-
// Non public properties:
|
|
57
|
-
setReportedBoundingBox?: React.Dispatch<
|
|
58
|
-
React.SetStateAction<[number, number, number, number, number, number]>
|
|
59
|
-
>;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const defaultProps = {
|
|
63
|
-
"@@type": "PolylinesLayer",
|
|
64
|
-
name: "PolylinesLayer",
|
|
65
|
-
id: "polylines-layer",
|
|
66
|
-
widthUnits: "pixels",
|
|
67
|
-
linesWidth: 5,
|
|
68
|
-
color: [0, 0, 200, 255],
|
|
69
|
-
pickable: true,
|
|
70
|
-
visible: true,
|
|
71
|
-
ZIncreasingDownwards: true,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
interface IDataAttributes {
|
|
75
|
-
length: number;
|
|
76
|
-
startIndices: Uint32Array;
|
|
77
|
-
attributes: {
|
|
78
|
-
getPath: {
|
|
79
|
-
value: Float32Array;
|
|
80
|
-
size: number;
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
pathType: PathType;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export default class PolylinesLayer extends CompositeLayer<
|
|
87
|
-
PolylinesLayerProps<unknown>
|
|
88
|
-
> {
|
|
89
|
-
renderLayers(): [PathLayer?] {
|
|
90
|
-
const layer = new PathLayer(
|
|
91
|
-
this.getSubLayerProps({
|
|
92
|
-
id: "polylines-layer",
|
|
93
|
-
widthUnits: this.props.widthUnits,
|
|
94
|
-
pickable: this.props.pickable,
|
|
95
|
-
billboard: true,
|
|
96
|
-
jointRounded: true,
|
|
97
|
-
capRounded: true,
|
|
98
|
-
data: this.state["dataAttributes"],
|
|
99
|
-
_pathType: this.state["dataAttributes"].pathType,
|
|
100
|
-
getColor: () => this.props.color,
|
|
101
|
-
getWidth: () => this.props.linesWidth,
|
|
102
|
-
|
|
103
|
-
updateTriggers: {
|
|
104
|
-
getColor: [this.props.color],
|
|
105
|
-
getWidth: [this.props.linesWidth],
|
|
106
|
-
},
|
|
107
|
-
})
|
|
108
|
-
);
|
|
109
|
-
return [layer];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
initializeState(): void {
|
|
113
|
-
const dataAttributes = this.rebuildDataAttributes(true);
|
|
114
|
-
this.setState({ dataAttributes });
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
updateState({ props, oldProps }: UpdateParameters<PolylinesLayer>): void {
|
|
118
|
-
const needs_reload =
|
|
119
|
-
!isEqual(props.polylinePoints, oldProps.polylinePoints) ||
|
|
120
|
-
!isEqual(props.startIndices, oldProps.startIndices) ||
|
|
121
|
-
!isEqual(props.polylinesClosed, oldProps.polylinesClosed) ||
|
|
122
|
-
!isEqual(props.ZIncreasingDownwards, oldProps.ZIncreasingDownwards);
|
|
123
|
-
|
|
124
|
-
if (needs_reload) {
|
|
125
|
-
const dataAttributes = this.rebuildDataAttributes(false);
|
|
126
|
-
this.setState({ dataAttributes });
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
private rebuildDataAttributes(
|
|
131
|
-
reportBoundingBox: boolean
|
|
132
|
-
): IDataAttributes | null {
|
|
133
|
-
const dataArrays = this.loadData();
|
|
134
|
-
if (this.props.ZIncreasingDownwards) {
|
|
135
|
-
invertZCoordinate(dataArrays.positions);
|
|
136
|
-
}
|
|
137
|
-
if (
|
|
138
|
-
typeof this.props.setReportedBoundingBox === "function" &&
|
|
139
|
-
reportBoundingBox
|
|
140
|
-
) {
|
|
141
|
-
const boundingBox = defineBoundingBox(dataArrays.positions);
|
|
142
|
-
this.props.setReportedBoundingBox(boundingBox);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return {
|
|
146
|
-
length: dataArrays.linesCount,
|
|
147
|
-
startIndices: dataArrays.startIndices,
|
|
148
|
-
attributes: {
|
|
149
|
-
getPath: {
|
|
150
|
-
value: dataArrays.positions,
|
|
151
|
-
size: 3,
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
pathType: dataArrays.pathType,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
private loadData(): {
|
|
159
|
-
linesCount: number;
|
|
160
|
-
startIndices: Uint32Array;
|
|
161
|
-
positions: Float32Array;
|
|
162
|
-
pathType: PathType;
|
|
163
|
-
} {
|
|
164
|
-
this.normalizeStartIndices();
|
|
165
|
-
const data = this.closePolylines();
|
|
166
|
-
|
|
167
|
-
return {
|
|
168
|
-
linesCount: data.startIndices.length,
|
|
169
|
-
positions: new Float32Array(data.polylinePoints),
|
|
170
|
-
startIndices: new Uint32Array(data.startIndices),
|
|
171
|
-
pathType: data.pathType,
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
private closePolylines(): {
|
|
176
|
-
polylinePoints: number[];
|
|
177
|
-
startIndices: number[];
|
|
178
|
-
pathType: PathType;
|
|
179
|
-
} {
|
|
180
|
-
const isClosedFunc = this.createIsClosedFunc();
|
|
181
|
-
if (!isClosedFunc.func) {
|
|
182
|
-
return {
|
|
183
|
-
polylinePoints: this.props.polylinePoints,
|
|
184
|
-
startIndices: this.props.startIndices,
|
|
185
|
-
pathType: isClosedFunc.pathType,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
let startIndexShift = 0;
|
|
189
|
-
const closedPoints: number[] = [];
|
|
190
|
-
const closedStartIndices: number[] = [];
|
|
191
|
-
const linesCount = this.props.startIndices.length - 1;
|
|
192
|
-
for (let i = 0; i < linesCount; ++i) {
|
|
193
|
-
const isClosed = isClosedFunc.func(i);
|
|
194
|
-
closedStartIndices.push(
|
|
195
|
-
this.props.startIndices[i] + startIndexShift
|
|
196
|
-
);
|
|
197
|
-
if (isClosed) {
|
|
198
|
-
this.closePolyline(i, closedPoints);
|
|
199
|
-
++startIndexShift;
|
|
200
|
-
} else {
|
|
201
|
-
this.copyPolyline(i, closedPoints);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return {
|
|
205
|
-
polylinePoints: closedPoints,
|
|
206
|
-
startIndices: closedStartIndices,
|
|
207
|
-
pathType: isClosedFunc.pathType,
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
private normalizeStartIndices() {
|
|
212
|
-
const lastIndex = this.props.startIndices.slice(-1)[0];
|
|
213
|
-
const totalPointsCount = this.props.polylinePoints.length / 3;
|
|
214
|
-
if (lastIndex < totalPointsCount) {
|
|
215
|
-
this.props.startIndices.push(totalPointsCount);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
private copyPolyline(lineIndex: number, outPoints: number[]) {
|
|
220
|
-
const startPoint = this.props.startIndices[lineIndex];
|
|
221
|
-
const endPoint = this.props.startIndices[lineIndex + 1];
|
|
222
|
-
for (let idx = startPoint; idx < endPoint; ++idx) {
|
|
223
|
-
outPoints.push(...this.getPolylinePoint(idx));
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
private closePolyline(lineIndex: number, outPoints: number[]) {
|
|
228
|
-
this.copyPolyline(lineIndex, outPoints);
|
|
229
|
-
const startPoint = this.props.startIndices[lineIndex];
|
|
230
|
-
outPoints.push(...this.getPolylinePoint(startPoint));
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
private getPolylinePoint(index: number): number[] {
|
|
234
|
-
return this.props.polylinePoints.slice(3 * index, 3 * (index + 1));
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
private createIsClosedFunc(): {
|
|
238
|
-
func: IsPolylineClosedFunc | null;
|
|
239
|
-
pathType: PathType;
|
|
240
|
-
} {
|
|
241
|
-
if (this.props.polylinesClosed === true) {
|
|
242
|
-
return {
|
|
243
|
-
func: () => true,
|
|
244
|
-
pathType: "loop",
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
if (Array.isArray(this.props.polylinesClosed)) {
|
|
248
|
-
return {
|
|
249
|
-
func: (lineIndex: number) => {
|
|
250
|
-
return (this.props.polylinesClosed as boolean[])[lineIndex];
|
|
251
|
-
},
|
|
252
|
-
pathType: null,
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
return {
|
|
256
|
-
func: null,
|
|
257
|
-
pathType: "open",
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
PolylinesLayer.layerName = "PolylinesLayer";
|
|
263
|
-
PolylinesLayer.defaultProps = defaultProps;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { GeoJsonLayer } from "@deck.gl/layers/typed";
|
|
2
|
-
import { Feature } from "geojson";
|
|
3
|
-
import { PickingInfo } from "@deck.gl/core/typed";
|
|
4
|
-
import { DeckGLLayerContext } from "../../components/Map";
|
|
5
|
-
import { isDrawingEnabled } from "../utils/layerTools";
|
|
6
|
-
|
|
7
|
-
export default class SelectableGeoJsonLayer extends GeoJsonLayer<Feature> {
|
|
8
|
-
onClick(info: PickingInfo): boolean {
|
|
9
|
-
// Make selection only when drawing is disabled
|
|
10
|
-
if (isDrawingEnabled(this.context.layerManager)) {
|
|
11
|
-
return false;
|
|
12
|
-
} else {
|
|
13
|
-
(this.context as DeckGLLayerContext).userData.setEditedData({
|
|
14
|
-
selectedGeoJsonFeature: info.object,
|
|
15
|
-
});
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
SelectableGeoJsonLayer.layerName = "SelectableGeoJsonLayer";
|
|
22
|
-
SelectableGeoJsonLayer.defaultProps = {
|
|
23
|
-
visible: true,
|
|
24
|
-
pickable: true,
|
|
25
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// RGB to float decoder parameters.
|
|
2
|
-
|
|
3
|
-
const fs = `struct Decoder
|
|
4
|
-
{
|
|
5
|
-
vec3 rgbScaler; // r, g and b multipliers
|
|
6
|
-
float floatScaler; // value multiplier
|
|
7
|
-
float offset; // translation of the r, g, b sum
|
|
8
|
-
float step; // discretize the value in a number of steps
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
uniform Decoder decoder;
|
|
12
|
-
|
|
13
|
-
uniform float valueRangeMin;
|
|
14
|
-
uniform float valueRangeMax;
|
|
15
|
-
uniform float colorMapRangeMin;
|
|
16
|
-
uniform float colorMapRangeMax;
|
|
17
|
-
|
|
18
|
-
// Decode the RGB value using the decoder parameter.
|
|
19
|
-
float decode_rgb2float(vec3 rgb, Decoder dec) {
|
|
20
|
-
rgb *= dec.rgbScaler * vec3(16711680.0, 65280.0, 255.0); //255*256*256, 255*256, 255
|
|
21
|
-
float value = (rgb.r + rgb.g + rgb.b + dec.offset) * dec.floatScaler;
|
|
22
|
-
|
|
23
|
-
// Value must be in [0, 1] and step in (0, 1]
|
|
24
|
-
value = floor(value / dec.step + 0.5) * dec.step;
|
|
25
|
-
|
|
26
|
-
// If colorMapRangeMin/Max specified, color map will span this interval.
|
|
27
|
-
float x = value * (valueRangeMax - valueRangeMin) + valueRangeMin;
|
|
28
|
-
x = (x - colorMapRangeMin) / (colorMapRangeMax - colorMapRangeMin);
|
|
29
|
-
x = max(0.0, x);
|
|
30
|
-
x = min(1.0, x);
|
|
31
|
-
|
|
32
|
-
return x;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Decode the RGB value using the decoder uniform.
|
|
36
|
-
float decode_rgb2float(vec3 rgb) {
|
|
37
|
-
return decode_rgb2float(rgb, decoder);
|
|
38
|
-
}
|
|
39
|
-
`;
|
|
40
|
-
|
|
41
|
-
export default fs;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { ValueDecoder } from "../utils/propertyMapTools";
|
|
2
|
-
import fs from "./decoder.fs.glsl";
|
|
3
|
-
|
|
4
|
-
// Shader module for the property map value decoder.
|
|
5
|
-
// See https://luma.gl/docs/developer-guide/shader-modules
|
|
6
|
-
|
|
7
|
-
const DEFAULT_DECODER: ValueDecoder = {
|
|
8
|
-
rgbScaler: [1, 1, 1],
|
|
9
|
-
floatScaler: 1,
|
|
10
|
-
offset: 0,
|
|
11
|
-
step: 0,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
interface DecoderUniforms {
|
|
15
|
-
"decoder.rgbScaler": typeof DEFAULT_DECODER.rgbScaler;
|
|
16
|
-
"decoder.floatScaler": typeof DEFAULT_DECODER.floatScaler;
|
|
17
|
-
"decoder.offset": typeof DEFAULT_DECODER.offset;
|
|
18
|
-
"decoder.step": typeof DEFAULT_DECODER.step;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Disable complaint about `any`
|
|
22
|
-
// eslint-disable-next-line
|
|
23
|
-
function getUniforms(opts: any): DecoderUniforms | {} {
|
|
24
|
-
if (opts && opts.valueDecoder) {
|
|
25
|
-
const {
|
|
26
|
-
rgbScaler = DEFAULT_DECODER.rgbScaler,
|
|
27
|
-
floatScaler = DEFAULT_DECODER.floatScaler,
|
|
28
|
-
offset = DEFAULT_DECODER.offset,
|
|
29
|
-
step = DEFAULT_DECODER.step,
|
|
30
|
-
} = opts.valueDecoder;
|
|
31
|
-
return {
|
|
32
|
-
"decoder.rgbScaler": rgbScaler,
|
|
33
|
-
"decoder.floatScaler": floatScaler,
|
|
34
|
-
"decoder.offset": offset,
|
|
35
|
-
"decoder.step": Math.max(step, 0.0000001), // singularity at 0
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return {};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export default {
|
|
43
|
-
name: "decoder",
|
|
44
|
-
fs,
|
|
45
|
-
getUniforms,
|
|
46
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as decoder } from "./decoder";
|