-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtile-layer-2d.js
More file actions
64 lines (57 loc) · 1.34 KB
/
tile-layer-2d.js
File metadata and controls
64 lines (57 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { TileLayer } from '@deck.gl/geo-layers';
import { RasterLayer } from '@kylebarron/deck.gl-raster';
import { loadImages } from '../util/image';
export function TileLayer2d(props) {
const {
id = 'tile-layer-2d',
tileSize = 256,
maxZoom = props.useNaip ? 17 : 13,
landsatMosaicId,
naipMosaicId,
landsatBands,
landsatBandCombination,
landsatColormapName,
onViewportLoad,
onTileLoad,
} = props || {};
return new TileLayer({
id,
minZoom: 0,
maxZoom,
tileSize,
getTileData: args => getTileData(Object.assign(args, props)),
renderSubLayers,
maxRequests: 10,
updateTriggers: {
// Need to expand landsatBands array since comparison is shallow
getTileData: [
landsatMosaicId,
naipMosaicId,
landsatColormapName,
landsatBandCombination,
...landsatBands,
],
},
onViewportLoad,
onTileLoad,
});
}
async function getTileData(options) {
return loadImages(options);
}
function renderSubLayers(props) {
const {
bbox: { west, south, east, north },
} = props.tile;
const { data } = props;
if (!data) {
return null;
}
const { modules, images, landsatAssetIds, ...moduleProps } = data;
return new RasterLayer(props, {
modules,
images,
moduleProps,
bounds: [west, south, east, north],
});
}