@deck.gl-community/infovis-layers 9.3.2 → 9.3.7
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.cjs +2998 -114
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/layers/animation-layer/animation-layer.d.ts +30 -0
- package/dist/layers/animation-layer/animation-layer.d.ts.map +1 -0
- package/dist/layers/animation-layer/animation-layer.js +53 -0
- package/dist/layers/animation-layer/animation-layer.js.map +1 -0
- package/dist/layers/animation-layer/animation.d.ts +86 -0
- package/dist/layers/animation-layer/animation.d.ts.map +1 -0
- package/dist/layers/animation-layer/animation.js +214 -0
- package/dist/layers/animation-layer/animation.js.map +1 -0
- package/dist/layers/block-layer/block-layer-fragment.glsl.d.ts +3 -0
- package/dist/layers/block-layer/block-layer-fragment.glsl.d.ts.map +1 -0
- package/dist/layers/block-layer/block-layer-fragment.glsl.js +41 -0
- package/dist/layers/block-layer/block-layer-fragment.glsl.js.map +1 -0
- package/dist/layers/block-layer/block-layer-uniforms.d.ts +27 -0
- package/dist/layers/block-layer/block-layer-uniforms.d.ts.map +1 -0
- package/dist/layers/block-layer/block-layer-uniforms.js +26 -0
- package/dist/layers/block-layer/block-layer-uniforms.js.map +1 -0
- package/dist/layers/block-layer/block-layer-vertex.glsl.d.ts +3 -0
- package/dist/layers/block-layer/block-layer-vertex.glsl.d.ts.map +1 -0
- package/dist/layers/block-layer/block-layer-vertex.glsl.js +67 -0
- package/dist/layers/block-layer/block-layer-vertex.glsl.js.map +1 -0
- package/dist/layers/block-layer/block-layer.d.ts +71 -0
- package/dist/layers/block-layer/block-layer.d.ts.map +1 -0
- package/dist/layers/block-layer/block-layer.js +108 -0
- package/dist/layers/block-layer/block-layer.js.map +1 -0
- package/dist/layers/fast-text-layer/fast-text-layer.d.ts +148 -0
- package/dist/layers/fast-text-layer/fast-text-layer.d.ts.map +1 -0
- package/dist/layers/fast-text-layer/fast-text-layer.js +862 -0
- package/dist/layers/fast-text-layer/fast-text-layer.js.map +1 -0
- package/dist/layers/fast-text-layer/fast-text-layer.test.d.ts +2 -0
- package/dist/layers/fast-text-layer/fast-text-layer.test.d.ts.map +1 -0
- package/dist/layers/fast-text-layer/fast-text-layer.test.js +300 -0
- package/dist/layers/fast-text-layer/fast-text-layer.test.js.map +1 -0
- package/dist/layers/fast-text-layer/fast-text-layout.d.ts +179 -0
- package/dist/layers/fast-text-layer/fast-text-layout.d.ts.map +1 -0
- package/dist/layers/fast-text-layer/fast-text-layout.js +665 -0
- package/dist/layers/fast-text-layer/fast-text-layout.js.map +1 -0
- package/dist/layers/fast-text-layer/font-atlas.d.ts +98 -0
- package/dist/layers/fast-text-layer/font-atlas.d.ts.map +1 -0
- package/dist/layers/fast-text-layer/font-atlas.js +337 -0
- package/dist/layers/fast-text-layer/font-atlas.js.map +1 -0
- package/dist/layers/fast-text-layer/index.d.ts +4 -0
- package/dist/layers/fast-text-layer/index.d.ts.map +1 -0
- package/dist/layers/fast-text-layer/index.js +4 -0
- package/dist/layers/fast-text-layer/index.js.map +1 -0
- package/dist/layers/time-delta-layer.d.ts +22 -60
- package/dist/layers/time-delta-layer.d.ts.map +1 -1
- package/dist/layers/time-delta-layer.js +31 -53
- package/dist/layers/time-delta-layer.js.map +1 -1
- package/dist/synchronized-views/synchronized-views.js +1 -1
- package/dist/synchronized-views/synchronized-views.js.map +1 -1
- package/dist/utils/format-utils.d.ts +27 -3
- package/dist/utils/format-utils.d.ts.map +1 -1
- package/dist/utils/format-utils.js +72 -40
- package/dist/utils/format-utils.js.map +1 -1
- package/dist/utils/utf8-string-view.d.ts +53 -0
- package/dist/utils/utf8-string-view.d.ts.map +1 -0
- package/dist/utils/utf8-string-view.js +169 -0
- package/dist/utils/utf8-string-view.js.map +1 -0
- package/dist/utils/utf8-string-view.test.d.ts +2 -0
- package/dist/utils/utf8-string-view.test.d.ts.map +1 -0
- package/dist/utils/utf8-string-view.test.js +88 -0
- package/dist/utils/utf8-string-view.test.js.map +1 -0
- package/dist/views/bounds-utils.d.ts +23 -0
- package/dist/views/bounds-utils.d.ts.map +1 -0
- package/dist/views/bounds-utils.js +65 -0
- package/dist/views/bounds-utils.js.map +1 -0
- package/dist/views/layer-bounds-filter.d.ts +48 -0
- package/dist/views/layer-bounds-filter.d.ts.map +1 -0
- package/dist/views/layer-bounds-filter.js +99 -0
- package/dist/views/layer-bounds-filter.js.map +1 -0
- package/dist/views/layer-filter.js +4 -4
- package/dist/views/layer-filter.js.map +1 -1
- package/dist/views/orthographic-utils.d.ts +30 -2
- package/dist/views/orthographic-utils.d.ts.map +1 -1
- package/dist/views/orthographic-utils.js +33 -14
- package/dist/views/orthographic-utils.js.map +1 -1
- package/dist/views/view-layout/build-views-from-view-layout.d.ts +37 -0
- package/dist/views/view-layout/build-views-from-view-layout.d.ts.map +1 -0
- package/dist/views/view-layout/build-views-from-view-layout.js +413 -0
- package/dist/views/view-layout/build-views-from-view-layout.js.map +1 -0
- package/dist/views/view-layout/index.d.ts +3 -0
- package/dist/views/view-layout/index.d.ts.map +1 -0
- package/dist/views/view-layout/index.js +3 -0
- package/dist/views/view-layout/index.js.map +1 -0
- package/dist/views/view-layout/view-layout-item.d.ts +74 -0
- package/dist/views/view-layout/view-layout-item.d.ts.map +1 -0
- package/dist/views/view-layout/view-layout-item.js +48 -0
- package/dist/views/view-layout/view-layout-item.js.map +1 -0
- package/dist/views/view-layout/view-layout.test.d.ts +2 -0
- package/dist/views/view-layout/view-layout.test.d.ts.map +1 -0
- package/dist/views/view-layout/view-layout.test.js +112 -0
- package/dist/views/view-layout/view-layout.test.js.map +1 -0
- package/dist/views/viewport-bounds-utils.d.ts +55 -0
- package/dist/views/viewport-bounds-utils.d.ts.map +1 -0
- package/dist/views/viewport-bounds-utils.js +70 -0
- package/dist/views/viewport-bounds-utils.js.map +1 -0
- package/package.json +15 -5
- package/src/index.ts +91 -2
- package/src/layers/animation-layer/animation-layer.ts +92 -0
- package/src/layers/animation-layer/animation.ts +328 -0
- package/src/layers/block-layer/block-layer-fragment.glsl.ts +41 -0
- package/src/layers/block-layer/block-layer-uniforms.ts +43 -0
- package/src/layers/block-layer/block-layer-vertex.glsl.ts +67 -0
- package/src/layers/block-layer/block-layer.ts +199 -0
- package/src/layers/fast-text-layer/fast-text-layer.test.ts +359 -0
- package/src/layers/fast-text-layer/fast-text-layer.ts +1208 -0
- package/src/layers/fast-text-layer/fast-text-layout.ts +1124 -0
- package/src/layers/fast-text-layer/font-atlas.ts +574 -0
- package/src/layers/fast-text-layer/index.ts +37 -0
- package/src/layers/time-delta-layer.ts +55 -70
- package/src/synchronized-views/synchronized-views.ts +1 -1
- package/src/utils/format-utils.ts +90 -40
- package/src/utils/utf8-string-view.test.ts +119 -0
- package/src/utils/utf8-string-view.ts +273 -0
- package/src/views/bounds-utils.ts +88 -0
- package/src/views/layer-bounds-filter.ts +160 -0
- package/src/views/layer-filter.ts +4 -4
- package/src/views/orthographic-utils.ts +65 -18
- package/src/views/view-layout/build-views-from-view-layout.ts +547 -0
- package/src/views/view-layout/index.ts +18 -0
- package/src/views/view-layout/view-layout-item.ts +125 -0
- package/src/views/view-layout/view-layout.test.ts +129 -0
- package/src/views/viewport-bounds-utils.ts +104 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {OrthographicView} from '@deck.gl/core';
|
|
2
|
+
import {describe, expect, it} from 'vitest';
|
|
3
|
+
|
|
4
|
+
import {buildViewsFromViewLayout, ViewLayoutItem} from '.';
|
|
5
|
+
|
|
6
|
+
describe('buildViewsFromViewLayout', () => {
|
|
7
|
+
it('splits remaining row width evenly across children without explicit widths', () => {
|
|
8
|
+
const layout = new ViewLayoutItem({
|
|
9
|
+
type: 'row',
|
|
10
|
+
children: [
|
|
11
|
+
new OrthographicView({id: 'fixed', width: 100}),
|
|
12
|
+
new OrthographicView({id: 'flex-a'}),
|
|
13
|
+
new OrthographicView({id: 'flex-b'})
|
|
14
|
+
]
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const compiled = buildViewsFromViewLayout({
|
|
18
|
+
layout,
|
|
19
|
+
width: 400,
|
|
20
|
+
height: 120
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
expect(compiled.rectsById.fixed).toEqual({x: 0, y: 0, width: 100, height: 120});
|
|
24
|
+
expect(compiled.rectsById['flex-a']).toEqual({x: 100, y: 0, width: 150, height: 120});
|
|
25
|
+
expect(compiled.rectsById['flex-b']).toEqual({x: 250, y: 0, width: 150, height: 120});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('splits remaining column height evenly across children without explicit heights', () => {
|
|
29
|
+
const layout = new ViewLayoutItem({
|
|
30
|
+
type: 'column',
|
|
31
|
+
children: [
|
|
32
|
+
new OrthographicView({id: 'header', height: 40}),
|
|
33
|
+
new OrthographicView({id: 'body-a'}),
|
|
34
|
+
new OrthographicView({id: 'body-b'})
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const compiled = buildViewsFromViewLayout({
|
|
39
|
+
layout,
|
|
40
|
+
width: 200,
|
|
41
|
+
height: 200
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
expect(compiled.rectsById.header).toEqual({x: 0, y: 0, width: 200, height: 40});
|
|
45
|
+
expect(compiled.rectsById['body-a']).toEqual({x: 0, y: 40, width: 200, height: 80});
|
|
46
|
+
expect(compiled.rectsById['body-b']).toEqual({x: 0, y: 120, width: 200, height: 80});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('resolves overlay children against the same parent bounds', () => {
|
|
50
|
+
const layout = new ViewLayoutItem({
|
|
51
|
+
type: 'overlay',
|
|
52
|
+
children: [new OrthographicView({id: 'base'}), new OrthographicView({id: 'top'})]
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const compiled = buildViewsFromViewLayout({
|
|
56
|
+
layout,
|
|
57
|
+
width: 320,
|
|
58
|
+
height: 180
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
expect(compiled.rectsById.base).toEqual({x: 0, y: 0, width: 320, height: 180});
|
|
62
|
+
expect(compiled.rectsById.top).toEqual({x: 0, y: 0, width: 320, height: 180});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('resolves raw view expressions against the current parent bounds', () => {
|
|
66
|
+
const layout = new ViewLayoutItem({
|
|
67
|
+
type: 'overlay',
|
|
68
|
+
children: [
|
|
69
|
+
new OrthographicView({
|
|
70
|
+
id: 'calc-view',
|
|
71
|
+
x: 10,
|
|
72
|
+
y: '10%',
|
|
73
|
+
width: 'calc(50% - 20px)',
|
|
74
|
+
height: '50%'
|
|
75
|
+
})
|
|
76
|
+
]
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const compiled = buildViewsFromViewLayout({
|
|
80
|
+
layout,
|
|
81
|
+
width: 300,
|
|
82
|
+
height: 200
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
expect(compiled.rectsById['calc-view']).toEqual({x: 10, y: 20, width: 130, height: 100});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('supports nested items and reuses unchanged compiled views by id', () => {
|
|
89
|
+
const layout = new ViewLayoutItem({
|
|
90
|
+
type: 'column',
|
|
91
|
+
children: [
|
|
92
|
+
new ViewLayoutItem({
|
|
93
|
+
type: 'row',
|
|
94
|
+
height: 50,
|
|
95
|
+
children: [
|
|
96
|
+
new ViewLayoutItem({type: 'spacer', width: 80}),
|
|
97
|
+
new OrthographicView({id: 'header'})
|
|
98
|
+
]
|
|
99
|
+
}),
|
|
100
|
+
new ViewLayoutItem({
|
|
101
|
+
type: 'row',
|
|
102
|
+
children: [
|
|
103
|
+
new OrthographicView({id: 'legend', width: 80}),
|
|
104
|
+
new OrthographicView({id: 'main'})
|
|
105
|
+
]
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const first = buildViewsFromViewLayout({
|
|
111
|
+
layout,
|
|
112
|
+
width: 300,
|
|
113
|
+
height: 200
|
|
114
|
+
});
|
|
115
|
+
const second = buildViewsFromViewLayout({
|
|
116
|
+
layout,
|
|
117
|
+
width: 300,
|
|
118
|
+
height: 200,
|
|
119
|
+
previous: first
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
expect(second.rectsById.header).toEqual({x: 80, y: 0, width: 220, height: 50});
|
|
123
|
+
expect(second.rectsById.legend).toEqual({x: 0, y: 50, width: 80, height: 150});
|
|
124
|
+
expect(second.rectsById.main).toEqual({x: 80, y: 50, width: 220, height: 150});
|
|
125
|
+
expect(second.views.find(view => view.props.id === 'main')).toBe(
|
|
126
|
+
first.views.find(view => view.props.id === 'main')
|
|
127
|
+
);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Bounds} from './bounds-utils';
|
|
6
|
+
import type {OrthographicViewState} from '@deck.gl/core';
|
|
7
|
+
|
|
8
|
+
/** Default floating-point tolerance used when comparing bounds values. @defaultValue 1e-6 */
|
|
9
|
+
export const DEFAULT_BOUNDS_EPSILON = 1e-6;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Axis-aligned bounding box describing the area that is currently visible in a Deck.gl viewport.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export type ViewportBounds = {
|
|
16
|
+
/** Inclusive minimum world-space X coordinate within the viewport. */
|
|
17
|
+
minX: number;
|
|
18
|
+
/** Inclusive maximum world-space X coordinate within the viewport. */
|
|
19
|
+
maxX: number;
|
|
20
|
+
/** Inclusive minimum world-space Y coordinate within the viewport. */
|
|
21
|
+
minY: number;
|
|
22
|
+
/** Inclusive maximum world-space Y coordinate within the viewport. */
|
|
23
|
+
maxY: number;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** Floating-point comparison configuration for {@link boundsAreEqual}. */
|
|
27
|
+
export type BoundsEqualityOptions = {
|
|
28
|
+
/** Maximum allowed coordinate delta before bounds differ. @defaultValue DEFAULT_BOUNDS_EPSILON */
|
|
29
|
+
epsilon?: number;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns `true` when two bounds tuples are identical within a configurable floating-point
|
|
34
|
+
* tolerance.
|
|
35
|
+
*
|
|
36
|
+
* @param a - First bounds tuple to compare.
|
|
37
|
+
* @param b - Second bounds tuple to compare.
|
|
38
|
+
* @param options - Comparison configuration.
|
|
39
|
+
* @param options.epsilon - Maximum allowed absolute difference between coordinate values before
|
|
40
|
+
* the bounds are considered distinct. Defaults to {@link DEFAULT_BOUNDS_EPSILON}.
|
|
41
|
+
*/
|
|
42
|
+
export function boundsAreEqual(a: Bounds, b: Bounds, options?: BoundsEqualityOptions): boolean {
|
|
43
|
+
const epsilon = options?.epsilon ?? DEFAULT_BOUNDS_EPSILON;
|
|
44
|
+
let [ax, ay] = a[0];
|
|
45
|
+
let [bx, by] = b[0];
|
|
46
|
+
if (Math.abs(ax - bx) > epsilon || Math.abs(ay - by) > epsilon) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
[ax, ay] = a[1];
|
|
50
|
+
[bx, by] = b[1];
|
|
51
|
+
if (Math.abs(ax - bx) > epsilon || Math.abs(ay - by) > epsilon) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Computes the world-space bounds of an orthographic viewport given its view state and Deck.gl
|
|
59
|
+
* dimensions.
|
|
60
|
+
*
|
|
61
|
+
* @param view - The orthographic view state describing the viewport target and zoom level.
|
|
62
|
+
* @param deckDimensions - The pixel dimensions of the Deck.gl canvas hosting the view.
|
|
63
|
+
* @returns The minimum and maximum X/Y world-space coordinates visible within the viewport.
|
|
64
|
+
*/
|
|
65
|
+
export function getViewportBoundsForViewState(
|
|
66
|
+
view: OrthographicViewState,
|
|
67
|
+
deckDimensions: {width: number; height: number}
|
|
68
|
+
): ViewportBounds {
|
|
69
|
+
const target = view.target ?? [0, 0];
|
|
70
|
+
const zoomValue = view.zoom;
|
|
71
|
+
const zoomArray = Array.isArray(zoomValue)
|
|
72
|
+
? zoomValue
|
|
73
|
+
: typeof zoomValue === 'number'
|
|
74
|
+
? [zoomValue, zoomValue]
|
|
75
|
+
: [0, 0];
|
|
76
|
+
|
|
77
|
+
const zoomX = zoomArray[0] ?? 0;
|
|
78
|
+
const zoomY = zoomArray[1] ?? zoomArray[0] ?? 0;
|
|
79
|
+
const scaleX = 2 ** zoomX || 1;
|
|
80
|
+
const scaleY = 2 ** zoomY || 1;
|
|
81
|
+
const halfWidth = deckDimensions.width / scaleX / 2;
|
|
82
|
+
const halfHeight = deckDimensions.height / scaleY / 2;
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
minX: target[0] - halfWidth,
|
|
86
|
+
maxX: target[0] + halfWidth,
|
|
87
|
+
minY: target[1] - halfHeight,
|
|
88
|
+
maxY: target[1] + halfHeight
|
|
89
|
+
} satisfies ViewportBounds;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Determines whether a bounds tuple lies entirely outside the supplied viewport bounds.
|
|
94
|
+
*
|
|
95
|
+
* @param bounds - The bounds tuple that may or may not intersect with the viewport.
|
|
96
|
+
* @param viewport - The viewport bounds to test against.
|
|
97
|
+
* @returns `true` when the bounds are completely outside of the viewport; otherwise `false`.
|
|
98
|
+
*/
|
|
99
|
+
export function isBoundsCompletelyOutside(bounds: Bounds, viewport: ViewportBounds): boolean {
|
|
100
|
+
const [[minX, minY], [maxX, maxY]] = bounds;
|
|
101
|
+
return (
|
|
102
|
+
maxX < viewport.minX || minX > viewport.maxX || maxY < viewport.minY || minY > viewport.maxY
|
|
103
|
+
);
|
|
104
|
+
}
|