@itwin/core-frontend 5.1.0-dev.47 → 5.1.0-dev.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/IModelApp.d.ts +1 -1
- package/lib/cjs/IModelApp.js +1 -1
- package/lib/cjs/IModelApp.js.map +1 -1
- package/lib/cjs/RealityDataSource.d.ts +65 -3
- package/lib/cjs/RealityDataSource.d.ts.map +1 -1
- package/lib/cjs/RealityDataSource.js +79 -3
- package/lib/cjs/RealityDataSource.js.map +1 -1
- package/lib/cjs/RealityDataSourceTilesetUrlImpl.js +1 -1
- package/lib/cjs/RealityDataSourceTilesetUrlImpl.js.map +1 -1
- package/lib/cjs/internal/GoogleMapsDecorator.d.ts +53 -0
- package/lib/cjs/internal/GoogleMapsDecorator.d.ts.map +1 -0
- package/lib/cjs/internal/GoogleMapsDecorator.js +132 -0
- package/lib/cjs/internal/GoogleMapsDecorator.js.map +1 -0
- package/lib/cjs/internal/RealityDataSourceGoogle3dTilesImpl.d.ts +83 -0
- package/lib/cjs/internal/RealityDataSourceGoogle3dTilesImpl.d.ts.map +1 -0
- package/lib/cjs/internal/RealityDataSourceGoogle3dTilesImpl.js +201 -0
- package/lib/cjs/internal/RealityDataSourceGoogle3dTilesImpl.js.map +1 -0
- package/lib/cjs/internal/cross-package.d.ts +1 -0
- package/lib/cjs/internal/cross-package.d.ts.map +1 -1
- package/lib/cjs/internal/cross-package.js +4 -1
- package/lib/cjs/internal/cross-package.js.map +1 -1
- package/lib/cjs/internal/tile/RealityModelTileTree.d.ts +5 -2
- package/lib/cjs/internal/tile/RealityModelTileTree.d.ts.map +1 -1
- package/lib/cjs/internal/tile/RealityModelTileTree.js +15 -4
- package/lib/cjs/internal/tile/RealityModelTileTree.js.map +1 -1
- package/lib/cjs/tile/GltfReader.d.ts +1 -0
- package/lib/cjs/tile/GltfReader.d.ts.map +1 -1
- package/lib/cjs/tile/GltfReader.js +1 -0
- package/lib/cjs/tile/GltfReader.js.map +1 -1
- package/lib/cjs/tile/RealityTile.d.ts +5 -0
- package/lib/cjs/tile/RealityTile.d.ts.map +1 -1
- package/lib/cjs/tile/RealityTile.js +5 -0
- package/lib/cjs/tile/RealityTile.js.map +1 -1
- package/lib/esm/IModelApp.d.ts +1 -1
- package/lib/esm/IModelApp.js +1 -1
- package/lib/esm/IModelApp.js.map +1 -1
- package/lib/esm/RealityDataSource.d.ts +65 -3
- package/lib/esm/RealityDataSource.d.ts.map +1 -1
- package/lib/esm/RealityDataSource.js +77 -3
- package/lib/esm/RealityDataSource.js.map +1 -1
- package/lib/esm/RealityDataSourceTilesetUrlImpl.js +1 -1
- package/lib/esm/RealityDataSourceTilesetUrlImpl.js.map +1 -1
- package/lib/esm/internal/GoogleMapsDecorator.d.ts +53 -0
- package/lib/esm/internal/GoogleMapsDecorator.d.ts.map +1 -0
- package/lib/esm/internal/GoogleMapsDecorator.js +126 -0
- package/lib/esm/internal/GoogleMapsDecorator.js.map +1 -0
- package/lib/esm/internal/RealityDataSourceGoogle3dTilesImpl.d.ts +83 -0
- package/lib/esm/internal/RealityDataSourceGoogle3dTilesImpl.d.ts.map +1 -0
- package/lib/esm/internal/RealityDataSourceGoogle3dTilesImpl.js +197 -0
- package/lib/esm/internal/RealityDataSourceGoogle3dTilesImpl.js.map +1 -0
- package/lib/esm/internal/cross-package.d.ts +1 -0
- package/lib/esm/internal/cross-package.d.ts.map +1 -1
- package/lib/esm/internal/cross-package.js +1 -0
- package/lib/esm/internal/cross-package.js.map +1 -1
- package/lib/esm/internal/tile/RealityModelTileTree.d.ts +5 -2
- package/lib/esm/internal/tile/RealityModelTileTree.d.ts.map +1 -1
- package/lib/esm/internal/tile/RealityModelTileTree.js +15 -4
- package/lib/esm/internal/tile/RealityModelTileTree.js.map +1 -1
- package/lib/esm/tile/GltfReader.d.ts +1 -0
- package/lib/esm/tile/GltfReader.d.ts.map +1 -1
- package/lib/esm/tile/GltfReader.js +1 -0
- package/lib/esm/tile/GltfReader.js.map +1 -1
- package/lib/esm/tile/RealityTile.d.ts +5 -0
- package/lib/esm/tile/RealityTile.d.ts.map +1 -1
- package/lib/esm/tile/RealityTile.js +5 -0
- package/lib/esm/tile/RealityTile.js.map +1 -1
- package/lib/public/images/google_on_non_white.png +0 -0
- package/lib/public/images/google_on_non_white_hdpi.png +0 -0
- package/lib/public/images/google_on_white.png +0 -0
- package/lib/public/images/google_on_white_hdpi.png +0 -0
- package/package.json +22 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealityDataSource.js","sourceRoot":"","sources":["../../src/RealityDataSource.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAA2G;AAC3G,oDAA6J;AAC7J,4EAAyE;AACzE,8CAAkG;AAClG,uFAAoF;AACpF,2FAAwF;AACxF,+FAA4F;AAC5F,2CAAwC;AAGxC,MAAM,cAAc,GAAW,+CAAsB,CAAC,WAAW,CAAC;AAElE;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,2BAAY;IAChD,YAAmB,WAA8B,EAAE,OAAe,EAAE,WAA6B;QAC/F,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IAC3C,CAAC;CACF;AAJD,4CAIC;AAkGD;;GAEG;AACH,IAAiB,iBAAiB,CAuFjC;AAvFD,WAAiB,iBAAiB;IAChC;;;;;OAKG;IACH,SAAgB,gBAAgB,CAAC,UAAkB,EAAE,aAAmC,EAAE,WAA+B;QACvH,IAAI,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,+BAAiB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC/E,IAAI,iCAAsB,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;YACrD,MAAM,QAAQ,GAAG,iCAAmB,CAAC,cAAc,CAAC;YACpD,IAAI,iBAAiB,GAAyB,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAG,iC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ACtC,CAAC;IAED,+DAA+D;IACxD,IAAI,CAAC,IAAY;QACtB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACF;AA7BD,8EA6BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\nimport { BentleyError, GuidString, Logger, LoggingMetaData, RealityDataStatus } from \"@itwin/core-bentley\";\r\nimport { Cartographic, EcefLocation, OrbitGtBlobProps, RealityData, RealityDataFormat, RealityDataProvider, RealityDataSourceKey } from \"@itwin/core-common\";\r\nimport { FrontendLoggerCategory } from \"./common/FrontendLoggerCategory\";\r\nimport { CesiumIonAssetProvider, ContextShareProvider, getCesiumAssetUrl } from \"./tile/internal\";\r\nimport { RealityDataSourceTilesetUrlImpl } from \"./RealityDataSourceTilesetUrlImpl\";\r\nimport { RealityDataSourceContextShareImpl } from \"./RealityDataSourceContextShareImpl\";\r\nimport { RealityDataSourceCesiumIonAssetImpl } from \"./RealityDataSourceCesiumIonAssetImpl\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\n\r\nconst loggerCategory: string = FrontendLoggerCategory.RealityData;\r\n\r\n/**\r\n * Reality Data Operation error\r\n * @alpha\r\n */\r\nexport class RealityDataError extends BentleyError {\r\n public constructor(errorNumber: RealityDataStatus, message: string, getMetaData?: LoggingMetaData) {\r\n super(errorNumber, message, getMetaData);\r\n }\r\n}\r\n\r\n/** This interface provide spatial location and volume of interest, in meters, centered around `spatial location`\r\n * @alpha\r\n */\r\nexport interface SpatialLocationAndExtents {\r\n /** location of the point at the center of the reaity data */\r\n location: Cartographic | EcefLocation;\r\n /** extents of the volume around location */\r\n worldRange: Range3d;\r\n /** true if this reality data is geolocated\r\n * A reality data is geolocated when we can compute a valid position relative to the earth surface.\r\n * Note that some reality data contains custom coordinate system without any information on the relative position on earth.\r\n * These reality data will have a location and worldRange but will be identified by the isGeoLocated set to false.\r\n */\r\n isGeolocated: boolean;\r\n}\r\n\r\n/** This interface provides information to identify the product and engine that create this reality data\r\n * @alpha\r\n */\r\nexport interface PublisherProductInfo {\r\n /** product that create this reality data */\r\n product: string;\r\n /** engine that create this reality data */\r\n engine: string;\r\n /** the version of the engine that create this reality data */\r\n version: string;\r\n}\r\n\r\n/** This interface provide methods used to access a reality data from a reality data provider\r\n * @beta\r\n */\r\nexport interface RealityDataSource {\r\n readonly key: RealityDataSourceKey;\r\n readonly isContextShare: boolean;\r\n readonly realityDataId: string | undefined;\r\n /** Metatdata on the reality data source */\r\n readonly realityData: RealityData | undefined;\r\n /** The reality data type (e.g.: \"RealityMesh3DTiles\", OPC, Terrain3DTiles, Cesium3DTiles, ... )*/\r\n readonly realityDataType: string | undefined;\r\n /** This method returns the URL to obtain the Reality Data properties.\r\n * @param iTwinId id of associated iTwin project\r\n * @returns string containing the URL to reality data.\r\n */\r\n getServiceUrl(iTwinId: GuidString | undefined): Promise<string | undefined>;\r\n /** If true, the geometricError property of the tiles will be used to compute screen-space error.\r\n * @alpha\r\n */\r\n readonly usesGeometricError?: boolean;\r\n /** If [[usesGeometricError]] is `true`, optionally specifies the maximum error, in pixels, to permit for a tile before requiring refinement of that tile.\r\n * Default: 16\r\n * @alpha\r\n */\r\n readonly maximumScreenSpaceError?: number;\r\n /** Given the URL of a tile's content, return the type of that content.\r\n * \"tileset\" indicates the content points to a JSON tileset describing the structure of the tile tree below the tile.\r\n * \"tile\" indicates the content points to a binary representation of the tile's graphics.\r\n * @alpha\r\n */\r\n getTileContentType(url: string): \"tile\" | \"tileset\";\r\n\r\n /** Gets a reality data root document json\r\n * @returns tile data json\r\n * @internal\r\n */\r\n getRootDocument(iTwinId: GuidString | undefined): Promise<any>;\r\n /** Gets tile content\r\n * @param name name or path of tile\r\n * @returns array buffer of tile content\r\n * @internal\r\n */\r\n getTileContent(name: string): Promise<any>;\r\n /** Gets a tileset's app data json\r\n * @param name name or path of tile\r\n * @returns app data json object\r\n * @internal\r\n */\r\n getTileJson(name: string): Promise<any>;\r\n /** Gets spatial location and extents of this reality data source.\r\n * Will return undefined if cannot be resolved or is unbounded (cover entire earth eg: Open Street Map Building from Ion Asset)\r\n * @returns spatial location and extents\r\n * @throws [[RealityDataError]] if source is invalid or cannot be read\r\n * @alpha\r\n */\r\n getSpatialLocationAndExtents(): Promise<SpatialLocationAndExtents | undefined>;\r\n /** Gets information to identify the product and engine that create this reality data\r\n * Will return undefined if cannot be resolved\r\n * @returns information to identify the product and engine that create this reality data\r\n * @alpha\r\n */\r\n getPublisherProductInfo(): Promise<PublisherProductInfo | undefined>;\r\n /** Optional, gets the tileset url associated with the reality data source\r\n * @returns tileset url\r\n * @internal\r\n */\r\n getTilesetUrl?(): string | undefined;\r\n}\r\n/** Utility functions for RealityDataSource\r\n * @beta\r\n */\r\nexport namespace RealityDataSource {\r\n /** Create a RealityDataSourceKey from a tilesetUrl.\r\n * @param tilesetUrl the reality data attachment url\r\n * @param inputProvider identify the RealityDataProvider if known, otherwise function will try to extract it from the tilesetUrl\r\n * @param inputFormat identify the RealityDataFormat if known, otherwise function will try to extract it from the tilesetUrl\r\n * @returns the RealityDataSourceKey that uniquely identify a reality data for a provider\r\n */\r\n export function createKeyFromUrl(tilesetUrl: string, inputProvider?: RealityDataProvider, inputFormat?: RealityDataFormat): RealityDataSourceKey {\r\n let format = inputFormat ? inputFormat : RealityDataFormat.fromUrl(tilesetUrl);\r\n if (CesiumIonAssetProvider.isProviderUrl(tilesetUrl)) {\r\n const provider = RealityDataProvider.CesiumIonAsset;\r\n let cesiumIonAssetKey: RealityDataSourceKey = { provider, format, id: CesiumIonAssetProvider.osmBuildingId }; // default OSM building\r\n // Parse URL to extract possible asset id and key if provided\r\n const cesiumAsset = CesiumIonAssetProvider.parseCesiumUrl(tilesetUrl);\r\n if (cesiumAsset) {\r\n cesiumIonAssetKey = RealityDataSource.createCesiumIonAssetKey(cesiumAsset.id, cesiumAsset.key);\r\n }\r\n return cesiumIonAssetKey;\r\n }\r\n\r\n // Try to extract realityDataId from URL and if not possible, use the url as the key\r\n if (ContextShareProvider.isProviderUrl(tilesetUrl)) {\r\n const info = ContextShareProvider.getInfoFromUrl(tilesetUrl);\r\n const provider = inputProvider ? inputProvider : info.provider;\r\n format = inputFormat ? inputFormat : info.format;\r\n const contextShareKey: RealityDataSourceKey = { provider, format, id: info.id, iTwinId: info.iTwinId };\r\n return contextShareKey;\r\n }\r\n\r\n // default to tileSetUrl\r\n const provider2 = inputProvider ? inputProvider : RealityDataProvider.TilesetUrl;\r\n const urlKey: RealityDataSourceKey = { provider: provider2, format, id: tilesetUrl };\r\n return urlKey;\r\n }\r\n /** @alpha - was used for a very specific case of point cloud (opc) attachment that should not be made public */\r\n export function createKeyFromBlobUrl(blobUrl: string, inputProvider?: RealityDataProvider, inputFormat?: RealityDataFormat): RealityDataSourceKey {\r\n const info = ContextShareProvider.getInfoFromBlobUrl(blobUrl);\r\n const format = inputFormat ? inputFormat : info.format;\r\n const provider = inputProvider ? inputProvider : info.provider;\r\n const contextShareKey: RealityDataSourceKey = { provider, format, id: info.id };\r\n return contextShareKey;\r\n }\r\n /** @alpha - OrbitGtBlobProps is alpha */\r\n export function createKeyFromOrbitGtBlobProps(orbitGtBlob: OrbitGtBlobProps, inputProvider?: RealityDataProvider, inputFormat?: RealityDataFormat): RealityDataSourceKey {\r\n const format = inputFormat ? inputFormat : RealityDataFormat.OPC;\r\n if (orbitGtBlob.blobFileName && orbitGtBlob.blobFileName.toLowerCase().startsWith(\"http\")) {\r\n return RealityDataSource.createKeyFromBlobUrl(orbitGtBlob.blobFileName, inputProvider, format);\r\n } else if (orbitGtBlob.rdsUrl) {\r\n return RealityDataSource.createKeyFromUrl(orbitGtBlob.rdsUrl, inputProvider, format);\r\n }\r\n const provider = inputProvider ? inputProvider : RealityDataProvider.OrbitGtBlob;\r\n const id = `${orbitGtBlob.accountName}:${orbitGtBlob.containerName}:${orbitGtBlob.blobFileName}:?${orbitGtBlob.sasToken}`;\r\n return { provider, format, id };\r\n }\r\n /** @alpha - OrbitGtBlobProps is alpha */\r\n export function createOrbitGtBlobPropsFromKey(rdSourceKey: RealityDataSourceKey): OrbitGtBlobProps | undefined {\r\n if (rdSourceKey.provider !== RealityDataProvider.OrbitGtBlob)\r\n return undefined;\r\n const splitIds = rdSourceKey.id.split(\":\");\r\n const sasTokenIndex = rdSourceKey.id.indexOf(\":?\");\r\n const sasToken = rdSourceKey.id.substring(sasTokenIndex + 2);\r\n const orbitGtBlob: OrbitGtBlobProps = {\r\n accountName: splitIds[0],\r\n containerName: splitIds[1],\r\n blobFileName: splitIds[2],\r\n sasToken,\r\n };\r\n return orbitGtBlob;\r\n }\r\n /** @internal - Is used by \"fdt attach cesium asset\" keyin*/\r\n export function createCesiumIonAssetKey(osmAssetId: number, requestKey: string): RealityDataSourceKey {\r\n const id = getCesiumAssetUrl(osmAssetId,requestKey);\r\n return {provider: RealityDataProvider.CesiumIonAsset, format: RealityDataFormat.ThreeDTile, id};\r\n }\r\n /** Return an instance of a RealityDataSource from a source key.\r\n * There will aways be only one reality data RealityDataSource for a corresponding reality data source key.\r\n * @alpha\r\n */\r\n export async function fromKey(key: RealityDataSourceKey, iTwinId: GuidString | undefined): Promise<RealityDataSource | undefined> {\r\n const provider = IModelApp.realityDataSourceProviders.find(key.provider);\r\n if (!provider) {\r\n Logger.logWarning(loggerCategory, `RealityDataSourceProvider \"${key.provider}\" is not registered`);\r\n return undefined;\r\n }\r\n\r\n return provider.createRealityDataSource(key, iTwinId);\r\n }\r\n}\r\n\r\n/** A named supplier of [RealityDataSource]]s.\r\n * The provider's name is stored in a [RealityDataSourceKey]($common). When the [[RealityDataSource]] is requested from the key,\r\n * the provider is looked up in [[IModelApp.realityDataSourceProviders]] by its name and, if found, its [[createRealityDataSource]] method\r\n * is invoked to produce the reality data source.\r\n * @alpha\r\n */\r\nexport interface RealityDataSourceProvider {\r\n /** Produce a RealityDataSource for the specified `key`.\r\n * @param key Identifies the reality data source.\r\n * @param iTwinId A default iTwinId to use.\r\n * @returns the requested reality data source, or `undefined` if it could not be produced.\r\n */\r\n createRealityDataSource(key: RealityDataSourceKey, iTwinId: GuidString | undefined): Promise<RealityDataSource | undefined>;\r\n}\r\n\r\n/** A registry of [[RealityDataSourceProvider]]s identified by their unique names. The registry can be accessed via [[IModelApp.realityDataSourceProviders]].\r\n * It includes a handful of built-in providers for sources like Cesium ION, ContextShare, OrbitGT, and arbitrary public-accessible URLs.\r\n * Any number of additional providers can be registered. They should typically be registered just after [[IModelAp.startup]].\r\n * @alpha\r\n */\r\nexport class RealityDataSourceProviderRegistry {\r\n private readonly _providers = new Map<string, RealityDataSourceProvider>();\r\n\r\n /** @internal */\r\n public constructor() {\r\n this.register(RealityDataProvider.CesiumIonAsset, {\r\n createRealityDataSource: async (key, iTwinId) => RealityDataSourceCesiumIonAssetImpl.createFromKey(key, iTwinId),\r\n });\r\n this.register(RealityDataProvider.TilesetUrl, {\r\n createRealityDataSource: async (key, iTwinId) => RealityDataSourceTilesetUrlImpl.createFromKey(key, iTwinId),\r\n });\r\n this.register(RealityDataProvider.ContextShare, {\r\n createRealityDataSource: async (key, iTwinId) => RealityDataSourceContextShareImpl.createFromKey(key, iTwinId),\r\n });\r\n this.register(RealityDataProvider.OrbitGtBlob, {\r\n // ###TODO separate TilesetUrlImpl\r\n createRealityDataSource: async (key, iTwinId) => RealityDataSourceTilesetUrlImpl.createFromKey(key, iTwinId),\r\n });\r\n }\r\n\r\n /** Register `provider` to produce [[RealityDataSource]]s for the specified provider `name`. */\r\n public register(name: string, provider: RealityDataSourceProvider): void {\r\n this._providers.set(name, provider);\r\n }\r\n\r\n /** Look up the provider registered by the specified `name`. */\r\n public find(name: string): RealityDataSourceProvider | undefined {\r\n return this._providers.get(name);\r\n }\r\n}\r\n"]}
|
|
1
|
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Aa,EAAC,EAAE,CAAC,CAAC;QAEvC,yDAAyD;QACzD,IAAI,YAAY,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAC1B,oCAAoC;YACpC,iGAAiG;YACjG,MAAM,gBAAgB,GAAG,CAAC,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAEjF,IAAI,YAAY,GAAG,2BAA2B,CAAC;YAC/C,YAAY,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC5E,YAAY,IAAI,OAAO,CAAC;YAExB,KAAK,CAAC,WAAW,CAAC,qBAAS,CAAC,YAAY,CAAC;gBACvC,OAAO,EAAE,GAAG,qBAAS,CAAC,UAAU,iCAAiC;gBACjE,OAAO,EAAE,gCAAgC;gBACzC,MAAM,EAAE,YAAY;aACrB,CAAC,CAAC,CAAC;QACN,CAAC;IACH,CAAC;CACF;AA9DD,sDA8DC;AAED;;GAEG;AACH,SAAgB,mBAAmB;IACjC,OAAO,kDAAkD,CAAC;AAC5D,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\nimport { BentleyError, BentleyStatus, GuidString, Logger, LoggingMetaData, RealityDataStatus } from \"@itwin/core-bentley\";\r\nimport { Cartographic, EcefLocation, OrbitGtBlobProps, RealityData, RealityDataFormat, RealityDataProvider, RealityDataSourceKey } from \"@itwin/core-common\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport { FrontendLoggerCategory } from \"./common/FrontendLoggerCategory\";\r\nimport { CesiumIonAssetProvider, ContextShareProvider, getCesiumAssetUrl } from \"./tile/internal\";\r\nimport { RealityDataSourceTilesetUrlImpl } from \"./RealityDataSourceTilesetUrlImpl\";\r\nimport { RealityDataSourceContextShareImpl } from \"./RealityDataSourceContextShareImpl\";\r\nimport { RealityDataSourceCesiumIonAssetImpl } from \"./RealityDataSourceCesiumIonAssetImpl\";\r\nimport { RealityDataSourceGoogle3dTilesImpl } from \"./internal/RealityDataSourceGoogle3dTilesImpl\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { getCopyrights, GoogleMapsDecorator } from \"./internal/GoogleMapsDecorator\";\r\nimport { DecorateContext } from \"./ViewContext\";\r\nimport { ScreenViewport } from \"./Viewport\";\r\n\r\nconst loggerCategory: string = FrontendLoggerCategory.RealityData;\r\n\r\n/**\r\n * Reality Data Operation error\r\n * @alpha\r\n */\r\nexport class RealityDataError extends BentleyError {\r\n public constructor(errorNumber: RealityDataStatus, message: string, getMetaData?: LoggingMetaData) {\r\n super(errorNumber, message, getMetaData);\r\n }\r\n}\r\n\r\n/** This interface provide spatial location and volume of interest, in meters, centered around `spatial location`\r\n * @alpha\r\n */\r\nexport interface SpatialLocationAndExtents {\r\n /** location of the point at the center of the reaity data */\r\n location: Cartographic | EcefLocation;\r\n /** extents of the volume around location */\r\n worldRange: Range3d;\r\n /** true if this reality data is geolocated\r\n * A reality data is geolocated when we can compute a valid position relative to the earth surface.\r\n * Note that some reality data contains custom coordinate system without any information on the relative position on earth.\r\n * These reality data will have a location and worldRange but will be identified by the isGeoLocated set to false.\r\n */\r\n isGeolocated: boolean;\r\n}\r\n\r\n/** This interface provides information to identify the product and engine that create this reality data\r\n * @alpha\r\n */\r\nexport interface PublisherProductInfo {\r\n /** product that create this reality data */\r\n product: string;\r\n /** engine that create this reality data */\r\n engine: string;\r\n /** the version of the engine that create this reality data */\r\n version: string;\r\n}\r\n\r\n/** This interface provide methods used to access a reality data from a reality data provider\r\n * @beta\r\n */\r\nexport interface RealityDataSource {\r\n readonly key: RealityDataSourceKey;\r\n readonly isContextShare: boolean;\r\n readonly realityDataId: string | undefined;\r\n /** Metatdata on the reality data source */\r\n readonly realityData: RealityData | undefined;\r\n /** The reality data type (e.g.: \"RealityMesh3DTiles\", OPC, Terrain3DTiles, Cesium3DTiles, ... )*/\r\n readonly realityDataType: string | undefined;\r\n /** This method returns the URL to obtain the Reality Data properties.\r\n * @param iTwinId id of associated iTwin project\r\n * @returns string containing the URL to reality data.\r\n */\r\n getServiceUrl(iTwinId: GuidString | undefined): Promise<string | undefined>;\r\n /** If true, the geometricError property of the tiles will be used to compute screen-space error.\r\n * @alpha\r\n */\r\n readonly usesGeometricError?: boolean;\r\n /** If [[usesGeometricError]] is `true`, optionally specifies the maximum error, in pixels, to permit for a tile before requiring refinement of that tile.\r\n * Default: 16\r\n * @alpha\r\n */\r\n readonly maximumScreenSpaceError?: number;\r\n /** Given the URL of a tile's content, return the type of that content.\r\n * \"tileset\" indicates the content points to a JSON tileset describing the structure of the tile tree below the tile.\r\n * \"tile\" indicates the content points to a binary representation of the tile's graphics.\r\n * @alpha\r\n */\r\n getTileContentType(url: string): \"tile\" | \"tileset\";\r\n\r\n /** Gets a reality data root document json\r\n * @returns tile data json\r\n * @internal\r\n */\r\n getRootDocument(iTwinId: GuidString | undefined): Promise<any>;\r\n /** Gets tile content\r\n * @param name name or path of tile\r\n * @returns array buffer of tile content\r\n * @internal\r\n */\r\n getTileContent(name: string): Promise<any>;\r\n /** Gets a tileset's app data json\r\n * @param name name or path of tile\r\n * @returns app data json object\r\n * @internal\r\n */\r\n getTileJson(name: string): Promise<any>;\r\n /** Gets spatial location and extents of this reality data source.\r\n * Will return undefined if cannot be resolved or is unbounded (cover entire earth eg: Open Street Map Building from Ion Asset)\r\n * @returns spatial location and extents\r\n * @throws [[RealityDataError]] if source is invalid or cannot be read\r\n * @alpha\r\n */\r\n getSpatialLocationAndExtents(): Promise<SpatialLocationAndExtents | undefined>;\r\n /** Gets information to identify the product and engine that create this reality data\r\n * Will return undefined if cannot be resolved\r\n * @returns information to identify the product and engine that create this reality data\r\n * @alpha\r\n */\r\n getPublisherProductInfo(): Promise<PublisherProductInfo | undefined>;\r\n /** Optional, gets the tileset url associated with the reality data source\r\n * @returns tileset url\r\n * @internal\r\n */\r\n getTilesetUrl?(): string | undefined;\r\n}\r\n/** Utility functions for RealityDataSource\r\n * @beta\r\n */\r\nexport namespace RealityDataSource {\r\n /** Create a RealityDataSourceKey from a tilesetUrl.\r\n * @param tilesetUrl the reality data attachment url\r\n * @param inputProvider identify the RealityDataProvider if known, otherwise function will try to extract it from the tilesetUrl\r\n * @param inputFormat identify the RealityDataFormat if known, otherwise function will try to extract it from the tilesetUrl\r\n * @returns the RealityDataSourceKey that uniquely identify a reality data for a provider\r\n */\r\n export function createKeyFromUrl(tilesetUrl: string, inputProvider?: RealityDataProvider, inputFormat?: RealityDataFormat): RealityDataSourceKey {\r\n let format = inputFormat ? inputFormat : RealityDataFormat.fromUrl(tilesetUrl);\r\n if (CesiumIonAssetProvider.isProviderUrl(tilesetUrl)) {\r\n const provider = RealityDataProvider.CesiumIonAsset;\r\n let cesiumIonAssetKey: RealityDataSourceKey = { provider, format, id: CesiumIonAssetProvider.osmBuildingId }; // default OSM building\r\n // Parse URL to extract possible asset id and key if provided\r\n const cesiumAsset = CesiumIonAssetProvider.parseCesiumUrl(tilesetUrl);\r\n if (cesiumAsset) {\r\n cesiumIonAssetKey = RealityDataSource.createCesiumIonAssetKey(cesiumAsset.id, cesiumAsset.key);\r\n }\r\n return cesiumIonAssetKey;\r\n }\r\n\r\n // Try to extract realityDataId from URL and if not possible, use the url as the key\r\n if (ContextShareProvider.isProviderUrl(tilesetUrl)) {\r\n const info = ContextShareProvider.getInfoFromUrl(tilesetUrl);\r\n const provider = inputProvider ? inputProvider : info.provider;\r\n format = inputFormat ? inputFormat : info.format;\r\n const contextShareKey: RealityDataSourceKey = { provider, format, id: info.id, iTwinId: info.iTwinId };\r\n return contextShareKey;\r\n }\r\n\r\n // default to tileSetUrl\r\n const provider2 = inputProvider ? inputProvider : RealityDataProvider.TilesetUrl;\r\n const urlKey: RealityDataSourceKey = { provider: provider2, format, id: tilesetUrl };\r\n return urlKey;\r\n }\r\n /** @alpha - was used for a very specific case of point cloud (opc) attachment that should not be made public */\r\n export function createKeyFromBlobUrl(blobUrl: string, inputProvider?: RealityDataProvider, inputFormat?: RealityDataFormat): RealityDataSourceKey {\r\n const info = ContextShareProvider.getInfoFromBlobUrl(blobUrl);\r\n const format = inputFormat ? inputFormat : info.format;\r\n const provider = inputProvider ? inputProvider : info.provider;\r\n const contextShareKey: RealityDataSourceKey = { provider, format, id: info.id };\r\n return contextShareKey;\r\n }\r\n /** @alpha - OrbitGtBlobProps is alpha */\r\n export function createKeyFromOrbitGtBlobProps(orbitGtBlob: OrbitGtBlobProps, inputProvider?: RealityDataProvider, inputFormat?: RealityDataFormat): RealityDataSourceKey {\r\n const format = inputFormat ? inputFormat : RealityDataFormat.OPC;\r\n if (orbitGtBlob.blobFileName && orbitGtBlob.blobFileName.toLowerCase().startsWith(\"http\")) {\r\n return RealityDataSource.createKeyFromBlobUrl(orbitGtBlob.blobFileName, inputProvider, format);\r\n } else if (orbitGtBlob.rdsUrl) {\r\n return RealityDataSource.createKeyFromUrl(orbitGtBlob.rdsUrl, inputProvider, format);\r\n }\r\n const provider = inputProvider ? inputProvider : RealityDataProvider.OrbitGtBlob;\r\n const id = `${orbitGtBlob.accountName}:${orbitGtBlob.containerName}:${orbitGtBlob.blobFileName}:?${orbitGtBlob.sasToken}`;\r\n return { provider, format, id };\r\n }\r\n /** @alpha - OrbitGtBlobProps is alpha */\r\n export function createOrbitGtBlobPropsFromKey(rdSourceKey: RealityDataSourceKey): OrbitGtBlobProps | undefined {\r\n if (rdSourceKey.provider !== RealityDataProvider.OrbitGtBlob)\r\n return undefined;\r\n const splitIds = rdSourceKey.id.split(\":\");\r\n const sasTokenIndex = rdSourceKey.id.indexOf(\":?\");\r\n const sasToken = rdSourceKey.id.substring(sasTokenIndex + 2);\r\n const orbitGtBlob: OrbitGtBlobProps = {\r\n accountName: splitIds[0],\r\n containerName: splitIds[1],\r\n blobFileName: splitIds[2],\r\n sasToken,\r\n };\r\n return orbitGtBlob;\r\n }\r\n /** @internal - Is used by \"fdt attach cesium asset\" keyin*/\r\n export function createCesiumIonAssetKey(osmAssetId: number, requestKey: string): RealityDataSourceKey {\r\n const id = getCesiumAssetUrl(osmAssetId,requestKey);\r\n return {provider: RealityDataProvider.CesiumIonAsset, format: RealityDataFormat.ThreeDTile, id};\r\n }\r\n /** Return an instance of a RealityDataSource from a source key.\r\n * There will aways be only one reality data RealityDataSource for a corresponding reality data source key.\r\n * @alpha\r\n */\r\n export async function fromKey(key: RealityDataSourceKey, iTwinId: GuidString | undefined): Promise<RealityDataSource | undefined> {\r\n const provider = IModelApp.realityDataSourceProviders.find(key.provider);\r\n if (!provider) {\r\n Logger.logWarning(loggerCategory, `RealityDataSourceProvider \"${key.provider}\" is not registered`);\r\n return undefined;\r\n }\r\n\r\n return provider.createRealityDataSource(key, iTwinId);\r\n }\r\n}\r\n\r\n/** A named supplier of [RealityDataSource]]s.\r\n * The provider's name is stored in a [RealityDataSourceKey]($common). When the [[RealityDataSource]] is requested from the key,\r\n * the provider is looked up in [[IModelApp.realityDataSourceProviders]] by its name and, if found, its [[createRealityDataSource]] method\r\n * is invoked to produce the reality data source.\r\n * @beta\r\n */\r\n\r\nexport interface RealityDataSourceProvider {\r\n /** Produce a RealityDataSource for the specified `key`.\r\n * @param key Identifies the reality data source.\r\n * @param iTwinId A default iTwinId to use.\r\n * @returns the requested reality data source, or `undefined` if it could not be produced.\r\n */\r\n createRealityDataSource(key: RealityDataSourceKey, iTwinId: GuidString | undefined): Promise<RealityDataSource | undefined>;\r\n /** Optionally add any decorations specific to this reality data source provider.\r\n * For example, the Google Photorealistic 3D Tiles reality data source provider will add the Google logo.\r\n */\r\n decorate?(_context: DecorateContext): void;\r\n /** Optionally add attribution logo cards to the viewport's logo div. */\r\n addAttributions?(cards: HTMLTableElement, vp: ScreenViewport): Promise<void>;\r\n /** Enables cached decorations for this provider. @see [[ViewportDecorator.useCachedDecorations]] */\r\n useCachedDecorations?: true | undefined;\r\n}\r\n\r\n/** A registry of [[RealityDataSourceProvider]]s identified by their unique names. The registry can be accessed via [[IModelApp.realityDataSourceProviders]].\r\n * It includes a handful of built-in providers for sources like Cesium ION, ContextShare, OrbitGT, and arbitrary public-accessible URLs.\r\n * Any number of additional providers can be registered. They should typically be registered just after [[IModelApp.startup]].\r\n * @beta\r\n */\r\nexport class RealityDataSourceProviderRegistry {\r\n private readonly _providers = new Map<string, RealityDataSourceProvider>();\r\n\r\n /** @internal */\r\n public constructor() {\r\n this.register(RealityDataProvider.CesiumIonAsset, {\r\n createRealityDataSource: async (key, iTwinId) => RealityDataSourceCesiumIonAssetImpl.createFromKey(key, iTwinId),\r\n });\r\n this.register(RealityDataProvider.TilesetUrl, {\r\n createRealityDataSource: async (key, iTwinId) => RealityDataSourceTilesetUrlImpl.createFromKey(key, iTwinId),\r\n });\r\n this.register(RealityDataProvider.ContextShare, {\r\n createRealityDataSource: async (key, iTwinId) => RealityDataSourceContextShareImpl.createFromKey(key, iTwinId),\r\n });\r\n this.register(RealityDataProvider.OrbitGtBlob, {\r\n // ###TODO separate TilesetUrlImpl\r\n createRealityDataSource: async (key, iTwinId) => RealityDataSourceTilesetUrlImpl.createFromKey(key, iTwinId),\r\n });\r\n }\r\n\r\n /** Register `provider` to produce [[RealityDataSource]]s for the specified provider `name`. */\r\n public register(name: string, provider: RealityDataSourceProvider): void {\r\n this._providers.set(name, provider);\r\n }\r\n\r\n /** Look up the provider registered by the specified `name`. */\r\n public find(name: string): RealityDataSourceProvider | undefined {\r\n return this._providers.get(name);\r\n }\r\n}\r\n\r\n/**\r\n * Options for creating a Google Photorealistic 3D Tiles reality data source provider.\r\n * The caller must provide either an API key or a function that returns an auth token.\r\n * @beta\r\n */\r\nexport type Google3dTilesProviderOptions = {\r\n /** Google Map Tiles API Key used to access Google 3D Tiles. */\r\n apiKey: string;\r\n getAuthToken?: never;\r\n /** 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`. */\r\n showCreditsOnScreen?: boolean\r\n} | {\r\n apiKey?: never;\r\n /** Function that returns an OAuth token for authenticating with Google 3D Tiles. This token is expected to not contain the \"Bearer\" prefix. */\r\n getAuthToken: () => Promise<string>;\r\n /** 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`. */\r\n showCreditsOnScreen?: boolean;\r\n};\r\n\r\n/**\r\n * Will provide Google Photorealistic 3D Tiles (in 3dTile format).\r\n * A valid API key or getAuthToken fuction must be supplied when creating this provider.\r\n * To use this provider, you must register it with [[IModelApp.realityDataSourceProviders]].\r\n * Example usage:\r\n * ```ts\r\n * [[include:GooglePhotorealistic3dTiles_providerApiKey]]\r\n * ```\r\n * @see [Google Photorealistic 3D Tiles]($docs/learning/frontend/GooglePhotorealistic3dTiles.md)\r\n * @beta\r\n */\r\nexport class Google3dTilesProvider implements RealityDataSourceProvider {\r\n /** Google Map Tiles API Key used to access Google 3D Tiles. */\r\n private _apiKey?: string;\r\n /** Function that returns an OAuth token for authenticating with Google 3D Tiles. This token is expected to not contain the \"Bearer\" prefix. */\r\n private _getAuthToken?: () => Promise<string | undefined>;\r\n /** Decorator for Google Maps logos. */\r\n private _decorator: GoogleMapsDecorator;\r\n /** Enables cached decorations for this provider. @see [[ViewportDecorator.useCachedDecorations]] */\r\n public readonly useCachedDecorations = true;\r\n\r\n public async createRealityDataSource(key: RealityDataSourceKey, iTwinId: GuidString | undefined): Promise<RealityDataSource | undefined> {\r\n if (!this._apiKey && !this._getAuthToken) {\r\n Logger.logError(loggerCategory, \"Either an API key or getAuthToken function are required to create a Google3dTilesProvider.\");\r\n return undefined;\r\n }\r\n return RealityDataSourceGoogle3dTilesImpl.createFromKey(key, iTwinId, this._apiKey, this._getAuthToken);\r\n }\r\n\r\n public constructor(options: Google3dTilesProviderOptions) {\r\n this._apiKey = options.apiKey;\r\n this._getAuthToken = options.getAuthToken;\r\n this._decorator = new GoogleMapsDecorator(options.showCreditsOnScreen ?? true);\r\n }\r\n\r\n /**\r\n * Initialize the Google 3D Tiles reality data source provider by activating its decorator, which consists of loading the correct Google Maps logo.\r\n * @returns `true` if the decorator was successfully activated, otherwise `false`.\r\n */\r\n public async initialize(): Promise<boolean> {\r\n const isActivated = await this._decorator.activate(\"satellite\");\r\n if (!isActivated) {\r\n const msg = \"Failed to activate decorator\";\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n return isActivated;\r\n }\r\n\r\n public decorate(_context: DecorateContext): void {\r\n this._decorator.decorate(_context);\r\n }\r\n\r\n public async addAttributions(cards: HTMLTableElement, vp: ScreenViewport): Promise<void> {\r\n const copyrightMap = getCopyrights(vp);\r\n\r\n // Only add another logo card if the tiles have copyright\r\n if (copyrightMap.size > 0) {\r\n // Order by most occurances to least\r\n // See https://developers.google.com/maps/documentation/tile/create-renderer#display-attributions\r\n const sortedCopyrights = [...copyrightMap.entries()].sort((a, b) => b[1] - a[1]);\r\n\r\n let copyrightMsg = \"Data provided by:<br><ul>\";\r\n copyrightMsg += sortedCopyrights.map(([key]) => `<li>${key}</li>`).join(\"\");\r\n copyrightMsg += \"</ul>\";\r\n\r\n cards.appendChild(IModelApp.makeLogoCard({\r\n iconSrc: `${IModelApp.publicPath}images/google_on_white_hdpi.png`,\r\n heading: \"Google Photorealistic 3D Tiles\",\r\n notice: copyrightMsg\r\n }));\r\n }\r\n }\r\n}\r\n\r\n/** Returns the URL used for retrieving Google Photorealistic 3D Tiles.\r\n * @beta\r\n */\r\nexport function getGoogle3dTilesUrl() {\r\n return \"https://tile.googleapis.com/v1/3dtiles/root.json\";\r\n}\r\n"]}
|
|
@@ -70,7 +70,7 @@ class RealityDataSourceTilesetUrlImpl {
|
|
|
70
70
|
// otherwise the full path to root document is given.
|
|
71
71
|
// The base URL contains the base URL from which tile relative path are constructed.
|
|
72
72
|
// The tile's path root will need to be reinserted for child tiles to return a 200
|
|
73
|
-
// If the original url includes search paramaters, they are stored in _searchParams to be reinserted into child tile requests.
|
|
73
|
+
// If the original root tileset url includes search paramaters, they are stored in _searchParams to be reinserted into child tile requests.
|
|
74
74
|
setBaseUrl(url) {
|
|
75
75
|
const urlParts = url.split("/");
|
|
76
76
|
const newUrl = new URL(url);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealityDataSourceTilesetUrlImpl.js","sourceRoot":"","sources":["../../src/RealityDataSourceTilesetUrlImpl.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAwE;AACxE,oDAAoJ;AAEpJ,+CAA4C;AAE5C,8CAA8D;AAE9D;;;;;;EAME;AACF,MAAa,+BAA+B;IAC1B,GAAG,CAAuB;IAC1C,2EAA2E;IACnE,WAAW,CAAqB;IACxC,sIAAsI;IAC9H,QAAQ,GAAW,EAAE,CAAC;IAC9B,wIAAwI;IAChI,aAAa,GAAW,EAAE,CAAC;IAEnC;;OAEG;IACH,YAAsB,KAA6B;QACjD,IAAA,qBAAM,EAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,KAAK,iCAAmB,CAAC,UAAU,IAAI,KAAK,CAAC,SAAS,CAAC,QAAQ,KAAK,iCAAmB,CAAC,WAAW,CAAC,CAAC;QACpI,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,SAA+B,EAAE,QAAgC;QACjG,IAAI,SAAS,CAAC,QAAQ,KAAK,iCAAmB,CAAC,UAAU;YACvD,OAAO,SAAS,CA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B,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;IACzG,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,4BAA4B;QACvC,IAAI,eAAsD,CAAC;QAC3D,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,+BAAiB,CAAC,UAAU,EAAE,CAAC;YACrD,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;YAC3D,eAAe,GAAG,sCAA2B,CAAC,4BAA4B,CAAC,YAAY,CAAC,CAAC;QAC3F,CAAC;QACD,OAAO,eAAe,CAAC;IACzB,CAAC;IACD;;;;;OAKG;IACI,KAAK,CAAC,uBAAuB;QAClC,IAAI,aAA+C,CAAC;QACpD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF;AAnJD,0EAmJC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\nimport { assert, BentleyStatus, GuidString } from \"@itwin/core-bentley\";\r\nimport { IModelError, RealityData, RealityDataFormat, RealityDataProvider, RealityDataSourceKey, RealityDataSourceProps } from \"@itwin/core-common\";\r\n\r\nimport { request } from \"./request/Request\";\r\nimport { PublisherProductInfo, RealityDataSource, SpatialLocationAndExtents } from \"./RealityDataSource\";\r\nimport { ThreeDTileFormatInterpreter } from \"./tile/internal\";\r\n\r\n/** This class provides access to the reality data provider services.\r\n * It encapsulates access to a reality data weiter it be from local access, http or ProjectWise Context Share.\r\n * The key provided at the creation determines if this is ProjectWise Context Share reference.\r\n * If not then it is considered local (ex: C:\\temp\\TileRoot.json) or plain http access (http://someserver.com/data/TileRoot.json)\r\n * There is a one to one relationship between a reality data and the instances of present class.\r\n* @internal\r\n*/\r\nexport class RealityDataSourceTilesetUrlImpl implements RealityDataSource {\r\n public readonly key: RealityDataSourceKey;\r\n /** The URL that supplies the 3d tiles for displaying the reality model. */\r\n private _tilesetUrl: string | undefined;\r\n /** For use by all Reality Data. For RD stored on PW Context Share, represents the portion from the root of the Azure Blob Container*/\r\n private _baseUrl: string = \"\";\r\n /** Need to be passed down to child tile requests when requesting from blob storage, e.g. a Cesium export from the Mesh Export Service*/\r\n private _searchParams: string = \"\";\r\n\r\n /** Construct a new reality data source.\r\n * @param props JSON representation of the reality data source\r\n */\r\n protected constructor(props: RealityDataSourceProps) {\r\n assert(props.sourceKey.provider === RealityDataProvider.TilesetUrl || props.sourceKey.provider === RealityDataProvider.OrbitGtBlob);\r\n this.key = props.sourceKey;\r\n this._tilesetUrl = this.key.id;\r\n }\r\n\r\n /**\r\n * Create an instance of this class from a source key and iTwin context/\r\n */\r\n public static async createFromKey(sourceKey: RealityDataSourceKey, _iTwinId: GuidString | undefined): Promise<RealityDataSource | undefined> {\r\n if (sourceKey.provider !== RealityDataProvider.TilesetUrl)\r\n return undefined;\r\n const rdSource = new RealityDataSourceTilesetUrlImpl({ sourceKey });\r\n return rdSource;\r\n }\r\n\r\n public get isContextShare(): boolean {\r\n return false;\r\n }\r\n /**\r\n * Returns Reality Data if available\r\n */\r\n public get realityData(): RealityData | undefined {\r\n return undefined;\r\n }\r\n public get realityDataId(): string | undefined {\r\n return undefined;\r\n }\r\n /**\r\n * Returns Reality Data type if available\r\n */\r\n public get realityDataType(): string | undefined {\r\n return undefined;\r\n }\r\n\r\n public getTilesetUrl(): string | undefined {\r\n return this._tilesetUrl;\r\n }\r\n // This is to set the root url from the provided root document path.\r\n // If the root document is stored on PW Context Share then the root document property of the Reality Data is provided,\r\n // otherwise the full path to root document is given.\r\n // The base URL contains the base URL from which tile relative path are constructed.\r\n // The tile's path root will need to be reinserted for child tiles to return a 200\r\n // If the original url includes search paramaters, they are stored in _searchParams to be reinserted into child tile requests.\r\n private setBaseUrl(url: string): void {\r\n const urlParts = url.split(\"/\");\r\n const newUrl = new URL(url);\r\n this._searchParams = newUrl.search;\r\n urlParts.pop();\r\n if (urlParts.length === 0)\r\n this._baseUrl = \"\";\r\n else\r\n this._baseUrl = `${urlParts.join(\"/\")}/`;\r\n }\r\n\r\n /**\r\n * This method returns the URL to access the actual 3d tiles from the service provider.\r\n * @returns string containing the URL to reality data.\r\n */\r\n public async getServiceUrl(_iTwinId: GuidString | undefined): Promise<string | undefined> {\r\n return this._tilesetUrl;\r\n }\r\n\r\n public async getRootDocument(iTwinId: GuidString | undefined): Promise<any> {\r\n const url = await this.getServiceUrl(iTwinId);\r\n if (!url)\r\n throw new IModelError(BentleyStatus.ERROR, \"Unable to get service url\");\r\n\r\n // The following is only if the reality data is not stored on PW Context Share.\r\n this.setBaseUrl(url);\r\n return request(url, \"json\");\r\n }\r\n\r\n private isValidURL(url: string){\r\n try {\r\n new URL(url);\r\n } catch {\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /** Returns the tile URL.\r\n * If the tile path is a relative URL, the base URL is prepended to it.\r\n * For both absolute and relative tile path URLs, the search parameters are checked. If the search params are empty, the base URL's search params are appended to the tile path.\r\n */\r\n private getTileUrl(tilePath: string){\r\n if (this.isValidURL(tilePath)) {\r\n const url = new URL(tilePath);\r\n return url.search === \"\" ? `${tilePath}${this._searchParams}` : tilePath;\r\n }\r\n return tilePath.includes(\"?\") ? `${this._baseUrl}${tilePath}` : `${this._baseUrl}${tilePath}${this._searchParams}`;\r\n }\r\n\r\n /**\r\n * Returns the tile content. The path to the tile is relative to the base url of present reality data whatever the type.\r\n */\r\n public async getTileContent(name: string): Promise<ArrayBuffer> {\r\n return request(this.getTileUrl(name), \"arraybuffer\");\r\n }\r\n\r\n /**\r\n * Returns the tile content in json format. The path to the tile is relative to the base url of present reality data whatever the type.\r\n */\r\n public async getTileJson(name: string): Promise<any> {\r\n return request(this.getTileUrl(name), \"json\");\r\n }\r\n\r\n public getTileContentType(url: string): \"tile\" | \"tileset\" {\r\n return new URL(url, \"https://localhost/\").pathname.toLowerCase().endsWith(\"json\") ? \"tileset\" : \"tile\";\r\n }\r\n\r\n /**\r\n * Gets spatial location and extents of this reality data source\r\n * @returns spatial location and extents\r\n * @internal\r\n */\r\n public async getSpatialLocationAndExtents(): Promise<SpatialLocationAndExtents | undefined> {\r\n let spatialLocation: SpatialLocationAndExtents | undefined;\r\n if (this.key.format === RealityDataFormat.ThreeDTile) {\r\n const rootDocument = await this.getRootDocument(undefined);\r\n spatialLocation = ThreeDTileFormatInterpreter.getSpatialLocationAndExtents(rootDocument);\r\n }\r\n return spatialLocation;\r\n }\r\n /**\r\n * Gets information to identify the product and engine that create this reality data\r\n * Will return undefined if cannot be resolved\r\n * @returns information to identify the product and engine that create this reality data\r\n * @alpha\r\n */\r\n public async getPublisherProductInfo(): Promise<PublisherProductInfo | undefined> {\r\n let publisherInfo: PublisherProductInfo | undefined;\r\n return publisherInfo;\r\n }\r\n}\r\n\r\n"]}
|
|
1
|
+
{"version":3,"file":"RealityDataSourceTilesetUrlImpl.js","sourceRoot":"","sources":["../../src/RealityDataSourceTilesetUrlImpl.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAwE;AACxE,oDAAoJ;AAEpJ,+CAA4C;AAE5C,8CAA8D;AAE9D;;;;;;EAME;AACF,MAAa,+BAA+B;IAC1B,GAAG,CAAuB;IAC1C,2EAA2E;IACnE,WAAW,CAAqB;IACxC,sIAAsI;IAC9H,QAAQ,GAAW,EAAE,CAAC;IAC9B,wIAAwI;IAChI,aAAa,GAAW,EAAE,CAAC;IAEnC;;OAEG;IACH,YAAsB,KAA6B;QACjD,IAAA,qBAAM,EAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,KAAK,iCAAmB,CAAC,UAAU,IAAI,KAAK,CAAC,SAAS,CAAC,QAAQ,KAAK,iCAAmB,CAAC,WAAW,CAAC,CAAC;QACpI,IAAI,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IAAI,CAAC,EAAE,aAAa,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,WAAW,CAAC,IAAY;QACnC,OAAO,IAAA,iBAAO,EAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;IAEM,kBAAkB,CAAC,GAAW;QACnC,OAAO,IAAI,GAAG,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;IACzG,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,4BAA4B;QACvC,IAAI,eAAsD,CAAC;QAC3D,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,+BAAiB,CAAC,UAAU,EAAE,CAAC;YACrD,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;YAC3D,eAAe,GAAG,sCAA2B,CAAC,4BAA4B,CAAC,YAAY,CAAC,CAAC;QAC3F,CAAC;QACD,OAAO,eAAe,CAAC;IACzB,CAAC;IACD;;;;;OAKG;IACI,KAAK,CAAC,uBAAuB;QAClC,IAAI,aAA+C,CAAC;QACpD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF;AAnJD,0EAmJC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\nimport { assert, BentleyStatus, GuidString } from \"@itwin/core-bentley\";\r\nimport { IModelError, RealityData, RealityDataFormat, RealityDataProvider, RealityDataSourceKey, RealityDataSourceProps } from \"@itwin/core-common\";\r\n\r\nimport { request } from \"./request/Request\";\r\nimport { PublisherProductInfo, RealityDataSource, SpatialLocationAndExtents } from \"./RealityDataSource\";\r\nimport { ThreeDTileFormatInterpreter } from \"./tile/internal\";\r\n\r\n/** This class provides access to the reality data provider services.\r\n * It encapsulates access to a reality data weiter it be from local access, http or ProjectWise Context Share.\r\n * The key provided at the creation determines if this is ProjectWise Context Share reference.\r\n * If not then it is considered local (ex: C:\\temp\\TileRoot.json) or plain http access (http://someserver.com/data/TileRoot.json)\r\n * There is a one to one relationship between a reality data and the instances of present class.\r\n* @internal\r\n*/\r\nexport class RealityDataSourceTilesetUrlImpl implements RealityDataSource {\r\n public readonly key: RealityDataSourceKey;\r\n /** The URL that supplies the 3d tiles for displaying the reality model. */\r\n private _tilesetUrl: string | undefined;\r\n /** For use by all Reality Data. For RD stored on PW Context Share, represents the portion from the root of the Azure Blob Container*/\r\n private _baseUrl: string = \"\";\r\n /** Need to be passed down to child tile requests when requesting from blob storage, e.g. a Cesium export from the Mesh Export Service*/\r\n private _searchParams: string = \"\";\r\n\r\n /** Construct a new reality data source.\r\n * @param props JSON representation of the reality data source\r\n */\r\n protected constructor(props: RealityDataSourceProps) {\r\n assert(props.sourceKey.provider === RealityDataProvider.TilesetUrl || props.sourceKey.provider === RealityDataProvider.OrbitGtBlob);\r\n this.key = props.sourceKey;\r\n this._tilesetUrl = this.key.id;\r\n }\r\n\r\n /**\r\n * Create an instance of this class from a source key and iTwin context/\r\n */\r\n public static async createFromKey(sourceKey: RealityDataSourceKey, _iTwinId: GuidString | undefined): Promise<RealityDataSource | undefined> {\r\n if (sourceKey.provider !== RealityDataProvider.TilesetUrl)\r\n return undefined;\r\n const rdSource = new RealityDataSourceTilesetUrlImpl({ sourceKey });\r\n return rdSource;\r\n }\r\n\r\n public get isContextShare(): boolean {\r\n return false;\r\n }\r\n /**\r\n * Returns Reality Data if available\r\n */\r\n public get realityData(): RealityData | undefined {\r\n return undefined;\r\n }\r\n public get realityDataId(): string | undefined {\r\n return undefined;\r\n }\r\n /**\r\n * Returns Reality Data type if available\r\n */\r\n public get realityDataType(): string | undefined {\r\n return undefined;\r\n }\r\n\r\n public getTilesetUrl(): string | undefined {\r\n return this._tilesetUrl;\r\n }\r\n // This is to set the root url from the provided root document path.\r\n // If the root document is stored on PW Context Share then the root document property of the Reality Data is provided,\r\n // otherwise the full path to root document is given.\r\n // The base URL contains the base URL from which tile relative path are constructed.\r\n // The tile's path root will need to be reinserted for child tiles to return a 200\r\n // If the original root tileset url includes search paramaters, they are stored in _searchParams to be reinserted into child tile requests.\r\n private setBaseUrl(url: string): void {\r\n const urlParts = url.split(\"/\");\r\n const newUrl = new URL(url);\r\n this._searchParams = newUrl.search;\r\n urlParts.pop();\r\n if (urlParts.length === 0)\r\n this._baseUrl = \"\";\r\n else\r\n this._baseUrl = `${urlParts.join(\"/\")}/`;\r\n }\r\n\r\n /**\r\n * This method returns the URL to access the actual 3d tiles from the service provider.\r\n * @returns string containing the URL to reality data.\r\n */\r\n public async getServiceUrl(_iTwinId: GuidString | undefined): Promise<string | undefined> {\r\n return this._tilesetUrl;\r\n }\r\n\r\n public async getRootDocument(iTwinId: GuidString | undefined): Promise<any> {\r\n const url = await this.getServiceUrl(iTwinId);\r\n if (!url)\r\n throw new IModelError(BentleyStatus.ERROR, \"Unable to get service url\");\r\n\r\n // The following is only if the reality data is not stored on PW Context Share.\r\n this.setBaseUrl(url);\r\n return request(url, \"json\");\r\n }\r\n\r\n private isValidURL(url: string){\r\n try {\r\n new URL(url);\r\n } catch {\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /** Returns the tile URL.\r\n * If the tile path is a relative URL, the base URL is prepended to it.\r\n * For both absolute and relative tile path URLs, the search parameters are checked. If the search params are empty, the base URL's search params are appended to the tile path.\r\n */\r\n private getTileUrl(tilePath: string){\r\n if (this.isValidURL(tilePath)) {\r\n const url = new URL(tilePath);\r\n return url.search === \"\" ? `${tilePath}${this._searchParams}` : tilePath;\r\n }\r\n return tilePath.includes(\"?\") ? `${this._baseUrl}${tilePath}` : `${this._baseUrl}${tilePath}${this._searchParams}`;\r\n }\r\n\r\n /**\r\n * Returns the tile content. The path to the tile is relative to the base url of present reality data whatever the type.\r\n */\r\n public async getTileContent(name: string): Promise<ArrayBuffer> {\r\n return request(this.getTileUrl(name), \"arraybuffer\");\r\n }\r\n\r\n /**\r\n * Returns the tile content in json format. The path to the tile is relative to the base url of present reality data whatever the type.\r\n */\r\n public async getTileJson(name: string): Promise<any> {\r\n return request(this.getTileUrl(name), \"json\");\r\n }\r\n\r\n public getTileContentType(url: string): \"tile\" | \"tileset\" {\r\n return new URL(url, \"https://localhost/\").pathname.toLowerCase().endsWith(\"json\") ? \"tileset\" : \"tile\";\r\n }\r\n\r\n /**\r\n * Gets spatial location and extents of this reality data source\r\n * @returns spatial location and extents\r\n * @internal\r\n */\r\n public async getSpatialLocationAndExtents(): Promise<SpatialLocationAndExtents | undefined> {\r\n let spatialLocation: SpatialLocationAndExtents | undefined;\r\n if (this.key.format === RealityDataFormat.ThreeDTile) {\r\n const rootDocument = await this.getRootDocument(undefined);\r\n spatialLocation = ThreeDTileFormatInterpreter.getSpatialLocationAndExtents(rootDocument);\r\n }\r\n return spatialLocation;\r\n }\r\n /**\r\n * Gets information to identify the product and engine that create this reality data\r\n * Will return undefined if cannot be resolved\r\n * @returns information to identify the product and engine that create this reality data\r\n * @alpha\r\n */\r\n public async getPublisherProductInfo(): Promise<PublisherProductInfo | undefined> {\r\n let publisherInfo: PublisherProductInfo | undefined;\r\n return publisherInfo;\r\n }\r\n}\r\n\r\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Point3d } from "@itwin/core-geometry";
|
|
2
|
+
import { CanvasDecoration } from "../render/CanvasDecoration";
|
|
3
|
+
import { DecorateContext } from "../ViewContext";
|
|
4
|
+
import { Decorator } from "../ViewManager";
|
|
5
|
+
import { Sprite } from "../Sprites";
|
|
6
|
+
import { ScreenViewport } from "../Viewport";
|
|
7
|
+
/** Layer types that can be added to the map.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
type GoogleMapsMapTypes = "roadmap" | "satellite" | "terrain";
|
|
11
|
+
/** A simple decorator that shows the logo at a given screen position.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare class LogoDecoration implements CanvasDecoration {
|
|
15
|
+
private _sprite?;
|
|
16
|
+
/** The current position of the logo in view coordinates. */
|
|
17
|
+
readonly position: Point3d;
|
|
18
|
+
private _offset;
|
|
19
|
+
set offset(offset: Point3d | undefined);
|
|
20
|
+
/** The logo offset in view coordinates.*/
|
|
21
|
+
get offset(): Point3d | undefined;
|
|
22
|
+
/** Move the logo to the lower left corner of the screen. */
|
|
23
|
+
moveToLowerLeftCorner(context: DecorateContext): boolean;
|
|
24
|
+
/** Indicate if the logo is loaded and ready to be drawn. */
|
|
25
|
+
get isLoaded(): boolean;
|
|
26
|
+
activate(sprite: Sprite): Promise<boolean>;
|
|
27
|
+
/** Draw this sprite onto the supplied canvas.
|
|
28
|
+
* @see [[CanvasDecoration.drawDecoration]]
|
|
29
|
+
*/
|
|
30
|
+
drawDecoration(ctx: CanvasRenderingContext2D): void;
|
|
31
|
+
decorate(context: DecorateContext): void;
|
|
32
|
+
}
|
|
33
|
+
/** A decorator that adds the Google Maps logo to the lower left corner of the screen.
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export declare class GoogleMapsDecorator implements Decorator {
|
|
37
|
+
readonly logo: LogoDecoration;
|
|
38
|
+
private _showCreditsOnScreen?;
|
|
39
|
+
/** Create a new GoogleMapsDecorator.
|
|
40
|
+
* @param showCreditsOnScreen If true, the data attributions/copyrights from the Google Photorealistic 3D Tiles will be displayed on screen. The Google Maps logo will always be displayed.
|
|
41
|
+
*/
|
|
42
|
+
constructor(showCreditsOnScreen?: boolean);
|
|
43
|
+
/** Activate the logo based on the given map type. */
|
|
44
|
+
activate(mapType: GoogleMapsMapTypes): Promise<boolean>;
|
|
45
|
+
/** Decorate implementation */
|
|
46
|
+
decorate: (context: DecorateContext) => void;
|
|
47
|
+
}
|
|
48
|
+
/** Get copyrights from tiles currently in the viewport.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
export declare function getCopyrights(vp: ScreenViewport): Map<string, number>;
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=GoogleMapsDecorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleMapsDecorator.d.ts","sourceRoot":"","sources":["../../../src/internal/GoogleMapsDecorator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAe,MAAM,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,KAAK,kBAAkB,GAAI,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;AAE/D;;GAEG;AACH,qBAAa,cAAe,YAAW,gBAAgB;IACrD,OAAO,CAAC,OAAO,CAAC,CAAS;IAEzB,4DAA4D;IAC5D,SAAgB,QAAQ,UAAiB;IAEzC,OAAO,CAAC,OAAO,CAAsB;IAErC,IAAW,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,EAE5C;IAED,0CAA0C;IAC1C,IAAW,MAAM,IALS,OAAO,GAAG,SAAS,CAO5C;IAED,4DAA4D;IACrD,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO;IAa/D,4DAA4D;IAC5D,IAAW,QAAQ,YAA8C;IAEpD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAWvD;;OAEG;IACI,cAAc,CAAC,GAAG,EAAE,wBAAwB,GAAG,IAAI;IAOnD,QAAQ,CAAC,OAAO,EAAE,eAAe;CAGzC;AAED;;GAEG;AACH,qBAAa,mBAAoB,YAAW,SAAS;IACnD,SAAgB,IAAI,iBAAwB;IAC5C,OAAO,CAAC,oBAAoB,CAAC,CAAU;IAEvC;;OAEG;gBACS,mBAAmB,CAAC,EAAE,OAAO;IAIzC,qDAAqD;IACxC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAYpE,8BAA8B;IACvB,QAAQ,YAAa,eAAe,UA2BzC;CACH;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAcrE"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.GoogleMapsDecorator = exports.LogoDecoration = void 0;
|
|
8
|
+
exports.getCopyrights = getCopyrights;
|
|
9
|
+
const core_geometry_1 = require("@itwin/core-geometry");
|
|
10
|
+
const IModelApp_1 = require("../IModelApp");
|
|
11
|
+
const Sprites_1 = require("../Sprites");
|
|
12
|
+
/** A simple decorator that shows the logo at a given screen position.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
class LogoDecoration {
|
|
16
|
+
_sprite;
|
|
17
|
+
/** The current position of the logo in view coordinates. */
|
|
18
|
+
position = new core_geometry_1.Point3d();
|
|
19
|
+
_offset;
|
|
20
|
+
set offset(offset) {
|
|
21
|
+
this._offset = offset;
|
|
22
|
+
}
|
|
23
|
+
/** The logo offset in view coordinates.*/
|
|
24
|
+
get offset() {
|
|
25
|
+
return this._offset;
|
|
26
|
+
}
|
|
27
|
+
/** Move the logo to the lower left corner of the screen. */
|
|
28
|
+
moveToLowerLeftCorner(context) {
|
|
29
|
+
if (!this._sprite || !this._sprite.isLoaded)
|
|
30
|
+
return false;
|
|
31
|
+
this.position.x = this._offset?.x ?? 0;
|
|
32
|
+
this.position.y = context.viewport.parentDiv.clientHeight - this._sprite.size.y;
|
|
33
|
+
if (this._offset?.y)
|
|
34
|
+
this.position.y -= this._offset.y;
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
/* TODO: Add other move methods as needed */
|
|
38
|
+
/** Indicate if the logo is loaded and ready to be drawn. */
|
|
39
|
+
get isLoaded() { return this._sprite?.isLoaded ?? false; }
|
|
40
|
+
async activate(sprite) {
|
|
41
|
+
this._sprite = sprite;
|
|
42
|
+
return new Promise((resolve, _reject) => {
|
|
43
|
+
sprite.loadPromise.then(() => {
|
|
44
|
+
resolve(true);
|
|
45
|
+
}).catch(() => {
|
|
46
|
+
resolve(false);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** Draw this sprite onto the supplied canvas.
|
|
51
|
+
* @see [[CanvasDecoration.drawDecoration]]
|
|
52
|
+
*/
|
|
53
|
+
drawDecoration(ctx) {
|
|
54
|
+
if (this.isLoaded) {
|
|
55
|
+
// Draw image with an origin at the top left corner
|
|
56
|
+
ctx.drawImage(this._sprite.image, 0, 0);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
decorate(context) {
|
|
60
|
+
context.addCanvasDecoration(this);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.LogoDecoration = LogoDecoration;
|
|
64
|
+
/** A decorator that adds the Google Maps logo to the lower left corner of the screen.
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
class GoogleMapsDecorator {
|
|
68
|
+
logo = new LogoDecoration();
|
|
69
|
+
_showCreditsOnScreen;
|
|
70
|
+
/** Create a new GoogleMapsDecorator.
|
|
71
|
+
* @param showCreditsOnScreen If true, the data attributions/copyrights from the Google Photorealistic 3D Tiles will be displayed on screen. The Google Maps logo will always be displayed.
|
|
72
|
+
*/
|
|
73
|
+
constructor(showCreditsOnScreen) {
|
|
74
|
+
this._showCreditsOnScreen = showCreditsOnScreen;
|
|
75
|
+
}
|
|
76
|
+
/** Activate the logo based on the given map type. */
|
|
77
|
+
async activate(mapType) {
|
|
78
|
+
// Pick the logo that is the most visible on the background map
|
|
79
|
+
const imageName = mapType === "roadmap" ?
|
|
80
|
+
"google_on_white" :
|
|
81
|
+
"google_on_non_white";
|
|
82
|
+
// We need to move the logo right after the 'i.js' button
|
|
83
|
+
this.logo.offset = new core_geometry_1.Point3d(45, 10);
|
|
84
|
+
return this.logo.activate(Sprites_1.IconSprites.getSpriteFromUrl(`${IModelApp_1.IModelApp.publicPath}images/${imageName}.png`));
|
|
85
|
+
}
|
|
86
|
+
;
|
|
87
|
+
/** Decorate implementation */
|
|
88
|
+
decorate = (context) => {
|
|
89
|
+
if (!this.logo.isLoaded)
|
|
90
|
+
return;
|
|
91
|
+
this.logo.moveToLowerLeftCorner(context);
|
|
92
|
+
this.logo.decorate(context);
|
|
93
|
+
if (!this._showCreditsOnScreen)
|
|
94
|
+
return;
|
|
95
|
+
// Get data attribution (copyright) text
|
|
96
|
+
const copyrightMap = getCopyrights(context.viewport);
|
|
97
|
+
// Order by most occurances to least
|
|
98
|
+
// See https://developers.google.com/maps/documentation/tile/create-renderer#display-attributions
|
|
99
|
+
const sortedCopyrights = [...copyrightMap.entries()].sort((a, b) => b[1] - a[1]);
|
|
100
|
+
const copyrightText = sortedCopyrights.map(([key]) => ` • ${key}`).join("");
|
|
101
|
+
// Create and add element, offset to leave space for i.js and Google logos
|
|
102
|
+
const elem = document.createElement("div");
|
|
103
|
+
elem.innerHTML = copyrightText;
|
|
104
|
+
elem.style.color = "white";
|
|
105
|
+
elem.style.fontSize = "11px";
|
|
106
|
+
elem.style.textWrap = "wrap";
|
|
107
|
+
elem.style.position = "absolute";
|
|
108
|
+
elem.style.bottom = "10px";
|
|
109
|
+
elem.style.left = "107px";
|
|
110
|
+
context.addHtmlDecoration(elem);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
exports.GoogleMapsDecorator = GoogleMapsDecorator;
|
|
114
|
+
/** Get copyrights from tiles currently in the viewport.
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
function getCopyrights(vp) {
|
|
118
|
+
const tiles = IModelApp_1.IModelApp.tileAdmin.getTilesForUser(vp)?.selected;
|
|
119
|
+
const copyrightMap = new Map();
|
|
120
|
+
if (tiles) {
|
|
121
|
+
for (const tile of tiles) {
|
|
122
|
+
if (tile.copyright) {
|
|
123
|
+
for (const copyright of tile.copyright.split(";")) {
|
|
124
|
+
const currentCount = copyrightMap.get(copyright);
|
|
125
|
+
copyrightMap.set(copyright, currentCount ? currentCount + 1 : 1);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return copyrightMap;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=GoogleMapsDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleMapsDecorator.js","sourceRoot":"","sources":["../../../src/internal/GoogleMapsDecorator.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AA4I/F,sCAcC;AAxJD,wDAA+C;AAG/C,4CAAyC;AAEzC,wCAAiD;AASjD;;GAEG;AACH,MAAa,cAAc;IACjB,OAAO,CAAU;IAEzB,4DAA4D;IAC5C,QAAQ,GAAG,IAAI,uBAAO,EAAE,CAAC;IAEjC,OAAO,CAAsB;IAErC,IAAW,MAAM,CAAC,MAA2B;QAC3C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,0CAA0C;IAC1C,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,4DAA4D;IACrD,qBAAqB,CAAC,OAAwB;QACnD,IAA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,SAAS,CAAC,CAAC;oBACjD,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACnE,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { Point3d } from \"@itwin/core-geometry\";\r\nimport { CanvasDecoration } from \"../render/CanvasDecoration\";\r\nimport { DecorateContext } from \"../ViewContext\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { Decorator } from \"../ViewManager\";\r\nimport { IconSprites, Sprite } from \"../Sprites\";\r\nimport { RealityTile } from \"../tile/internal\";\r\nimport { ScreenViewport } from \"../Viewport\";\r\n\r\n/** Layer types that can be added to the map.\r\n * @internal\r\n */\r\ntype GoogleMapsMapTypes = \"roadmap\" | \"satellite\" | \"terrain\";\r\n\r\n/** A simple decorator that shows the logo at a given screen position.\r\n * @internal\r\n */\r\nexport class LogoDecoration implements CanvasDecoration {\r\n private _sprite?: Sprite;\r\n\r\n /** The current position of the logo in view coordinates. */\r\n public readonly position = new Point3d();\r\n\r\n private _offset: Point3d | undefined;\r\n\r\n public set offset(offset: Point3d | undefined) {\r\n this._offset = offset;\r\n }\r\n\r\n /** The logo offset in view coordinates.*/\r\n public get offset() {\r\n return this._offset;\r\n }\r\n\r\n /** Move the logo to the lower left corner of the screen. */\r\n public moveToLowerLeftCorner(context: DecorateContext): boolean {\r\n if (!this._sprite || !this._sprite.isLoaded)\r\n return false;\r\n\r\n this.position.x = this._offset?.x ?? 0;\r\n this.position.y = context.viewport.parentDiv.clientHeight - this._sprite.size.y;\r\n if (this._offset?.y)\r\n this.position.y -= this._offset.y;\r\n return true;\r\n }\r\n\r\n /* TODO: Add other move methods as needed */\r\n\r\n /** Indicate if the logo is loaded and ready to be drawn. */\r\n public get isLoaded() { return this._sprite?.isLoaded ?? false; }\r\n\r\n public async activate(sprite: Sprite): Promise<boolean> {\r\n this._sprite = sprite;\r\n return new Promise<boolean>((resolve, _reject) => {\r\n sprite.loadPromise.then(() => {\r\n resolve(true);\r\n }).catch(() => {\r\n resolve (false);\r\n });\r\n });\r\n }\r\n\r\n /** Draw this sprite onto the supplied canvas.\r\n * @see [[CanvasDecoration.drawDecoration]]\r\n */\r\n public drawDecoration(ctx: CanvasRenderingContext2D): void {\r\n if (this.isLoaded) {\r\n // Draw image with an origin at the top left corner\r\n ctx.drawImage(this._sprite!.image!, 0, 0);\r\n }\r\n }\r\n\r\n public decorate(context: DecorateContext) {\r\n context.addCanvasDecoration(this);\r\n }\r\n}\r\n\r\n/** A decorator that adds the Google Maps logo to the lower left corner of the screen.\r\n * @internal\r\n */\r\nexport class GoogleMapsDecorator implements Decorator {\r\n public readonly logo = new LogoDecoration();\r\n private _showCreditsOnScreen?: boolean;\r\n\r\n /** Create a new GoogleMapsDecorator.\r\n * @param showCreditsOnScreen If true, the data attributions/copyrights from the Google Photorealistic 3D Tiles will be displayed on screen. The Google Maps logo will always be displayed.\r\n */\r\n constructor(showCreditsOnScreen?: boolean) {\r\n this._showCreditsOnScreen = showCreditsOnScreen;\r\n }\r\n\r\n /** Activate the logo based on the given map type. */\r\n public async activate(mapType: GoogleMapsMapTypes): Promise<boolean> {\r\n // Pick the logo that is the most visible on the background map\r\n const imageName = mapType === \"roadmap\" ?\r\n \"google_on_white\" :\r\n \"google_on_non_white\";\r\n\r\n // We need to move the logo right after the 'i.js' button\r\n this.logo.offset = new Point3d(45, 10);\r\n\r\n return this.logo.activate(IconSprites.getSpriteFromUrl(`${IModelApp.publicPath}images/${imageName}.png`));\r\n };\r\n\r\n /** Decorate implementation */\r\n public decorate = (context: DecorateContext) => {\r\n if (!this.logo.isLoaded)\r\n return;\r\n this.logo.moveToLowerLeftCorner(context);\r\n this.logo.decorate(context);\r\n\r\n if (!this._showCreditsOnScreen)\r\n return;\r\n\r\n // Get data attribution (copyright) text\r\n const copyrightMap = getCopyrights(context.viewport);\r\n // Order by most occurances to least\r\n // See https://developers.google.com/maps/documentation/tile/create-renderer#display-attributions\r\n const sortedCopyrights = [...copyrightMap.entries()].sort((a, b) => b[1] - a[1]);\r\n const copyrightText = sortedCopyrights.map(([key]) => ` • ${key}`).join(\"\");\r\n\r\n // Create and add element, offset to leave space for i.js and Google logos\r\n const elem = document.createElement(\"div\");\r\n elem.innerHTML = copyrightText;\r\n elem.style.color = \"white\";\r\n elem.style.fontSize = \"11px\";\r\n elem.style.textWrap = \"wrap\";\r\n elem.style.position = \"absolute\";\r\n elem.style.bottom = \"10px\";\r\n elem.style.left = \"107px\";\r\n\r\n context.addHtmlDecoration(elem);\r\n };\r\n}\r\n\r\n/** Get copyrights from tiles currently in the viewport.\r\n * @internal\r\n */\r\nexport function getCopyrights(vp: ScreenViewport): Map<string, number> {\r\n const tiles = IModelApp.tileAdmin.getTilesForUser(vp)?.selected;\r\n const copyrightMap = new Map<string, number>();\r\n if (tiles) {\r\n for (const tile of tiles as Set<RealityTile>) {\r\n if (tile.copyright) {\r\n for (const copyright of tile.copyright.split(\";\")) {\r\n const currentCount = copyrightMap.get(copyright);\r\n copyrightMap.set(copyright, currentCount ? currentCount + 1 : 1);\r\n }\r\n }\r\n }\r\n }\r\n return copyrightMap;\r\n}"]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Tiles
|
|
3
|
+
*/
|
|
4
|
+
import { GuidString } from "@itwin/core-bentley";
|
|
5
|
+
import { RealityData, RealityDataSourceKey, RealityDataSourceProps } from "@itwin/core-common";
|
|
6
|
+
import { PublisherProductInfo, RealityDataSource, SpatialLocationAndExtents } from "../RealityDataSource";
|
|
7
|
+
/** This class provides access to the reality data provider services.
|
|
8
|
+
* It encapsulates access to a reality data from the Google Photorealistic 3D Tiles service.
|
|
9
|
+
* A valid Google 3D Tiles authentication key must be configured for this provider to work (provide the key in the [[RealityDataSourceGoogle3dTilesImpl.createFromKey]] method).
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare class RealityDataSourceGoogle3dTilesImpl implements RealityDataSource {
|
|
13
|
+
readonly key: RealityDataSourceKey;
|
|
14
|
+
/** The URL that supplies the 3d tiles for displaying the Google 3D Tiles tileset. */
|
|
15
|
+
private _tilesetUrl;
|
|
16
|
+
/** Base URL of the Google 3D Tiles tileset. Does not include trailing subdirectories. */
|
|
17
|
+
private _baseUrl;
|
|
18
|
+
/** Search parameters that must be passed down to child tile requests. */
|
|
19
|
+
private _searchParams?;
|
|
20
|
+
/** Google Map Tiles API Key used to access Google 3D Tiles. */
|
|
21
|
+
private _apiKey?;
|
|
22
|
+
/** Function that returns an OAuth token for authenticating with GP3sDT. This token is expected to not contain the "Bearer" prefix. */
|
|
23
|
+
private _getAuthToken?;
|
|
24
|
+
/** This is necessary for Google 3D Tiles tilesets! This tells the iTwin.js tiling system to use the geometric error specified in the tileset rather than any of our own. */
|
|
25
|
+
readonly usesGeometricError = true;
|
|
26
|
+
readonly maximumScreenSpaceError = 16;
|
|
27
|
+
/** Construct a new reality data source.
|
|
28
|
+
* @param props JSON representation of the reality data source
|
|
29
|
+
*/
|
|
30
|
+
protected constructor(props: RealityDataSourceProps, apiKey: string | undefined, _getAuthToken?: () => Promise<string | undefined>);
|
|
31
|
+
/**
|
|
32
|
+
* Create an instance of this class from a source key and iTwin context.
|
|
33
|
+
*/
|
|
34
|
+
static createFromKey(sourceKey: RealityDataSourceKey, _iTwinId: GuidString | undefined, apiKey: string | undefined, _getAuthToken?: () => Promise<string | undefined>): Promise<RealityDataSource | undefined>;
|
|
35
|
+
get isContextShare(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Returns Reality Data if available
|
|
38
|
+
*/
|
|
39
|
+
get realityData(): RealityData | undefined;
|
|
40
|
+
get realityDataId(): string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Returns Reality Data type if available
|
|
43
|
+
*/
|
|
44
|
+
get realityDataType(): string | undefined;
|
|
45
|
+
getTilesetUrl(): string | undefined;
|
|
46
|
+
/** Return the URL of the Google 3D Tiles tileset with its API key included. */
|
|
47
|
+
private getTilesetUrlWithKey;
|
|
48
|
+
protected setBaseUrl(url: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* This method returns the URL to access the actual 3d tiles from the service provider.
|
|
51
|
+
* @returns string containing the URL to reality data.
|
|
52
|
+
*/
|
|
53
|
+
getServiceUrl(_iTwinId: GuidString | undefined): Promise<string | undefined>;
|
|
54
|
+
getRootDocument(_iTwinId: GuidString | undefined): Promise<any>;
|
|
55
|
+
/** Returns the tile URL relative to the base URL.
|
|
56
|
+
* If the tile path is a relative URL, the base URL is prepended to it.
|
|
57
|
+
* For both absolute and relative tile path URLs, the search parameters are checked. If the search params are empty, the base URL's search params are appended to the tile path.
|
|
58
|
+
*/
|
|
59
|
+
getTileUrl(tilePath: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Returns the tile content. The path to the tile is relative to the base url of present reality data whatever the type.
|
|
62
|
+
*/
|
|
63
|
+
getTileContent(name: string): Promise<ArrayBuffer>;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the tile content in json format. The path to the tile is relative to the base url of present reality data whatever the type.
|
|
66
|
+
*/
|
|
67
|
+
getTileJson(name: string): Promise<any>;
|
|
68
|
+
getTileContentType(url: string): "tile" | "tileset";
|
|
69
|
+
/**
|
|
70
|
+
* Gets spatial location and extents of this reality data source
|
|
71
|
+
* @returns spatial location and extents
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
getSpatialLocationAndExtents(): Promise<SpatialLocationAndExtents | undefined>;
|
|
75
|
+
/**
|
|
76
|
+
* Gets information to identify the product and engine that create this reality data
|
|
77
|
+
* Will return undefined if cannot be resolved
|
|
78
|
+
* @returns information to identify the product and engine that create this reality data
|
|
79
|
+
* @alpha
|
|
80
|
+
*/
|
|
81
|
+
getPublisherProductInfo(): Promise<PublisherProductInfo | undefined>;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=RealityDataSourceGoogle3dTilesImpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RealityDataSourceGoogle3dTilesImpl.d.ts","sourceRoot":"","sources":["../../../src/internal/RealityDataSourceGoogle3dTilesImpl.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAiB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAe,WAAW,EAAqB,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG/H,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAG1G;;;;EAIE;AACF,qBAAa,kCAAmC,YAAW,iBAAiB;IAC1E,SAAgB,GAAG,EAAE,oBAAoB,CAAC;IAC1C,qFAAqF;IACrF,OAAO,CAAC,WAAW,CAAqB;IACxC,yFAAyF;IACzF,OAAO,CAAC,QAAQ,CAAa;IAC7B,yEAAyE;IACzE,OAAO,CAAC,aAAa,CAAC,CAAkB;IACxC,+DAA+D;IAC/D,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,sIAAsI;IACtI,OAAO,CAAC,aAAa,CAAC,CAAoC;IAE1D,4KAA4K;IAC5K,SAAgB,kBAAkB,QAAQ;IAC1C,SAAgB,uBAAuB,MAAM;IAE7C;;OAEG;IACH,SAAS,aAAa,KAAK,EAAE,sBAAsB,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAOlI;;OAEG;WACiB,aAAa,CAAC,SAAS,EAAE,oBAAoB,EAAE,QAAQ,EAAE,UAAU,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GA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