UNPKG

@itwin/core-frontend

Version:
222 lines • 11.8 kB
/** @packageDocumentation * @module Tiles */ import { BentleyError, GuidString, LoggingMetaData, RealityDataStatus } from "@itwin/core-bentley"; import { Cartographic, EcefLocation, OrbitGtBlobProps, RealityData, RealityDataFormat, RealityDataProvider, RealityDataSourceKey } from "@itwin/core-common"; import { Range3d } from "@itwin/core-geometry"; import { DecorateContext } from "./ViewContext"; import { ScreenViewport } from "./Viewport"; /** * Reality Data Operation error * @alpha */ export declare class RealityDataError extends BentleyError { constructor(errorNumber: RealityDataStatus, message: string, getMetaData?: LoggingMetaData); } /** This interface provide spatial location and volume of interest, in meters, centered around `spatial location` * @alpha */ export interface SpatialLocationAndExtents { /** location of the point at the center of the reaity data */ location: Cartographic | EcefLocation; /** extents of the volume around location */ worldRange: Range3d; /** true if this reality data is geolocated * A reality data is geolocated when we can compute a valid position relative to the earth surface. * Note that some reality data contains custom coordinate system without any information on the relative position on earth. * These reality data will have a location and worldRange but will be identified by the isGeoLocated set to false. */ isGeolocated: boolean; } /** This interface provides information to identify the product and engine that create this reality data * @alpha */ export interface PublisherProductInfo { /** product that create this reality data */ product: string; /** engine that create this reality data */ engine: string; /** the version of the engine that create this reality data */ version: string; } /** This interface provide methods used to access a reality data from a reality data provider * @beta */ export interface RealityDataSource { readonly key: RealityDataSourceKey; readonly isContextShare: boolean; readonly realityDataId: string | undefined; /** Metatdata on the reality data source */ readonly realityData: RealityData | undefined; /** The reality data type (e.g.: "RealityMesh3DTiles", OPC, Terrain3DTiles, Cesium3DTiles, ... )*/ readonly realityDataType: string | undefined; /** This method returns the URL to obtain the Reality Data properties. * @param iTwinId id of associated iTwin project * @returns string containing the URL to reality data. */ getServiceUrl(iTwinId: GuidString | undefined): Promise<string | undefined>; /** If true, the geometricError property of the tiles will be used to compute screen-space error. * @alpha */ readonly usesGeometricError?: boolean; /** If [[usesGeometricError]] is `true`, optionally specifies the maximum error, in pixels, to permit for a tile before requiring refinement of that tile. * Default: 16 * @alpha */ readonly maximumScreenSpaceError?: number; /** Given the URL of a tile's content, return the type of that content. * "tileset" indicates the content points to a JSON tileset describing the structure of the tile tree below the tile. * "tile" indicates the content points to a binary representation of the tile's graphics. * @alpha */ getTileContentType(url: string): "tile" | "tileset"; /** Gets a reality data root document json * @returns tile data json * @internal */ getRootDocument(iTwinId: GuidString | undefined): Promise<any>; /** Gets tile content * @param name name or path of tile * @returns array buffer of tile content * @internal */ getTileContent(name: string): Promise<any>; /** Gets a tileset's app data json * @param name name or path of tile * @returns app data json object * @internal */ getTileJson(name: string): Promise<any>; /** Gets spatial location and extents of this reality data source. * Will return undefined if cannot be resolved or is unbounded (cover entire earth eg: Open Street Map Building from Ion Asset) * @returns spatial location and extents * @throws [[RealityDataError]] if source is invalid or cannot be read * @alpha */ getSpatialLocationAndExtents(): Promise<SpatialLocationAndExtents | undefined>; /** Gets information to identify the product and engine that create this reality data * Will return undefined if cannot be resolved * @returns information to identify the product and engine that create this reality data * @alpha */ getPublisherProductInfo(): Promise<PublisherProductInfo | undefined>; /** Optional, gets the tileset url associated with the reality data source * @returns tileset url * @internal */ getTilesetUrl?(): string | undefined; } /** Utility functions for RealityDataSource * @beta */ export declare namespace RealityDataSource { /** Create a RealityDataSourceKey from a tilesetUrl. * @param tilesetUrl the reality data attachment url * @param inputProvider identify the RealityDataProvider if known, otherwise function will try to extract it from the tilesetUrl * @param inputFormat identify the RealityDataFormat if known, otherwise function will try to extract it from the tilesetUrl * @returns the RealityDataSourceKey that uniquely identify a reality data for a provider */ function createKeyFromUrl(tilesetUrl: string, inputProvider?: RealityDataProvider, inputFormat?: RealityDataFormat): RealityDataSourceKey; /** @alpha - was used for a very specific case of point cloud (opc) attachment that should not be made public */ function createKeyFromBlobUrl(blobUrl: string, inputProvider?: RealityDataProvider, inputFormat?: RealityDataFormat): RealityDataSourceKey; /** @alpha - OrbitGtBlobProps is alpha */ function createKeyFromOrbitGtBlobProps(orbitGtBlob: OrbitGtBlobProps, inputProvider?: RealityDataProvider, inputFormat?: RealityDataFormat): RealityDataSourceKey; /** @alpha - OrbitGtBlobProps is alpha */ function createOrbitGtBlobPropsFromKey(rdSourceKey: RealityDataSourceKey): OrbitGtBlobProps | undefined; /** @internal - Is used by "fdt attach cesium asset" keyin*/ function createCesiumIonAssetKey(osmAssetId: number, requestKey: string): RealityDataSourceKey; /** Return an instance of a RealityDataSource from a source key. * There will aways be only one reality data RealityDataSource for a corresponding reality data source key. * @alpha */ function fromKey(key: RealityDataSourceKey, iTwinId: GuidString | undefined): Promise<RealityDataSource | undefined>; } /** A named supplier of [RealityDataSource]]s. * The provider's name is stored in a [RealityDataSourceKey]($common). When the [[RealityDataSource]] is requested from the key, * the provider is looked up in [[IModelApp.realityDataSourceProviders]] by its name and, if found, its [[createRealityDataSource]] method * is invoked to produce the reality data source. * @beta */ export interface RealityDataSourceProvider { /** Produce a RealityDataSource for the specified `key`. * @param key Identifies the reality data source. * @param iTwinId A default iTwinId to use. * @returns the requested reality data source, or `undefined` if it could not be produced. */ createRealityDataSource(key: RealityDataSourceKey, iTwinId: GuidString | undefined): Promise<RealityDataSource | undefined>; /** Optionally add any decorations specific to this reality data source provider. * For example, the Google Photorealistic 3D Tiles reality data source provider will add the Google logo. */ decorate?(_context: DecorateContext): void; /** Optionally add attribution logo cards to the viewport's logo div. */ addAttributions?(cards: HTMLTableElement, vp: ScreenViewport): Promise<void>; /** Enables cached decorations for this provider. @see [[ViewportDecorator.useCachedDecorations]] */ useCachedDecorations?: true | undefined; } /** A registry of [[RealityDataSourceProvider]]s identified by their unique names. The registry can be accessed via [[IModelApp.realityDataSourceProviders]]. * It includes a handful of built-in providers for sources like Cesium ION, ContextShare, OrbitGT, and arbitrary public-accessible URLs. * Any number of additional providers can be registered. They should typically be registered just after [[IModelApp.startup]]. * @beta */ export declare class RealityDataSourceProviderRegistry { private readonly _providers; /** @internal */ constructor(); /** Register `provider` to produce [[RealityDataSource]]s for the specified provider `name`. */ register(name: string, provider: RealityDataSourceProvider): void; /** Look up the provider registered by the specified `name`. */ find(name: string): RealityDataSourceProvider | undefined; } /** * Options for creating a Google Photorealistic 3D Tiles reality data source provider. * The caller must provide either an API key or a function that returns an auth token. * @beta */ export type Google3dTilesProviderOptions = { /** Google Map Tiles API Key used to access Google 3D Tiles. */ apiKey: string; getAuthToken?: never; /** If true, the data attributions/copyrights from the Google 3D Tiles will be displayed on screen. The Google Maps logo will always be displayed. Defaults to `true`. */ showCreditsOnScreen?: boolean; } | { apiKey?: never; /** Function that returns an OAuth token for authenticating with Google 3D Tiles. This token is expected to not contain the "Bearer" prefix. */ getAuthToken: () => Promise<string>; /** If true, the data attributions/copyrights from the Google 3D Tiles will be displayed on screen. The Google Maps logo will always be displayed. Defaults to `true`. */ showCreditsOnScreen?: boolean; }; /** * Will provide Google Photorealistic 3D Tiles (in 3dTile format). * A valid API key or getAuthToken fuction must be supplied when creating this provider. * To use this provider, you must register it with [[IModelApp.realityDataSourceProviders]]. * Example usage: * ```ts * [[include:GooglePhotorealistic3dTiles_providerApiKey]] * ``` * @see [Google Photorealistic 3D Tiles]($docs/learning/frontend/GooglePhotorealistic3dTiles.md) * @beta */ export declare class Google3dTilesProvider implements RealityDataSourceProvider { /** Google Map Tiles API Key used to access Google 3D Tiles. */ private _apiKey?; /** Function that returns an OAuth token for authenticating with Google 3D Tiles. This token is expected to not contain the "Bearer" prefix. */ private _getAuthToken?; /** Decorator for Google Maps logos. */ private _decorator; /** Enables cached decorations for this provider. @see [[ViewportDecorator.useCachedDecorations]] */ readonly useCachedDecorations = true; createRealityDataSource(key: RealityDataSourceKey, iTwinId: GuidString | undefined): Promise<RealityDataSource | undefined>; constructor(options: Google3dTilesProviderOptions); /** * Initialize the Google 3D Tiles reality data source provider by activating its decorator, which consists of loading the correct Google Maps logo. * @returns `true` if the decorator was successfully activated, otherwise `false`. */ initialize(): Promise<boolean>; decorate(_context: DecorateContext): void; addAttributions(cards: HTMLTableElement, vp: ScreenViewport): Promise<void>; } /** Returns the URL used for retrieving Google Photorealistic 3D Tiles. * @beta */ export declare function getGoogle3dTilesUrl(): string; //# sourceMappingURL=RealityDataSource.d.ts.map