mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
Cesium switches the map stacks through its globe port, as any renderer does, rather than through a map engine of its own. Every route keeps its behaviour: - Google 3D turned off is kept hidden, and shown again without loading it anew; the key route's tiles take clamped marks, as the token routes' do. - Esri goes to its deepest level (23); its "Map data not yet available" picture is a missing tile, so the parent's imagery stays. - Cesium ion's world imagery is Bing over HTTPS on any page, with ion's credits; a token ion refuses refuses the switch, as before. - Keyless terrain that does not answer is the flat ellipsoid, tried again behind it; world terrain asks ion first, as before. - window.__godsEyeView.tileset is the Cesium photoreal tileset.
83 lines
2.8 KiB
JavaScript
83 lines
2.8 KiB
JavaScript
import { MAP_STACKS } from './catalog.js';
|
|
import { photorealUnavailableReason } from './availability.js';
|
|
import { keySetupRequirementEnvVars } from '../keySetupCore.mjs';
|
|
import { t } from '../i18n/index.js';
|
|
import { mapEngine } from './engine.js';
|
|
import { ESRI_ATTRIBUTION_HTML } from './attribution.js';
|
|
|
|
/**
|
|
* Select sources and setup guidance without putting provider branches in the
|
|
* controller. Each source builds its imagery and terrain through the
|
|
* `engine` given (the scene's map engine, `engine.js`), else the one the
|
|
* adapter provided for viewers with no renderer, when it is first shown.
|
|
*/
|
|
export function createDefaultMapSources({
|
|
googleTileset = null,
|
|
cesiumToken = '',
|
|
googleApiKey = '',
|
|
engine = null,
|
|
} = {}) {
|
|
const engineOf = () => engine ?? mapEngine();
|
|
const ionToken = String(cesiumToken || '').trim();
|
|
const hasIon = Boolean(ionToken);
|
|
const hasGoogle = Boolean(String(googleApiKey || '').trim());
|
|
const terrain = {
|
|
id: hasIon ? 'world' : 'keyless',
|
|
create: hasIon
|
|
? (request) => engineOf().terrain.world(ionToken, request)
|
|
: (request) => engineOf().terrain.keyless(request),
|
|
};
|
|
return {
|
|
defaultId: googleTileset ? 'photoreal' : 'esri-imagery',
|
|
unknownId: 'photoreal',
|
|
recoveryId: googleTileset ? 'photoreal' : null,
|
|
state: { hasCesiumIonToken: hasIon },
|
|
sources: MAP_STACKS.map((descriptor) => {
|
|
const common = {
|
|
descriptor,
|
|
available: !descriptor.requiresIon || hasIon,
|
|
// Read when shown, so it follows the locale.
|
|
unavailableReason: descriptor.requiresIon
|
|
? () =>
|
|
t('Needs {envVars} — add it in Provider Settings', {
|
|
envVars: keySetupRequirementEnvVars('cesium-ion'),
|
|
})
|
|
: null,
|
|
};
|
|
if (descriptor.kind === 'photoreal')
|
|
return {
|
|
...common,
|
|
available: Boolean(googleTileset),
|
|
unavailableReason: () =>
|
|
photorealUnavailableReason(hasIon || hasGoogle),
|
|
tileset: googleTileset,
|
|
};
|
|
const imagery =
|
|
descriptor.kind === 'ion'
|
|
? () => engineOf().imagery.ion(descriptor.style, ionToken)
|
|
: descriptor.id === 'osm'
|
|
? () => engineOf().imagery.osm()
|
|
: () => engineOf().imagery.esri();
|
|
return {
|
|
...common,
|
|
imagery,
|
|
terrain,
|
|
...(descriptor.id === 'esri-imagery'
|
|
? {
|
|
credit: ESRI_ATTRIBUTION_HTML,
|
|
constructionFallback: {
|
|
id: 'osm',
|
|
message: 'Esri Satellite is unavailable; using OSM',
|
|
},
|
|
tileFailureFallback: {
|
|
id: 'osm',
|
|
threshold: 2,
|
|
message: 'Esri Satellite tile requests failed; using OSM',
|
|
},
|
|
}
|
|
: {}),
|
|
};
|
|
}),
|
|
};
|
|
}
|