fix(library): Norway's cadastre and sea depths draw to the far edge of a tilted view again

The two dense entries (cadastre from z14, sea depths from z11) were drawn
by Cesium only on globe tiles as fine as their minimum zoom, with their
minimum zoom tiles filling the coarsest of those. Through the globe port
they dropped the minimum level and refused every tile below it, so the
far band of a tilted view, one globe level coarser, was blank.

The imagery contract gains hiddenBelowMinLevel: a layer drawn nowhere the
surface is coarser than its minLevel. Cesium gives such a layer
minimumTerrainLevel as the library set it before (minLevel - 1 for Web
Mercator tiles on the geographic globe); the entries keep their minimum
level and drop the admit hook.
This commit is contained in:
Sameh Khamis committed 2026-11-14 08:01:36 -08:00
1 parent 91b080a45a
commit ecf8b31756
5 files changed
+63 -41

No files matched your search

+14
View File
@@ -132,6 +132,20 @@ test('the look writes through to the Cesium layer', () => {
assert.equal(layer.lit, false);
});
test('a layer hidden below its minimum level shows from the globe level as fine as it', () => {
const { scene, port } = setup();
port.imagery.add({
kind: 'xyz',
url: url('dense'),
minLevel: 14,
hiddenBelowMinLevel: true,
});
port.imagery.add({ kind: 'xyz', url: url('plain'), minLevel: 14 });
// Web Mercator z14 is as fine as the geographic globe's level 13.
assert.equal(scene.imageryLayers.get(0)._minimumTerrainLevel, 13);
assert.equal(scene.imageryLayers.get(1)._minimumTerrainLevel, undefined);
});
test('imagery drapes on the drawn base tileset while the globe is hidden', () => {
const { scene, port, tick } = setup();
const tileset = fakeTileset();
+26 -3
View File
@@ -108,6 +108,21 @@ function canvasProvider(spec) {
};
}
/**
* The Cesium layer options a spec asks for: one hidden below its minimum
* level is shown only from the globe level as fine as it (Cesium's globe
* tiles are geographic, two Web Mercator tiles across a level's one).
* @param {import('../contract/globe').ImagerySpec} spec
* @returns {object|undefined}
*/
export function layerOptions(spec) {
if (!spec.hiddenBelowMinLevel || !(spec.minLevel > 0)) return undefined;
const tiling =
spec.tiling ?? (spec.kind === 'canvas' ? 'geographic' : 'webMercator');
const shift = tiling === 'geographic' ? 0 : 1;
return { minimumTerrainLevel: Math.max(0, spec.minLevel - shift) };
}
/**
* The Cesium provider a spec describes; a promise for the kinds Cesium
* builds from metadata it fetches first.
@@ -437,10 +452,14 @@ export function createCesiumImagery(
/** A Cesium layer for the record, with its look. */
function build(record) {
const options = layerOptions(record.spec);
const layer =
record.provider !== undefined
? new Cesium.ImageryLayer(record.provider)
: Cesium.ImageryLayer.fromProviderAsync(record.providerPromise);
? new Cesium.ImageryLayer(record.provider, options)
: Cesium.ImageryLayer.fromProviderAsync(
record.providerPromise,
options,
);
layer.alpha = record.alpha;
// A layer showing timed frames hides its own imagery.
layer.show = record.show && !record.timed;
@@ -710,11 +729,15 @@ export function createCesiumImagery(
return hookProvider(provider, spec, record.ctx);
});
provider.catch(() => {});
entry.layer = Cesium.ImageryLayer.fromProviderAsync(provider);
entry.layer = Cesium.ImageryLayer.fromProviderAsync(
provider,
layerOptions(spec),
);
} else {
entry.offError = record.watchErrors(made);
entry.layer = new Cesium.ImageryLayer(
timed.video ? made : hookProvider(made, spec, record.ctx),
layerOptions(spec),
);
}
entry.layer.alpha = 0;
+6
View File
@@ -82,6 +82,12 @@ export interface ImagerySpec {
rectangle?: GeoRect;
minLevel?: number;
maxLevel?: number;
/**
* Drawn nowhere the surface is coarser than `minLevel`, rather than made
* from `minLevel` tiles there: for a layer whose `minLevel` tiles are too
* many to fetch far out.
*/
hiddenBelowMinLevel?: boolean;
tileSize?: number;
credit?: Credit;
/** Requests in flight at once for this layer. */