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

@@ -3,7 +3,7 @@
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { describe, it } from 'node:test';
import { planTile, type CountryTiles } from './open-satellite';
import { fallbackNeeded, planTile, type CountryTiles } from './open-satellite';
const fixtures = new URL('../../../test/fixtures/satellite-countries/', import.meta.url);
@@ -96,3 +96,31 @@ describe('planTile', () => {
assert.deepEqual(asked, [`12/${x}/${y}`]);
});
});
describe('fallbackNeeded', () => {
it('is not needed up to zoom 12, where the imagery of the whole world is', async () => {
const { asked, tiles } = savedTiles();
// a tile of 512 pixels at zoom 11 covers four tiles of the open imagery at zoom 12
assert.equal(await fallbackNeeded(...tile(-0.12, 51.5, 11), tiles), false);
assert.deepEqual(asked, []);
});
it('is needed far from every country, without asking for countries', async () => {
const { asked, tiles } = savedTiles();
assert.equal(await fallbackNeeded(...tile(-0.12, 51.5, 13), tiles), true);
assert.deepEqual(asked, []);
});
it('is not needed where the countries cover its four tiles', async () => {
const { tiles } = savedTiles();
// Paris, and Wattrelos between France and Belgium
assert.equal(await fallbackNeeded(...tile(2.35, 48.85, 14), tiles), false);
assert.equal(await fallbackNeeded(12, 2083, 1375, tiles), false);
});
it('is needed where one of its four tiles is outside the countries', async () => {
const { tiles } = savedTiles();
// Basel, with a tile entirely in Germany
assert.equal(await fallbackNeeded(12, 2134, 1430, tiles), true);
});
});