diff --git a/website/src/lib/components/map/open-satellite.test.ts b/website/src/lib/components/map/open-satellite.test.ts index c1a867aa6..4f5455430 100644 --- a/website/src/lib/components/map/open-satellite.test.ts +++ b/website/src/lib/components/map/open-satellite.test.ts @@ -26,16 +26,21 @@ describe('planTile', () => { assert.deepEqual(await plan(21.01, 52.23, 16), { parts: ['pl:full'], fallback: false }); }); + it('takes every tile up to zoom 12 from the imagery of the whole world', async () => { + assert.deepEqual(await plan(2.35, 48.85, 12), { parts: [], fallback: true }); + assert.deepEqual(await plan(7.589, 47.5895, 12), { parts: [], fallback: true }); + }); + it('takes a tile outside every country from the fallback', async () => { assert.deepEqual(await plan(-0.12, 51.5, 14), { parts: [], fallback: true }); // Germany, which is not in the patchwork assert.deepEqual(await plan(9.73, 52.37, 14), { parts: [], fallback: true }); - assert.deepEqual(await plan(-30, 40, 10), { parts: [], fallback: true }); + assert.deepEqual(await plan(-30, 40, 13), { parts: [], fallback: true }); }); it('puts the countries of a border tile together, over the fallback where none is', async () => { // Menton: France and Italy, which is not in the patchwork - assert.deepEqual(await plan(7.5, 43.8, 12), { + assert.deepEqual(await plan(7.5, 43.78, 13), { parts: ['fr:partial'], fallback: true, }); @@ -50,8 +55,4 @@ describe('planTile', () => { fallback: false, }); }); - - it('does not take a tile covering several countries from their agencies', async () => { - assert.deepEqual(await plan(2.35, 48.85, 6), { parts: [], fallback: true }); - }); }); diff --git a/website/src/lib/components/map/open-satellite.ts b/website/src/lib/components/map/open-satellite.ts index 80cd3293d..ed74ae3e5 100644 --- a/website/src/lib/components/map/open-satellite.ts +++ b/website/src/lib/components/map/open-satellite.ts @@ -15,8 +15,6 @@ type ImagerySource = { /** Key of the coverage in satellite-coverage.json */ id: string; url: TileUrl; - /** Below it, a tile spans too many sources and the fallback is used. */ - minzoom: number; /** Above it, the tile of this zoom level is scaled up. */ maxzoom: number; }; @@ -26,6 +24,16 @@ const xyz = (z, x, y) => template.replace('{z}', String(z)).replace('{x}', String(x)).replace('{y}', String(y)); +const ignOrthophotos = xyz( + 'https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ORTHOIMAGERY.ORTHOPHOTOS&STYLE=normal&FORMAT=image/jpeg&TILEMATRIXSET=PM&TILEMATRIX={z}&TILECOL={x}&TILEROW={y}' +); + +/** + * Up to zoom 12, IGN's orthophotos cover the whole world with a mosaic of satellite images: all + * tiles come from it there, and the national sources and the commercial fallback only above. + */ +const world: ImagerySource = { id: 'world', url: ignOrthophotos, maxzoom: 12 }; + /** In order of priority, the first one covering a point is used. */ const sources: ImagerySource[] = [ { @@ -33,15 +41,11 @@ const sources: ImagerySource[] = [ url: xyz( 'https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.swissimage/default/current/3857/{z}/{x}/{y}.jpeg' ), - minzoom: 8, maxzoom: 20, }, { id: 'fr', - url: xyz( - 'https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ORTHOIMAGERY.ORTHOPHOTOS&STYLE=normal&FORMAT=image/jpeg&TILEMATRIXSET=PM&TILEMATRIX={z}&TILECOL={x}&TILEROW={y}' - ), - minzoom: 8, + url: ignOrthophotos, maxzoom: 19, }, { @@ -49,7 +53,6 @@ const sources: ImagerySource[] = [ url: xyz( 'https://www.ign.es/wmts/pnoa-ma?layer=OI.OrthoimageCoverage&style=default&tilematrixset=GoogleMapsCompatible&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/jpeg&TileMatrix={z}&TileCol={x}&TileRow={y}' ), - minzoom: 8, maxzoom: 19, }, { @@ -57,7 +60,6 @@ const sources: ImagerySource[] = [ url: xyz( 'https://mapsneu.wien.gv.at/basemap/bmaporthofoto30cm/normal/google3857/{z}/{y}/{x}.jpeg' ), - minzoom: 8, maxzoom: 19, }, { @@ -65,7 +67,6 @@ const sources: ImagerySource[] = [ url: xyz( 'https://service.pdok.nl/hwh/luchtfotorgb/wmts/v1_0/Actueel_orthoHR/EPSG:3857/{z}/{x}/{y}.jpeg' ), - minzoom: 8, maxzoom: 19, }, { @@ -73,7 +74,6 @@ const sources: ImagerySource[] = [ url: xyz( 'https://wmts1.geoportail.lu/opendata/wmts/ortho_latest/GLOBAL_WEBMERCATOR_4_V3/{z}/{x}/{y}.jpeg' ), - minzoom: 8, maxzoom: 19, }, { @@ -81,7 +81,6 @@ const sources: ImagerySource[] = [ url: xyz( 'https://ags.cuzk.gov.cz/arcgis1/rest/services/ORTOFOTO_WM/MapServer/tile/{z}/{y}/{x}' ), - minzoom: 8, maxzoom: 19, }, { @@ -89,7 +88,6 @@ const sources: ImagerySource[] = [ url: xyz( 'https://wmts.ngi.be/inspire/ortho/1.0.0/orthoimage_coverage/default/3857/latest/{z}/{y}/{x}.png' ), - minzoom: 8, maxzoom: 19, }, { @@ -97,7 +95,6 @@ const sources: ImagerySource[] = [ url: xyz( 'https://mapy.geoportal.gov.pl/wss/service/PZGIK/ORTO/WMTS/StandardResolution?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ORTOFOTOMAPA&STYLE=default&FORMAT=image/jpeg&TILEMATRIXSET=EPSG:3857&TILEMATRIX=EPSG:3857:{z}&TILEROW={y}&TILECOL={x}' ), - minzoom: 8, maxzoom: 19, }, ]; @@ -357,12 +354,12 @@ export async function planTile( x: number, y: number ): Promise<{ parts: TilePart[]; fallback: boolean }> { + if (z <= world.maxzoom) return { parts: [], fallback: true }; const n = 2 ** z; const rect: Rect = [x / n, y / n, (x + 1) / n, (y + 1) / n]; const coverageBySource = await getCoverages(); const parts: TilePart[] = []; for (const source of sources) { - if (z < source.minzoom) continue; const relation = relate(coverageBySource.get(source.id)!, rect); if (relation.relation === 'full') { return { parts: [{ ...relation, source }], fallback: false }; @@ -377,8 +374,7 @@ export function maptilerSource(maptilerKey: string): ImagerySource { return { id: 'fallback', url: xyz(`https://api.maptiler.com/tiles/satellite-v2/{z}/{x}/{y}.jpg?key=${maptilerKey}`), - minzoom: 0, - maxzoom: 20, + maxzoom: 18, }; } @@ -386,9 +382,10 @@ export async function loadTile( z: number, x: number, y: number, - fallback: ImagerySource, + commercialFallback: ImagerySource, signal: AbortSignal ): Promise { + const fallback = z <= world.maxzoom ? world : commercialFallback; const plan = await planTile(z, x, y); const { parts } = plan;