Skip to content

Multi-source terrain provider feature #12817

@juunie-roh

Description

@juunie-roh

Feature

Image
Mixed terrain example with worldTerrain and Ellipsoid.

This issue was originated from Cesium Community.

What is it for:

Enables terrain to be loaded from multiple sources according to configured areas(with specific zoom level and tile coordinates) as the image shown above. It also enables setting fallback terrain, an error boundary for terrain provider.

Concept

I have implemented the feature on @juun-roh/cesium-utils, with name HybridTerrainProvider. It works as below:

  1. The HybridTerrainProvider extends existing TerrainProvider class.
  2. Configure areas to override terrain source with zoom levels, tile coordinates, and TerrainProvider having different terrain sources.
  3. Override requestTileGeometry method with configured area inclusion checks.
  4. Delegate the method to configured terrain provider's requestTileGeometry, with configured areas.
  5. If returns false, proceed with default/fallback provider's.

The overall concept of this feature is to redirect the requestTileGeometry with different providers.

Implementation

You can see my full implementation here.

Briefly, how I redirected the method is by this:

requestTileGeometry(
    x: number,
    y: number,
    level: number,
    request?: Request,
  ): Promise<Awaited<TerrainData>> | undefined {
    if (!this._ready) return undefined;

    // Check regions for a match
    for (const region of this._regions) {
      if (this._regionContains(region, x, y, level)) {
        return region.provider.requestTileGeometry(x, y, level, request);
      }
    }

    // Fall back to default provider
    if (this._defaultProvider.getTileDataAvailable(x, y, level)) {
      return this._defaultProvider.requestTileGeometry(x, y, level, request);
    }

    // Final fallback
    return this._fallbackProvider.requestTileGeometry(x, y, level, request);
  }

Request for Guidance

My implementation does not follow Cesium's API design, since it has a separate development environment, so I'm expecting it to take some time to open a direct pull request about this feature.

Meanwhile, I'd appreciate feedback on this feature:

  • API design preferences
  • Any architectural considerations I've missed

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions