split 256px and 512px sources

This commit is contained in:
vcoppe committed 2026-11-29 16:37:22 +01:00
1 parent 4e4142dabc
commit 9372df1c61
4 files changed
+154 -42

No files matched your search

+33 -1
View File
@@ -3,10 +3,11 @@ import assert from 'node:assert/strict';
import { afterEach, beforeEach, describe, it } from 'node:test';
import type { Map as MapLibreMap, StyleSpecification } from 'maplibre-gl';
import { writable } from 'svelte/store';
import { overlays, type LayerTreeType } from '$lib/data/layers';
import { basemaps, overlays, type LayerTreeType } from '$lib/data/layers';
import { engine } from '$lib/engine';
import { settings } from '$lib/state/settings';
import { StyleManager } from './style';
import { openSatelliteAttribution, openSatelliteFallbackAttribution } from './open-satellite';
const URL_A = 'https://example.com/a.json';
const URL_B = 'https://example.com/b.json';
@@ -218,3 +219,34 @@ describe('StyleManager, with the style URL of an extension', () => {
assert.ok(fake.layers.has('tiles'));
});
});
describe('StyleManager, with a basemap of the open satellite imagery', () => {
it('gives its imagery the credits of the agencies, its fallback those of MapTiler, and leaves the other sources alone', async () => {
answerWith({
[basemaps.libertySatellite as string]: {
version: 8,
sources: {
satellite: { type: 'raster', tiles: ['opensat://{z}/{x}/{y}'], tileSize: 256 },
fallback: {
type: 'raster',
tiles: ['opensat-fallback://{z}/{x}/{y}'],
tileSize: 512,
},
other: { type: 'raster', tiles: ['https://other/{z}/{x}/{y}'] },
},
layers: [{ id: 'satellite', type: 'raster', source: 'satellite' }],
},
});
const manager = new StyleManager(writable<MapLibreMap | null>(null), 'key');
const built = await manager.buildStyle('libertySatellite');
assert.equal(
(built.sources.satellite as { attribution?: string }).attribution,
openSatelliteAttribution
);
assert.equal(
(built.sources.fallback as { attribution?: string }).attribution,
openSatelliteFallbackAttribution
);
assert.equal((built.sources.other as { attribution?: string }).attribution, undefined);
});
});