@itwin/core-frontend 4.8.0-dev.39 → 4.8.0-dev.40
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/SubCategoriesCache.js +1 -1
- package/lib/cjs/SubCategoriesCache.js.map +1 -1
- package/lib/cjs/tile/map/ArcGisUtilities.js +2 -2
- package/lib/cjs/tile/map/ArcGisUtilities.js.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/ArcGISImageryProvider.js +2 -2
- package/lib/cjs/tile/map/ImageryProviders/ArcGISImageryProvider.js.map +1 -1
- package/lib/cjs/tools/AccuDrawTool.d.ts +21 -0
- package/lib/cjs/tools/AccuDrawTool.d.ts.map +1 -1
- package/lib/cjs/tools/AccuDrawTool.js +93 -1
- package/lib/cjs/tools/AccuDrawTool.js.map +1 -1
- package/lib/esm/SubCategoriesCache.js +1 -1
- package/lib/esm/SubCategoriesCache.js.map +1 -1
- package/lib/esm/tile/map/ArcGisUtilities.js +2 -2
- package/lib/esm/tile/map/ArcGisUtilities.js.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/ArcGISImageryProvider.js +2 -2
- package/lib/esm/tile/map/ImageryProviders/ArcGISImageryProvider.js.map +1 -1
- package/lib/esm/tools/AccuDrawTool.d.ts +21 -0
- package/lib/esm/tools/AccuDrawTool.d.ts.map +1 -1
- package/lib/esm/tools/AccuDrawTool.js +89 -0
- package/lib/esm/tools/AccuDrawTool.js.map +1 -1
- package/lib/public/locales/en/CoreTools.json +15 -0
- package/package.json +18 -18
|
@@ -96,7 +96,7 @@ class SubCategoriesCache {
|
|
|
96
96
|
if (undefined === set)
|
|
97
97
|
this._byCategoryId.set(categoryId, set = new Set());
|
|
98
98
|
set.add(subCategoryId);
|
|
99
|
-
if (override)
|
|
99
|
+
if (override || !this._appearances.has(subCategoryId))
|
|
100
100
|
this._appearances.set(subCategoryId, appearance);
|
|
101
101
|
}
|
|
102
102
|
async getCategoryInfo(inputCategoryIds) {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QAAQ,CAAC,WAAoB,EAAE,IAAe;YACpD,IAAA,qBAAM,EAAC,SAAS,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC;YACpC,IAAA,qBAAM,EAAC,SAAS,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC;YAEpC,IAAI,SAAS,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;gBAC7B,2DAA2D;gBAC3D,sJAAsJ;gBACtJ,iIAAiI;gBACjI,IAAI,CAAC,KAAK,GAAG,IAAI,UAAU,CAAC,mBAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;YACrE,CAAC;iBAAM,CAAC;gBACN,mGAAmG;gBACnG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC5B,KAAK,MAAM,UAAU,IAAI,mBAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;oBACjD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;KACF;IAvGY,wBAAK,QAuGjB,CAAA;AACH,CAAC,EAjLgB,kBAAkB,kCAAlB,kBAAkB,QAiLlC","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 { assert, CompressedId64Set, Id64, Id64Arg, Id64Set, Id64String, OrderedId64Iterable } from \"@itwin/core-bentley\";\r\nimport { SubCategoryAppearance, SubCategoryResultRow } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\n\r\n/** A cancelable paginated request for subcategory information.\r\n * @see SubCategoriesCache\r\n * @internal\r\n */\r\nexport interface SubCategoriesRequest {\r\n /** The Ids of any categories which were requested but were not yet loaded. */\r\n readonly missingCategoryIds: Id64Set;\r\n /** A promise which resolves to true when all of the requested categories have been loaded, or to false if not all categories were loaded.\r\n * Categories may fail to load if the request is explicitly canceled or if the IModelConnection is closed before all categories are loaded.\r\n */\r\n readonly promise: Promise<boolean>;\r\n /** Cancels the request. */\r\n cancel(): void;\r\n}\r\n\r\nconst invalidCategoryIdEntry = new Set<string>();\r\n\r\n/** A cache of information about the subcategories contained within an [[IModelConnection]]. It is populated on demand.\r\n * @internal\r\n */\r\nexport class SubCategoriesCache {\r\n private readonly _byCategoryId = new Map<string, Id64Set>();\r\n private readonly _appearances = new Map<string, SubCategoryAppearance>();\r\n private readonly _imodel: IModelConnection;\r\n private _missingAtTimeOfPreload: Id64Set | undefined;\r\n\r\n public constructor(imodel: IModelConnection) { this._imodel = imodel; }\r\n\r\n /** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */\r\n public getSubCategories(categoryId: string): Id64Set | undefined { return this._byCategoryId.get(categoryId); }\r\n\r\n /** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */\r\n public getSubCategoryAppearance(subCategoryId: Id64String): SubCategoryAppearance | undefined { return this._appearances.get(subCategoryId.toString()); }\r\n\r\n /** Request that the subcategory information for all of the specified categories is loaded.\r\n * If all such information has already been loaded, returns undefined.\r\n * Otherwise, dispatches an asynchronous request to load those categories which are not already loaded and returns a cancellable request object\r\n * containing the corresponding promise and the set of categories still to be loaded.\r\n */\r\n public load(categoryIds: Id64Arg): SubCategoriesRequest | undefined {\r\n const missing = this.getMissing(categoryIds);\r\n if (undefined === missing)\r\n return undefined;\r\n\r\n const request = new SubCategoriesCache.Request(missing, this._imodel);\r\n const promise = request.dispatch().then((result?: SubCategoriesCache.Result) => {\r\n if (undefined !== result)\r\n this.processResults(result, missing);\r\n\r\n return !request.wasCanceled;\r\n });\r\n return {\r\n missingCategoryIds: missing,\r\n promise,\r\n cancel: () => request.cancel(),\r\n };\r\n }\r\n\r\n /** Load all subcategories that come from used spatial categories of the iModel into the cache. */\r\n public async loadAllUsedSpatialSubCategories(): Promise<void> {\r\n try {\r\n const results = await this._imodel.queryAllUsedSpatialSubCategories();\r\n if (undefined !== results){\r\n this.processResults(results, new Set<string>(), false);\r\n }\r\n } catch (e) {\r\n // In case of a truncated response, gracefully handle the error and exit.\r\n }\r\n\r\n }\r\n /** Given categoryIds, return which of these are not cached. */\r\n private getMissing(categoryIds: Id64Arg): Id64Set | undefined {\r\n let missing: Id64Set | undefined;\r\n for (const catId of Id64.iterable(categoryIds)) {\r\n if (undefined === this._byCategoryId.get(catId)) {\r\n if (undefined === missing)\r\n missing = new Set<string>();\r\n\r\n missing.add(catId);\r\n }\r\n }\r\n\r\n return missing;\r\n }\r\n\r\n public clear(): void {\r\n this._byCategoryId.clear();\r\n this._appearances.clear();\r\n }\r\n\r\n public onIModelConnectionClose(): void {\r\n this.clear();\r\n }\r\n\r\n private static createSubCategoryAppearance(json?: any) {\r\n let props: SubCategoryAppearance.Props | undefined;\r\n if (\"string\" === typeof json && 0 < json.length)\r\n props = JSON.parse(json);\r\n\r\n return new SubCategoryAppearance(props);\r\n }\r\n\r\n private processResults(result: SubCategoriesCache.Result, missing: Id64Set, override: boolean = true): void {\r\n for (const row of result){\r\n this.add(row.parentId, row.id, SubCategoriesCache.createSubCategoryAppearance(row.appearance), override);\r\n }\r\n\r\n // Ensure that any category Ids which returned no results (e.g., non-existent category, invalid Id, etc) are still recorded so they are not repeatedly re-requested\r\n for (const id of missing)\r\n if (undefined === this._byCategoryId.get(id))\r\n this._byCategoryId.set(id, invalidCategoryIdEntry);\r\n }\r\n\r\n /** Exposed strictly for tests.\r\n * @internal\r\n */\r\n public add(categoryId: string, subCategoryId: string, appearance: SubCategoryAppearance, override: boolean) {\r\n let set = this._byCategoryId.get(categoryId);\r\n if (undefined === set)\r\n this._byCategoryId.set(categoryId, set = new Set<string>());\r\n\r\n set.add(subCategoryId);\r\n if (override)\r\n this._appearances.set(subCategoryId, appearance);\r\n }\r\n\r\n public async getCategoryInfo(inputCategoryIds: Id64String | Iterable<Id64String>): Promise<Map<Id64String, IModelConnection.Categories.CategoryInfo>> {\r\n // Eliminate duplicates...\r\n const categoryIds = new Set<string>(typeof inputCategoryIds === \"string\" ? [inputCategoryIds] : inputCategoryIds);\r\n const req = this.load(categoryIds);\r\n if (req)\r\n await req.promise;\r\n\r\n const map = new Map<Id64String, IModelConnection.Categories.CategoryInfo>();\r\n for (const categoryId of categoryIds) {\r\n const subCategoryIds = this._byCategoryId.get(categoryId);\r\n if (!subCategoryIds)\r\n continue;\r\n\r\n const subCategories = this.mapSubCategoryInfos(categoryId, subCategoryIds);\r\n map.set(categoryId, { id: categoryId, subCategories });\r\n }\r\n\r\n return map;\r\n }\r\n\r\n public async getSubCategoryInfo(categoryId: Id64String, inputSubCategoryIds: Id64String | Iterable<Id64String>): Promise<Map<Id64String, IModelConnection.Categories.SubCategoryInfo>> {\r\n // Eliminate duplicates...\r\n const subCategoryIds = new Set<string>(typeof inputSubCategoryIds === \"string\" ? [inputSubCategoryIds] : inputSubCategoryIds);\r\n const req = this.load(categoryId);\r\n if (req)\r\n await req.promise;\r\n\r\n return this.mapSubCategoryInfos(categoryId, subCategoryIds);\r\n }\r\n\r\n private mapSubCategoryInfos(categoryId: Id64String, subCategoryIds: Set<Id64String>): Map<Id64String, IModelConnection.Categories.SubCategoryInfo> {\r\n const map = new Map<Id64String, IModelConnection.Categories.SubCategoryInfo>();\r\n for (const id of subCategoryIds) {\r\n const appearance = this._appearances.get(id);\r\n if (appearance)\r\n map.set(id, { id, categoryId, appearance });\r\n }\r\n\r\n return map;\r\n }\r\n}\r\n\r\n/** This namespace and the types within it are exported strictly for use in tests.\r\n * @internal\r\n */\r\nexport namespace SubCategoriesCache { // eslint-disable-line no-redeclare\r\n export type Result = SubCategoryResultRow[];\r\n\r\n export class Request {\r\n private readonly _imodel: IModelConnection;\r\n private readonly _categoryIds: CompressedId64Set[] = [];\r\n private readonly _result: Result = [];\r\n private _canceled = false;\r\n private _curCategoryIdsIndex = 0;\r\n\r\n public get wasCanceled() { return this._canceled || this._imodel.isClosed; }\r\n\r\n public constructor(categoryIds: Set<string>, imodel: IModelConnection, maxCategoriesPerQuery = 2500) {\r\n this._imodel = imodel;\r\n\r\n const catIds = [...categoryIds];\r\n OrderedId64Iterable.sortArray(catIds); // sort categories, so that given the same set of categoryIds we will always create the same batches.\r\n while (catIds.length !== 0) {\r\n const end = (catIds.length > maxCategoriesPerQuery) ? maxCategoriesPerQuery : catIds.length;\r\n const compressedIds = CompressedId64Set.compressArray(catIds.splice(0, end));\r\n this._categoryIds.push(compressedIds);\r\n }\r\n }\r\n\r\n public cancel() { this._canceled = true; }\r\n\r\n public async dispatch(): Promise<Result | undefined> {\r\n if (this.wasCanceled || this._curCategoryIdsIndex >= this._categoryIds.length) // handle case of empty category Id set...\r\n return undefined;\r\n\r\n try {\r\n const catIds = this._categoryIds[this._curCategoryIdsIndex];\r\n const result = await this._imodel.querySubCategories(catIds);\r\n this._result.push(...result);\r\n if (this.wasCanceled)\r\n return undefined;\r\n } catch {\r\n // ###TODO: detect cases in which retry is warranted\r\n // Note that currently, if we succeed in obtaining some pages of results and fail to retrieve another page, we will end up processing the\r\n // incomplete results. Since we're not retrying, that's the best we can do.\r\n }\r\n\r\n // Finished with current batch of categoryIds. Dispatch the next batch if one exists.\r\n if (++this._curCategoryIdsIndex < this._categoryIds.length) {\r\n if (this.wasCanceled)\r\n return undefined;\r\n else\r\n return this.dispatch();\r\n }\r\n\r\n // Even if we were canceled, we've retrieved all the rows. Might as well process them to prevent another request for some of the same rows from being enqueued.\r\n return this._result;\r\n }\r\n }\r\n\r\n export type QueueFunc = () => void;\r\n\r\n export class QueueEntry {\r\n public readonly categoryIds: Id64Set;\r\n public readonly funcs: QueueFunc[];\r\n\r\n public constructor(categoryIds: Id64Set, func: QueueFunc) {\r\n this.categoryIds = categoryIds;\r\n this.funcs = [func];\r\n }\r\n }\r\n\r\n /** A \"queue\" of SubCategoriesRequests, which consists of between 0 and 2 entries. Each entry specifies the set of category IDs to be loaded and a list of functions to be executed\r\n * when loading is completed. This is used to enforce ordering of operations upon subcategories despite the need to asynchronously load them. It incidentally also provides an\r\n * opportunity to reduce the number of backend requests by batching consecutive requests.\r\n * Chiefly used by [[Viewport]].\r\n * @internal\r\n */\r\n export class Queue {\r\n /* NB: Members marked protected for use in tests only. */\r\n protected _current?: QueueEntry;\r\n protected _next?: QueueEntry;\r\n protected _request?: SubCategoriesRequest;\r\n protected _disposed = false;\r\n\r\n /** Push a request onto the queue. The requested categories will be loaded if necessary, and then\r\n * the supplied function will be invoked. Any previously-pushed requests are guaranteed to be processed before this one.\r\n */\r\n public push(cache: SubCategoriesCache, categoryIds: Id64Arg, func: QueueFunc): void {\r\n if (this._disposed)\r\n return;\r\n else if (undefined === this._current)\r\n this.pushCurrent(cache, categoryIds, func);\r\n else\r\n this.pushNext(categoryIds, func);\r\n }\r\n\r\n /** Cancel all requests and empty the queue. */\r\n public dispose(): void {\r\n if (undefined !== this._request) {\r\n assert(undefined !== this._current);\r\n this._request.cancel();\r\n this._request = undefined;\r\n }\r\n\r\n this._current = this._next = undefined;\r\n this._disposed = true;\r\n }\r\n\r\n public get isEmpty(): boolean {\r\n return undefined === this._current && undefined === this._next;\r\n }\r\n\r\n private pushCurrent(cache: SubCategoriesCache, categoryIds: Id64Arg, func: QueueFunc): void {\r\n assert(undefined === this._next);\r\n assert(undefined === this._current);\r\n assert(undefined === this._request);\r\n\r\n this._request = cache.load(categoryIds);\r\n if (undefined === this._request) {\r\n // All requested categories are already loaded.\r\n func();\r\n return;\r\n } else {\r\n // We need to load the requested categories before invoking the function.\r\n this.processCurrent(cache, new QueueEntry(Id64.toIdSet(categoryIds, true), func));\r\n }\r\n }\r\n\r\n private processCurrent(cache: SubCategoriesCache, entry: QueueEntry): void {\r\n assert(undefined !== this._request);\r\n assert(undefined === this._current);\r\n assert(undefined === this._next);\r\n\r\n this._current = entry;\r\n this._request.promise.then((completed: boolean) => { // eslint-disable-line @typescript-eslint/no-floating-promises\r\n if (this._disposed)\r\n return;\r\n\r\n // Invoke all the functions which were awaiting this set of IModelConnection.Categories.\r\n assert(undefined !== this._current);\r\n if (completed)\r\n for (const func of this._current.funcs)\r\n func();\r\n\r\n this._request = undefined;\r\n this._current = undefined;\r\n\r\n // If we have more requests, process them.\r\n const next = this._next;\r\n this._next = undefined;\r\n if (undefined !== next) {\r\n this._request = cache.load(next.categoryIds);\r\n if (undefined === this._request) {\r\n // All categories loaded.\r\n for (const func of next.funcs)\r\n func();\r\n } else {\r\n // We need to load the requested categories before invoking the pending functions.\r\n this.processCurrent(cache, next);\r\n }\r\n }\r\n });\r\n }\r\n\r\n private pushNext(categoryIds: Id64Arg, func: QueueFunc): void {\r\n assert(undefined !== this._current);\r\n assert(undefined !== this._request);\r\n\r\n if (undefined === this._next) {\r\n // We have a request currently in process and none pending.\r\n // We could potentially determine that this request doesn't require any categories that are not already loaded or being loaded by the current request.\r\n // But we will find that out (synchronously) when current request completes, unless more requests come in. Probably not worth it.\r\n this._next = new QueueEntry(Id64.toIdSet(categoryIds, true), func);\r\n } else {\r\n // We have a request currently in process, and one or more pending. Append this one to the pending.\r\n this._next.funcs.push(func);\r\n for (const categoryId of Id64.iterable(categoryIds))\r\n this._next.categoryIds.add(categoryId);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SubCategoriesCache.js","sourceRoot":"","sources":["../../src/SubCategoriesCache.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAyH;AACzH,oDAAiF;AAkBjF,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAU,CAAC;AAEjD;;GAEG;AACH,MAAa,kBAAkB;IAM7B,YAAmB,MAAwB;QAL1B,kBAAa,GAAG,IAAI,GAAG,EAAmB,CAAC;QAC3C,iBAAY,GAAG,IAAI,GAAG,EAAiC,CAAC;QAI1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAAC,CAAC;IAEvE,wIAAwI;IACjI,gBAAgB,CAAC,UAAkB,I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YACrE,CAAC;iBAAM,CAAC;gBACN,mGAAmG;gBACnG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC5B,KAAK,MAAM,UAAU,IAAI,mBAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;oBACjD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;KACF;IAvGY,wBAAK,QAuGjB,CAAA;AACH,CAAC,EAjLgB,kBAAkB,kCAAlB,kBAAkB,QAiLlC","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 { assert, CompressedId64Set, Id64, Id64Arg, Id64Set, Id64String, OrderedId64Iterable } from \"@itwin/core-bentley\";\r\nimport { SubCategoryAppearance, SubCategoryResultRow } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\n\r\n/** A cancelable paginated request for subcategory information.\r\n * @see SubCategoriesCache\r\n * @internal\r\n */\r\nexport interface SubCategoriesRequest {\r\n /** The Ids of any categories which were requested but were not yet loaded. */\r\n readonly missingCategoryIds: Id64Set;\r\n /** A promise which resolves to true when all of the requested categories have been loaded, or to false if not all categories were loaded.\r\n * Categories may fail to load if the request is explicitly canceled or if the IModelConnection is closed before all categories are loaded.\r\n */\r\n readonly promise: Promise<boolean>;\r\n /** Cancels the request. */\r\n cancel(): void;\r\n}\r\n\r\nconst invalidCategoryIdEntry = new Set<string>();\r\n\r\n/** A cache of information about the subcategories contained within an [[IModelConnection]]. It is populated on demand.\r\n * @internal\r\n */\r\nexport class SubCategoriesCache {\r\n private readonly _byCategoryId = new Map<string, Id64Set>();\r\n private readonly _appearances = new Map<string, SubCategoryAppearance>();\r\n private readonly _imodel: IModelConnection;\r\n private _missingAtTimeOfPreload: Id64Set | undefined;\r\n\r\n public constructor(imodel: IModelConnection) { this._imodel = imodel; }\r\n\r\n /** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */\r\n public getSubCategories(categoryId: string): Id64Set | undefined { return this._byCategoryId.get(categoryId); }\r\n\r\n /** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */\r\n public getSubCategoryAppearance(subCategoryId: Id64String): SubCategoryAppearance | undefined { return this._appearances.get(subCategoryId.toString()); }\r\n\r\n /** Request that the subcategory information for all of the specified categories is loaded.\r\n * If all such information has already been loaded, returns undefined.\r\n * Otherwise, dispatches an asynchronous request to load those categories which are not already loaded and returns a cancellable request object\r\n * containing the corresponding promise and the set of categories still to be loaded.\r\n */\r\n public load(categoryIds: Id64Arg): SubCategoriesRequest | undefined {\r\n const missing = this.getMissing(categoryIds);\r\n if (undefined === missing)\r\n return undefined;\r\n\r\n const request = new SubCategoriesCache.Request(missing, this._imodel);\r\n const promise = request.dispatch().then((result?: SubCategoriesCache.Result) => {\r\n if (undefined !== result)\r\n this.processResults(result, missing);\r\n\r\n return !request.wasCanceled;\r\n });\r\n return {\r\n missingCategoryIds: missing,\r\n promise,\r\n cancel: () => request.cancel(),\r\n };\r\n }\r\n\r\n /** Load all subcategories that come from used spatial categories of the iModel into the cache. */\r\n public async loadAllUsedSpatialSubCategories(): Promise<void> {\r\n try {\r\n const results = await this._imodel.queryAllUsedSpatialSubCategories();\r\n if (undefined !== results){\r\n this.processResults(results, new Set<string>(), false);\r\n }\r\n } catch (e) {\r\n // In case of a truncated response, gracefully handle the error and exit.\r\n }\r\n\r\n }\r\n /** Given categoryIds, return which of these are not cached. */\r\n private getMissing(categoryIds: Id64Arg): Id64Set | undefined {\r\n let missing: Id64Set | undefined;\r\n for (const catId of Id64.iterable(categoryIds)) {\r\n if (undefined === this._byCategoryId.get(catId)) {\r\n if (undefined === missing)\r\n missing = new Set<string>();\r\n\r\n missing.add(catId);\r\n }\r\n }\r\n\r\n return missing;\r\n }\r\n\r\n public clear(): void {\r\n this._byCategoryId.clear();\r\n this._appearances.clear();\r\n }\r\n\r\n public onIModelConnectionClose(): void {\r\n this.clear();\r\n }\r\n\r\n private static createSubCategoryAppearance(json?: any) {\r\n let props: SubCategoryAppearance.Props | undefined;\r\n if (\"string\" === typeof json && 0 < json.length)\r\n props = JSON.parse(json);\r\n\r\n return new SubCategoryAppearance(props);\r\n }\r\n\r\n private processResults(result: SubCategoriesCache.Result, missing: Id64Set, override: boolean = true): void {\r\n for (const row of result){\r\n this.add(row.parentId, row.id, SubCategoriesCache.createSubCategoryAppearance(row.appearance), override);\r\n }\r\n\r\n // Ensure that any category Ids which returned no results (e.g., non-existent category, invalid Id, etc) are still recorded so they are not repeatedly re-requested\r\n for (const id of missing)\r\n if (undefined === this._byCategoryId.get(id))\r\n this._byCategoryId.set(id, invalidCategoryIdEntry);\r\n }\r\n\r\n /** Exposed strictly for tests.\r\n * @internal\r\n */\r\n public add(categoryId: string, subCategoryId: string, appearance: SubCategoryAppearance, override: boolean) {\r\n let set = this._byCategoryId.get(categoryId);\r\n if (undefined === set)\r\n this._byCategoryId.set(categoryId, set = new Set<string>());\r\n\r\n set.add(subCategoryId);\r\n if (override || !this._appearances.has(subCategoryId))\r\n this._appearances.set(subCategoryId, appearance);\r\n }\r\n\r\n public async getCategoryInfo(inputCategoryIds: Id64String | Iterable<Id64String>): Promise<Map<Id64String, IModelConnection.Categories.CategoryInfo>> {\r\n // Eliminate duplicates...\r\n const categoryIds = new Set<string>(typeof inputCategoryIds === \"string\" ? [inputCategoryIds] : inputCategoryIds);\r\n const req = this.load(categoryIds);\r\n if (req)\r\n await req.promise;\r\n\r\n const map = new Map<Id64String, IModelConnection.Categories.CategoryInfo>();\r\n for (const categoryId of categoryIds) {\r\n const subCategoryIds = this._byCategoryId.get(categoryId);\r\n if (!subCategoryIds)\r\n continue;\r\n\r\n const subCategories = this.mapSubCategoryInfos(categoryId, subCategoryIds);\r\n map.set(categoryId, { id: categoryId, subCategories });\r\n }\r\n\r\n return map;\r\n }\r\n\r\n public async getSubCategoryInfo(categoryId: Id64String, inputSubCategoryIds: Id64String | Iterable<Id64String>): Promise<Map<Id64String, IModelConnection.Categories.SubCategoryInfo>> {\r\n // Eliminate duplicates...\r\n const subCategoryIds = new Set<string>(typeof inputSubCategoryIds === \"string\" ? [inputSubCategoryIds] : inputSubCategoryIds);\r\n const req = this.load(categoryId);\r\n if (req)\r\n await req.promise;\r\n\r\n return this.mapSubCategoryInfos(categoryId, subCategoryIds);\r\n }\r\n\r\n private mapSubCategoryInfos(categoryId: Id64String, subCategoryIds: Set<Id64String>): Map<Id64String, IModelConnection.Categories.SubCategoryInfo> {\r\n const map = new Map<Id64String, IModelConnection.Categories.SubCategoryInfo>();\r\n for (const id of subCategoryIds) {\r\n const appearance = this._appearances.get(id);\r\n if (appearance)\r\n map.set(id, { id, categoryId, appearance });\r\n }\r\n\r\n return map;\r\n }\r\n}\r\n\r\n/** This namespace and the types within it are exported strictly for use in tests.\r\n * @internal\r\n */\r\nexport namespace SubCategoriesCache { // eslint-disable-line no-redeclare\r\n export type Result = SubCategoryResultRow[];\r\n\r\n export class Request {\r\n private readonly _imodel: IModelConnection;\r\n private readonly _categoryIds: CompressedId64Set[] = [];\r\n private readonly _result: Result = [];\r\n private _canceled = false;\r\n private _curCategoryIdsIndex = 0;\r\n\r\n public get wasCanceled() { return this._canceled || this._imodel.isClosed; }\r\n\r\n public constructor(categoryIds: Set<string>, imodel: IModelConnection, maxCategoriesPerQuery = 2500) {\r\n this._imodel = imodel;\r\n\r\n const catIds = [...categoryIds];\r\n OrderedId64Iterable.sortArray(catIds); // sort categories, so that given the same set of categoryIds we will always create the same batches.\r\n while (catIds.length !== 0) {\r\n const end = (catIds.length > maxCategoriesPerQuery) ? maxCategoriesPerQuery : catIds.length;\r\n const compressedIds = CompressedId64Set.compressArray(catIds.splice(0, end));\r\n this._categoryIds.push(compressedIds);\r\n }\r\n }\r\n\r\n public cancel() { this._canceled = true; }\r\n\r\n public async dispatch(): Promise<Result | undefined> {\r\n if (this.wasCanceled || this._curCategoryIdsIndex >= this._categoryIds.length) // handle case of empty category Id set...\r\n return undefined;\r\n\r\n try {\r\n const catIds = this._categoryIds[this._curCategoryIdsIndex];\r\n const result = await this._imodel.querySubCategories(catIds);\r\n this._result.push(...result);\r\n if (this.wasCanceled)\r\n return undefined;\r\n } catch {\r\n // ###TODO: detect cases in which retry is warranted\r\n // Note that currently, if we succeed in obtaining some pages of results and fail to retrieve another page, we will end up processing the\r\n // incomplete results. Since we're not retrying, that's the best we can do.\r\n }\r\n\r\n // Finished with current batch of categoryIds. Dispatch the next batch if one exists.\r\n if (++this._curCategoryIdsIndex < this._categoryIds.length) {\r\n if (this.wasCanceled)\r\n return undefined;\r\n else\r\n return this.dispatch();\r\n }\r\n\r\n // Even if we were canceled, we've retrieved all the rows. Might as well process them to prevent another request for some of the same rows from being enqueued.\r\n return this._result;\r\n }\r\n }\r\n\r\n export type QueueFunc = () => void;\r\n\r\n export class QueueEntry {\r\n public readonly categoryIds: Id64Set;\r\n public readonly funcs: QueueFunc[];\r\n\r\n public constructor(categoryIds: Id64Set, func: QueueFunc) {\r\n this.categoryIds = categoryIds;\r\n this.funcs = [func];\r\n }\r\n }\r\n\r\n /** A \"queue\" of SubCategoriesRequests, which consists of between 0 and 2 entries. Each entry specifies the set of category IDs to be loaded and a list of functions to be executed\r\n * when loading is completed. This is used to enforce ordering of operations upon subcategories despite the need to asynchronously load them. It incidentally also provides an\r\n * opportunity to reduce the number of backend requests by batching consecutive requests.\r\n * Chiefly used by [[Viewport]].\r\n * @internal\r\n */\r\n export class Queue {\r\n /* NB: Members marked protected for use in tests only. */\r\n protected _current?: QueueEntry;\r\n protected _next?: QueueEntry;\r\n protected _request?: SubCategoriesRequest;\r\n protected _disposed = false;\r\n\r\n /** Push a request onto the queue. The requested categories will be loaded if necessary, and then\r\n * the supplied function will be invoked. Any previously-pushed requests are guaranteed to be processed before this one.\r\n */\r\n public push(cache: SubCategoriesCache, categoryIds: Id64Arg, func: QueueFunc): void {\r\n if (this._disposed)\r\n return;\r\n else if (undefined === this._current)\r\n this.pushCurrent(cache, categoryIds, func);\r\n else\r\n this.pushNext(categoryIds, func);\r\n }\r\n\r\n /** Cancel all requests and empty the queue. */\r\n public dispose(): void {\r\n if (undefined !== this._request) {\r\n assert(undefined !== this._current);\r\n this._request.cancel();\r\n this._request = undefined;\r\n }\r\n\r\n this._current = this._next = undefined;\r\n this._disposed = true;\r\n }\r\n\r\n public get isEmpty(): boolean {\r\n return undefined === this._current && undefined === this._next;\r\n }\r\n\r\n private pushCurrent(cache: SubCategoriesCache, categoryIds: Id64Arg, func: QueueFunc): void {\r\n assert(undefined === this._next);\r\n assert(undefined === this._current);\r\n assert(undefined === this._request);\r\n\r\n this._request = cache.load(categoryIds);\r\n if (undefined === this._request) {\r\n // All requested categories are already loaded.\r\n func();\r\n return;\r\n } else {\r\n // We need to load the requested categories before invoking the function.\r\n this.processCurrent(cache, new QueueEntry(Id64.toIdSet(categoryIds, true), func));\r\n }\r\n }\r\n\r\n private processCurrent(cache: SubCategoriesCache, entry: QueueEntry): void {\r\n assert(undefined !== this._request);\r\n assert(undefined === this._current);\r\n assert(undefined === this._next);\r\n\r\n this._current = entry;\r\n this._request.promise.then((completed: boolean) => { // eslint-disable-line @typescript-eslint/no-floating-promises\r\n if (this._disposed)\r\n return;\r\n\r\n // Invoke all the functions which were awaiting this set of IModelConnection.Categories.\r\n assert(undefined !== this._current);\r\n if (completed)\r\n for (const func of this._current.funcs)\r\n func();\r\n\r\n this._request = undefined;\r\n this._current = undefined;\r\n\r\n // If we have more requests, process them.\r\n const next = this._next;\r\n this._next = undefined;\r\n if (undefined !== next) {\r\n this._request = cache.load(next.categoryIds);\r\n if (undefined === this._request) {\r\n // All categories loaded.\r\n for (const func of next.funcs)\r\n func();\r\n } else {\r\n // We need to load the requested categories before invoking the pending functions.\r\n this.processCurrent(cache, next);\r\n }\r\n }\r\n });\r\n }\r\n\r\n private pushNext(categoryIds: Id64Arg, func: QueueFunc): void {\r\n assert(undefined !== this._current);\r\n assert(undefined !== this._request);\r\n\r\n if (undefined === this._next) {\r\n // We have a request currently in process and none pending.\r\n // We could potentially determine that this request doesn't require any categories that are not already loaded or being loaded by the current request.\r\n // But we will find that out (synchronously) when current request completes, unless more requests come in. Probably not worth it.\r\n this._next = new QueueEntry(Id64.toIdSet(categoryIds, true), func);\r\n } else {\r\n // We have a request currently in process, and one or more pending. Append this one to the pending.\r\n this._next.funcs.push(func);\r\n for (const categoryId of Id64.iterable(categoryIds))\r\n this._next.categoryIds.add(categoryId);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -233,10 +233,10 @@ class ArcGisUtilities {
|
|
|
233
233
|
await ArcGisUtilities.appendSecurityToken(tmpUrl, accessClient, { mapLayerUrl: new URL(url), userName, password });
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
let response = await fetch(tmpUrl
|
|
236
|
+
let response = await fetch(tmpUrl, { method: "GET" });
|
|
237
237
|
if (response.status === 401 && !requireToken && (0, utils_1.headersIncludeAuthMethod)(response.headers, ["ntlm", "negotiate"])) {
|
|
238
238
|
// We got a http 401 challenge, lets try again with SSO enabled (i.e. Windows Authentication)
|
|
239
|
-
response = await fetch(
|
|
239
|
+
response = await fetch(tmpUrl, { method: "GET", credentials: "include" });
|
|
240
240
|
}
|
|
241
241
|
// Append security token when corresponding error code is returned by ArcGIS service
|
|
242
242
|
let errorCode = await ArcGisUtilities.checkForResponseErrorCode(response);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArcGisUtilities.js","sourceRoot":"","sources":["../../../../src/tile/map/ArcGisUtilities.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,wDAAuD;AAEvD,0CAAyM;AACzM,+CAA4C;AAC5C,+CAA+D;AAE/D;;GAEG;AAEH;;;GAGG;AACH,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,mFAAwB,CAAA;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,EAAC,CAAC,CAAC;QAC1C,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,mBAAmB,CAAE,aAAqB,EAAE,QAAgB,EAAE,QAAiB,EAAE,QAAiB,EAAE,YAAoB,CAAC;QAErI,IAAI,MAAwB,EAAE,MAAwB,CAAC;QAEvD,MAAM,UAAU,GAAG,eAAe,CAAC,uBAAuB,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;QAEpH,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAE1B,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,GAAG,CAAC,CAAC;gBACX,sFAAsF;gBACtF,OAAO,MAAM,GAAG,UAAU,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,KAAK,GAAG,QAAQ,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,KAAK,GAAG,QAAQ,CAAC,GAAG,SAAS,CAAC,EAAE,MAAM,EAAE;oBAC/I,CAAC;YAEL,CAAC;YAED,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,GAAG,aAAa,CAAC;gBACvB,iFAAiF;gBACjF,OAAO,MAAM,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,KAAK,GAAG,QAAQ,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,KAAK,GAAG,QAAQ,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE;oBAC9H,CAAC;YACL,CAAC;QACH,CAAC;QACD,OAAO,EAAC,MAAM,EAAE,MAAM,EAAC,CAAC;IAC1B,CAAC;;AAzWH,0CA2WC;AAzLgB,6BAAa,GAAG,IAAI,GAAG,EAA2C,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\nimport { Angle, Constant } from \"@itwin/core-geometry\";\r\nimport { MapSubLayerProps } from \"@itwin/core-common\";\r\nimport { MapCartoRectangle, MapLayerAccessClient, MapLayerAccessToken, MapLayerAccessTokenParams, MapLayerSource, MapLayerSourceStatus, MapLayerSourceValidation, ValidateSourceArgs} from \"../internal\";\r\nimport { IModelApp } from \"../../IModelApp\";\r\nimport { headersIncludeAuthMethod } from \"../../request/utils\";\r\n\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\n/**\r\n * Class representing an ArcGIS error code.\r\n * @internal\r\n */\r\nexport enum ArcGisErrorCode {\r\n InvalidCredentials = 401,\r\n MissingPermissions = 403,\r\n InvalidToken = 498,\r\n TokenRequired = 499,\r\n UnknownError = 1000,\r\n NoTokenService = 1001,\r\n}\r\n\r\n/**\r\n * Class representing an ArcGIS service metadata.\r\n * @internal\r\n */\r\nexport interface ArcGISServiceMetadata {\r\n /** JSON content from the service */\r\n content: any;\r\n\r\n /** Indicates if an access token is required to access the service */\r\n accessTokenRequired: boolean;\r\n}\r\n\r\n/** Arguments for validating ArcGIS sources\r\n * @internal\r\n */\r\nexport interface ArcGisValidateSourceArgs extends ValidateSourceArgs {\r\n /** List of capabilities 'keyword' that needs to be advertised in the service's metadata in order to be valid. For example: 'Map', 'Query', etc*/\r\n capabilitiesFilter: string[];\r\n}\r\n\r\n/** Arguments for fetching service metadata\r\n * @internal\r\n */\r\nexport interface ArcGisGetServiceJsonArgs {\r\n url: string;\r\n formatId: string;\r\n userName?: string;\r\n password?: string;\r\n queryParams?: {[key: string]: string};\r\n ignoreCache?: boolean;\r\n requireToken?: boolean;\r\n}\r\n\r\n/**\r\n * Class containing utilities relating to ArcGIS services and coordinate systems.\r\n * @internal\r\n */\r\nexport class ArcGisUtilities {\r\n\r\n private static getBBoxString(range?: MapCartoRectangle) {\r\n if (!range)\r\n range = MapCartoRectangle.createMaximum();\r\n\r\n return `${range.low.x * Angle.degreesPerRadian},${range.low.y * Angle.degreesPerRadian},${range.high.x * Angle.degreesPerRadian},${range.high.y * Angle.degreesPerRadian}`;\r\n }\r\n\r\n public static async getNationalMapSources(): Promise<MapLayerSource[]> {\r\n const sources = new Array<MapLayerSource>();\r\n const response = await fetch(\"https://viewer.nationalmap.gov/tnmaccess/api/getMapServiceList\", { method: \"GET\" });\r\n const services = await response.json();\r\n\r\n if (!Array.isArray(services))\r\n return sources;\r\n\r\n for (const service of services) {\r\n if (service.wmsUrl.length === 0) // Exclude Wfs..\r\n continue;\r\n switch (service.serviceType) {\r\n case \"ArcGIS\":\r\n sources.push(MapLayerSource.fromJSON({ name: service.displayName, url: service.serviceLink, formatId: \"ArcGIS\" })!);\r\n break;\r\n default: {\r\n const wmsIndex = service.wmsUrl.lastIndexOf(\"/wms\");\r\n if (wmsIndex > 0) {\r\n const url = service.wmsUrl.slice(0, wmsIndex + 4);\r\n sources.push(MapLayerSource.fromJSON({ name: service.displayName, url, formatId: \"WMS\" })!);\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n return sources;\r\n }\r\n\r\n public static async getServiceDirectorySources(url: string, baseUrl?: string): Promise<MapLayerSource[]> {\r\n if (undefined === baseUrl)\r\n baseUrl = url;\r\n let sources = new Array<MapLayerSource>();\r\n const response = await fetch(`${url}?f=json`, { method: \"GET\" });\r\n const json = await response.json();\r\n if (json !== undefined) {\r\n if (Array.isArray(json.folders)) {\r\n for (const folder of json.folders) {\r\n sources = sources.concat(await ArcGisUtilities.getServiceDirectorySources(`${url}/${folder}`, url));\r\n }\r\n }\r\n if (Array.isArray(json.services)) {\r\n for (const service of json.services) {\r\n let source;\r\n if (service.type === \"MapServer\")\r\n source = MapLayerSource.fromJSON({ name: service.name, url: `${baseUrl}/${service.name}/MapServer`, formatId: \"ArcGIS\" });\r\n else if (service.type === \"ImageServer\")\r\n source = MapLayerSource.fromJSON({ name: service.name, url: `${baseUrl}/${service.name}/ImageServer`, formatId: \"ArcGIS\" });\r\n if (source)\r\n sources.push(source);\r\n }\r\n }\r\n }\r\n\r\n return sources;\r\n }\r\n\r\n /**\r\n * Get map layer sources from an ArcGIS query.\r\n * @param range Range for the query.\r\n * @param url URL for the query.\r\n * @returns List of map layer sources.\r\n */\r\n public static async getSourcesFromQuery(range?: MapCartoRectangle, url = \"https://usgs.maps.arcgis.com/sharing/rest/search\"): Promise<MapLayerSource[]> {\r\n const sources = new Array<MapLayerSource>();\r\n for (let start = 1; start > 0;) {\r\n const response = await fetch(`${url}?f=json&q=(group:9d1199a521334e77a7d15abbc29f8144) AND (type:\"Map Service\")&bbox=${ArcGisUtilities.getBBoxString(range)}&sortOrder=desc&start=${start}&num=100`, { method: \"GET\" });\r\n const json = await response.json();\r\n if (!json)\r\n break;\r\n\r\n start = json.nextStart ? json.nextStart : -1;\r\n if (json !== undefined && Array.isArray(json.results)) {\r\n for (const result of json.results) {\r\n const source = MapLayerSource.fromJSON({ name: result.name ? result.name : result.title, url: result.url, formatId: \"ArcGIS\" });\r\n if (source)\r\n sources.push(source);\r\n }\r\n }\r\n }\r\n\r\n return sources;\r\n }\r\n\r\n /**\r\n * Parse the URL to check if it represents a valid ArcGIS service\r\n * @param url URL to validate.\r\n * @param serviceType Service type to validate (i.e FeatureServer, MapServer)\r\n * @return Validation Status.\r\n */\r\n public static validateUrl(url: string, serviceType: string): MapLayerSourceStatus {\r\n const urlObj = new URL(url.toLowerCase());\r\n if (urlObj.pathname.includes(\"/rest/services/\")) {\r\n // This seem to be an ArcGIS URL, lets check the service type\r\n if (urlObj.pathname.endsWith(`${serviceType.toLowerCase()}`)) {\r\n return MapLayerSourceStatus.Valid;\r\n } else {\r\n return MapLayerSourceStatus.IncompatibleFormat;\r\n }\r\n } else {\r\n return MapLayerSourceStatus.InvalidUrl;\r\n }\r\n }\r\n\r\n /**\r\n * Attempt to access an ArcGIS service, and validate its service metadata.\r\n * @param source Source to validate.\r\n * @param opts Validation options\r\n */\r\n public static async validateSource(args: ArcGisValidateSourceArgs): Promise<MapLayerSourceValidation> {\r\n const {source, ignoreCache, capabilitiesFilter} = args;\r\n const metadata = await this.getServiceJson({url: source.url, formatId: source.formatId, userName: source.userName, password: source.password, queryParams: source.collectQueryParams(), ignoreCache});\r\n const json = metadata?.content;\r\n if (json === undefined) {\r\n return { status: MapLayerSourceStatus.InvalidUrl };\r\n } else if (json.error !== undefined) {\r\n\r\n // If we got a 'Token Required' error, lets check what authentification methods this ESRI service offers\r\n // and return information needed to initiate the authentification process... the end-user\r\n // will have to provide his credentials before we can fully validate this source.\r\n // Note: Some servers will throw a error 403 (You do not have permissions to access this resource or perform this operation),\r\n // instead of 499 (TokenRequired)\r\n if (json.error.code === ArcGisErrorCode.TokenRequired || json.error.code === ArcGisErrorCode.MissingPermissions) {\r\n return (source.userName || source.password) ? {status: MapLayerSourceStatus.InvalidCredentials} : {status: MapLayerSourceStatus.RequireAuth};\r\n } else if (json.error.code === ArcGisErrorCode.InvalidCredentials)\r\n return { status: MapLayerSourceStatus.InvalidCredentials};\r\n }\r\n\r\n // Check this service support the expected queries\r\n let hasCapabilities = false;\r\n let capsArray: string[] = [];\r\n if (json.capabilities && typeof json.capabilities === \"string\" ) {\r\n const capabilities: string = json.capabilities;\r\n capsArray = capabilities.split(\",\").map((entry) => entry.toLowerCase());\r\n\r\n const filtered = capsArray.filter((element, _index, _array) => capabilitiesFilter.includes(element));\r\n hasCapabilities = (filtered.length === capabilitiesFilter.length);\r\n }\r\n if (!hasCapabilities) {\r\n return { status: MapLayerSourceStatus.InvalidFormat};\r\n }\r\n\r\n // Only EPSG:3857 is supported with pre-rendered tiles.\r\n if (json.tileInfo && capsArray.includes(\"tilesonly\") && !ArcGisUtilities.isEpsg3857Compatible(json.tileInfo)) {\r\n return { status: MapLayerSourceStatus.InvalidCoordinateSystem};\r\n }\r\n\r\n let subLayers;\r\n if (json.layers) {\r\n\r\n subLayers = new Array<MapSubLayerProps>();\r\n\r\n for (const layer of json.layers) {\r\n const parent = layer.parentLayerId < 0 ? undefined : layer.parentLayerId;\r\n const children = Array.isArray(layer.subLayerIds) ? layer.subLayerIds : undefined;\r\n subLayers.push({ name: layer.name, visible: layer.defaultVisibility !== false, id: layer.id, parent, children });\r\n }\r\n }\r\n return { status: MapLayerSourceStatus.Valid, subLayers };\r\n }\r\n\r\n /** Validate MapService tiling metadata and checks if the tile tree is 'Google Maps' compatible. */\r\n public static isEpsg3857Compatible(tileInfo: any) {\r\n if (tileInfo.spatialReference?.latestWkid !== 3857 || !Array.isArray(tileInfo.lods))\r\n return false;\r\n\r\n const zeroLod = tileInfo.lods[0];\r\n return zeroLod.level === 0 && Math.abs(zeroLod.resolution - 156543.03392800014) < .001;\r\n }\r\n\r\n private static _serviceCache = new Map<string, ArcGISServiceMetadata|undefined>();\r\n\r\n /**\r\n * Fetches an ArcGIS service metadata, and returns its JSON representation.\r\n * If an access client has been configured for the specified formatId,\r\n * it will be used to apply required security token.\r\n * By default, response for each URL are cached.\r\n * @param url URL of the ArcGIS service\r\n * @param formatId Format ID of the service\r\n * @param userName Username to use for legacy token based security\r\n * @param password Password to use for legacy token based security\r\n * @param ignoreCache Flag to skip cache lookup (i.e. force a new server request)\r\n * @param requireToken Flag to indicate if a token is required\r\n */\r\n\r\n public static async getServiceJson(args: ArcGisGetServiceJsonArgs): Promise<ArcGISServiceMetadata|undefined> {\r\n const {url, formatId, userName, password, queryParams, ignoreCache, requireToken} = args;\r\n if (!ignoreCache) {\r\n const cached = ArcGisUtilities._serviceCache.get(url);\r\n if (cached !== undefined)\r\n return cached;\r\n }\r\n const appendParams = (urlObj: URL, params?: {[key: string]: string}) => {\r\n if (params) {\r\n Object.keys(params).forEach((paramKey) => {\r\n if (!urlObj.searchParams.has(paramKey))\r\n urlObj.searchParams.append(paramKey, params[paramKey]);\r\n });\r\n }\r\n };\r\n\r\n const createUrlObj = () => {\r\n const tmpUrl = new URL(url);\r\n tmpUrl.searchParams.append(\"f\", \"json\");\r\n appendParams(tmpUrl, queryParams);\r\n return tmpUrl;\r\n };\r\n\r\n let accessTokenRequired = false;\r\n try {\r\n let tmpUrl = createUrlObj();\r\n\r\n // In some cases, caller might already know token is required, so append it immediately\r\n if (requireToken) {\r\n const accessClient = IModelApp.mapLayerFormatRegistry.getAccessClient(formatId);\r\n if (accessClient) {\r\n accessTokenRequired = true;\r\n await ArcGisUtilities.appendSecurityToken(tmpUrl, accessClient, {mapLayerUrl: new URL(url), userName, password});\r\n }\r\n }\r\n let response = await fetch(tmpUrl.toString(), { method: \"GET\" });\r\n if (response.status === 401 && !requireToken && headersIncludeAuthMethod(response.headers, [\"ntlm\", \"negotiate\"])) {\r\n // We got a http 401 challenge, lets try again with SSO enabled (i.e. Windows Authentication)\r\n response = await fetch(url, {method: \"GET\", credentials: \"include\" });\r\n }\r\n\r\n // Append security token when corresponding error code is returned by ArcGIS service\r\n let errorCode = await ArcGisUtilities.checkForResponseErrorCode(response);\r\n if (!accessTokenRequired\r\n && (errorCode === ArcGisErrorCode.TokenRequired || errorCode === ArcGisErrorCode.MissingPermissions) ) {\r\n accessTokenRequired = true;\r\n // If token required\r\n const accessClient = IModelApp.mapLayerFormatRegistry.getAccessClient(formatId);\r\n if (accessClient) {\r\n tmpUrl = createUrlObj();\r\n await ArcGisUtilities.appendSecurityToken(tmpUrl, accessClient, {mapLayerUrl: new URL(url), userName, password});\r\n response = await fetch(tmpUrl.toString(), { method: \"GET\" });\r\n errorCode = await ArcGisUtilities.checkForResponseErrorCode(response);\r\n }\r\n }\r\n\r\n const json = await response.json();\r\n const info = {content: json, accessTokenRequired};\r\n // Cache the response only if it doesn't contain any error.\r\n ArcGisUtilities._serviceCache.set(url, (errorCode === undefined ? info : undefined));\r\n return info; // Always return json, even though it contains an error code.\r\n\r\n } catch (_error) {\r\n ArcGisUtilities._serviceCache.set(url, undefined);\r\n return undefined;\r\n }\r\n }\r\n\r\n /** Read a response from ArcGIS server and check for error code in the response. */\r\n public static async checkForResponseErrorCode(response: Response) {\r\n const tmpResponse = response;\r\n if (response.headers && tmpResponse.headers.get(\"content-type\")?.toLowerCase().includes(\"json\")) {\r\n\r\n try {\r\n // Note:\r\n // Since response stream can only be read once (i.e. calls to .json() method)\r\n // we have to clone the response object in order to check for potential error code,\r\n // but still keep the response stream as unread.\r\n const clonedResponse = tmpResponse.clone();\r\n const json = await clonedResponse.json();\r\n if (json?.error?.code !== undefined)\r\n return json?.error?.code as number;\r\n } catch { }\r\n\r\n }\r\n return undefined;\r\n }\r\n\r\n // return the appended access token if available.\r\n public static async appendSecurityToken(url: URL, accessClient: MapLayerAccessClient, accessTokenParams: MapLayerAccessTokenParams): Promise<MapLayerAccessToken|undefined> {\r\n\r\n // Append security token if available\r\n let accessToken: MapLayerAccessToken|undefined;\r\n try {\r\n accessToken = await accessClient.getAccessToken(accessTokenParams);\r\n } catch {}\r\n\r\n if (accessToken?.token) {\r\n url.searchParams.append(\"token\", accessToken.token);\r\n return accessToken;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Compute scale, resolution values for requested zoom levels (WSG 84)\r\n * Use a scale of 96 dpi for Google Maps scales\r\n * Based on this article: https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Resolution_and_Scale\r\n * @param startZoom Zoom level where scales begins to be computed\r\n * @param endZoom Zoom level where scales ends to be computed\r\n * @param latitude Latitude in degrees to use to compute scales (i.e 0 for Equator)\r\n * @param tileSize Size of a tile in pixels (i.e 256)\r\n * @param screenDpi Monitor resolution in dots per inch (i.e. typically 96dpi is used by Google Maps)\r\n * @returns An array containing resolution and scale values for each requested zoom level\r\n */\r\n public static computeZoomLevelsScales(startZoom: number = 0, endZoom: number = 20, latitude: number = 0, tileSize: number = 256, screenDpi = 96): {zoom: number, resolution: number, scale: number}[] {\r\n // Note: There is probably a more direct way to compute this, but I prefer to go for a simple and well documented approach.\r\n if (startZoom <0 || endZoom < startZoom || tileSize < 0 || screenDpi < 1 || latitude < -90 || latitude > 90)\r\n return [];\r\n\r\n const inchPerMeter = 1 / 0.0254;\r\n const results: {zoom: number, resolution: number, scale: number}[] = [];\r\n const equatorLength = Constant.earthRadiusWGS84.equator * 2 * Math.PI;\r\n const zoom0Resolution = equatorLength / tileSize; // in meters per pixel\r\n\r\n const cosLatitude = Math.cos(latitude);\r\n for (let zoom = startZoom; zoom<= endZoom; zoom++) {\r\n const resolution = zoom0Resolution * cosLatitude / Math.pow(2, zoom);\r\n const scale = screenDpi * inchPerMeter * resolution;\r\n results.push({zoom, resolution, scale});\r\n }\r\n\r\n return results;\r\n }\r\n\r\n /**\r\n * Match the provided minScale, maxScale values to corresponding wgs84 zoom levels\r\n * @param defaultMaxLod Value of the last LOD (i.e 22)\r\n * @param tileSize Size of a tile in pixels (i.e 256)\r\n * @param minScale Minimum scale value that needs to be matched to a LOD level\r\n * @param maxScale Maximum scale value that needs to be matched to a LOD level\r\n * @returns minLod: LOD value matching minScale, maxLod: LOD value matching maxScale\r\n */\r\n public static getZoomLevelsScales( defaultMaxLod: number, tileSize: number, minScale?: number, maxScale?: number, tolerance: number = 0): {minLod?: number, maxLod?: number} {\r\n\r\n let minLod: number|undefined, maxLod: number|undefined;\r\n\r\n const zoomScales = ArcGisUtilities.computeZoomLevelsScales(0, defaultMaxLod, 0 /* latitude 0 = Equator*/, tileSize);\r\n\r\n if (zoomScales.length > 0) {\r\n\r\n if (minScale) {\r\n minLod = 0;\r\n // We are looking for the largest scale value with a scale value smaller than minScale\r\n for (; minLod < zoomScales.length && (zoomScales[minLod].scale > minScale && Math.abs(zoomScales[minLod].scale - minScale) > tolerance); minLod++)\r\n ;\r\n\r\n }\r\n\r\n if (maxScale) {\r\n maxLod = defaultMaxLod;\r\n // We are looking for the smallest scale value with a value greater than maxScale\r\n for (; maxLod >= 0 && zoomScales[maxLod].scale < maxScale && Math.abs(zoomScales[maxLod].scale - maxScale) > tolerance; maxLod--)\r\n ;\r\n }\r\n }\r\n return {minLod, maxLod};\r\n }\r\n\r\n}\r\n"]}
|
|
1
|
+
{"version":3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oBAC9H,CAAC;YACL,CAAC;QACH,CAAC;QACD,OAAO,EAAC,MAAM,EAAE,MAAM,EAAC,CAAC;IAC1B,CAAC;;AAzWH,0CA2WC;AAzLgB,6BAAa,GAAG,IAAI,GAAG,EAA2C,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\nimport { Angle, Constant } from \"@itwin/core-geometry\";\r\nimport { MapSubLayerProps } from \"@itwin/core-common\";\r\nimport { MapCartoRectangle, MapLayerAccessClient, MapLayerAccessToken, MapLayerAccessTokenParams, MapLayerSource, MapLayerSourceStatus, MapLayerSourceValidation, ValidateSourceArgs} from \"../internal\";\r\nimport { IModelApp } from \"../../IModelApp\";\r\nimport { headersIncludeAuthMethod } from \"../../request/utils\";\r\n\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\n/**\r\n * Class representing an ArcGIS error code.\r\n * @internal\r\n */\r\nexport enum ArcGisErrorCode {\r\n InvalidCredentials = 401,\r\n MissingPermissions = 403,\r\n InvalidToken = 498,\r\n TokenRequired = 499,\r\n UnknownError = 1000,\r\n NoTokenService = 1001,\r\n}\r\n\r\n/**\r\n * Class representing an ArcGIS service metadata.\r\n * @internal\r\n */\r\nexport interface ArcGISServiceMetadata {\r\n /** JSON content from the service */\r\n content: any;\r\n\r\n /** Indicates if an access token is required to access the service */\r\n accessTokenRequired: boolean;\r\n}\r\n\r\n/** Arguments for validating ArcGIS sources\r\n * @internal\r\n */\r\nexport interface ArcGisValidateSourceArgs extends ValidateSourceArgs {\r\n /** List of capabilities 'keyword' that needs to be advertised in the service's metadata in order to be valid. For example: 'Map', 'Query', etc*/\r\n capabilitiesFilter: string[];\r\n}\r\n\r\n/** Arguments for fetching service metadata\r\n * @internal\r\n */\r\nexport interface ArcGisGetServiceJsonArgs {\r\n url: string;\r\n formatId: string;\r\n userName?: string;\r\n password?: string;\r\n queryParams?: {[key: string]: string};\r\n ignoreCache?: boolean;\r\n requireToken?: boolean;\r\n}\r\n\r\n/**\r\n * Class containing utilities relating to ArcGIS services and coordinate systems.\r\n * @internal\r\n */\r\nexport class ArcGisUtilities {\r\n\r\n private static getBBoxString(range?: MapCartoRectangle) {\r\n if (!range)\r\n range = MapCartoRectangle.createMaximum();\r\n\r\n return `${range.low.x * Angle.degreesPerRadian},${range.low.y * Angle.degreesPerRadian},${range.high.x * Angle.degreesPerRadian},${range.high.y * Angle.degreesPerRadian}`;\r\n }\r\n\r\n public static async getNationalMapSources(): Promise<MapLayerSource[]> {\r\n const sources = new Array<MapLayerSource>();\r\n const response = await fetch(\"https://viewer.nationalmap.gov/tnmaccess/api/getMapServiceList\", { method: \"GET\" });\r\n const services = await response.json();\r\n\r\n if (!Array.isArray(services))\r\n return sources;\r\n\r\n for (const service of services) {\r\n if (service.wmsUrl.length === 0) // Exclude Wfs..\r\n continue;\r\n switch (service.serviceType) {\r\n case \"ArcGIS\":\r\n sources.push(MapLayerSource.fromJSON({ name: service.displayName, url: service.serviceLink, formatId: \"ArcGIS\" })!);\r\n break;\r\n default: {\r\n const wmsIndex = service.wmsUrl.lastIndexOf(\"/wms\");\r\n if (wmsIndex > 0) {\r\n const url = service.wmsUrl.slice(0, wmsIndex + 4);\r\n sources.push(MapLayerSource.fromJSON({ name: service.displayName, url, formatId: \"WMS\" })!);\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n return sources;\r\n }\r\n\r\n public static async getServiceDirectorySources(url: string, baseUrl?: string): Promise<MapLayerSource[]> {\r\n if (undefined === baseUrl)\r\n baseUrl = url;\r\n let sources = new Array<MapLayerSource>();\r\n const response = await fetch(`${url}?f=json`, { method: \"GET\" });\r\n const json = await response.json();\r\n if (json !== undefined) {\r\n if (Array.isArray(json.folders)) {\r\n for (const folder of json.folders) {\r\n sources = sources.concat(await ArcGisUtilities.getServiceDirectorySources(`${url}/${folder}`, url));\r\n }\r\n }\r\n if (Array.isArray(json.services)) {\r\n for (const service of json.services) {\r\n let source;\r\n if (service.type === \"MapServer\")\r\n source = MapLayerSource.fromJSON({ name: service.name, url: `${baseUrl}/${service.name}/MapServer`, formatId: \"ArcGIS\" });\r\n else if (service.type === \"ImageServer\")\r\n source = MapLayerSource.fromJSON({ name: service.name, url: `${baseUrl}/${service.name}/ImageServer`, formatId: \"ArcGIS\" });\r\n if (source)\r\n sources.push(source);\r\n }\r\n }\r\n }\r\n\r\n return sources;\r\n }\r\n\r\n /**\r\n * Get map layer sources from an ArcGIS query.\r\n * @param range Range for the query.\r\n * @param url URL for the query.\r\n * @returns List of map layer sources.\r\n */\r\n public static async getSourcesFromQuery(range?: MapCartoRectangle, url = \"https://usgs.maps.arcgis.com/sharing/rest/search\"): Promise<MapLayerSource[]> {\r\n const sources = new Array<MapLayerSource>();\r\n for (let start = 1; start > 0;) {\r\n const response = await fetch(`${url}?f=json&q=(group:9d1199a521334e77a7d15abbc29f8144) AND (type:\"Map Service\")&bbox=${ArcGisUtilities.getBBoxString(range)}&sortOrder=desc&start=${start}&num=100`, { method: \"GET\" });\r\n const json = await response.json();\r\n if (!json)\r\n break;\r\n\r\n start = json.nextStart ? json.nextStart : -1;\r\n if (json !== undefined && Array.isArray(json.results)) {\r\n for (const result of json.results) {\r\n const source = MapLayerSource.fromJSON({ name: result.name ? result.name : result.title, url: result.url, formatId: \"ArcGIS\" });\r\n if (source)\r\n sources.push(source);\r\n }\r\n }\r\n }\r\n\r\n return sources;\r\n }\r\n\r\n /**\r\n * Parse the URL to check if it represents a valid ArcGIS service\r\n * @param url URL to validate.\r\n * @param serviceType Service type to validate (i.e FeatureServer, MapServer)\r\n * @return Validation Status.\r\n */\r\n public static validateUrl(url: string, serviceType: string): MapLayerSourceStatus {\r\n const urlObj = new URL(url.toLowerCase());\r\n if (urlObj.pathname.includes(\"/rest/services/\")) {\r\n // This seem to be an ArcGIS URL, lets check the service type\r\n if (urlObj.pathname.endsWith(`${serviceType.toLowerCase()}`)) {\r\n return MapLayerSourceStatus.Valid;\r\n } else {\r\n return MapLayerSourceStatus.IncompatibleFormat;\r\n }\r\n } else {\r\n return MapLayerSourceStatus.InvalidUrl;\r\n }\r\n }\r\n\r\n /**\r\n * Attempt to access an ArcGIS service, and validate its service metadata.\r\n * @param source Source to validate.\r\n * @param opts Validation options\r\n */\r\n public static async validateSource(args: ArcGisValidateSourceArgs): Promise<MapLayerSourceValidation> {\r\n const {source, ignoreCache, capabilitiesFilter} = args;\r\n const metadata = await this.getServiceJson({url: source.url, formatId: source.formatId, userName: source.userName, password: source.password, queryParams: source.collectQueryParams(), ignoreCache});\r\n const json = metadata?.content;\r\n if (json === undefined) {\r\n return { status: MapLayerSourceStatus.InvalidUrl };\r\n } else if (json.error !== undefined) {\r\n\r\n // If we got a 'Token Required' error, lets check what authentification methods this ESRI service offers\r\n // and return information needed to initiate the authentification process... the end-user\r\n // will have to provide his credentials before we can fully validate this source.\r\n // Note: Some servers will throw a error 403 (You do not have permissions to access this resource or perform this operation),\r\n // instead of 499 (TokenRequired)\r\n if (json.error.code === ArcGisErrorCode.TokenRequired || json.error.code === ArcGisErrorCode.MissingPermissions) {\r\n return (source.userName || source.password) ? {status: MapLayerSourceStatus.InvalidCredentials} : {status: MapLayerSourceStatus.RequireAuth};\r\n } else if (json.error.code === ArcGisErrorCode.InvalidCredentials)\r\n return { status: MapLayerSourceStatus.InvalidCredentials};\r\n }\r\n\r\n // Check this service support the expected queries\r\n let hasCapabilities = false;\r\n let capsArray: string[] = [];\r\n if (json.capabilities && typeof json.capabilities === \"string\" ) {\r\n const capabilities: string = json.capabilities;\r\n capsArray = capabilities.split(\",\").map((entry) => entry.toLowerCase());\r\n\r\n const filtered = capsArray.filter((element, _index, _array) => capabilitiesFilter.includes(element));\r\n hasCapabilities = (filtered.length === capabilitiesFilter.length);\r\n }\r\n if (!hasCapabilities) {\r\n return { status: MapLayerSourceStatus.InvalidFormat};\r\n }\r\n\r\n // Only EPSG:3857 is supported with pre-rendered tiles.\r\n if (json.tileInfo && capsArray.includes(\"tilesonly\") && !ArcGisUtilities.isEpsg3857Compatible(json.tileInfo)) {\r\n return { status: MapLayerSourceStatus.InvalidCoordinateSystem};\r\n }\r\n\r\n let subLayers;\r\n if (json.layers) {\r\n\r\n subLayers = new Array<MapSubLayerProps>();\r\n\r\n for (const layer of json.layers) {\r\n const parent = layer.parentLayerId < 0 ? undefined : layer.parentLayerId;\r\n const children = Array.isArray(layer.subLayerIds) ? layer.subLayerIds : undefined;\r\n subLayers.push({ name: layer.name, visible: layer.defaultVisibility !== false, id: layer.id, parent, children });\r\n }\r\n }\r\n return { status: MapLayerSourceStatus.Valid, subLayers };\r\n }\r\n\r\n /** Validate MapService tiling metadata and checks if the tile tree is 'Google Maps' compatible. */\r\n public static isEpsg3857Compatible(tileInfo: any) {\r\n if (tileInfo.spatialReference?.latestWkid !== 3857 || !Array.isArray(tileInfo.lods))\r\n return false;\r\n\r\n const zeroLod = tileInfo.lods[0];\r\n return zeroLod.level === 0 && Math.abs(zeroLod.resolution - 156543.03392800014) < .001;\r\n }\r\n\r\n private static _serviceCache = new Map<string, ArcGISServiceMetadata|undefined>();\r\n\r\n /**\r\n * Fetches an ArcGIS service metadata, and returns its JSON representation.\r\n * If an access client has been configured for the specified formatId,\r\n * it will be used to apply required security token.\r\n * By default, response for each URL are cached.\r\n * @param url URL of the ArcGIS service\r\n * @param formatId Format ID of the service\r\n * @param userName Username to use for legacy token based security\r\n * @param password Password to use for legacy token based security\r\n * @param ignoreCache Flag to skip cache lookup (i.e. force a new server request)\r\n * @param requireToken Flag to indicate if a token is required\r\n */\r\n\r\n public static async getServiceJson(args: ArcGisGetServiceJsonArgs): Promise<ArcGISServiceMetadata|undefined> {\r\n const {url, formatId, userName, password, queryParams, ignoreCache, requireToken} = args;\r\n if (!ignoreCache) {\r\n const cached = ArcGisUtilities._serviceCache.get(url);\r\n if (cached !== undefined)\r\n return cached;\r\n }\r\n const appendParams = (urlObj: URL, params?: {[key: string]: string}) => {\r\n if (params) {\r\n Object.keys(params).forEach((paramKey) => {\r\n if (!urlObj.searchParams.has(paramKey))\r\n urlObj.searchParams.append(paramKey, params[paramKey]);\r\n });\r\n }\r\n };\r\n\r\n const createUrlObj = () => {\r\n const tmpUrl = new URL(url);\r\n tmpUrl.searchParams.append(\"f\", \"json\");\r\n appendParams(tmpUrl, queryParams);\r\n return tmpUrl;\r\n };\r\n\r\n let accessTokenRequired = false;\r\n try {\r\n let tmpUrl = createUrlObj();\r\n\r\n // In some cases, caller might already know token is required, so append it immediately\r\n if (requireToken) {\r\n const accessClient = IModelApp.mapLayerFormatRegistry.getAccessClient(formatId);\r\n if (accessClient) {\r\n accessTokenRequired = true;\r\n await ArcGisUtilities.appendSecurityToken(tmpUrl, accessClient, {mapLayerUrl: new URL(url), userName, password});\r\n }\r\n }\r\n let response = await fetch(tmpUrl, { method: \"GET\" });\r\n if (response.status === 401 && !requireToken && headersIncludeAuthMethod(response.headers, [\"ntlm\", \"negotiate\"])) {\r\n // We got a http 401 challenge, lets try again with SSO enabled (i.e. Windows Authentication)\r\n response = await fetch(tmpUrl, {method: \"GET\", credentials: \"include\" });\r\n }\r\n\r\n // Append security token when corresponding error code is returned by ArcGIS service\r\n let errorCode = await ArcGisUtilities.checkForResponseErrorCode(response);\r\n if (!accessTokenRequired\r\n && (errorCode === ArcGisErrorCode.TokenRequired || errorCode === ArcGisErrorCode.MissingPermissions) ) {\r\n accessTokenRequired = true;\r\n // If token required\r\n const accessClient = IModelApp.mapLayerFormatRegistry.getAccessClient(formatId);\r\n if (accessClient) {\r\n tmpUrl = createUrlObj();\r\n await ArcGisUtilities.appendSecurityToken(tmpUrl, accessClient, {mapLayerUrl: new URL(url), userName, password});\r\n response = await fetch(tmpUrl.toString(), { method: \"GET\" });\r\n errorCode = await ArcGisUtilities.checkForResponseErrorCode(response);\r\n }\r\n }\r\n\r\n const json = await response.json();\r\n const info = {content: json, accessTokenRequired};\r\n // Cache the response only if it doesn't contain any error.\r\n ArcGisUtilities._serviceCache.set(url, (errorCode === undefined ? info : undefined));\r\n return info; // Always return json, even though it contains an error code.\r\n\r\n } catch (_error) {\r\n ArcGisUtilities._serviceCache.set(url, undefined);\r\n return undefined;\r\n }\r\n }\r\n\r\n /** Read a response from ArcGIS server and check for error code in the response. */\r\n public static async checkForResponseErrorCode(response: Response) {\r\n const tmpResponse = response;\r\n if (response.headers && tmpResponse.headers.get(\"content-type\")?.toLowerCase().includes(\"json\")) {\r\n\r\n try {\r\n // Note:\r\n // Since response stream can only be read once (i.e. calls to .json() method)\r\n // we have to clone the response object in order to check for potential error code,\r\n // but still keep the response stream as unread.\r\n const clonedResponse = tmpResponse.clone();\r\n const json = await clonedResponse.json();\r\n if (json?.error?.code !== undefined)\r\n return json?.error?.code as number;\r\n } catch { }\r\n\r\n }\r\n return undefined;\r\n }\r\n\r\n // return the appended access token if available.\r\n public static async appendSecurityToken(url: URL, accessClient: MapLayerAccessClient, accessTokenParams: MapLayerAccessTokenParams): Promise<MapLayerAccessToken|undefined> {\r\n\r\n // Append security token if available\r\n let accessToken: MapLayerAccessToken|undefined;\r\n try {\r\n accessToken = await accessClient.getAccessToken(accessTokenParams);\r\n } catch {}\r\n\r\n if (accessToken?.token) {\r\n url.searchParams.append(\"token\", accessToken.token);\r\n return accessToken;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Compute scale, resolution values for requested zoom levels (WSG 84)\r\n * Use a scale of 96 dpi for Google Maps scales\r\n * Based on this article: https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Resolution_and_Scale\r\n * @param startZoom Zoom level where scales begins to be computed\r\n * @param endZoom Zoom level where scales ends to be computed\r\n * @param latitude Latitude in degrees to use to compute scales (i.e 0 for Equator)\r\n * @param tileSize Size of a tile in pixels (i.e 256)\r\n * @param screenDpi Monitor resolution in dots per inch (i.e. typically 96dpi is used by Google Maps)\r\n * @returns An array containing resolution and scale values for each requested zoom level\r\n */\r\n public static computeZoomLevelsScales(startZoom: number = 0, endZoom: number = 20, latitude: number = 0, tileSize: number = 256, screenDpi = 96): {zoom: number, resolution: number, scale: number}[] {\r\n // Note: There is probably a more direct way to compute this, but I prefer to go for a simple and well documented approach.\r\n if (startZoom <0 || endZoom < startZoom || tileSize < 0 || screenDpi < 1 || latitude < -90 || latitude > 90)\r\n return [];\r\n\r\n const inchPerMeter = 1 / 0.0254;\r\n const results: {zoom: number, resolution: number, scale: number}[] = [];\r\n const equatorLength = Constant.earthRadiusWGS84.equator * 2 * Math.PI;\r\n const zoom0Resolution = equatorLength / tileSize; // in meters per pixel\r\n\r\n const cosLatitude = Math.cos(latitude);\r\n for (let zoom = startZoom; zoom<= endZoom; zoom++) {\r\n const resolution = zoom0Resolution * cosLatitude / Math.pow(2, zoom);\r\n const scale = screenDpi * inchPerMeter * resolution;\r\n results.push({zoom, resolution, scale});\r\n }\r\n\r\n return results;\r\n }\r\n\r\n /**\r\n * Match the provided minScale, maxScale values to corresponding wgs84 zoom levels\r\n * @param defaultMaxLod Value of the last LOD (i.e 22)\r\n * @param tileSize Size of a tile in pixels (i.e 256)\r\n * @param minScale Minimum scale value that needs to be matched to a LOD level\r\n * @param maxScale Maximum scale value that needs to be matched to a LOD level\r\n * @returns minLod: LOD value matching minScale, maxLod: LOD value matching maxScale\r\n */\r\n public static getZoomLevelsScales( defaultMaxLod: number, tileSize: number, minScale?: number, maxScale?: number, tolerance: number = 0): {minLod?: number, maxLod?: number} {\r\n\r\n let minLod: number|undefined, maxLod: number|undefined;\r\n\r\n const zoomScales = ArcGisUtilities.computeZoomLevelsScales(0, defaultMaxLod, 0 /* latitude 0 = Equator*/, tileSize);\r\n\r\n if (zoomScales.length > 0) {\r\n\r\n if (minScale) {\r\n minLod = 0;\r\n // We are looking for the largest scale value with a scale value smaller than minScale\r\n for (; minLod < zoomScales.length && (zoomScales[minLod].scale > minScale && Math.abs(zoomScales[minLod].scale - minScale) > tolerance); minLod++)\r\n ;\r\n\r\n }\r\n\r\n if (maxScale) {\r\n maxLod = defaultMaxLod;\r\n // We are looking for the smallest scale value with a value greater than maxScale\r\n for (; maxLod >= 0 && zoomScales[maxLod].scale < maxScale && Math.abs(zoomScales[maxLod].scale - maxScale) > tolerance; maxLod--)\r\n ;\r\n }\r\n }\r\n return {minLod, maxLod};\r\n }\r\n\r\n}\r\n"]}
|
|
@@ -99,10 +99,10 @@ class ArcGISImageryProvider extends internal_1.MapLayerImageryProvider {
|
|
|
99
99
|
await this._firstRequestPromise;
|
|
100
100
|
let response;
|
|
101
101
|
try {
|
|
102
|
-
response = await fetch(urlObj
|
|
102
|
+
response = await fetch(urlObj, { ...options, credentials: this._includeUserCredentials ? "include" : undefined });
|
|
103
103
|
if (response.status === 401 && !this._lastAccessToken && (0, utils_1.headersIncludeAuthMethod)(response.headers, ["ntlm", "negotiate"])) {
|
|
104
104
|
// We got a http 401 challenge, lets try again with SSO enabled (i.e. Windows Authentication)
|
|
105
|
-
response = await fetch(
|
|
105
|
+
response = await fetch(urlObj, { ...options, credentials: "include" });
|
|
106
106
|
if (response.status === 200) {
|
|
107
107
|
this._includeUserCredentials = true; // avoid going through 401 challenges over and over
|
|
108
108
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArcGISImageryProvider.js","sourceRoot":"","sources":["../../../../../src/tile/map/ImageryProviders/ArcGISImageryProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,6CAA4L;AAC5L,kDAA+C;AAC/C,sEAA2F;AAC3F,kDAAkE;AAElE;;;;;;GAMG;AACH,MAAsB,qBAAsB,SAAQ,kCAAuB;IAYzE,IAAoB,sBAAsB,KAAK,OAAO,IAAI,CAAC,eAAe,CAAC,CAAA,CAAC;IAE5E,YAAY,QAA+B,EAAE,eAAwB;QACnE,KAAK,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QAVnC;;UAEE;QACQ,yBAAoB,GAAG,KAAK,CAAC;QAE7B,oBAAe,GAAG,KAAK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CAAC;QAEvC,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA1KD,sDA0KC","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\n\r\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\r\nimport { ArcGisErrorCode, ArcGISServiceMetadata, ArcGisUtilities, MapLayerAccessClient, MapLayerAccessToken, MapLayerImageryProvider, MapLayerImageryProviderStatus } from \"../../internal\";\r\nimport { IModelApp } from \"../../../IModelApp\";\r\nimport { NotifyMessageDetails, OutputMessagePriority } from \"../../../NotificationManager\";\r\nimport { headersIncludeAuthMethod } from \"../../../request/utils\";\r\n\r\n/** Base class for ArcGIS map-layer imagery providers.\r\n *\r\n * The initial purpose of this class is to offer shared methods\r\n * to query ArcGIS services and apply the appropriate security token.\r\n * @see [[ArcGISMapLayerImageryProvider]]\r\n * @internal\r\n */\r\nexport abstract class ArcGISImageryProvider extends MapLayerImageryProvider {\r\n\r\n protected _accessClient: MapLayerAccessClient|undefined;\r\n protected _lastAccessToken: MapLayerAccessToken|undefined;\r\n\r\n /** Flag indicating if access token should be added to request.\r\n * @note We assume a service to require access token for the entire viewing session.\r\n */\r\n protected _accessTokenRequired = false;\r\n\r\n protected _querySupported = false;\r\n\r\n public override get supportsMapFeatureInfo() { return this._querySupported;}\r\n\r\n constructor(settings: ImageMapLayerSettings, usesCachedTiles: boolean) {\r\n super(settings, usesCachedTiles);\r\n this._accessClient = IModelApp.mapLayerFormatRegistry?.getAccessClient(settings.formatId);\r\n }\r\n\r\n /** Updates the accessClient token state whenever the status of the provider change.\r\n * @internal\r\n * */\r\n protected override onStatusUpdated(status: MapLayerImageryProviderStatus) {\r\n if (status === MapLayerImageryProviderStatus.RequireAuth) {\r\n\r\n // Invalidate the token, so a new one get generated\r\n if (this._accessClient?.invalidateToken !== undefined && this._lastAccessToken !== undefined) {\r\n this._accessClient.invalidateToken(this._lastAccessToken);\r\n }\r\n\r\n // Make sure we don't re-use this token again (i.e force login process)\r\n this._lastAccessToken = undefined;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch an ArcGIS service metadata, and returns its JSON representation.\r\n * This wrapper maintains token state and should be used instead of the the ArcGisUtilities version.\r\n */\r\n protected async getServiceJson() {\r\n let metadata: ArcGISServiceMetadata|undefined;\r\n try {\r\n metadata = await ArcGisUtilities.getServiceJson({url: this._settings.url, formatId: this._settings.formatId, userName: this._settings.userName, password: this._settings.password, queryParams: this._settings.collectQueryParams()});\r\n\r\n } catch (_e) {\r\n }\r\n if (metadata && metadata.accessTokenRequired) {\r\n const accessClient = IModelApp.mapLayerFormatRegistry.getAccessClient(this._settings.formatId);\r\n if (accessClient) {\r\n try {\r\n // Keep track of last used access token, so we can invalidate it later when an errors occurs\r\n const accessToken = await accessClient.getAccessToken({mapLayerUrl: new URL(this._settings.url)});\r\n this._lastAccessToken = accessToken;\r\n } catch {\r\n }\r\n }\r\n // By turning this ON, tiles requests will include security token\r\n this._accessTokenRequired = metadata.accessTokenRequired;\r\n }\r\n return metadata;\r\n }\r\n\r\n /**\r\n * Make a request to an ArcGIS service using the provided URL and init parameters.\r\n * @param url URL to query\r\n * @param options Custom settings to apply to the request.\r\n * Refer to fetch API for more details (https://developer.mozilla.org/en-US/docs/Web/API/fetch)\r\n */\r\n protected async fetch(url: URL, options?: RequestInit) {\r\n\r\n let errorCode: number | undefined;\r\n const urlObj = new URL(url);\r\n const queryParams = this._settings.collectQueryParams();\r\n Object.keys(queryParams).forEach((paramKey) => {\r\n if (!urlObj.searchParams.has(paramKey))\r\n urlObj.searchParams.append(paramKey, queryParams[paramKey]);\r\n });\r\n\r\n if (this._accessTokenRequired && this._accessClient) {\r\n this._lastAccessToken = await ArcGisUtilities.appendSecurityToken(urlObj, this._accessClient, {\r\n mapLayerUrl: new URL(this._settings.url),\r\n userName: this._settings.userName,\r\n password: this._settings.password });\r\n }\r\n\r\n // We want to complete the first request before letting other requests go;\r\n // this done to avoid flooding server with requests missing credentials\r\n if (!this._firstRequestPromise)\r\n this._firstRequestPromise = new Promise<void>((resolve: any) => this.onFirstRequestCompleted.addOnce(()=>resolve()));\r\n else\r\n await this._firstRequestPromise;\r\n\r\n let response: Response|undefined;\r\n try {\r\n response = await fetch(urlObj.toString(), {...options, credentials: this._includeUserCredentials ? \"include\" : undefined});\r\n\r\n if (response.status === 401 && !this._lastAccessToken && headersIncludeAuthMethod(response.headers, [\"ntlm\", \"negotiate\"])) {\r\n // We got a http 401 challenge, lets try again with SSO enabled (i.e. Windows Authentication)\r\n response = await fetch(url, {...options, credentials: \"include\" });\r\n if (response.status === 200) {\r\n this._includeUserCredentials = true; // avoid going through 401 challenges over and over\r\n }\r\n }\r\n\r\n if ((this._lastAccessToken && response.status === 400)\r\n || response.headers.get(\"content-type\")?.toLowerCase().includes(\"htm\")) {\r\n // For some reasons when we make a request with the fetch() api and there is a token error\r\n // we receive a status 400 instead of proper json response. (i.e doing the same request in the browser gives a different response)\r\n // For some other request, we also seen error message in html.\r\n // When it occurs, we fall back to root service request so we get a proper JSON response with error code.\r\n const tmpUrl = new URL(this._settings.url);\r\n if (this._lastAccessToken && this._accessTokenRequired)\r\n tmpUrl.searchParams.append(\"token\", this._lastAccessToken.token);\r\n tmpUrl.searchParams.append(\"f\",\"json\");\r\n response = await fetch(tmpUrl.toString(), options);\r\n }\r\n\r\n errorCode = await ArcGisUtilities.checkForResponseErrorCode(response);\r\n\r\n if (errorCode !== undefined &&\r\n ( errorCode === ArcGisErrorCode.TokenRequired\r\n || errorCode === ArcGisErrorCode.InvalidToken\r\n || errorCode === ArcGisErrorCode.MissingPermissions\r\n ) ) {\r\n\r\n if (this._settings.userName && this._settings.userName.length > 0 && this._lastAccessToken ) {\r\n // **** Legacy token ONLY ***\r\n\r\n // Token might have expired, make a second attempt by forcing new token.\r\n if (this._accessClient?.invalidateToken !== undefined && this._lastAccessToken !== undefined)\r\n this._accessClient.invalidateToken(this._lastAccessToken);\r\n\r\n const urlObj2 = new URL(url);\r\n if (this._accessClient) {\r\n try {\r\n this._lastAccessToken = await ArcGisUtilities.appendSecurityToken(urlObj, this._accessClient, {mapLayerUrl: urlObj, userName: this._settings.userName, password: this._settings.password });\r\n } catch {\r\n }\r\n }\r\n\r\n // Make a second attempt with refreshed token\r\n response = await fetch(urlObj2.toString(), options);\r\n errorCode = await ArcGisUtilities.checkForResponseErrorCode(response);\r\n }\r\n\r\n if (errorCode !== undefined &&\r\n ( errorCode === ArcGisErrorCode.TokenRequired\r\n || errorCode === ArcGisErrorCode.InvalidToken\r\n || errorCode === ArcGisErrorCode.MissingPermissions\r\n ) ) {\r\n // Looks like the initially generated token has expired.\r\n\r\n if (this.status === MapLayerImageryProviderStatus.Valid ) {\r\n // Only report new status change to avoid spamming the UI\r\n this.setStatus(MapLayerImageryProviderStatus.RequireAuth);\r\n this.onStatusChanged.raiseEvent(this);\r\n const msg = IModelApp.localization.getLocalizedString(\"iModelJs:MapLayers.Messages.FetchTooltipTokenError\", { layerName: this._settings.name });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Warning, msg));\r\n }\r\n }\r\n }\r\n } finally {\r\n this.onFirstRequestCompleted.raiseEvent();\r\n }\r\n\r\n if (response === undefined)\r\n throw new Error(\"fetch call failed\");\r\n\r\n return response;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ArcGISImageryProvider.js","sourceRoot":"","sources":["../../../../../src/tile/map/ImageryProviders/ArcGISImageryProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,6CAA4L;AAC5L,kDAA+C;AAC/C,sEAA2F;AAC3F,kDAAkE;AAElE;;;;;;GAMG;AACH,MAAsB,qBAAsB,SAAQ,kCAAuB;IAYzE,IAAoB,sBAAsB,KAAK,OAAO,IAAI,CAAC,eAAe,CAA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gBAAS,CAAC;YACT,IAAI,CAAC,uBAAuB,CAAC,UAAU,EAAE,CAAC;QAC5C,CAAC;QAED,IAAI,QAAQ,KAAK,SAAS;YACxB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAEvC,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA1KD,sDA0KC","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\n\r\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\r\nimport { ArcGisErrorCode, ArcGISServiceMetadata, ArcGisUtilities, MapLayerAccessClient, MapLayerAccessToken, MapLayerImageryProvider, MapLayerImageryProviderStatus } from \"../../internal\";\r\nimport { IModelApp } from \"../../../IModelApp\";\r\nimport { NotifyMessageDetails, OutputMessagePriority } from \"../../../NotificationManager\";\r\nimport { headersIncludeAuthMethod } from \"../../../request/utils\";\r\n\r\n/** Base class for ArcGIS map-layer imagery providers.\r\n *\r\n * The initial purpose of this class is to offer shared methods\r\n * to query ArcGIS services and apply the appropriate security token.\r\n * @see [[ArcGISMapLayerImageryProvider]]\r\n * @internal\r\n */\r\nexport abstract class ArcGISImageryProvider extends MapLayerImageryProvider {\r\n\r\n protected _accessClient: MapLayerAccessClient|undefined;\r\n protected _lastAccessToken: MapLayerAccessToken|undefined;\r\n\r\n /** Flag indicating if access token should be added to request.\r\n * @note We assume a service to require access token for the entire viewing session.\r\n */\r\n protected _accessTokenRequired = false;\r\n\r\n protected _querySupported = false;\r\n\r\n public override get supportsMapFeatureInfo() { return this._querySupported;}\r\n\r\n constructor(settings: ImageMapLayerSettings, usesCachedTiles: boolean) {\r\n super(settings, usesCachedTiles);\r\n this._accessClient = IModelApp.mapLayerFormatRegistry?.getAccessClient(settings.formatId);\r\n }\r\n\r\n /** Updates the accessClient token state whenever the status of the provider change.\r\n * @internal\r\n * */\r\n protected override onStatusUpdated(status: MapLayerImageryProviderStatus) {\r\n if (status === MapLayerImageryProviderStatus.RequireAuth) {\r\n\r\n // Invalidate the token, so a new one get generated\r\n if (this._accessClient?.invalidateToken !== undefined && this._lastAccessToken !== undefined) {\r\n this._accessClient.invalidateToken(this._lastAccessToken);\r\n }\r\n\r\n // Make sure we don't re-use this token again (i.e force login process)\r\n this._lastAccessToken = undefined;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch an ArcGIS service metadata, and returns its JSON representation.\r\n * This wrapper maintains token state and should be used instead of the the ArcGisUtilities version.\r\n */\r\n protected async getServiceJson() {\r\n let metadata: ArcGISServiceMetadata|undefined;\r\n try {\r\n metadata = await ArcGisUtilities.getServiceJson({url: this._settings.url, formatId: this._settings.formatId, userName: this._settings.userName, password: this._settings.password, queryParams: this._settings.collectQueryParams()});\r\n\r\n } catch (_e) {\r\n }\r\n if (metadata && metadata.accessTokenRequired) {\r\n const accessClient = IModelApp.mapLayerFormatRegistry.getAccessClient(this._settings.formatId);\r\n if (accessClient) {\r\n try {\r\n // Keep track of last used access token, so we can invalidate it later when an errors occurs\r\n const accessToken = await accessClient.getAccessToken({mapLayerUrl: new URL(this._settings.url)});\r\n this._lastAccessToken = accessToken;\r\n } catch {\r\n }\r\n }\r\n // By turning this ON, tiles requests will include security token\r\n this._accessTokenRequired = metadata.accessTokenRequired;\r\n }\r\n return metadata;\r\n }\r\n\r\n /**\r\n * Make a request to an ArcGIS service using the provided URL and init parameters.\r\n * @param url URL to query\r\n * @param options Custom settings to apply to the request.\r\n * Refer to fetch API for more details (https://developer.mozilla.org/en-US/docs/Web/API/fetch)\r\n */\r\n protected async fetch(url: URL, options?: RequestInit) {\r\n\r\n let errorCode: number | undefined;\r\n const urlObj = new URL(url);\r\n const queryParams = this._settings.collectQueryParams();\r\n Object.keys(queryParams).forEach((paramKey) => {\r\n if (!urlObj.searchParams.has(paramKey))\r\n urlObj.searchParams.append(paramKey, queryParams[paramKey]);\r\n });\r\n\r\n if (this._accessTokenRequired && this._accessClient) {\r\n this._lastAccessToken = await ArcGisUtilities.appendSecurityToken(urlObj, this._accessClient, {\r\n mapLayerUrl: new URL(this._settings.url),\r\n userName: this._settings.userName,\r\n password: this._settings.password });\r\n }\r\n\r\n // We want to complete the first request before letting other requests go;\r\n // this done to avoid flooding server with requests missing credentials\r\n if (!this._firstRequestPromise)\r\n this._firstRequestPromise = new Promise<void>((resolve: any) => this.onFirstRequestCompleted.addOnce(()=>resolve()));\r\n else\r\n await this._firstRequestPromise;\r\n\r\n let response: Response|undefined;\r\n try {\r\n response = await fetch(urlObj, {...options, credentials: this._includeUserCredentials ? \"include\" : undefined});\r\n\r\n if (response.status === 401 && !this._lastAccessToken && headersIncludeAuthMethod(response.headers, [\"ntlm\", \"negotiate\"])) {\r\n // We got a http 401 challenge, lets try again with SSO enabled (i.e. Windows Authentication)\r\n response = await fetch(urlObj, {...options, credentials: \"include\" });\r\n if (response.status === 200) {\r\n this._includeUserCredentials = true; // avoid going through 401 challenges over and over\r\n }\r\n }\r\n\r\n if ((this._lastAccessToken && response.status === 400)\r\n || response.headers.get(\"content-type\")?.toLowerCase().includes(\"htm\")) {\r\n // For some reasons when we make a request with the fetch() api and there is a token error\r\n // we receive a status 400 instead of proper json response. (i.e doing the same request in the browser gives a different response)\r\n // For some other request, we also seen error message in html.\r\n // When it occurs, we fall back to root service request so we get a proper JSON response with error code.\r\n const tmpUrl = new URL(this._settings.url);\r\n if (this._lastAccessToken && this._accessTokenRequired)\r\n tmpUrl.searchParams.append(\"token\", this._lastAccessToken.token);\r\n tmpUrl.searchParams.append(\"f\",\"json\");\r\n response = await fetch(tmpUrl.toString(), options);\r\n }\r\n\r\n errorCode = await ArcGisUtilities.checkForResponseErrorCode(response);\r\n\r\n if (errorCode !== undefined &&\r\n ( errorCode === ArcGisErrorCode.TokenRequired\r\n || errorCode === ArcGisErrorCode.InvalidToken\r\n || errorCode === ArcGisErrorCode.MissingPermissions\r\n ) ) {\r\n\r\n if (this._settings.userName && this._settings.userName.length > 0 && this._lastAccessToken ) {\r\n // **** Legacy token ONLY ***\r\n\r\n // Token might have expired, make a second attempt by forcing new token.\r\n if (this._accessClient?.invalidateToken !== undefined && this._lastAccessToken !== undefined)\r\n this._accessClient.invalidateToken(this._lastAccessToken);\r\n\r\n const urlObj2 = new URL(url);\r\n if (this._accessClient) {\r\n try {\r\n this._lastAccessToken = await ArcGisUtilities.appendSecurityToken(urlObj, this._accessClient, {mapLayerUrl: urlObj, userName: this._settings.userName, password: this._settings.password });\r\n } catch {\r\n }\r\n }\r\n\r\n // Make a second attempt with refreshed token\r\n response = await fetch(urlObj2.toString(), options);\r\n errorCode = await ArcGisUtilities.checkForResponseErrorCode(response);\r\n }\r\n\r\n if (errorCode !== undefined &&\r\n ( errorCode === ArcGisErrorCode.TokenRequired\r\n || errorCode === ArcGisErrorCode.InvalidToken\r\n || errorCode === ArcGisErrorCode.MissingPermissions\r\n ) ) {\r\n // Looks like the initially generated token has expired.\r\n\r\n if (this.status === MapLayerImageryProviderStatus.Valid ) {\r\n // Only report new status change to avoid spamming the UI\r\n this.setStatus(MapLayerImageryProviderStatus.RequireAuth);\r\n this.onStatusChanged.raiseEvent(this);\r\n const msg = IModelApp.localization.getLocalizedString(\"iModelJs:MapLayers.Messages.FetchTooltipTokenError\", { layerName: this._settings.name });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Warning, msg));\r\n }\r\n }\r\n }\r\n } finally {\r\n this.onFirstRequestCompleted.raiseEvent();\r\n }\r\n\r\n if (response === undefined)\r\n throw new Error(\"fetch call failed\");\r\n\r\n return response;\r\n }\r\n}\r\n"]}
|
|
@@ -15,6 +15,10 @@ import { BeButtonEvent, EventHandled, InputCollector, Tool } from "./Tool";
|
|
|
15
15
|
* @alpha
|
|
16
16
|
*/
|
|
17
17
|
export declare class AccuDrawShortcuts {
|
|
18
|
+
/** Disable/Enable AccuDraw for the session */
|
|
19
|
+
static sessionToggle(): void;
|
|
20
|
+
/** Suspend/Unsuspend AccuDraw for the active tool */
|
|
21
|
+
static suspendToggle(): void;
|
|
18
22
|
static rotateAxesByPoint(isSnapped: boolean, aboutCurrentZ: boolean): boolean;
|
|
19
23
|
static updateACSByPoints(acs: AuxCoordSystemState, vp: Viewport, points: Point3d[], isDynamics: boolean): boolean;
|
|
20
24
|
static processPendingHints(): void;
|
|
@@ -27,6 +31,8 @@ export declare class AccuDrawShortcuts {
|
|
|
27
31
|
static setOrigin(explicitOrigin?: Point3d): void;
|
|
28
32
|
static changeCompassMode(): void;
|
|
29
33
|
static lockSmart(): void;
|
|
34
|
+
/** Disable indexing when not currently indexed; if indexed, enable respective lock. */
|
|
35
|
+
static lockIndex(): void;
|
|
30
36
|
static lockX(): void;
|
|
31
37
|
static lockY(): void;
|
|
32
38
|
static lockZ(): void;
|
|
@@ -50,6 +56,16 @@ export declare class AccuDrawShortcuts {
|
|
|
50
56
|
static processShortcutKey(keyEvent: KeyboardEvent): Promise<boolean>;
|
|
51
57
|
}
|
|
52
58
|
/** @internal */
|
|
59
|
+
export declare class AccuDrawSessionToggleTool extends Tool {
|
|
60
|
+
static toolId: string;
|
|
61
|
+
run(): Promise<boolean>;
|
|
62
|
+
}
|
|
63
|
+
/** @internal */
|
|
64
|
+
export declare class AccuDrawSuspendToggleTool extends Tool {
|
|
65
|
+
static toolId: string;
|
|
66
|
+
run(): Promise<boolean>;
|
|
67
|
+
}
|
|
68
|
+
/** @internal */
|
|
53
69
|
export declare class AccuDrawSetOriginTool extends Tool {
|
|
54
70
|
static toolId: string;
|
|
55
71
|
run(): Promise<boolean>;
|
|
@@ -60,6 +76,11 @@ export declare class AccuDrawSetLockSmartTool extends Tool {
|
|
|
60
76
|
run(): Promise<boolean>;
|
|
61
77
|
}
|
|
62
78
|
/** @internal */
|
|
79
|
+
export declare class AccuDrawSetLockIndexTool extends Tool {
|
|
80
|
+
static toolId: string;
|
|
81
|
+
run(): Promise<boolean>;
|
|
82
|
+
}
|
|
83
|
+
/** @internal */
|
|
63
84
|
export declare class AccuDrawSetLockXTool extends Tool {
|
|
64
85
|
static toolId: string;
|
|
65
86
|
run(): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccuDrawTool.d.ts","sourceRoot":"","sources":["../../../src/tools/AccuDrawTool.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAsB,OAAO,EAAuB,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAY,aAAa,EAA4B,SAAS,EAA6B,YAAY,EAAa,MAAM,aAAa,CAAC;AAE/I,OAAO,EAAqB,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAsC,YAAY,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAY/G;;;;GAIG;AACH,qBAAa,iBAAiB;
|
|
1
|
+
{"version":3,"file":"AccuDrawTool.d.ts","sourceRoot":"","sources":["../../../src/tools/AccuDrawTool.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAsB,OAAO,EAAuB,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAY,aAAa,EAA4B,SAAS,EAA6B,YAAY,EAAa,MAAM,aAAa,CAAC;AAE/I,OAAO,EAAqB,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,Q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,MAAM,SAAiC;IAC9D,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,IAAI,CAAC,CAAsB;IAEnB,uBAAuB,IAAI,OAAO;IAClC,sBAAsB,IAAI,aAAa;IAEvC,mBAAmB,IAAI,IAAI;IAKpC,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,QAAQ,GAAG,OAAO;IAS1D,cAAc,CAAC,EAAE,EAAE,aAAa,GAAG,SAAS,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO;IAqBhE,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;CAQzD;AAED,gBAAgB;AAChB,qBAAa,qBAAsB,SAAQ,qBAAqB;IAC9D,OAAuB,MAAM,SAAgC;IAC7D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,IAAI,CAAC,CAAsB;IAEnB,uBAAuB,IAAI,OAAO;IAClC,sBAAsB,IAAI,aAAa;IAEvC,mBAAmB,IAAI,IAAI;IAepC,cAAc,CAAC,EAAE,EAAE,aAAa,GAAG,SAAS,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO;IAyBhE,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;CAezD"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module Tools
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.DefineACSByPointsTool = exports.DefineACSByElementTool = exports.AccuDrawRotateElementTool = exports.AccuDrawRotateAxesTool = exports.AccuDrawRotateViewTool = exports.AccuDrawRotateSideTool = exports.AccuDrawRotateFrontTool = exports.AccuDrawRotateTopTool = exports.AccuDrawRotateCycleTool = exports.AccuDrawChangeModeTool = exports.AccuDrawSetLockAngleTool = exports.AccuDrawSetLockDistanceTool = exports.AccuDrawSetLockZTool = exports.AccuDrawSetLockYTool = exports.AccuDrawSetLockXTool = exports.AccuDrawSetLockSmartTool = exports.AccuDrawSetOriginTool = exports.AccuDrawShortcuts = void 0;
|
|
10
|
+
exports.DefineACSByPointsTool = exports.DefineACSByElementTool = exports.AccuDrawRotateElementTool = exports.AccuDrawRotateAxesTool = exports.AccuDrawRotateViewTool = exports.AccuDrawRotateSideTool = exports.AccuDrawRotateFrontTool = exports.AccuDrawRotateTopTool = exports.AccuDrawRotateCycleTool = exports.AccuDrawChangeModeTool = exports.AccuDrawSetLockAngleTool = exports.AccuDrawSetLockDistanceTool = exports.AccuDrawSetLockZTool = exports.AccuDrawSetLockYTool = exports.AccuDrawSetLockXTool = exports.AccuDrawSetLockIndexTool = exports.AccuDrawSetLockSmartTool = exports.AccuDrawSetOriginTool = exports.AccuDrawSuspendToggleTool = exports.AccuDrawSessionToggleTool = exports.AccuDrawShortcuts = void 0;
|
|
11
11
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
12
|
const core_geometry_1 = require("@itwin/core-geometry");
|
|
13
13
|
const AccuDraw_1 = require("../AccuDraw");
|
|
@@ -28,6 +28,25 @@ function normalizedCrossProduct(vec1, vec2, out) {
|
|
|
28
28
|
* @alpha
|
|
29
29
|
*/
|
|
30
30
|
class AccuDrawShortcuts {
|
|
31
|
+
/** Disable/Enable AccuDraw for the session */
|
|
32
|
+
static sessionToggle() {
|
|
33
|
+
const accudraw = IModelApp_1.IModelApp.accuDraw;
|
|
34
|
+
if (accudraw.isEnabled)
|
|
35
|
+
accudraw.disableForSession();
|
|
36
|
+
else
|
|
37
|
+
accudraw.enableForSession();
|
|
38
|
+
}
|
|
39
|
+
/** Suspend/Unsuspend AccuDraw for the active tool */
|
|
40
|
+
static suspendToggle() {
|
|
41
|
+
const accudraw = IModelApp_1.IModelApp.accuDraw;
|
|
42
|
+
if (!accudraw.isEnabled)
|
|
43
|
+
return;
|
|
44
|
+
if (accudraw.isActive)
|
|
45
|
+
accudraw.deactivate();
|
|
46
|
+
else
|
|
47
|
+
accudraw.activate();
|
|
48
|
+
accudraw.refreshDecorationsAndDynamics();
|
|
49
|
+
}
|
|
31
50
|
static rotateAxesByPoint(isSnapped, aboutCurrentZ) {
|
|
32
51
|
const accudraw = IModelApp_1.IModelApp.accuDraw;
|
|
33
52
|
if (!accudraw.isEnabled)
|
|
@@ -412,6 +431,46 @@ class AccuDrawShortcuts {
|
|
|
412
431
|
}
|
|
413
432
|
accudraw.refreshDecorationsAndDynamics();
|
|
414
433
|
}
|
|
434
|
+
/** Disable indexing when not currently indexed; if indexed, enable respective lock. */
|
|
435
|
+
static lockIndex() {
|
|
436
|
+
const accudraw = IModelApp_1.IModelApp.accuDraw;
|
|
437
|
+
if (!accudraw.isEnabled)
|
|
438
|
+
return;
|
|
439
|
+
if (accudraw.flags.indexLocked) {
|
|
440
|
+
if (accudraw.locked)
|
|
441
|
+
this.lockSmart();
|
|
442
|
+
accudraw.flags.indexLocked = false;
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
if (AccuDraw_1.CompassMode.Polar === accudraw.compassMode) {
|
|
446
|
+
if (accudraw.indexed & AccuDraw_1.LockedStates.XY_BM) {
|
|
447
|
+
accudraw.setFieldLock(AccuDraw_1.ItemField.ANGLE_Item, true);
|
|
448
|
+
accudraw.angleLock();
|
|
449
|
+
}
|
|
450
|
+
if (accudraw.indexed & AccuDraw_1.LockedStates.DIST_BM)
|
|
451
|
+
this.lockDistance();
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
if (accudraw.indexed & AccuDraw_1.LockedStates.X_BM) {
|
|
455
|
+
this.lockX();
|
|
456
|
+
if (accudraw.indexed & AccuDraw_1.LockedStates.DIST_BM)
|
|
457
|
+
this.lockY();
|
|
458
|
+
}
|
|
459
|
+
if (accudraw.indexed & AccuDraw_1.LockedStates.Y_BM) {
|
|
460
|
+
this.lockY();
|
|
461
|
+
if (accudraw.indexed & AccuDraw_1.LockedStates.DIST_BM)
|
|
462
|
+
this.lockX();
|
|
463
|
+
}
|
|
464
|
+
if (accudraw.indexed & AccuDraw_1.LockedStates.DIST_BM && !(accudraw.indexed & AccuDraw_1.LockedStates.XY_BM)) {
|
|
465
|
+
if (accudraw.locked & AccuDraw_1.LockedStates.X_BM)
|
|
466
|
+
this.lockY();
|
|
467
|
+
else
|
|
468
|
+
this.lockX();
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
accudraw.flags.indexLocked = true;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
415
474
|
static lockX() {
|
|
416
475
|
const accudraw = IModelApp_1.IModelApp.accuDraw;
|
|
417
476
|
if (!accudraw.isEnabled)
|
|
@@ -811,6 +870,12 @@ class AccuDrawShortcuts {
|
|
|
811
870
|
case "d":
|
|
812
871
|
AccuDrawShortcuts.lockDistance();
|
|
813
872
|
return true;
|
|
873
|
+
case "h":
|
|
874
|
+
AccuDrawShortcuts.suspendToggle();
|
|
875
|
+
return true;
|
|
876
|
+
case "l":
|
|
877
|
+
AccuDrawShortcuts.lockIndex();
|
|
878
|
+
return true;
|
|
814
879
|
case "m":
|
|
815
880
|
AccuDrawShortcuts.changeCompassMode();
|
|
816
881
|
return true;
|
|
@@ -844,6 +909,24 @@ class AccuDrawShortcuts {
|
|
|
844
909
|
}
|
|
845
910
|
exports.AccuDrawShortcuts = AccuDrawShortcuts;
|
|
846
911
|
/** @internal */
|
|
912
|
+
class AccuDrawSessionToggleTool extends Tool_1.Tool {
|
|
913
|
+
async run() {
|
|
914
|
+
AccuDrawShortcuts.sessionToggle();
|
|
915
|
+
return true;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
exports.AccuDrawSessionToggleTool = AccuDrawSessionToggleTool;
|
|
919
|
+
AccuDrawSessionToggleTool.toolId = "AccuDraw.SessionToggle";
|
|
920
|
+
/** @internal */
|
|
921
|
+
class AccuDrawSuspendToggleTool extends Tool_1.Tool {
|
|
922
|
+
async run() {
|
|
923
|
+
AccuDrawShortcuts.suspendToggle();
|
|
924
|
+
return true;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
exports.AccuDrawSuspendToggleTool = AccuDrawSuspendToggleTool;
|
|
928
|
+
AccuDrawSuspendToggleTool.toolId = "AccuDraw.SuspendToggle";
|
|
929
|
+
/** @internal */
|
|
847
930
|
class AccuDrawSetOriginTool extends Tool_1.Tool {
|
|
848
931
|
async run() {
|
|
849
932
|
AccuDrawShortcuts.setOrigin();
|
|
@@ -862,6 +945,15 @@ class AccuDrawSetLockSmartTool extends Tool_1.Tool {
|
|
|
862
945
|
exports.AccuDrawSetLockSmartTool = AccuDrawSetLockSmartTool;
|
|
863
946
|
AccuDrawSetLockSmartTool.toolId = "AccuDraw.LockSmart";
|
|
864
947
|
/** @internal */
|
|
948
|
+
class AccuDrawSetLockIndexTool extends Tool_1.Tool {
|
|
949
|
+
async run() {
|
|
950
|
+
AccuDrawShortcuts.lockIndex();
|
|
951
|
+
return true;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
exports.AccuDrawSetLockIndexTool = AccuDrawSetLockIndexTool;
|
|
955
|
+
AccuDrawSetLockIndexTool.toolId = "AccuDraw.LockIndex";
|
|
956
|
+
/** @internal */
|
|
865
957
|
class AccuDrawSetLockXTool extends Tool_1.Tool {
|
|
866
958
|
async run() {
|
|
867
959
|
AccuDrawShortcuts.lockX();
|