mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 00:02:25 +00:00
Global clouds drawn from a feed's tiles to the level it names
A weather feed that supplies its own tiles may name, per product, the deepest level of the geographic tiling its tiles hold detail at (frameMaximumLevel, 0-12). Global infrared is then drawn from those tiles to that level, each given the regional infrared display transfer, rather than from one 2048x1024 image cut to level 3. Other tiled products take the named level in place of 6. A feed naming no usable level keeps the layer's own detail.
This commit is contained in:
1 parent
3d25a284f9
commit
97bce938c4
5 files changed
+205
-8
No files matched your search
@@ -13,8 +13,13 @@ import {
|
||||
acquireInfraredMosaic,
|
||||
processInfraredImage,
|
||||
} from './infraredImage.js';
|
||||
// Bounded display detail for the hourly, approximately 3 km global product.
|
||||
// Bounded display detail for the hourly, approximately 3 km global product
|
||||
// when it is drawn from one 2048 × 1024 mosaic.
|
||||
const GLOBAL_TILE_MAXIMUM_LEVEL = 3;
|
||||
// Detail of the tiled products when the feed does not name its own.
|
||||
const TILE_MAXIMUM_LEVEL = 6;
|
||||
// The deepest level a feed may name: about 150 m a pixel.
|
||||
const SUPPLIED_MAXIMUM_LEVEL_LIMIT = 12;
|
||||
// Six decoded 2048×1024 canvases (8 MiB each) bound the cache below 50 MiB.
|
||||
const MAX_MOSAICS = 6;
|
||||
const MAX_PREFETCH_TILES = 8;
|
||||
@@ -45,10 +50,33 @@ function createGlobeRendering({
|
||||
let prefetchJob = null;
|
||||
let prefetchedKey = null;
|
||||
|
||||
/** The deepest level the feed's own tiles of `product` go to, or null. */
|
||||
function suppliedLevel(product) {
|
||||
if (!frameSource?.getTile) return null;
|
||||
let level = null;
|
||||
try {
|
||||
level = frameSource.maximumLevel?.(product) ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
return Number.isInteger(level) &&
|
||||
level >= 0 &&
|
||||
level <= SUPPLIED_MAXIMUM_LEVEL_LIMIT
|
||||
? level
|
||||
: null;
|
||||
}
|
||||
|
||||
/** Global clouds come from one mosaic unless the feed tiles them itself. */
|
||||
function fromMosaic(product) {
|
||||
return product === 'clouds' && suppliedLevel(product) === null;
|
||||
}
|
||||
|
||||
function profile(product) {
|
||||
return {
|
||||
tileSize: 256,
|
||||
maximumLevel: product === 'clouds' ? GLOBAL_TILE_MAXIMUM_LEVEL : 6,
|
||||
maximumLevel:
|
||||
suppliedLevel(product) ??
|
||||
(product === 'clouds' ? GLOBAL_TILE_MAXIMUM_LEVEL : TILE_MAXIMUM_LEVEL),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -252,7 +280,7 @@ function createGlobeRendering({
|
||||
!snapshot.times.includes(time)
|
||||
)
|
||||
return false;
|
||||
const global = snapshot.product === 'clouds';
|
||||
const global = fromMosaic(snapshot.product);
|
||||
const tiles = global ? [] : prefetchTiles(snapshot);
|
||||
const supplied = !global && Boolean(frameSource?.getTile);
|
||||
const urls = global || supplied ? [] : tileUrls(snapshot, time, tiles);
|
||||
@@ -315,7 +343,7 @@ function createGlobeRendering({
|
||||
lastError = null;
|
||||
const { west, south, east, north } = snapshot.bounds;
|
||||
const rectangle = cesium.Rectangle.fromDegrees(west, south, east, north);
|
||||
const global = snapshot.product === 'clouds';
|
||||
const global = fromMosaic(snapshot.product);
|
||||
const frame = {
|
||||
snapshot,
|
||||
creditSnapshot,
|
||||
@@ -484,7 +512,14 @@ function createGlobeRendering({
|
||||
.then((image) => {
|
||||
// Cesium decodes tiles as ImageBitmaps already flipped, since WebGL
|
||||
// ignores UNPACK_FLIP_Y for them; a canvas upload flips again.
|
||||
if (!frame.closed && snapshot.product === 'clouds-regional')
|
||||
// Infrared tiles get the display transfer the mosaic already
|
||||
// carries.
|
||||
if (
|
||||
!frame.closed &&
|
||||
!global &&
|
||||
(snapshot.product === 'clouds-regional' ||
|
||||
snapshot.product === 'clouds')
|
||||
)
|
||||
image = processInfraredImage(image, infrared, createCanvas, {
|
||||
flipY:
|
||||
typeof ImageBitmap !== 'undefined' &&
|
||||
|
||||
Reference in new issue
Block a user