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

+8 -22
View File
@@ -430,9 +430,6 @@ export function minimumTerrainLevelFor(entry) {
*/
export const LIBRARY_AERIAL_Z = 10;
/** Why a dense entry's tile below its minimum zoom is not drawn. */
const BELOW_MIN_ZOOM = 'below the entry’s minimum zoom';
/**
* The globe port imagery spec for a tiles entry.
* @param {object} entry Validated tiles entry.
@@ -442,10 +439,9 @@ const BELOW_MIN_ZOOM = 'below the entry’s minimum zoom';
export function libraryImagerySpec(entry, url) {
const bbox = entry.source.bounded ? entry.coverage.bbox : null;
const minZoom = entry.source.minZoom ?? 0;
// A dense entry (`minimumTerrainLevelFor`) asks for no tile below its
// minimum zoom: the globe then takes this layer's tiles at its own
// level, a few zoomed out, and those below the minimum fail at once, so
// nothing is drawn or fetched until the view is close enough.
// A dense entry (`minimumTerrainLevelFor`) is hidden where the view is
// coarser than its minimum zoom, so nothing is drawn or fetched until the
// view is close enough; from there on it draws as any entry does.
const dense = minimumTerrainLevelFor(entry) !== undefined;
const tileTransform = libraryTileTransform(entry);
return {
@@ -453,7 +449,8 @@ export function libraryImagerySpec(entry, url) {
url,
tiling: 'webMercator',
tileSize: entry.source.tileSize ?? 256,
...(dense ? {} : { minLevel: minZoom }),
minLevel: minZoom,
...(dense ? { hiddenBelowMinLevel: true } : {}),
maxLevel: entry.source.maxZoom ?? 18,
credit: { text: entry.provider },
// A bounded entry requests tiles inside its coverage only.
@@ -469,14 +466,6 @@ export function libraryImagerySpec(entry, url) {
: {}),
...(entry.display.aerial ? { zOrder: LIBRARY_AERIAL_Z } : {}),
...(tileTransform ? { tileTransform } : {}),
...(dense
? {
admit: (tile, issue) =>
tile.level < minZoom
? Promise.reject(new Error(BELOW_MIN_ZOOM))
: issue(),
}
: {}),
};
}
@@ -501,7 +490,6 @@ export function createLibraryTileLayer(
const id = libraryLayerId(entry.id);
const extent = coverageExtent(entry);
const outlineMode = entry.display.outline || null;
const minZoom = entry.source.minZoom ?? 0;
/** The coverage outline's set, and how many rings it draws. */
let outline = null;
let outlineCount = 0;
@@ -606,8 +594,8 @@ export function createLibraryTileLayer(
libraryImagerySpec(entry, source.tileTemplate(entry)),
);
} catch (error) {
// A renderer without tile hooks cannot draw relief, clear the
// no-data fill or hold back a dense entry: no drape, not a wrong one.
// A renderer without tile hooks cannot draw relief or clear the
// no-data fill: no drape, not a wrong one.
console.warn(`[Library] ${entry.id} tiles refused:`, error);
refused = true;
return false;
@@ -615,11 +603,9 @@ export function createLibraryTileLayer(
imagery.alpha = entry.display.opacity ?? 1;
removeErrorListener = imagery.on('tileError', (error) => {
// A 4xx is the provider saying "no imagery here" (outside its
// coverage), and a tile below a dense entry's minimum zoom is held
// back on purpose: neither is a failure.
// coverage), not a failure.
const status = error?.status;
if (status >= 400 && status < 500) return;
if (error?.tile?.level < minZoom) return;
tileErrors += 1;
});
lastUpdate = Date.now();