The backward compatibility system ensures that old tile and terrain provider types are automatically migrated to new provider names. This allows existing projects to continue working seamlessly when provider names change.
sceneProperty (from props)
↓
useOverriddenProperty() - Apply plugin overrides
↓
applyBackwardCompatibility() - Migrate old types to new types
↓
applyFallbacks() - Fallback when no Cesium Ion token
↓
overriddenSceneProperty (passed to consumers)
Note: See FALLBACKS.md for information about the fallback system that runs after backward compatibility.
The backward compatibility logic is implemented in three files:
Contains the core migration logic:
applyBackwardCompatibility()- Main entry point that applies all migrationsmigrateTileType()- Migrates tile typesmigrateTerrainType()- Migrates terrain types
Comprehensive unit tests covering:
- All tile type migrations
- All terrain type migrations
- Edge cases (undefined values, missing fields, etc.)
- Immutability (original data is not modified)
Integration point where backward compatibility is applied:
const [overriddenScenePropertyRaw, overrideSceneProperty] = useOverriddenProperty(sceneProperty);
const overriddenSceneProperty = useMemo(
() => applyBackwardCompatibility(overriddenScenePropertyRaw),
[overriddenScenePropertyRaw],
);| Old Type | New Type | Asset ID | Notes |
|---|---|---|---|
undefined / null |
google_satellite |
- | Default when no type specified |
default |
cesium_ion |
2 | Cesium World Imagery |
default_label |
cesium_ion |
3 | Cesium World Imagery + Labels |
default_road |
cesium_ion |
4 | Cesium World Imagery + Roads |
black_marble |
cesium_ion |
3812 | NASA Black Marble |
stamen_toner |
open_street_map |
- | OpenStreetMap |
esri_world_topo |
open_street_map |
- | OpenStreetMap |
Before migration:
{
"tiles": [
{ "id": "tile-1", "tile_type": "default" },
{ "id": "tile-2", "tile_type": "stamen_toner" },
{ "id": "tile-3", "tile_url": "https://..." }
]
}After migration:
{
"tiles": [
{ "id": "tile-1", "tile_type": "cesium_ion", "cesium_ion_asset_id": 2 },
{ "id": "tile-2", "tile_type": "open_street_map" },
{ "id": "tile-3", "tile_url": "https://...", "tile_type": "google_satellite" }
]
}Note: Tiles without a tile_type field are automatically assigned "google_satellite" as the default.
- Default: If
terrainTypeisundefined,null, or empty AND terrain is enabled (terrain: true), set to"reearth_terrain" - ArcGIS migration: If
terrainTypeis"arcgis", change to"reearth_terrain"
Default terrain type:
// Before
{ "terrain": true }
// After
{ "terrain": true, "terrainType": "reearth_terrain" }ArcGIS migration:
// Before
{ "terrain": true, "terrainType": "arcgis" }
// After
{ "terrain": true, "terrainType": "reearth_terrain" }Run the unit tests:
yarn test backwardCompatibility.test.tsAll 19 tests should pass, covering:
- 9 tests for tile type migrations
- 4 tests for terrain type migrations
- 6 tests for the main
applyBackwardCompatibility()function
To add a new backward compatibility rule:
-
Update the migration function in
backwardCompatibility.ts:case "old_type": return { ...tile, tile_type: "new_type", // Add any additional fields };
-
Add test cases in
backwardCompatibility.test.ts:it('should migrate "old_type" to "new_type"', () => { const tile = { id: "test", tile_type: "old_type" }; const result = migrateTileType(tile); expect(result.tile_type).toBe("new_type"); });
-
Update this documentation with the new migration rule
- Immutability: The original
scenePropertyis never modified. All transformations return new objects. - Performance: Uses
useMemoto avoid re-computing migrations on every render. - Deep cloning: Uses
lodash-es/cloneDeepto ensure nested objects are properly cloned. - Asset ID preservation: If a tile already has a
cesium_ion_asset_id, it won't be overwritten.
The backend also has a corresponding database migration:
260525000715_update_tile_and_terrain_providers.go- Migrates tile and terrain types in MongoDB
This migration runs automatically on server startup to update existing data in the database.