Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ ENV REEARTH_AUTH0_AUDIENCE=null
ENV REEARTH_AUTH0_CLIENT_ID=null
ENV REEARTH_AUTH0_DOMAIN=null
ENV REEARTH_BRAND=null
ENV REEARTH_CESIUM_ION_ACCESS_TOKEN=null
ENV REEARTH_CLOUD_API=null
ENV REEARTH_CURRENT_TOS=null
ENV REEARTH_CUSTOM_PROVIDERS=null
Expand Down
1 change: 0 additions & 1 deletion web/docker/reearth_config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"auth0ClientId": ${REEARTH_AUTH0_CLIENT_ID},
"auth0Domain": ${REEARTH_AUTH0_DOMAIN},
"brand": ${REEARTH_BRAND},
"cesiumIonAccessToken": ${REEARTH_CESIUM_ION_ACCESS_TOKEN},
"cloudApi": ${REEARTH_CLOUD_API},
"currentTos": ${REEARTH_CURRENT_TOS},
"customProviders": ${REEARTH_CUSTOM_PROVIDERS},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const overriddenSceneProperty = useMemo(

| 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 |
Expand All @@ -80,21 +81,31 @@ const overriddenSceneProperty = useMemo(
"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://..." }
{ "id": "tile-3", "tile_url": "https://...", "tile_type": "google_satellite" }
]
}
```

Note: Tiles without a `tile_type` field are left unchanged.
Note: Tiles without a `tile_type` field are automatically assigned `"google_satellite"` as the default.

## Terrain Type Migrations

### Rules

1. **ArcGIS migration:** If `terrainType` is `"arcgis"`, change to `"reearth_terrain"`
1. **Default:** If `terrainType` is `undefined`, `null`, or empty AND terrain is enabled (`terrain: true`), set to `"reearth_terrain"`
2. **ArcGIS migration:** If `terrainType` is `"arcgis"`, change to `"reearth_terrain"`

### Examples

**Default terrain type:**
```json
// Before
{ "terrain": true }

// After
{ "terrain": true, "terrainType": "reearth_terrain" }
```

**ArcGIS migration:**
```json
// Before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ This directory contains a comprehensive system for handling backward compatibili
### Backward Compatibility Rules

**Tiles:**
- `undefined` / `null` / empty → `"google_satellite"` (default)
- `"default"` → `cesium_ion` (asset_id: 2)
- `"default_label"` → `cesium_ion` (asset_id: 3)
- `"default_road"` → `cesium_ion` (asset_id: 4)
Expand All @@ -77,6 +78,7 @@ This directory contains a comprehensive system for handling backward compatibili
- `"esri_world_topo"` → `open_street_map`

**Terrain:**
- `undefined` / `null` / empty → `"reearth_terrain"` (default, only when terrain is enabled)
- `"arcgis"` → `"reearth_terrain"`

### Fallback Rules (Only When No Cesium Ion Token)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe("migrateTileType", () => {
expect(result).toEqual(tile);
});

it("should not modify tile without tile_type", () => {
it("should default to google_satellite when tile_type is undefined", () => {
const tile = {
id: "test-tile",
tile_url: "https://example.com",
Expand All @@ -132,6 +132,7 @@ describe("migrateTileType", () => {
expect(result).toEqual({
id: "test-tile",
tile_url: "https://example.com",
tile_type: "google_satellite",
});
});
});
Expand Down Expand Up @@ -190,6 +191,34 @@ describe("migrateTerrainType", () => {
depthTestAgainstTerrain: true,
});
});

it("should default to reearth_terrain when terrainType is undefined", () => {
const terrain = {
terrain: true,
};

const result = migrateTerrainType(terrain);

expect(result).toEqual({
terrain: true,
terrainType: "reearth_terrain",
});
});

it("should default to reearth_terrain when terrainType is undefined with other properties", () => {
const terrain = {
terrain: true,
terrainExaggeration: 1.5,
};

const result = migrateTerrainType(terrain);

expect(result).toEqual({
terrain: true,
terrainType: "reearth_terrain",
terrainExaggeration: 1.5,
});
});
});

describe("applyBackwardCompatibility", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export function applyBackwardCompatibility(
/**
* Migrate tile type from old format to new format
* Backward compatibility rules:
* - undefined/null/empty → "google_satellite" (default)
* - "default" → "cesium_ion" with cesiumIonAssetId: 2
* - "default_label" → "cesium_ion" with cesiumIonAssetId: 3
* - "default_road" → "cesium_ion" with cesiumIonAssetId: 4
Expand All @@ -41,6 +42,17 @@ export function migrateTileType(
): NonNullable<SceneProperty["tiles"]>[number] {
const tileType = tile.tile_type;

// Default to google_satellite if no type specified
if (!tileType) {
console.warn(
`[Re:Earth] Tile type migrated: undefined → "google_satellite" - Backward compatibility (tile ID: ${tile.id})`,
);
return {
...tile,
tile_type: "google_satellite",
};
}

// Backward compatibility: migrate old tile types to new ones
switch (tileType) {
case "default": {
Expand Down Expand Up @@ -117,11 +129,23 @@ export function migrateTileType(
/**
* Migrate terrain type from old format to new format
* Backward compatibility rules:
* - undefined/null/empty → "reearth_terrain" (default, only when terrain is enabled)
* - If terrainType is "arcgis" (legacy) → change to "reearth_terrain"
*/
export function migrateTerrainType(terrain: TerrainProperty): TerrainProperty {
const { terrainType } = terrain;

// Default to reearth_terrain if no type specified and terrain is enabled
if (!terrainType && terrain.terrain) {
console.warn(
`[Re:Earth] Terrain type migrated: undefined → "reearth_terrain" - Backward compatibility (default)`,
);
return {
...terrain,
terrainType: "reearth_terrain",
};
}

// Migrate "arcgis" to "reearth_terrain" (handles legacy string type)
if ((terrainType as string) === "arcgis") {
console.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("Backward Compatibility + Fallbacks Integration", () => {
]);
expect(afterBackwardCompat?.terrain).toEqual({
terrain: true,
// terrainType is NOT added when missing
terrainType: "reearth_terrain", // Default added when missing
});

// Step 2: Apply fallbacks (no token, so fallbacks apply)
Expand All @@ -43,7 +43,7 @@ describe("Backward Compatibility + Fallbacks Integration", () => {
]);
expect(final?.terrain).toEqual({
terrain: true,
// terrainType remains undefined (no fallback when missing)
terrainType: "reearth_terrain", // Default was added in backward compat step
});
});

Expand Down Expand Up @@ -71,7 +71,7 @@ describe("Backward Compatibility + Fallbacks Integration", () => {
]);
expect(afterBackwardCompat?.terrain).toEqual({
terrain: true,
// terrainType is NOT added when missing
terrainType: "reearth_terrain", // Default added when missing
});

// Step 2: Apply fallbacks (has token, so NO fallbacks)
Expand All @@ -84,31 +84,31 @@ describe("Backward Compatibility + Fallbacks Integration", () => {
]);
expect(final?.terrain).toEqual({
terrain: true,
// terrainType remains undefined (token doesn't affect missing terrainType)
terrainType: "reearth_terrain", // Default was added in backward compat step
});
});

it("should handle tile without tile_type (no migration)", () => {
it("should handle tile without tile_type (adds google_satellite default)", () => {
const input: SceneProperty = {
tiles: [{ id: "tile-1", tile_url: "https://example.com" }],
};

// Step 1: Backward compatibility (does NOT add tile_type when missing)
// Step 1: Backward compatibility (adds google_satellite default)
const afterBackwardCompat = applyBackwardCompatibility(input);

expect(afterBackwardCompat?.tiles?.[0]).toEqual({
id: "tile-1",
tile_url: "https://example.com",
// tile_type and cesium_ion_asset_id are NOT added
tile_type: "google_satellite", // Default added
});

// Step 2: Apply fallbacks (no tile_type, so no fallback applies)
// Step 2: Apply fallbacks (google_satellite doesn't need fallback)
const final = applyFallbacks(afterBackwardCompat);

expect(final?.tiles?.[0]).toEqual({
id: "tile-1",
tile_url: "https://example.com",
// Remains unchanged
tile_type: "google_satellite", // Remains google_satellite
});
});

Expand Down
5 changes: 5 additions & 0 deletions web/src/published.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { createRoot } from "react-dom/client";

import App from "./publishedapp";
import loadConfig from "./services/config";
import { initializeSentinel } from "./services/sentinel";
import "./wdyr";

window.React = React;
Expand All @@ -14,6 +15,10 @@ window.ReactDOM = ReactDOM;
loadConfig().finally(() => {
const element = document.getElementById("root");
if (!element) throw new Error("root element is not found");

// Initialize Sentinel for secure asset authentication (non-blocking)
initializeSentinel();

const root = createRoot(element);
root.render(<App />);
});
Loading