mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
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.
This commit is contained in:
1 parent
d9ad7da9d5
commit
5fae3cf485
17 files changed
+2032
-15
No files matched your search
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @module render/cesium/vectorBase
|
||||
* @description `vectorBase` on Cesium: an imagery provider over the vector
|
||||
* base painter (`src/render/vectorBase/`), each Web Mercator tile painted
|
||||
* from the style at 256 px.
|
||||
*/
|
||||
import * as Cesium from 'cesium';
|
||||
import { paintVectorTile } from '../vectorBase/index.js';
|
||||
|
||||
/** The tile size vector base tiles are painted at, pixels. */
|
||||
export const VECTOR_TILE_PX = 256;
|
||||
|
||||
/** The deepest level painted; deeper, Cesium draws this level's tiles. */
|
||||
export const VECTOR_MAX_LEVEL = 20;
|
||||
|
||||
/**
|
||||
* A Cesium imagery provider painting a loaded style's tiles.
|
||||
* @param {Awaited<ReturnType<typeof import('../vectorBase/index.js').loadVectorStyle>>} style
|
||||
*/
|
||||
export function vectorBaseProvider(style) {
|
||||
const tilingScheme = new Cesium.WebMercatorTilingScheme();
|
||||
return {
|
||||
tilingScheme,
|
||||
tileWidth: VECTOR_TILE_PX,
|
||||
tileHeight: VECTOR_TILE_PX,
|
||||
minimumLevel: 0,
|
||||
maximumLevel: VECTOR_MAX_LEVEL,
|
||||
rectangle: tilingScheme.rectangle,
|
||||
credit: undefined,
|
||||
errorEvent: new Cesium.Event(),
|
||||
hasAlphaChannel: false,
|
||||
tileDiscardPolicy: undefined,
|
||||
proxy: undefined,
|
||||
getTileCredits: () => undefined,
|
||||
pickFeatures: () => undefined,
|
||||
requestImage: (x, y, level) =>
|
||||
paintVectorTile(style, level, x, y, { size: VECTOR_TILE_PX }),
|
||||
};
|
||||
}
|
||||
|
||||
/** A TileJSON attribution (markup) as plain text. */
|
||||
export function attributionText(html) {
|
||||
return String(html)
|
||||
.replace(/<[^>]*>/g, ' ')
|
||||
.replace(/©/gi, '©')
|
||||
.replace(/&/gi, '&')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
}
|
||||
Reference in new issue
Block a user