@longline/aqua-ui 1.0.164 → 1.0.166
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/controls/View/ScrollingContent.d.ts +2 -2
- package/controls/View/ScrollingContent.js +1 -1
- package/controls/View/View.d.ts +9 -5
- package/controls/View/View.js +13 -5
- package/map/layers/InterpolationLayer/DotsFragmentShader.d.ts +2 -0
- package/map/layers/InterpolationLayer/DotsFragmentShader.js +2 -0
- package/map/layers/InterpolationLayer/DotsVertexShader.d.ts +2 -0
- package/map/layers/InterpolationLayer/DotsVertexShader.js +2 -0
- package/map/layers/InterpolationLayer/InterpolationLayer.d.ts +6 -1
- package/map/layers/InterpolationLayer/InterpolationLayer.js +82 -4
- package/map/layers/ParticlesLayer/ParticlesLayer.js +8 -2
- package/package.json +1 -1
|
@@ -6,8 +6,8 @@ interface IProps {
|
|
|
6
6
|
children?: React.ReactNode;
|
|
7
7
|
/** Is this View in `ghost` mode? */
|
|
8
8
|
ghost?: boolean;
|
|
9
|
-
/** Height of the view, in
|
|
10
|
-
height:
|
|
9
|
+
/** Height of the view, in CSS units. */
|
|
10
|
+
height: string;
|
|
11
11
|
}
|
|
12
12
|
declare const ScrollingContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<IProps, never>> & string & Omit<(props: IProps) => React.JSX.Element, keyof React.Component<any, {}, any>>;
|
|
13
13
|
export { ScrollingContent };
|
|
@@ -17,6 +17,6 @@ var ScrollingContentBase = function (props) {
|
|
|
17
17
|
overflowY: "auto",
|
|
18
18
|
} }, !props.ghost && props.children));
|
|
19
19
|
};
|
|
20
|
-
var ScrollingContent = styled(ScrollingContentBase)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n height: calc(", "
|
|
20
|
+
var ScrollingContent = styled(ScrollingContentBase)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n height: calc(", " - 44px);\n"], ["\n position: relative;\n height: calc(", " - 44px);\n"])), function (p) { return p.height; });
|
|
21
21
|
export { ScrollingContent };
|
|
22
22
|
var templateObject_1;
|
package/controls/View/View.d.ts
CHANGED
|
@@ -22,24 +22,28 @@ interface IProps {
|
|
|
22
22
|
/**
|
|
23
23
|
* By default, content is ellipsized to one line. If `height` is set,
|
|
24
24
|
* content is allowed to grow, and a scrollbar is added. Height is in
|
|
25
|
-
*
|
|
25
|
+
* CSS units, e.g. `300px` or `30vh`.
|
|
26
26
|
*/
|
|
27
|
-
height?:
|
|
27
|
+
height?: string;
|
|
28
28
|
/**
|
|
29
29
|
* Views may provide their weight in relative units to other Views,
|
|
30
30
|
* for flexbox alignment, e.g. `2`.
|
|
31
31
|
*/
|
|
32
32
|
weight?: number;
|
|
33
33
|
/**
|
|
34
|
-
* Is this `View` in ghost mode?
|
|
34
|
+
* Is this `View` in ghost mode? Its value (i.e. `children`) will not be
|
|
35
35
|
* displayed.
|
|
36
36
|
* @default false
|
|
37
37
|
*/
|
|
38
38
|
ghost?: boolean;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* A `View` is used to display static (read-only) data. A `View` has a label,
|
|
42
|
-
* children are its value.
|
|
41
|
+
* A `View` is used to display static (read-only) data. A `View` has a label,
|
|
42
|
+
* and its children are its value. Optionally, a hint can be shown at the
|
|
43
|
+
* bottom of the `View`. By default, a `View` ellipsizes its content to a
|
|
44
|
+
* single line, and all views are the same height. A custom height can be set
|
|
45
|
+
* with the `height` attribute, and a scrollbar will then be added to the
|
|
46
|
+
* content.
|
|
43
47
|
*
|
|
44
48
|
* ```tsx
|
|
45
49
|
* <View label="Email address">{email}</View>
|
package/controls/View/View.js
CHANGED
|
@@ -41,17 +41,25 @@ var Content = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateO
|
|
|
41
41
|
var HintContent = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: absolute;\n bottom: 3px;\n left: 12px;\n right: 12px;\n\n font: ", ";\n color: ", ";\n user-select: none;\n // Hints don't wrap and are ellipsized:\n white-space: nowrap;\n overflow-x: hidden;\n text-overflow: ellipsis;\n"], ["\n position: absolute;\n bottom: 3px;\n left: 12px;\n right: 12px;\n\n font: ", ";\n color: ", ";\n user-select: none;\n // Hints don't wrap and are ellipsized:\n white-space: nowrap;\n overflow-x: hidden;\n text-overflow: ellipsis;\n"])), function (p) { return p.theme.font.bodySmall; }, function (p) { return p.theme.colors.neutral[80]; });
|
|
42
42
|
var ViewStyled = styled(ViewBase)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n // Position & size:\n position: relative;\n box-sizing: border-box;\n margin-bottom: 8px;\n \n ", "\n z-index: 0; // for :before\n padding-left: 12px;\n padding-right: 12px;\n\n // Appearance:\n border-radius: ", "px;\n background-color: rgb(from ", " r g b / 30%);\n border: none;\n font: ", ";\n color: ", ";\n\n // Content:\n overflow: hidden;\n\n // Hint background:\n ", "\n\n ", " {\n position: absolute;\n left: 12px;\n right: 12px;\n top: 10px;\n color: ", ";\n user-select: none;\n }\n\n // Ghost state:\n ", "\n\n // Views may provide their weight in relative units to other fields.\n ", "\n"], ["\n // Position & size:\n position: relative;\n box-sizing: border-box;\n margin-bottom: 8px;\n \n ", "\n z-index: 0; // for :before\n padding-left: 12px;\n padding-right: 12px;\n\n // Appearance:\n border-radius: ", "px;\n background-color: rgb(from ", " r g b / 30%);\n border: none;\n font: ", ";\n color: ", ";\n\n // Content:\n overflow: hidden;\n\n // Hint background:\n ", "\n\n ", " {\n position: absolute;\n left: 12px;\n right: 12px;\n top: 10px;\n color: ", ";\n user-select: none;\n }\n\n // Ghost state:\n ", "\n\n // Views may provide their weight in relative units to other fields.\n ", "\n"
|
|
43
43
|
/**
|
|
44
|
-
* A `View` is used to display static (read-only) data. A `View` has a label,
|
|
45
|
-
* children are its value.
|
|
44
|
+
* A `View` is used to display static (read-only) data. A `View` has a label,
|
|
45
|
+
* and its children are its value. Optionally, a hint can be shown at the
|
|
46
|
+
* bottom of the `View`. By default, a `View` ellipsizes its content to a
|
|
47
|
+
* single line, and all views are the same height. A custom height can be set
|
|
48
|
+
* with the `height` attribute, and a scrollbar will then be added to the
|
|
49
|
+
* content.
|
|
46
50
|
*
|
|
47
51
|
* ```tsx
|
|
48
52
|
* <View label="Email address">{email}</View>
|
|
49
53
|
* ```
|
|
50
54
|
*/
|
|
51
|
-
])), function (p) { return p.height && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["height: ", "
|
|
55
|
+
])), function (p) { return p.height && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["height: ", ";"], ["height: ", ";"])), p.height); }, function (p) { return p.theme.radius.normal; }, function (p) { return p.theme.colors.primary[5]; }, function (p) { return p.theme.font.bodyLarge; }, function (p) { return p.theme.colors.neutral[100]; }, function (p) { return !p.noHintBg && css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n &:before {\n z-index: -1;\n content: '';\n position: absolute;\n left: 0;\n bottom: 0;\n right: 0;\n height: 22px;\n background-color: rgb(from ", " r g b / 30%);\n }\n "], ["\n &:before {\n z-index: -1;\n content: '';\n position: absolute;\n left: 0;\n bottom: 0;\n right: 0;\n height: 22px;\n background-color: rgb(from ", " r g b / 30%);\n }\n "])), function (p) { return p.theme.colors.primary[1]; }); }, Label, function (p) { return p.theme.colors.neutral[100]; }, function (p) { return p.ghost && css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n outline: dashed 1px ", ";\n background-color: transparent;\n color: transparent;\n text-shadow: 0 0 3px rgb(from ", " r g b / 50%);\n pointer-events: none;\n user-select: none;\n \n ", " {\n color: transparent;\n text-shadow: 0 0 3px rgb(from ", " r g b / 50%);\n } \n "], ["\n outline: dashed 1px ", ";\n background-color: transparent;\n color: transparent;\n text-shadow: 0 0 3px rgb(from ", " r g b / 50%);\n pointer-events: none;\n user-select: none;\n \n ", " {\n color: transparent;\n text-shadow: 0 0 3px rgb(from ", " r g b / 50%);\n } \n "])), p.theme.colors.primary[2], function (p) { return p.theme.colors.neutral[100]; }, Label, function (p) { return p.theme.colors.neutral[100]; }); }, function (p) { return p.weight && css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["flex: ", ""], ["flex: ", ""])), p.weight); });
|
|
52
56
|
/**
|
|
53
|
-
* A `View` is used to display static (read-only) data. A `View` has a label,
|
|
54
|
-
* children are its value.
|
|
57
|
+
* A `View` is used to display static (read-only) data. A `View` has a label,
|
|
58
|
+
* and its children are its value. Optionally, a hint can be shown at the
|
|
59
|
+
* bottom of the `View`. By default, a `View` ellipsizes its content to a
|
|
60
|
+
* single line, and all views are the same height. A custom height can be set
|
|
61
|
+
* with the `height` attribute, and a scrollbar will then be added to the
|
|
62
|
+
* content.
|
|
55
63
|
*
|
|
56
64
|
* ```tsx
|
|
57
65
|
* <View label="Email address">{email}</View>
|
|
@@ -35,11 +35,16 @@ interface IProps {
|
|
|
35
35
|
* @default 99
|
|
36
36
|
*/
|
|
37
37
|
maxZoom?: number;
|
|
38
|
+
/**
|
|
39
|
+
* If set, renders a dot for each data point.
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
dots?: boolean;
|
|
38
43
|
}
|
|
39
44
|
/**
|
|
40
45
|
* An `InterpolationLayer` takes a data array of the form `{ latitude, longitude, value }`. It performs triangulation
|
|
41
46
|
* and draws the data in an OpenGL layer. Optionally, a number of contour `levels` can be set to draw contour lines.
|
|
42
47
|
* Gradient colors are configurable using `gradientStops`.
|
|
43
48
|
*/
|
|
44
|
-
declare const InterpolationLayer: ({ levels, contourColor, gradientStops, minZoom, maxZoom, ...props }: IProps) => React.JSX.Element;
|
|
49
|
+
declare const InterpolationLayer: ({ levels, contourColor, gradientStops, minZoom, maxZoom, dots, ...props }: IProps) => React.JSX.Element;
|
|
45
50
|
export { InterpolationLayer };
|
|
@@ -39,12 +39,15 @@ import { LevelsVertexShader } from './LevelsVertexShader';
|
|
|
39
39
|
import { LevelsFragmentShader } from './LevelsFragmentShader';
|
|
40
40
|
import { ContoursVertexShader } from './ContoursVertexShader';
|
|
41
41
|
import { ContoursFragmentShader } from './ContoursFragmentShader';
|
|
42
|
+
import { DotsVertexShader } from './DotsVertexShader';
|
|
43
|
+
import { DotsFragmentShader } from './DotsFragmentShader';
|
|
42
44
|
var TEXTURE_WIDTH = 1024;
|
|
43
45
|
var TEXTURE_HEIGHT = 1024;
|
|
44
46
|
var InterpolationLayerBase = function (props) {
|
|
45
47
|
var map = useMap();
|
|
46
48
|
var levelsProgram = React.useRef(null);
|
|
47
49
|
var contoursProgram = React.useRef(null);
|
|
50
|
+
var dotsProgram = React.useRef(null);
|
|
48
51
|
var levelsBuffer = React.useRef(null);
|
|
49
52
|
var contoursBuffer = React.useRef(null);
|
|
50
53
|
var fbo = React.useRef(null);
|
|
@@ -69,6 +72,45 @@ var InterpolationLayerBase = function (props) {
|
|
|
69
72
|
return point([dp.longitude, dp.latitude], { 'v': dp.value });
|
|
70
73
|
}));
|
|
71
74
|
var polys = tin(points, 'v');
|
|
75
|
+
/* // Calculate average side length of triangles.
|
|
76
|
+
let total = 0;
|
|
77
|
+
polys.features.forEach(p => {
|
|
78
|
+
const a = p.geometry.coordinates[0][0];
|
|
79
|
+
const b = p.geometry.coordinates[0][1];
|
|
80
|
+
const c = p.geometry.coordinates[0][2];
|
|
81
|
+
const d1 = Math.sqrt((a[0] - b[0])*(a[0]-b[0]) + (a[1] - b[1]) * (a[1] - b[1]));
|
|
82
|
+
const d2 = Math.sqrt((b[0] - c[0])*(b[0]-c[0]) + (b[1] - c[1]) * (b[1] - c[1]));
|
|
83
|
+
const d3 = Math.sqrt((a[0] - c[0])*(a[0]-c[0]) + (a[1] - c[1]) * (a[1] - c[1]));
|
|
84
|
+
const avg = (d1 + d2 + d3) / 3;
|
|
85
|
+
total += avg;
|
|
86
|
+
});
|
|
87
|
+
const avg = total / polys.features.length;
|
|
88
|
+
|
|
89
|
+
// Remove any triangles with a side of more than 2x avg
|
|
90
|
+
const factor = 4;
|
|
91
|
+
polys.features = polys.features.filter(p => {
|
|
92
|
+
const a = p.geometry.coordinates[0][0];
|
|
93
|
+
const b = p.geometry.coordinates[0][1];
|
|
94
|
+
const c = p.geometry.coordinates[0][2];
|
|
95
|
+
const d1 = Math.sqrt((a[0] - b[0])*(a[0]-b[0]) + (a[1] - b[1]) * (a[1] - b[1]));
|
|
96
|
+
const d2 = Math.sqrt((b[0] - c[0])*(b[0]-c[0]) + (b[1] - c[1]) * (b[1] - c[1]));
|
|
97
|
+
const d3 = Math.sqrt((a[0] - c[0])*(a[0]-c[0]) + (a[1] - c[1]) * (a[1] - c[1]));
|
|
98
|
+
if(d1 > factor * avg || d2 > factor * avg || d3 > factor * avg) return false;
|
|
99
|
+
return true;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Remove any triangles with a long side:
|
|
103
|
+
const sidefactor = 4;
|
|
104
|
+
polys.features = polys.features.filter(p => {
|
|
105
|
+
const a = p.geometry.coordinates[0][0];
|
|
106
|
+
const b = p.geometry.coordinates[0][1];
|
|
107
|
+
const c = p.geometry.coordinates[0][2];
|
|
108
|
+
const d1 = Math.sqrt((a[0] - b[0])*(a[0]-b[0]) + (a[1] - b[1]) * (a[1] - b[1]));
|
|
109
|
+
const d2 = Math.sqrt((b[0] - c[0])*(b[0]-c[0]) + (b[1] - c[1]) * (b[1] - c[1]));
|
|
110
|
+
const d3 = Math.sqrt((a[0] - c[0])*(a[0]-c[0]) + (a[1] - c[1]) * (a[1] - c[1]));
|
|
111
|
+
if(d1 > sidefactor * d2 || d1 > sidefactor * d3 || d2 > sidefactor * d3) return false;
|
|
112
|
+
return true;
|
|
113
|
+
});*/
|
|
72
114
|
return polys;
|
|
73
115
|
};
|
|
74
116
|
//
|
|
@@ -131,15 +173,37 @@ var InterpolationLayerBase = function (props) {
|
|
|
131
173
|
gl.attachShader(contoursProgram.current, fragmentShader);
|
|
132
174
|
gl.linkProgram(contoursProgram.current);
|
|
133
175
|
};
|
|
176
|
+
var createDotsProgram = function (gl) {
|
|
177
|
+
// create a vertex shader
|
|
178
|
+
var vertexShader = gl.createShader(gl.VERTEX_SHADER);
|
|
179
|
+
gl.shaderSource(vertexShader, DotsVertexShader);
|
|
180
|
+
gl.compileShader(vertexShader);
|
|
181
|
+
// create a fragment shader
|
|
182
|
+
var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
|
|
183
|
+
gl.shaderSource(fragmentShader, DotsFragmentShader);
|
|
184
|
+
gl.compileShader(fragmentShader);
|
|
185
|
+
// link the two shaders into a WebGL program
|
|
186
|
+
dotsProgram.current = gl.createProgram();
|
|
187
|
+
gl.attachShader(dotsProgram.current, vertexShader);
|
|
188
|
+
gl.attachShader(dotsProgram.current, fragmentShader);
|
|
189
|
+
gl.linkProgram(dotsProgram.current);
|
|
190
|
+
};
|
|
134
191
|
var onAddLayer = function (map, gl) {
|
|
135
192
|
// AddLayer is only called once.
|
|
136
193
|
if (!gl)
|
|
137
194
|
return;
|
|
138
195
|
var geometry = getGeometry();
|
|
139
|
-
var minValue =
|
|
140
|
-
var maxValue =
|
|
196
|
+
var minValue = Infinity;
|
|
197
|
+
var maxValue = -Infinity;
|
|
198
|
+
var len = geometry.features.length;
|
|
199
|
+
while (len--) {
|
|
200
|
+
var value = geometry.features[len].properties['a'];
|
|
201
|
+
minValue = value < minValue ? value : minValue;
|
|
202
|
+
maxValue = value > maxValue ? value : maxValue;
|
|
203
|
+
}
|
|
141
204
|
createLevelsProgram(gl);
|
|
142
205
|
createContoursProgram(gl);
|
|
206
|
+
createDotsProgram(gl);
|
|
143
207
|
createTexture(gl);
|
|
144
208
|
createFrameBuffer(gl);
|
|
145
209
|
// Convert dataset to triangle geometry.
|
|
@@ -218,6 +282,18 @@ var InterpolationLayerBase = function (props) {
|
|
|
218
282
|
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
219
283
|
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
|
220
284
|
};
|
|
285
|
+
var renderDots = function (gl, matrix) {
|
|
286
|
+
gl.useProgram(dotsProgram.current);
|
|
287
|
+
// Pass a matrix uniform in:
|
|
288
|
+
gl.uniformMatrix4fv(gl.getUniformLocation(dotsProgram.current, 'u_matrix'), false, matrix);
|
|
289
|
+
var aPos = gl.getAttribLocation(dotsProgram.current, 'a_pos');
|
|
290
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, levelsBuffer.current);
|
|
291
|
+
gl.enableVertexAttribArray(aPos);
|
|
292
|
+
gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 12, 0);
|
|
293
|
+
gl.enable(gl.BLEND);
|
|
294
|
+
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
295
|
+
gl.drawArrays(gl.POINTS, 0, numTriangles.current * 3);
|
|
296
|
+
};
|
|
221
297
|
var onRender = function (gl, matrix, zoom, width, height) {
|
|
222
298
|
// Render is called many times while the map is panned/zoomed.
|
|
223
299
|
// You cannot have access to the map though.
|
|
@@ -238,6 +314,8 @@ var InterpolationLayerBase = function (props) {
|
|
|
238
314
|
// Reset the viewport size to equal the map size:
|
|
239
315
|
gl.viewport(0, 0, width * window.devicePixelRatio, height * window.devicePixelRatio);
|
|
240
316
|
renderContours(gl, matrix, width, height);
|
|
317
|
+
if (props.dots)
|
|
318
|
+
renderDots(gl, matrix);
|
|
241
319
|
};
|
|
242
320
|
return (React.createElement(Layer, { id: null, type: "custom", beforeId: "overlay", key: time, onAdd: onAddLayer, render: function (gl, matrix) { return onRender(gl, matrix, map.current.getZoom(), map.current.getContainer().clientWidth, map.current.getContainer().clientHeight); } }));
|
|
243
321
|
};
|
|
@@ -250,7 +328,7 @@ var InterpolationLayer = function (_a) {
|
|
|
250
328
|
var _b = _a.levels, levels = _b === void 0 ? 0 : _b, _c = _a.contourColor, contourColor = _c === void 0 ? '#35ABE2' : _c, _d = _a.gradientStops, gradientStops = _d === void 0 ? [
|
|
251
329
|
{ pos: 0.0, color: '#0000ffff' },
|
|
252
330
|
{ pos: 1.0, color: '#000000ff' }
|
|
253
|
-
] : _d, _e = _a.minZoom, minZoom = _e === void 0 ? 0 : _e, _f = _a.maxZoom, maxZoom = _f === void 0 ? 99 : _f, props = __rest(_a, ["levels", "contourColor", "gradientStops", "minZoom", "maxZoom"]);
|
|
254
|
-
return React.createElement(InterpolationLayerBase, __assign({ levels: levels, contourColor: contourColor, gradientStops: gradientStops, minZoom: minZoom, maxZoom: maxZoom }, props));
|
|
331
|
+
] : _d, _e = _a.minZoom, minZoom = _e === void 0 ? 0 : _e, _f = _a.maxZoom, maxZoom = _f === void 0 ? 99 : _f, _g = _a.dots, dots = _g === void 0 ? false : _g, props = __rest(_a, ["levels", "contourColor", "gradientStops", "minZoom", "maxZoom", "dots"]);
|
|
332
|
+
return React.createElement(InterpolationLayerBase, __assign({ levels: levels, contourColor: contourColor, gradientStops: gradientStops, minZoom: minZoom, maxZoom: maxZoom, dots: dots }, props));
|
|
255
333
|
};
|
|
256
334
|
export { InterpolationLayer };
|
|
@@ -111,8 +111,14 @@ var ParticlesLayerBase = function (props) {
|
|
|
111
111
|
}));
|
|
112
112
|
var polys = tin(points, 'v');
|
|
113
113
|
// Find min and max values in GeoJSON:
|
|
114
|
-
var minValue =
|
|
115
|
-
var maxValue =
|
|
114
|
+
var minValue = Infinity;
|
|
115
|
+
var maxValue = -Infinity;
|
|
116
|
+
var len = polys.features.length;
|
|
117
|
+
while (len--) {
|
|
118
|
+
var value = polys.features[len].properties['a'];
|
|
119
|
+
minValue = value < minValue ? value : minValue;
|
|
120
|
+
maxValue = value > maxValue ? value : maxValue;
|
|
121
|
+
}
|
|
116
122
|
// Convert dataset to triangle geometry.
|
|
117
123
|
// Result is a list of v1,v2,v3, v1,v2,v3, ...
|
|
118
124
|
// where each vector has (x,y,value).
|