mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-12-06 10:34:13 +00:00
more national/regional imagery
This commit is contained in:
1 parent
22a269a6dc
commit
2365195bcb
23 files changed
+335
-27
No files matched your search
@@ -119,13 +119,124 @@ describe('planTile', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('leaves the islands of Portugal to the fallback', async () => {
|
it('takes Slovenia, Slovakia and Estonia from their agencies', async () => {
|
||||||
const { asked, tiles } = savedTiles();
|
const { tiles } = savedTiles();
|
||||||
// Funchal, on Madeira
|
// Ljubljana
|
||||||
assert.deepEqual(await plan(tile(-16.91, 32.65, 15), tiles), { parts: [], fallback: true });
|
assert.deepEqual(await plan(tile(14.506, 46.051, 16), tiles), {
|
||||||
|
parts: ['SI:full'],
|
||||||
|
fallback: false,
|
||||||
|
});
|
||||||
|
// Bad Radkersburg and Gornja Radgona, on the border of Austria and Slovenia
|
||||||
|
assert.deepEqual(await plan(tile(15.99, 46.685, 13), tiles), {
|
||||||
|
parts: ['AT:partial', 'SI:partial'],
|
||||||
|
fallback: false,
|
||||||
|
});
|
||||||
|
// Bratislava, on the border of Austria
|
||||||
|
assert.deepEqual(await plan(tile(17.05, 48.14, 13), tiles), {
|
||||||
|
parts: ['AT:partial', 'SK:partial'],
|
||||||
|
fallback: false,
|
||||||
|
});
|
||||||
|
// Valga, with Latvia, which is not in the patchwork, to the south
|
||||||
|
assert.deepEqual(await plan(tile(26.03, 57.777, 13), tiles), {
|
||||||
|
parts: ['EE:partial'],
|
||||||
|
fallback: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('takes Liechtenstein from the agency of Switzerland, with it as one', async () => {
|
||||||
|
const { tiles } = savedTiles();
|
||||||
|
// Vaduz
|
||||||
|
assert.deepEqual(await plan(tile(9.5215, 47.141, 16), tiles), {
|
||||||
|
parts: ['LI:full'],
|
||||||
|
fallback: false,
|
||||||
|
});
|
||||||
|
// the Rhine, on the border of Switzerland
|
||||||
|
const { parts, fallback } = await planTile(...tile(9.51, 47.141, 14), tiles);
|
||||||
|
assert.deepEqual(
|
||||||
|
parts.map((part) => part.relation),
|
||||||
|
['full']
|
||||||
|
);
|
||||||
|
assert.equal(fallback, false);
|
||||||
|
// near Schaanwald, on the border of Austria
|
||||||
|
const border = await plan([14, 8628, 5748], tiles);
|
||||||
|
assert.deepEqual(border, { parts: ['AT:partial', 'LI:partial'], fallback: false });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('takes Monaco from the agency of France, with it as one', async () => {
|
||||||
|
const { tiles } = savedTiles();
|
||||||
|
// the Casino
|
||||||
|
assert.deepEqual(await plan(tile(7.4281, 43.7392, 18), tiles), {
|
||||||
|
parts: ['MC:full'],
|
||||||
|
fallback: false,
|
||||||
|
});
|
||||||
|
// La Condamine, on the border of France
|
||||||
|
const { parts, fallback } = await planTile(...tile(7.4165, 43.7365, 17), tiles);
|
||||||
|
assert.deepEqual(
|
||||||
|
parts.map((part) => part.relation),
|
||||||
|
['full']
|
||||||
|
);
|
||||||
|
assert.equal(fallback, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('takes Madeira from its own agency, and leaves the Azores to the fallback', async () => {
|
||||||
|
const { tiles } = savedTiles();
|
||||||
|
// Funchal
|
||||||
|
assert.deepEqual(await plan(tile(-16.91, 32.65, 16), tiles), {
|
||||||
|
parts: ['PT-30:full'],
|
||||||
|
fallback: false,
|
||||||
|
});
|
||||||
|
const { asked, tiles: none } = savedTiles();
|
||||||
|
// Ponta Delgada
|
||||||
|
assert.deepEqual(await plan(tile(-25.67, 37.74, 15), none), { parts: [], fallback: true });
|
||||||
assert.deepEqual(asked, []);
|
assert.deepEqual(asked, []);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('takes the regions of Italy with imagery of the same year as one', async () => {
|
||||||
|
const { tiles } = savedTiles();
|
||||||
|
const years = async (...at: [number, number, number]) => {
|
||||||
|
const [z, x, y] = tile(...at);
|
||||||
|
const { parts, fallback } = await planTile(z, x, y, tiles);
|
||||||
|
return {
|
||||||
|
parts: parts
|
||||||
|
.map((p) => `${p.source.url(z, x, y).match(/AgEA_(\d+)/)?.[1]}:${p.relation}`)
|
||||||
|
.sort(),
|
||||||
|
fallback,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
// Orte, in Lazio, and the Umbrian side of the Tiber
|
||||||
|
assert.deepEqual(await years(12.386, 42.46, 13), { parts: ['2023:full'], fallback: false });
|
||||||
|
// the Vatican and Rome
|
||||||
|
assert.deepEqual(await years(12.4534, 41.9022, 14), {
|
||||||
|
parts: ['2023:full'],
|
||||||
|
fallback: false,
|
||||||
|
});
|
||||||
|
// Piacenza, in Emilia-Romagna, and Lombardy, north of the Po
|
||||||
|
assert.deepEqual(await years(9.69, 45.06, 13), {
|
||||||
|
parts: ['2023:partial', '2024:partial'],
|
||||||
|
fallback: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('takes Basilicata from its agency above the last zoom level of its imagery', async () => {
|
||||||
|
const { tiles } = savedTiles();
|
||||||
|
// Potenza
|
||||||
|
assert.deepEqual(await plan(tile(15.805, 40.64, 18), tiles), {
|
||||||
|
parts: ['IT-77:full'],
|
||||||
|
fallback: false,
|
||||||
|
});
|
||||||
|
// on the border of Campania, whose imagery is closer: as one only up to there
|
||||||
|
const border = [15.53345, 40.57318] as const;
|
||||||
|
const { parts } = await planTile(...tile(...border, 16), tiles);
|
||||||
|
assert.deepEqual(
|
||||||
|
parts.map((part) => part.relation),
|
||||||
|
['full']
|
||||||
|
);
|
||||||
|
assert.deepEqual(await plan(tile(...border, 17), tiles), {
|
||||||
|
parts: ['IT-72:partial', 'IT-77:partial'],
|
||||||
|
fallback: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('takes New Zealand from its agency, on both sides of the 180th meridian', async () => {
|
it('takes New Zealand from its agency, on both sides of the 180th meridian', async () => {
|
||||||
const { tiles } = savedTiles();
|
const { tiles } = savedTiles();
|
||||||
// New Plymouth, inland and on the coast, with the fallback at sea
|
// New Plymouth, inland and on the coast, with the fallback at sea
|
||||||
@@ -144,6 +255,39 @@ describe('planTile', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('takes Japan from its agency', async () => {
|
||||||
|
const { tiles } = savedTiles();
|
||||||
|
// Matsumoto
|
||||||
|
assert.deepEqual(await plan(tile(137.97, 36.235, 13), tiles), {
|
||||||
|
parts: ['JP:full'],
|
||||||
|
fallback: false,
|
||||||
|
});
|
||||||
|
// the Shiretoko peninsula, with the fallback at sea
|
||||||
|
assert.deepEqual(await plan(tile(145.19, 44.02, 14), tiles), {
|
||||||
|
parts: ['JP:partial'],
|
||||||
|
fallback: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('takes Taiwan from its agency, without the islands that have no imagery', async () => {
|
||||||
|
const { tiles } = savedTiles();
|
||||||
|
// Yushan
|
||||||
|
assert.deepEqual(await plan(tile(120.957, 23.47, 14), tiles), {
|
||||||
|
parts: ['TW:full'],
|
||||||
|
fallback: false,
|
||||||
|
});
|
||||||
|
// Kinmen, with the fallback at sea
|
||||||
|
assert.deepEqual(await plan(tile(118.29, 24.43, 13), tiles), {
|
||||||
|
parts: ['TW:partial'],
|
||||||
|
fallback: true,
|
||||||
|
});
|
||||||
|
// Matsu
|
||||||
|
assert.deepEqual(await plan(tile(119.93, 26.155, 14), tiles), {
|
||||||
|
parts: [],
|
||||||
|
fallback: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('takes the states of the United States with the same imagery as one', async () => {
|
it('takes the states of the United States with the same imagery as one', async () => {
|
||||||
const { tiles } = savedTiles();
|
const { tiles } = savedTiles();
|
||||||
// Kansas City, in Kansas and Missouri, both from the NAIP
|
// Kansas City, in Kansas and Missouri, both from the NAIP
|
||||||
@@ -162,15 +306,35 @@ describe('planTile', () => {
|
|||||||
parts: ['US-DC:full'],
|
parts: ['US-DC:full'],
|
||||||
fallback: false,
|
fallback: false,
|
||||||
});
|
});
|
||||||
// Portland, and the Columbia, with Washington, which is not in the patchwork, to the north
|
// Portland, and the Columbia, with Washington to the north
|
||||||
assert.deepEqual(await plan(tile(-122.68, 45.59, 16), tiles), {
|
assert.deepEqual(await plan(tile(-122.68, 45.59, 16), tiles), {
|
||||||
parts: ['US-OR:full'],
|
parts: ['US-OR:full'],
|
||||||
fallback: false,
|
fallback: false,
|
||||||
});
|
});
|
||||||
assert.deepEqual(await plan([13, 1305, 2927], tiles), {
|
assert.deepEqual(await plan([13, 1305, 2927], tiles), {
|
||||||
parts: ['US-OR:partial'],
|
parts: ['US-OR:partial', 'US-WA:partial'],
|
||||||
|
fallback: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('takes the states missing from the server of the USDA from that of GeoPlatform', async () => {
|
||||||
|
const { tiles } = savedTiles();
|
||||||
|
// Honolulu, with the fallback at sea
|
||||||
|
const honolulu = tile(-157.858, 21.307, 16);
|
||||||
|
assert.deepEqual(await plan(honolulu, tiles), { parts: ['US-HI:full'], fallback: false });
|
||||||
|
const [part] = (await planTile(...honolulu, tiles)).parts;
|
||||||
|
assert.match(part.source.url(...honolulu), /^https:\/\/imagery\.geoplatform\.gov\//);
|
||||||
|
assert.deepEqual(await plan(tile(-157.87, 21.29, 13), tiles), {
|
||||||
|
parts: ['US-HI:partial'],
|
||||||
fallback: true,
|
fallback: true,
|
||||||
});
|
});
|
||||||
|
// Four Corners, with Arizona and Colorado from there, and New Mexico and Utah from the USDA
|
||||||
|
const { parts, fallback } = await planTile(...tile(-109.0452, 36.999, 14), tiles);
|
||||||
|
assert.deepEqual(
|
||||||
|
parts.map((p) => p.relation),
|
||||||
|
['partial', 'partial']
|
||||||
|
);
|
||||||
|
assert.equal(fallback, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('asks for a tile of the countries once for all the tiles of imagery inside it', async () => {
|
it('asks for a tile of the countries once for all the tiles of imagery inside it', async () => {
|
||||||
|
|||||||
@@ -17,13 +17,15 @@ const OPEN_SATELLITE_PROTOCOL = 'opensat';
|
|||||||
type TileUrl = (z: number, x: number, y: number) => string;
|
type TileUrl = (z: number, x: number, y: number) => string;
|
||||||
|
|
||||||
type ImagerySource = {
|
type ImagerySource = {
|
||||||
/** ISO code of the country, or of its state, in the tileset of the countries */
|
/** ISO code of the country, or of its part, in the tileset of the countries */
|
||||||
id: string;
|
id: string;
|
||||||
/** Its credit, shown while its imagery is in view. */
|
/** Its credit, shown while its imagery is in view. */
|
||||||
attribution: string;
|
attribution: string;
|
||||||
url: TileUrl;
|
url: TileUrl;
|
||||||
/** Above it, the tile of this zoom level is scaled up. */
|
/** Above it, the tile of this zoom level is scaled up. */
|
||||||
maxzoom: number;
|
maxzoom: number;
|
||||||
|
/** Below it, the tiles of this zoom level are put together. */
|
||||||
|
minzoom?: number;
|
||||||
/**
|
/**
|
||||||
* Its server only answers pages on https: elsewhere, such as in the desktop app, the country
|
* Its server only answers pages on https: elsewhere, such as in the desktop app, the country
|
||||||
* is left to the fallback.
|
* is left to the fallback.
|
||||||
@@ -93,22 +95,63 @@ const naipStates = [
|
|||||||
'UT', 'VT', 'WI', 'WV', 'WY',
|
'UT', 'VT', 'WI', 'WV', 'WY',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For the states missing from it, the NAIP from the Forest Service and GeoPlatform, which is
|
||||||
|
* slower.
|
||||||
|
*/
|
||||||
|
const naipPlus = arcgis(
|
||||||
|
'https://imagery.geoplatform.gov/iipp/rest/services/NAIP/NAIP_plus/ImageServer'
|
||||||
|
);
|
||||||
|
const naipPlusStates = ['AZ', 'CO', 'DE', 'HI', 'WA'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The regions of Italy, San Marino and the Vatican, by the year of their imagery from AGEA: each
|
||||||
|
* is covered by a single one.
|
||||||
|
*/
|
||||||
|
// prettier-ignore
|
||||||
|
const ageaRegions = {
|
||||||
|
// Liguria, Tuscany, Marche, Abruzzo, Puglia, Sicily and Sardinia
|
||||||
|
2022: ['IT-42', 'IT-52', 'IT-57', 'IT-65', 'IT-75', 'IT-82', 'IT-88'],
|
||||||
|
// Trentino-South Tyrol, Friuli-Venezia Giulia, Emilia-Romagna, Umbria, Lazio, Campania and
|
||||||
|
// Basilicata
|
||||||
|
2023: ['IT-32', 'IT-36', 'IT-45', 'IT-55', 'IT-62', 'IT-72', 'IT-77', 'SM', 'VA'],
|
||||||
|
// Piedmont, Aosta Valley, Lombardy, Veneto, Molise and Calabria
|
||||||
|
2024: ['IT-21', 'IT-23', 'IT-25', 'IT-34', 'IT-67', 'IT-78'],
|
||||||
|
};
|
||||||
|
|
||||||
|
const agea = Object.entries(ageaRegions).flatMap(([year, regions]): ImagerySource[] => {
|
||||||
|
const url = xyz(
|
||||||
|
`https://geoportale.agea.gov.it/image/rest/services/AgEA/Ortofoto_AgEA_${year}/ImageServer/tile/{z}/{y}/{x}`
|
||||||
|
);
|
||||||
|
return regions.map((id) => ({
|
||||||
|
id,
|
||||||
|
attribution:
|
||||||
|
'© <a href="https://geoportale.agea.gov.it/legal-notes" target="_blank">AGEA CC BY 4.0</a>',
|
||||||
|
url,
|
||||||
|
// the images of Basilicata stop at zoom 16
|
||||||
|
maxzoom: id === 'IT-77' ? 16 : 18,
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
const swissimage = xyz(
|
||||||
|
'https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.swissimage/default/current/3857/{z}/{x}/{y}.jpeg'
|
||||||
|
);
|
||||||
|
|
||||||
/** In order of priority, the first one covering a point is used. */
|
/** In order of priority, the first one covering a point is used. */
|
||||||
const sources: ImagerySource[] = [
|
const sources: ImagerySource[] = [
|
||||||
{
|
// Liechtenstein is in the imagery of Switzerland
|
||||||
id: 'CH',
|
...['CH', 'LI'].map((id) => ({
|
||||||
|
id,
|
||||||
attribution: '<a href="https://www.swisstopo.admin.ch/" target="_blank">swisstopo</a>',
|
attribution: '<a href="https://www.swisstopo.admin.ch/" target="_blank">swisstopo</a>',
|
||||||
url: xyz(
|
url: swissimage,
|
||||||
'https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.swissimage/default/current/3857/{z}/{x}/{y}.jpeg'
|
|
||||||
),
|
|
||||||
maxzoom: 20,
|
maxzoom: 20,
|
||||||
},
|
})),
|
||||||
{
|
...['FR', 'MC'].map((id) => ({
|
||||||
id: 'FR',
|
id,
|
||||||
attribution: ignAttribution,
|
attribution: ignAttribution,
|
||||||
url: ignOrthophotos,
|
url: ignOrthophotos,
|
||||||
maxzoom: 19,
|
maxzoom: 19,
|
||||||
},
|
})),
|
||||||
{
|
{
|
||||||
id: 'ES',
|
id: 'ES',
|
||||||
attribution: 'PNOA © <a href="https://www.ign.es/" target="_blank">IGN España</a>',
|
attribution: 'PNOA © <a href="https://www.ign.es/" target="_blank">IGN España</a>',
|
||||||
@@ -166,7 +209,7 @@ const sources: ImagerySource[] = [
|
|||||||
maxzoom: 19,
|
maxzoom: 19,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// mainland Portugal only, as in the tileset of the countries
|
// mainland Portugal only, without its islands
|
||||||
id: 'PT',
|
id: 'PT',
|
||||||
attribution: '<a href="https://www.dgterritorio.gov.pt/" target="_blank">DGT</a>',
|
attribution: '<a href="https://www.dgterritorio.gov.pt/" target="_blank">DGT</a>',
|
||||||
url: wms(
|
url: wms(
|
||||||
@@ -176,6 +219,17 @@ const sources: ImagerySource[] = [
|
|||||||
),
|
),
|
||||||
maxzoom: 19,
|
maxzoom: 19,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// Madeira
|
||||||
|
id: 'PT-30',
|
||||||
|
attribution:
|
||||||
|
'<a href="https://irig.madeira.gov.pt/" target="_blank">DROTE, iRIG-Madeira</a>',
|
||||||
|
url: wms(
|
||||||
|
'https://irig-sig.madeira.gov.pt/ows/pg/qwc_config/DIR_orto_mosaico?LAYERS=Ortos&FORMAT=image/jpeg'
|
||||||
|
),
|
||||||
|
maxzoom: 20,
|
||||||
|
},
|
||||||
|
...agea,
|
||||||
{
|
{
|
||||||
id: 'DK',
|
id: 'DK',
|
||||||
attribution:
|
attribution:
|
||||||
@@ -185,6 +239,33 @@ const sources: ImagerySource[] = [
|
|||||||
),
|
),
|
||||||
maxzoom: 20,
|
maxzoom: 20,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'SI',
|
||||||
|
attribution:
|
||||||
|
'<a href="https://www.e-prostor.gov.si/" target="_blank">Geodetska uprava Republike Slovenije</a>',
|
||||||
|
url: wms(
|
||||||
|
'https://ipi.eprostor.gov.si/wms-si-gurs-dts/ows?LAYERS=SI.GURS.ZPDZ:DOF025_3857&FORMAT=image/jpeg'
|
||||||
|
),
|
||||||
|
maxzoom: 19,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'SK',
|
||||||
|
attribution: '© <a href="https://www.geoportal.sk/" target="_blank">GKÚ, NLC</a>',
|
||||||
|
url: wms(
|
||||||
|
'https://zbgisws.skgeodesy.sk/zbgis_ortofoto_wms/service.svc/get?LAYERS=1&FORMAT=image/jpeg'
|
||||||
|
),
|
||||||
|
maxzoom: 19,
|
||||||
|
httpsOnly: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'EE',
|
||||||
|
attribution:
|
||||||
|
'<a href="https://geoportaal.maaamet.ee/" target="_blank">Republic of Estonia Land and Spatial Development Board</a>',
|
||||||
|
// its rows are counted from the south
|
||||||
|
url: (z, x, y) =>
|
||||||
|
`https://tiles.maaamet.ee/tm/tms/1.0.0/foto@GMC/${z}/${x}/${2 ** z - 1 - y}.png`,
|
||||||
|
maxzoom: 18,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'NZ',
|
id: 'NZ',
|
||||||
attribution:
|
attribution:
|
||||||
@@ -194,6 +275,24 @@ const sources: ImagerySource[] = [
|
|||||||
),
|
),
|
||||||
maxzoom: 20,
|
maxzoom: 20,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'JP',
|
||||||
|
attribution:
|
||||||
|
'<a href="https://maps.gsi.go.jp/development/ichiran.html" target="_blank">国土地理院</a>',
|
||||||
|
url: xyz('https://cyberjapandata.gsi.go.jp/xyz/seamlessphoto/{z}/{x}/{y}.jpg'),
|
||||||
|
// satellite images below
|
||||||
|
minzoom: 14,
|
||||||
|
maxzoom: 18,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'TW',
|
||||||
|
attribution:
|
||||||
|
'© <a href="https://maps.nlsc.gov.tw/" target="_blank">內政部國土測繪中心 (NLSC)</a>',
|
||||||
|
url: xyz('https://wmts.nlsc.gov.tw/wmts/PHOTO2/default/GoogleMapsCompatible/{z}/{y}/{x}'),
|
||||||
|
// satellite images with clouds below
|
||||||
|
minzoom: 14,
|
||||||
|
maxzoom: 19,
|
||||||
|
},
|
||||||
// Germany, by state: Baden-Württemberg is left to the fallback, its services often give blank
|
// Germany, by state: Baden-Württemberg is left to the fallback, its services often give blank
|
||||||
// tiles
|
// tiles
|
||||||
{
|
{
|
||||||
@@ -323,13 +422,12 @@ const sources: ImagerySource[] = [
|
|||||||
),
|
),
|
||||||
maxzoom: 19,
|
maxzoom: 19,
|
||||||
},
|
},
|
||||||
// The United States, by state: Alaska, Arizona, Colorado, Delaware, Hawaii and Washington are
|
// The United States, by state: Alaska is left to the fallback. The USDA's server has none of
|
||||||
// left to the fallback. The NAIP has none of Maryland and the District of Columbia, and blurred
|
// Maryland and the District of Columbia, and blurred images of Oregon and Virginia.
|
||||||
// images of Oregon and Virginia.
|
...[...naipStates, ...naipPlusStates].map((state) => ({
|
||||||
...naipStates.map((state) => ({
|
|
||||||
id: `US-${state}`,
|
id: `US-${state}`,
|
||||||
attribution: '<a href="https://naip-usdaonline.hub.arcgis.com/" target="_blank">USDA</a>',
|
attribution: '<a href="https://naip-usdaonline.hub.arcgis.com/" target="_blank">USDA</a>',
|
||||||
url: naip,
|
url: naipPlusStates.includes(state) ? naipPlus : naip,
|
||||||
maxzoom: 18,
|
maxzoom: 18,
|
||||||
holes: true,
|
holes: true,
|
||||||
})),
|
})),
|
||||||
@@ -509,7 +607,12 @@ function countriesInTile(
|
|||||||
const area = rings.reduce((sum, ring) => sum + signedArea(ring), 0);
|
const area = rings.reduce((sum, ring) => sum + signedArea(ring), 0);
|
||||||
// less than a pixel: a polygon of the tile of the countries outside this one
|
// less than a pixel: a polygon of the tile of the countries outside this one
|
||||||
if (area < 1) continue;
|
if (area < 1) continue;
|
||||||
const same = countries.find((country) => country.source.url === source.url);
|
const same = countries.find(
|
||||||
|
(country) =>
|
||||||
|
country.source.url === source.url &&
|
||||||
|
// Basilicata has the imagery of its neighbours, but not as close
|
||||||
|
Math.min(country.source.maxzoom, z) === Math.min(source.maxzoom, z)
|
||||||
|
);
|
||||||
if (same) {
|
if (same) {
|
||||||
same.rings.push(...rings);
|
same.rings.push(...rings);
|
||||||
same.area += area;
|
same.area += area;
|
||||||
@@ -567,19 +670,59 @@ function isPng(bytes: ArrayBuffer) {
|
|||||||
return new Uint8Array(bytes, 0, 1)[0] === 0x89;
|
return new Uint8Array(bytes, 0, 1)[0] === 0x89;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The image of the tile, or of the part of its ancestor at the max zoom of the source. */
|
/**
|
||||||
|
* The image of the tile, or of the part of its ancestor at the max zoom of the source, or of its
|
||||||
|
* descendants at the min zoom.
|
||||||
|
*/
|
||||||
async function fetchImage(
|
async function fetchImage(
|
||||||
{ url, maxzoom, holes }: Pick<ImagerySource, 'url' | 'maxzoom' | 'holes'>,
|
source: Omit<ImagerySource, 'id' | 'attribution'>,
|
||||||
z: number,
|
z: number,
|
||||||
x: number,
|
x: number,
|
||||||
y: number,
|
y: number,
|
||||||
signal: AbortSignal
|
signal: AbortSignal
|
||||||
): Promise<TileImage | null> {
|
): Promise<TileImage | null> {
|
||||||
|
const { url, maxzoom, minzoom = 0, holes } = source;
|
||||||
|
if (z < minzoom) return fetchDescendants(source, minzoom - z, z, x, y, signal);
|
||||||
const d = Math.max(0, z - maxzoom);
|
const d = Math.max(0, z - maxzoom);
|
||||||
const bytes = await fetchBytes(url(z - d, x >> d, y >> d), signal);
|
const bytes = await fetchBytes(url(z - d, x >> d, y >> d), signal);
|
||||||
return bytes && decodeImage(bytes, d, x, y, !!holes && isPng(bytes));
|
return bytes && decodeImage(bytes, d, x, y, !!holes && isPng(bytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The tiles `d` zoom levels above that cover the tile, put together, with holes for those missing. */
|
||||||
|
async function fetchDescendants(
|
||||||
|
source: Omit<ImagerySource, 'id' | 'attribution'>,
|
||||||
|
d: number,
|
||||||
|
z: number,
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
signal: AbortSignal
|
||||||
|
): Promise<TileImage | null> {
|
||||||
|
const n = 2 ** d;
|
||||||
|
const tiles = await Promise.all(
|
||||||
|
Array.from({ length: n * n }, (_, i) =>
|
||||||
|
fetchImage(source, z + d, x * n + (i % n), y * n + Math.floor(i / n), signal)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (tiles.every((tile) => !tile)) return null;
|
||||||
|
const canvas = new OffscreenCanvas(TILE_SIZE * n, TILE_SIZE * n);
|
||||||
|
const context = canvas.getContext('2d')!;
|
||||||
|
tiles.forEach((tile, i) => {
|
||||||
|
if (!tile) return;
|
||||||
|
context.save();
|
||||||
|
context.translate((i % n) * TILE_SIZE, Math.floor(i / n) * TILE_SIZE);
|
||||||
|
drawImage(context, tile);
|
||||||
|
context.restore();
|
||||||
|
tile.image.close();
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
image: canvas.transferToImageBitmap(),
|
||||||
|
sx: 0,
|
||||||
|
sy: 0,
|
||||||
|
size: canvas.width,
|
||||||
|
holes: tiles.some((tile) => !tile || tile.holes),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
async function decodeImage(
|
async function decodeImage(
|
||||||
bytes: ArrayBuffer,
|
bytes: ArrayBuffer,
|
||||||
d: number,
|
d: number,
|
||||||
@@ -677,7 +820,8 @@ export async function loadTile(
|
|||||||
|
|
||||||
let images: (TileImage | null)[];
|
let images: (TileImage | null)[];
|
||||||
const { source, relation } = parts[0];
|
const { source, relation } = parts[0];
|
||||||
if (parts.length === 1 && relation === 'full' && z <= source.maxzoom) {
|
const ownTile = z >= (source.minzoom ?? 0) && z <= source.maxzoom;
|
||||||
|
if (parts.length === 1 && relation === 'full' && ownTile) {
|
||||||
const bytes = await fetchBytes(source.url(z, x, y), signal);
|
const bytes = await fetchBytes(source.url(z, x, y), signal);
|
||||||
const holes = !!bytes && !!source.holes && isPng(bytes);
|
const holes = !!bytes && !!source.holes && isPng(bytes);
|
||||||
// a single tile as it is, without drawing it again
|
// a single tile as it is, without drawing it again
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"zoom":10,"tiles":[316951,316952,316953,316954,316955,316956,316957,316958,317975,317976,317977,317978,317979,317980,317981,317982,318999,319000,319001,319002,319003,319004,319005,319006,319007,320023,320024,320025,320026,320027,320028,320029,320030,320031,321046,321047,321048,321049,321050,321051,321052,321053,321054,321055,322070,322071,322072,322073,322074,322075,322076,322077,322078,322079,323094,323095,323096,323097,323098,323099,323100,323101,323102,323103,323104,323105,324118,324119,324120,324121,324122,324123,324124,324125,324126,324127,325142,325143,325144,325145,325146,325147,325148,325149,325150,325151,325153,326166,326167,326168,326169,326170,326171,326172,326173,326174,326175,326176,326177,326178,326179,327190,327191,327192,327193,327194,327195,327196,327197,327198,327199,327200,327201,327202,327203,328214,328215,328216,328217,328218,328219,328220,328221,328222,328223,328224,328225,328226,328227,328228,329238,329239,329240,329241,329242,329243,329244,329245,329246,329247,329248,329249,329250,329251,329252,330262,330263,330264,330265,330266,330267,330268,330269,330270,330271,330272,330273,330274,330275,330281,330282,330283,331286,331287,331288,331289,331290,331291,331292,331293,331294,331295,331296,331297,331298,331299,331305,331306,331307,332310,332311,332312,332313,332314,332315,332316,332317,332318,332319,332320,332321,332322,332323,332328,332329,332330,332331,332332,332333,332334,332335,332336,332337,332338,332339,332340,332341,332342,332343,332344,332345,332346,332347,332348,332349,332350,332351,332352,332353,332354,332355,332356,333335,333336,333337,333338,333339,333340,333341,333342,333343,333344,333345,333346,333349,333350,333351,333352,333353,333354,333355,333356,333357,333358,333359,333360,333361,333362,333363,333364,333365,333366,333367,333368,333369,333370,333371,333372,333373,333374,333375,333376,333377,333378,333379,333380,334359,334360,334361,334362,334363,334364,334365,334366,334367,334368,334369,334370,334371,334372,334373,334374,334375,334376,334377,334378,334379,334380,334381,334382,334383,334384,334385,334386,334387,334388,334389,334390,334391,334392,334393,334394,334395,334396,334397,334398,334399,334400,334401,334402,334403,334404,335382,335383,335384,335385,335386,335387,335388,335389,335390,335391,335392,335393,335394,335395,335396,335397,335398,335399,335400,335401,335402,335403,335404,335405,335406,335407,335408,335409,335410,335411,335412,335413,335414,335415,335416,335417,335418,335419,335420,335421,335422,335423,335424,335425,335426,335427,335428,336407,336408,336409,336410,336411,336412,336413,336414,336415,336416,336417,336418,336419,336420,336421,336422,336423,336424,336425,336426,336427,336428,336429,336430,336431,336432,336433,336434,336435,336436,336437,336438,336439,336440,336441,336442,336443,336444,336445,336446,336447,336448,336449,336450,336451,336452,337427,337428,337429,337430,337431,337432,337433,337434,337435,337436,337437,337438,337439,337440,337441,337442,337443,337444,337445,337446,337447,337448,337449,337450,337451,337452,337453,337454,337455,337456,337457,337458,337459,337460,337461,337462,337463,337464,337465,337466,337467,337468,337469,337470,337471,337472,337473,337474,337475,337476,338450,338451,338452,338453,338454,338455,338456,338457,338458,338459,338460,338461,338462,338463,338464,338465,338466,338467,338468,338469,338470,338471,338472,338473,338474,338475,338476,338477,338478,338479,338480,338481,338482,338483,338484,338485,338486,338487,338488,338489,338490,338491,338492,338493,338494,338495,338496,338497,338498,338499,338500,339465,339466,339467,339468,339469,339470,339471,339472,339473,339474,339475,339476,339477,339478,339479,339480,339481,339482,339483,339484,339485,339486,339487,339488,339489,339490,339491,339492,339493,339494,339495,339496,339497,339498,339499,339500,339501,339502,339503,339504,339505,339506,339507,339508,339509,339510,339511,339512,339513,339514,339515,339516,339517,339518,339519,339520,339521,339522,339523,339524,340489,340490,340491,340492,340493,340494,340495,340496,340497,340498,340499,340500,340501,340502,340503,340504,340505,340506,340507,340508,340509,340510,340511,340512,340513,340514,340515,340516,340517,340518,340519,340520,340521,340522,340523,340524,340525,340526,340527,340528,340529,340530,340531,340532,340533,340534,340535,340536,340537,340538,340539,340540,340541,340542,340543,340544,340545,340546,340547,340548,341513,341514,341515,341516,341517,341518,341519,341520,341521,341522,341523,341524,341525,341526,341527,341528,341529,341530,341531,341532,341533,341534,341535,341536,341537,341538,341539,341540,341541,341542,341543,341544,341545,341546,341547,341548,341549,341550,341551,341552,341553,341554,341555,341556,341557,341558,341559,341560,341561,341562,341563,341564,341565,341566,341567,341568,341569,341570,341571,341572,342537,342538,342539,342540,342541,342542,342543,342544,342545,342546,342547,342548,342549,342550,342551,342552,342553,342554,342555,342556,342557,342558,342559,342560,342561,34Line truncated
|
{"zoom":10,"tiles":[305738,306754,306755,306756,306757,306758,306759,306760,306761,306762,306763,306764,306765,306766,306767,306768,307778,307779,307780,307781,307782,307783,307784,307785,307786,307787,307788,307789,307790,307791,307792,308802,308803,308804,308805,308806,308807,308808,308809,308810,308811,308812,308813,308814,308815,308816,309822,309823,309824,309825,309826,309827,309828,309829,309830,309831,309832,309833,309834,309835,309836,309837,309838,309839,309840,310846,310847,310848,310849,310850,310851,310852,310853,310854,310855,310856,310857,310858,310859,310860,310861,310862,310863,310864,311870,311871,311872,311873,311874,311875,311876,311877,311878,311879,311880,311881,311882,311883,311884,311885,311886,311887,311888,312894,312895,312896,312897,312898,312899,312900,312901,312902,312903,312904,312905,312906,312907,312908,312909,312910,312911,312912,313917,313918,313919,313920,313921,313922,313923,313924,313925,313926,313927,313928,313929,313930,313931,313932,313933,313934,313935,313936,314942,314943,314944,314945,314946,314947,314948,314949,314950,314951,314952,314953,314954,314955,314956,314957,314958,314959,314960,315966,315967,315968,315969,315970,315971,315972,315973,315974,315975,315976,315977,315978,315979,315980,315981,315982,315983,315984,316951,316952,316953,316954,316955,316956,316957,316958,316990,316994,316995,316996,316997,316998,316999,317000,317001,317002,317003,317004,317005,317006,317007,317008,317975,317976,317977,317978,317979,317980,317981,317982,318018,318019,318020,318021,318022,318023,318024,318025,318026,318027,318028,318029,318030,318031,318032,318999,319000,319001,319002,319003,319004,319005,319006,319007,319042,319043,319044,319045,319046,319047,319048,319049,319050,319051,319052,319053,319054,319055,319056,320023,320024,320025,320026,320027,320028,320029,320030,320031,321046,321047,321048,321049,321050,321051,321052,321053,321054,321055,322070,322071,322072,322073,322074,322075,322076,322077,322078,322079,323094,323095,323096,323097,323098,323099,323100,323101,323102,323103,323104,323105,324118,324119,324120,324121,324122,324123,324124,324125,324126,324127,325142,325143,325144,325145,325146,325147,325148,325149,325150,325151,325153,326166,326167,326168,326169,326170,326171,326172,326173,326174,326175,326176,326177,326178,326179,327190,327191,327192,327193,327194,327195,327196,327197,327198,327199,327200,327201,327202,327203,328214,328215,328216,328217,328218,328219,328220,328221,328222,328223,328224,328225,328226,328227,328228,329238,329239,329240,329241,329242,329243,329244,329245,329246,329247,329248,329249,329250,329251,329252,330262,330263,330264,330265,330266,330267,330268,330269,330270,330271,330272,330273,330274,330275,330281,330282,330283,331286,331287,331288,331289,331290,331291,331292,331293,331294,331295,331296,331297,331298,331299,331305,331306,331307,332310,332311,332312,332313,332314,332315,332316,332317,332318,332319,332320,332321,332322,332323,332328,332329,332330,332331,332332,332333,332334,332335,332336,332337,332338,332339,332340,332341,332342,332343,332344,332345,332346,332347,332348,332349,332350,332351,332352,332353,332354,332355,332356,333335,333336,333337,333338,333339,333340,333341,333342,333343,333344,333345,333346,333349,333350,333351,333352,333353,333354,333355,333356,333357,333358,333359,333360,333361,333362,333363,333364,333365,333366,333367,333368,333369,333370,333371,333372,333373,333374,333375,333376,333377,333378,333379,333380,334359,334360,334361,334362,334363,334364,334365,334366,334367,334368,334369,334370,334371,334372,334373,334374,334375,334376,334377,334378,334379,334380,334381,334382,334383,334384,334385,334386,334387,334388,334389,334390,334391,334392,334393,334394,334395,334396,334397,334398,334399,334400,334401,334402,334403,334404,335382,335383,335384,335385,335386,335387,335388,335389,335390,335391,335392,335393,335394,335395,335396,335397,335398,335399,335400,335401,335402,335403,335404,335405,335406,335407,335408,335409,335410,335411,335412,335413,335414,335415,335416,335417,335418,335419,335420,335421,335422,335423,335424,335425,335426,335427,335428,336407,336408,336409,336410,336411,336412,336413,336414,336415,336416,336417,336418,336419,336420,336421,336422,336423,336424,336425,336426,336427,336428,336429,336430,336431,336432,336433,336434,336435,336436,336437,336438,336439,336440,336441,336442,336443,336444,336445,336446,336447,336448,336449,336450,336451,336452,337427,337428,337429,337430,337431,337432,337433,337434,337435,337436,337437,337438,337439,337440,337441,337442,337443,337444,337445,337446,337447,337448,337449,337450,337451,337452,337453,337454,337455,337456,337457,337458,337459,337460,337461,337462,337463,337464,337465,337466,337467,337468,337469,337470,337471,337472,337473,337474,337475,337476,338450,338451,338452,338453,338454,338455,338456,338457,338458,338459,338460,338461,338462,338463,338464,338465,338466,338467,338468,338469,338470,338471,338472,338473,338474,338475,338476,338477,338478,338479,33Line truncated
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user