The class meant for use within the CesiumJS digital globe. Manages Resources and transforming their raster DEMs into QuantizedMeshTerrainData for rendering, utilizing the MARTINI algorithm.

Implements

  • TerrainProvider

Constructors

  • Constructs new MartiniTerrainProvider with preconstructed CogResources

    Parameters

    • resources: MaybePromiseArray<Resource | { id: string; resource: Resource }>

      An array of CogResources. The type is a little confusing on TypeDoc; It's an array of constructed CogResources or Promises to them, which can be put inside Promise.all if desired

    • providerOptions: Options = {}

      Since the resources are constructed individually, outside of the provider, these options are not shared with the resources. However, each resource.tileSize must match for the Martini algorithm to work.

    Returns Promise<MartiniTerrainProvider>

    Promise of new MariniTerrainProvider with resources

    If for any reason you'd like to pre-construct the CogResource(s), you can use this constructor to then create the MartiniTerrainProvider from those resources.

    import { CogResource, MartiniTerrainProvider } from '@landrush/martini-terrain-provider'
    const tileSize = 257 // must be shared amonst Provider & all resources
    const resources = [
    'https://server/cog-0-0.tif',
    'https://server/cog-0-1.tif',
    'https://server/cog-1-0.tif',
    'https://server/cog-1-1.tif'
    ].map(url => CogResource.fromSource(url, { ...resourceOptions, tileSize }))
    const terrainProvider = MartiniTerrainProvider.fromResources(resources, { ...providerOptions, tileSize })
  • Constructs new MartiniTerrainProvider with CogResources created from the GeoTIFF sources. The sources can be URLs, but also allows local/prefetched COG resources, such as from a File or ArrayBuffer

    Parameters

    • sources: (GeoTIFF | GeoTiffSource | { id: string; source: GeoTIFF | GeoTiffSource })[]

      GeoTIFF object (from geotiff.js) or a compatible source

    • options: Options = {}

      Customizable MartiniTerrainProvider settings. tileSize & ellipsoid are also passed to the newly created CogResources

    Returns Promise<MartiniTerrainProvider>

    Promise of new MariniTerrainProvider with resources created from the given sources

    If you have Cloud-Optimized GeoTIFF data (either a URL or prefetched, like a File or ArrayBuffer), you can pass it directly to this constructor and have the Provider create the necessary CogResource(s)

    import { MartiniTerrainProvider } from '@landrush/martini-terrain-provider'
    const terrainProvider = new MartiniTerrainProvider.fromSources([
    'https://server/cog-0-0.tif',
    'https://server/cog-0-1.tif'
    ], { ...options })

Properties

_errorAtMinZoom: number = 1000
availability: TileAvailability

Gets an object that can be used to determine availability of terrain from this provider, such as at points and in rectangles. This property may be undefined if availability information is not available.

credit: Credit = ...

Gets the credit to display when this terrain provider is active. Typically this is used to credit the source of the terrain.

ellipsoid: Ellipsoid
errorEvent: Event = ...

Gets an event that is raised when the terrain provider encounters an asynchronous error. By subscribing to the event, you will be notified of the error and can potentially recover from it. Event listeners are passed an instance of TileProviderError.

hasVertexNormals: false

Gets a value indicating whether or not the requested tiles include vertex normals.

hasWaterMask: false

Gets a value indicating whether or not the provider includes a water mask. The water mask indicates which areas of the globe are water rather than land, so they can be rendered as a reflective surface with animated waves.

maxWorkers: number = defaultPoolSize
minError: number = 0.1
minZoomLevel: number
ready: boolean
readyPromise: Promise<boolean>
stitchToBackupTile: boolean = false
terrainExaggeration: number = 1
tileSize: number = DEFAULT_TILE_SIZE

Tile size for MARTINI algorithm. Also resamples all GeoTIFFImage.readRasters() results in CogResource to this.tileSize

tilingScheme: GeographicTilingScheme

Gets the tiling scheme used by the provider.

Accessors

  • get backupTerrainProvider(): undefined | TerrainProvider
  • Returns undefined | TerrainProvider

  • set backupTerrainProvider(terrainProvider: undefined | TerrainProvider): void
  • Parameters

    • terrainProvider: undefined | TerrainProvider

    Returns void

Methods

  • Gets the maximum geometric error allowed in a tile at a given level.

    Parameters

    • level: number

      The tile level for which to get the maximum geometric error.

    Returns number

    The maximum geometric error.

  • Checks a tile (from x, y, z coordinates) for resources existing within the tile bounds, otherwise calls this._backupTerrainProvider.getTileDataAvailable(x,y,z)

    Parameters

    • x: number

      X coordinate for tile requesting geometry

    • y: number

      Y coordinate for tile requesting geometry

    • z: number

      Level of tile requesting geometry

    Returns undefined | boolean

    boolean indicating availability, or undefined if loading

  • Parameters

    • x: number

      — The X coordinate of the tile for which to request geometry.

    • y: number

      The Y coordinate of the tile for which to request geometry.

    • level: number

      The level of the tile for which to request geometry.

    Returns Promise<void>

    Undefined if nothing need to be loaded (if no backupTerrainProvider), or a Promise that resolves when all required tiles are loaded

  • Requests the geometry for a given tile.

    Parameters

    • x: number

      X coordinate for tile requesting geometry

    • y: number

      Y coordinate for tile requesting geometry

    • z: number

      Level of tile requesting geometry

    • Optionalreq: Request

      Request object. Intended for internal use only

    Returns undefined | Promise<TerrainData>

    Promise for requested geometry, or undefined (indicating too many pending requests)

  • Parameters

    • terrainProvider: undefined | TerrainProvider | Promise<TerrainProvider>

    Returns Promise<void>