Files
gods-eye-view/src/render/cesium/vectorBase.test.mjs
T
Sameh Khamis 5fae3cf485 Draw vectorBase: a MapLibre style's vector tiles painted as imagery
src/render/vectorBase/ is a Cesium-free painter: loadVectorStyle loads
a style and its TileJSON sources and compiles its layers (skipping, with a
reason, what it does not draw), and paintVectorTile paints a Web Mercator
tile on a canvas: background, fill, line and circle layers with filters in
both syntaxes, legacy functions and a listed subset of expressions, and
symbol text labels placed clear of each other inside the tile. Sources are
decoded with pbf and @mapbox/vector-tile, already dependencies. The Cesium
port loads the style before changing the base, draws it as Web Mercator
imagery under the base's other imagery, credits its sources, and claims
vectorBase; the stub loads the style. globe.base.vector serves a style and
tile from data URLs and reads the drawn fill.
2026-11-11 18:24:49 -08:00

35 lines
1.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import assert from 'node:assert/strict';
import * as Cesium from 'cesium';
import test from 'node:test';
import {
attributionText,
VECTOR_TILE_PX,
vectorBaseProvider,
} from './vectorBase.js';
import { cesiumCapabilities } from './ports.js';
test('the vector base is Web Mercator imagery painted from its style', () => {
const provider = vectorBaseProvider({
layers: [],
sources: {},
tiles: new Map(),
});
assert.ok(provider.tilingScheme instanceof Cesium.WebMercatorTilingScheme);
assert.equal(provider.tileWidth, VECTOR_TILE_PX);
assert.equal(provider.hasAlphaChannel, false);
assert.equal(typeof provider.requestImage, 'function');
});
test('a source’s attribution is credited as plain text', () => {
assert.equal(
attributionText(
'<a href="https://x.test">&copy; OpenMapTiles</a> <a href="y">Data &amp; more</a>',
),
'© OpenMapTiles Data & more',
);
});
test('a Cesium globe claims vectorBase', () => {
assert.ok(cesiumCapabilities({}).includes('vectorBase'));
});