@itwin/map-layers-formats 5.16.0-dev.3 → 5.16.0-dev.5

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.
Files changed (33) hide show
  1. package/lib/cjs/ArcGisFeature/ArcGisFeatureProvider.d.ts.map +1 -1
  2. package/lib/cjs/ArcGisFeature/ArcGisFeatureProvider.js +22 -8
  3. package/lib/cjs/ArcGisFeature/ArcGisFeatureProvider.js.map +1 -1
  4. package/lib/cjs/AzureMaps/AzureMapsImageryProvider.d.ts.map +1 -1
  5. package/lib/cjs/AzureMaps/AzureMapsImageryProvider.js +2 -1
  6. package/lib/cjs/AzureMaps/AzureMapsImageryProvider.js.map +1 -1
  7. package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.d.ts.map +1 -1
  8. package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.js +4 -1
  9. package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.js.map +1 -1
  10. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesFormat.d.ts.map +1 -1
  11. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesFormat.js +28 -11
  12. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesFormat.js.map +1 -1
  13. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesProvider.d.ts +1 -0
  14. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesProvider.d.ts.map +1 -1
  15. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesProvider.js +22 -0
  16. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesProvider.js.map +1 -1
  17. package/lib/esm/ArcGisFeature/ArcGisFeatureProvider.d.ts.map +1 -1
  18. package/lib/esm/ArcGisFeature/ArcGisFeatureProvider.js +23 -9
  19. package/lib/esm/ArcGisFeature/ArcGisFeatureProvider.js.map +1 -1
  20. package/lib/esm/AzureMaps/AzureMapsImageryProvider.d.ts.map +1 -1
  21. package/lib/esm/AzureMaps/AzureMapsImageryProvider.js +2 -1
  22. package/lib/esm/AzureMaps/AzureMapsImageryProvider.js.map +1 -1
  23. package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.d.ts.map +1 -1
  24. package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.js +4 -1
  25. package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.js.map +1 -1
  26. package/lib/esm/OgcApiFeatures/OgcApiFeaturesFormat.d.ts.map +1 -1
  27. package/lib/esm/OgcApiFeatures/OgcApiFeaturesFormat.js +29 -12
  28. package/lib/esm/OgcApiFeatures/OgcApiFeaturesFormat.js.map +1 -1
  29. package/lib/esm/OgcApiFeatures/OgcApiFeaturesProvider.d.ts +1 -0
  30. package/lib/esm/OgcApiFeatures/OgcApiFeaturesProvider.d.ts.map +1 -1
  31. package/lib/esm/OgcApiFeatures/OgcApiFeaturesProvider.js +23 -1
  32. package/lib/esm/OgcApiFeatures/OgcApiFeaturesProvider.js.map +1 -1
  33. package/package.json +12 -12
@@ -1 +1 @@
1
- {"version":3,"file":"ArcGisFeatureProvider.d.ts","sourceRoot":"","sources":["../../../src/ArcGisFeature/ArcGisFeatureProvider.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAkC,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAmB,qBAAqB,EAAmE,SAAS,EAAE,kBAAkB,EAAqB,qBAAqB,EAAE,mBAAmB,EAAiC,MAAM,EAAqB,MAAM,sBAAsB,CAAC;AACvS,OAAO,EAA8B,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAA4C,uBAAuB,EAAE,cAAc,EAAkC,MAAM,yBAAyB,CAAC;AAM/L,OAAO,EAAE,OAAO,EAAgB,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIvG;;EAEE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AE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAsBnE,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;CAgHjH"}
@@ -92,14 +92,15 @@ class ArcGisFeatureProvider extends core_frontend_1.ArcGISImageryProvider {
92
92
  const json = metadata?.content;
93
93
  if (json === undefined) {
94
94
  // By returning (i.e., not throwing), we ensure the tile tree gets created and the current provider is preserved to report status.
95
- if (this.status === core_frontend_1.MapLayerImageryProviderStatus.UntrustedOrigin)
95
+ if (this.status === core_frontend_1.MapLayerImageryProviderStatus.UntrustedOrigin || this.status === core_frontend_1.MapLayerImageryProviderStatus.RequireAuth)
96
96
  return;
97
97
  core_bentley_1.Logger.logError(loggerCategory, "Could not get service JSON");
98
98
  throw new core_common_1.ServerError(core_bentley_1.IModelStatus.ValidationFailed, "");
99
99
  }
100
- if (json?.error?.code === core_frontend_1.ArcGisErrorCode.TokenRequired
101
- || json?.error?.code === core_frontend_1.ArcGisErrorCode.InvalidToken
102
- || json?.error?.code === core_frontend_1.ArcGisErrorCode.MissingPermissions) {
100
+ const errorCode = metadata?.errorCode;
101
+ if (errorCode === core_frontend_1.ArcGisErrorCode.TokenRequired
102
+ || errorCode === core_frontend_1.ArcGisErrorCode.InvalidToken
103
+ || errorCode === core_frontend_1.ArcGisErrorCode.MissingPermissions) {
103
104
  // Check again layer status, it might have change during await.
104
105
  if (this.status === core_frontend_1.MapLayerImageryProviderStatus.Valid) {
105
106
  this.setStatus(core_frontend_1.MapLayerImageryProviderStatus.RequireAuth);
@@ -160,6 +161,9 @@ class ArcGisFeatureProvider extends core_frontend_1.ArcGISImageryProvider {
160
161
  if (!this._layerMetadata) {
161
162
  this._layerMetadata = await this.getLayerMetadata(this._layerId);
162
163
  if (!this._layerMetadata) {
164
+ // By returning (i.e., not throwing), we ensure the tile tree gets created and the current provider is preserved to report status.
165
+ if (this.status === core_frontend_1.MapLayerImageryProviderStatus.UntrustedOrigin || this.status === core_frontend_1.MapLayerImageryProviderStatus.RequireAuth)
166
+ return;
163
167
  core_bentley_1.Logger.logError(loggerCategory, "Could not layer metadata");
164
168
  throw new core_common_1.ServerError(core_bentley_1.IModelStatus.ValidationFailed, "");
165
169
  }
@@ -244,7 +248,11 @@ class ArcGisFeatureProvider extends core_frontend_1.ArcGISImageryProvider {
244
248
  tmpUrl.searchParams.append("outSR", "3857");
245
249
  tmpUrl.searchParams.append("returnExtentOnly", "true");
246
250
  tmpUrl.searchParams.append("f", ArcGisFeatureQuery_js_1.arcgisFeatureFormats.json);
247
- const cached = ArcGisFeatureProvider._extentCache.get(tmpUrl.toString());
251
+ // The cache is keyed by URL only, so responses customized by the fetch handler (e.g.
252
+ // header-authenticated) must not be shared with or served from differently-customized requests.
253
+ // Reads are skipped on registration state; writes on the actual provenance of the response, since a
254
+ // handler may be registered while the request awaits token acquisition or the first-request gate.
255
+ const cached = this.hasFetchHandler ? undefined : ArcGisFeatureProvider._extentCache.get(tmpUrl.toString());
248
256
  if (cached) {
249
257
  extentJson = cached;
250
258
  }
@@ -255,7 +263,8 @@ class ArcGisFeatureProvider extends core_frontend_1.ArcGISImageryProvider {
255
263
  (0, core_frontend_1.setRequestTimeout)(opts, 10000);
256
264
  const response = await this.fetch(tmpUrl, opts);
257
265
  extentJson = await response.json();
258
- ArcGisFeatureProvider._extentCache.set(tmpUrl.toString(), extentJson);
266
+ if (!this.isManagedByHandler(response))
267
+ ArcGisFeatureProvider._extentCache.set(tmpUrl.toString(), extentJson);
259
268
  }
260
269
  return (extentJson ? extentJson.extent : undefined);
261
270
  }
@@ -276,12 +285,17 @@ class ArcGisFeatureProvider extends core_frontend_1.ArcGISImageryProvider {
276
285
  const url = new URL(this._settings.url);
277
286
  url.pathname = `${url.pathname}/${layerId}`;
278
287
  metadata = await core_frontend_1.ArcGisUtilities.getServiceJson({
279
- url: url.toString(), formatId: this._settings.formatId,
288
+ url: url.toString(), layerUrl: this._settings.url, layerProperties: this._settings.properties, formatId: this._settings.formatId,
280
289
  userName: this._settings.userName, password: this._settings.password,
281
290
  queryParams: this._settings.collectQueryParams(), requireToken: this._accessTokenRequired
282
291
  });
283
292
  }
284
- catch {
293
+ catch (err) {
294
+ // Same status transitions as for the root service metadata; anything else yields no metadata.
295
+ if (err instanceof core_frontend_1.MapLayerAuthenticationFailedError)
296
+ this.reportAuthenticationFailure();
297
+ else if (err instanceof core_frontend_1.MapLayerUntrustedOriginError)
298
+ this.reportBlockedOrigin(err.url);
285
299
  }
286
300
  return metadata?.content;
287
301
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ArcGisFeatureProvider.js","sourceRoot":"","sources":["../../../src/ArcGisFeature/ArcGisFeatureProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAmG;AACnG,oDAAsH;AACtH,wDAAuS;AACvS,wDAA6E;AAC7E,kFAA4E;AAE5E,mEAA+L;AAE/L,yEAAuF;AACvF,6EAAuE;AACvE,2EAAqE;AACrE,6EAA6E;AAC7E,yDAAuG;AAEvG,MAAM,cAAc,GAAG,gCAAgC,CAAC;AAUxD;;EAEE;AACF,MAAa,qBAAqB;IACzB,MAAM,CAAU,UAAU,GAAG,0BAAO,CAAC,QAAQ,CAAE;QACpD,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,EAAE;QACP,WAAW,EAAE,WAAW;QACxB,SAAS,EAAE,04BAA04B;QACr5B,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,CAAC,CAAC;QACX,OAAO,EAAE,CAAC,EAAE;KACb,CAAC,CAAC;IAEI,MAAM,CAAU,eAAe,GAAiB;QACrD,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC;QACvB,KAAK,EAAE,CAAC;QACR,KAAK,EAAE,cAAc;KACtB,CAAC;IACK,MAA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AAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAChJ,CAAC;QAED,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YAC9C,MAAM,MAAM,GAAG,wBAAwB,CAAC;YACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAClD,OAAO,IAAI,yBAAW,CAAC,IAAA,uCAAwB,EAAC,QAAQ,CAAC,EAAE,+BAAiB,CAAC,GAAG,CAAC,CAAC;QACpF,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,qBAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,4CAA4C,SAAS,IAAI,GAAG,IAAI,MAAM,OAAO,2BAAY,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACnJ,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;;AA9iBH,sDAgjBC","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 { base64StringToUint8Array, BentleyError, IModelStatus, Logger } from \"@itwin/core-bentley\";\r\nimport { Cartographic, ImageMapLayerSettings, ImageSource, ImageSourceFormat, ServerError } from \"@itwin/core-common\";\r\nimport { ArcGisErrorCode, ArcGISImageryProvider, ArcGISServiceMetadata, ArcGisUtilities, FeatureGraphicsRenderer, HitDetail, ImageryMapTileTree, MapCartoRectangle, MapFeatureInfoOptions, MapLayerFeatureInfo, MapLayerImageryProviderStatus, QuadId, setRequestTimeout } from \"@itwin/core-frontend\";\r\nimport { Matrix4d, Point3d, Range2d, Transform } from \"@itwin/core-geometry\";\r\nimport { FeatureCanvasRenderer } from \"../Feature/FeatureCanvasRenderer.js\";\r\nimport { FeatureDefaultSymbology } from \"../Feature/FeatureSymbology.js\";\r\nimport { ArcGisExtent, ArcGisFeatureFormat, arcgisFeatureFormats, ArcGisFeatureQuery, ArcGisFeatureResultType, ArcGisGeometry, FeatureQueryQuantizationParams } from \"./ArcGisFeatureQuery.js\";\r\nimport { ArcGisFeatureReader } from \"./ArcGisFeatureReader.js\";\r\nimport { ArcGisFeatureResponse, ArcGisResponseData } from \"./ArcGisFeatureResponse.js\";\r\nimport { ArcGisJsonFeatureReader } from \"./ArcGisJsonFeatureReader.js\";\r\nimport { ArcGisPbfFeatureReader } from \"./ArcGisPbfFeatureReader.js\";\r\nimport { ArcGisSymbologyCanvasRenderer } from \"./ArcGisSymbologyRenderer.js\";\r\nimport { EsriPMS, EsriRenderer, EsriSFS, EsriSLS, EsriSLSProps, EsriSymbol } from \"./EsriSymbology.js\";\r\n\r\nconst loggerCategory = \"MapLayersFormats.ArcGISFeature\";\r\n\r\n/**\r\n* @internal\r\n*/\r\ninterface ArcGisFeatureUrl {\r\n url: string;\r\n envelope?: ArcGisExtent; // envelope representing the current computed URL, required to refine request.\r\n}\r\n\r\n/**\r\n* @internal\r\n*/\r\nexport class DefaultArcGiSymbology implements FeatureDefaultSymbology {\r\n public static readonly defaultPMS = EsriPMS.fromJSON( {\r\n type: \"esriPMS\",\r\n url: \"\",\r\n contentType: \"image/png\",\r\n imageData: \"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAmBJREFUOE+Nk01IVFEUx//n3jfvOZOaJkMtiiJ7o9RG3LgoqKhFSFJBTS1ahFBBi0ijfJXCIyQr+hBbSIsoW7iQoKKFCw2CkAI3tZAgy8Ei+xhoTCbnje/NPfHGnA816KzuPR+/c8/HJRQJE7o+VUhym0DcCOYGgBQEXjOLlyqo+nHanCkMoaL4rslKjZwOQLT4ek3Mmz3FACFNLB67ut6M1nWphbg8wI6VyJK5KEH0EQFVJRKbwzokAW++p/ErraAYSQK3u47bC3vLnA+ZB9i2gHF0oyQMCfCGNaUa+vauxs71wWz2V18cnBj8gQ8J1/eeBnHUa4sMFQDGdGno+4gwEAoQzjVUon3rqlx1KY9x7+0MWobjAPg3QJ2eZV4tAEyFNCN5FkSXyw2B3j1hRGvLcgBXMV5MptA4MOXr0gT0u5bZnAf0jBsyiSgJPAxqhON1K3FlRxUMvwFAtv7u0Wl0jvwEmJNEuOhakTt5wKEBifr6Oo14BIBRpgt07w6jcVMIngKGY7NofR5HwlF+zDcpsC193vyYB/innvHywCzdZfAR/+onX1segBTAxHzzfPE7/8yzzIPLjJE1LTixHZx5CtCK4gXLzovBiDPUsYxVM7gUkB3nWKlm6DYEnQGzXARxCOK+a1WfKtQXb6LNAvr7iCboCUA1Ocdsdv5KLPe7F6pH/w3wLbc+BwOuc5IZ1wEE/jonQbjptZn24tKKX7BgvR2r0NKZRwDvAqCI+Z30VJPTURv7P4A9psuQcYAUPwAoReBLrmX2Lmls7i8sZ7kWLwuoxA1FVJGxzMPLufi6P2r+2xFbOUjGAAAAAElFTkSuQmCC\",\r\n width: 16,\r\n height: 16,\r\n xoffset: -8,\r\n yoffset: -16,\r\n });\r\n\r\n public static readonly defaultSLSProps: EsriSLSProps = {\r\n type: \"esriSLS\",\r\n color: [0, 0, 255, 255],\r\n width: 1,\r\n style: \"esriSLSSolid\",\r\n };\r\n public static readonly defaultSLS = EsriSLS.fromJSON(this.defaultSLSProps);\r\n\r\n public static readonly defaultSFS = EsriSFS.fromJSON({\r\n type: \"esriSFS\",\r\n color: [0, 0, 255, 100], // blue fill\r\n style: \"esriSFSSolid\",\r\n outline: this.defaultSLSProps,\r\n });\r\n\r\n public async initialize() {\r\n // Marker image need to be loaded upfront;\r\n await DefaultArcGiSymbology.defaultPMS.loadImage();\r\n }\r\n\r\n public getSymbology(geomType: string): EsriSymbol {\r\n if (geomType === \"esriGeometryPoint\" || geomType === \"esriGeometryMultipoint\") {\r\n return DefaultArcGiSymbology.defaultPMS;\r\n } else if (geomType === \"esriGeometryLine\" || geomType === \"esriGeometryPolyline\") {\r\n return DefaultArcGiSymbology.defaultSLS;\r\n } else if (geomType === \"esriGeometryPolygon\") {\r\n return DefaultArcGiSymbology.defaultSFS;\r\n }\r\n\r\n throw new Error(`Could not get default symbology for geometry type: '${geomType}'`);\r\n }\r\n}\r\n\r\n/** Provide tiles from a ESRI ArcGIS Feature service\r\n* @internal\r\n*/\r\nexport class ArcGisFeatureProvider extends ArcGISImageryProvider {\r\n // Debug flags, should always be committed to FALSE !\r\n private _drawDebugInfo = false;\r\n private _debugFeatureGeom = false;\r\n\r\n private _supportsCoordinatesQuantization = false;\r\n\r\n private _layerId = 0;\r\n private _layerMetadata: any;\r\n private _format: ArcGisFeatureFormat | undefined;\r\n private _outSR = 102100;\r\n\r\n private _maxDepthFromLod = 0;\r\n private _minDepthFromLod = 0;\r\n\r\n private _defaultSymbol = new DefaultArcGiSymbology();\r\n private _renderer: EsriRenderer|undefined;\r\n private _symbologyRenderer: ArcGisSymbologyCanvasRenderer|undefined;\r\n\r\n private static readonly _nbSubTiles = 2; // Number of subtiles for a single axis\r\n public serviceJson: any;\r\n\r\n public override get minimumZoomLevel(): number { return this._minDepthFromLod; }\r\n public override get maximumZoomLevel(): number { return this._maxDepthFromLod; }\r\n\r\n private static _extentCache = new Map<string, any>();\r\n\r\n constructor(settings: ImageMapLayerSettings) {\r\n super(settings, true);\r\n }\r\n\r\n public override async initialize(): Promise<void> {\r\n const metadata = await this.getServiceJson();\r\n const json = metadata?.content;\r\n\r\n if (json === undefined) {\r\n // By returning (i.e., not throwing), we ensure the tile tree gets created and the current provider is preserved to report status.\r\n if (this.status === MapLayerImageryProviderStatus.UntrustedOrigin)\r\n return;\r\n Logger.logError(loggerCategory, \"Could not get service JSON\");\r\n throw new ServerError(IModelStatus.ValidationFailed, \"\");\r\n }\r\n\r\n if (json?.error?.code === ArcGisErrorCode.TokenRequired\r\n || json?.error?.code === ArcGisErrorCode.InvalidToken\r\n || json?.error?.code === ArcGisErrorCode.MissingPermissions\r\n ) {\r\n // Check again layer status, it might have change during await.\r\n if (this.status === MapLayerImageryProviderStatus.Valid) {\r\n this.setStatus(MapLayerImageryProviderStatus.RequireAuth);\r\n return;\r\n }\r\n }\r\n\r\n if (json.capabilities) {\r\n this._querySupported = json.capabilities.indexOf(\"Query\") >= 0;\r\n if (!this._querySupported)\r\n throw new ServerError(IModelStatus.ValidationFailed, \"\");\r\n }\r\n\r\n this.serviceJson = json;\r\n\r\n let foundVisibleSubLayer = false;\r\n if (this._settings.subLayers.length >= 0) {\r\n // There is more than sub-layer for this layer, pick the first visible one.\r\n for (const layer of this._settings.subLayers) {\r\n if (layer.visible && typeof layer.id === \"number\") {\r\n this._layerId = layer.id;\r\n foundVisibleSubLayer = true;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (!foundVisibleSubLayer && json !== undefined) {\r\n // No suitable sublayer was specified on the layerSettings object, lets find a default one in the capabilities\r\n\r\n // Check layer metadata\r\n if (Array.isArray(this.serviceJson.layers) && this.serviceJson.layers.length >= 1) {\r\n\r\n const hasDefaultVisibility = Object.keys(this.serviceJson.layers[0]).includes(\"defaultVisibility\");\r\n if (hasDefaultVisibility) {\r\n for (const layer of this.serviceJson.layers) {\r\n if (layer.defaultVisibility) {\r\n this._layerId = layer.id;\r\n break;\r\n }\r\n }\r\n } else {\r\n // On some older servers, the default visiblity is on the layer capabilities (i.e. not the service capabilities)\r\n for (const layer of this.serviceJson.layers) {\r\n const layerJson = await this.getLayerMetadata(layer.id);\r\n if (!layerJson) {\r\n continue;\r\n }\r\n\r\n if (layerJson.defaultVisibility) {\r\n this._layerId = layer.id;\r\n this._layerMetadata = layerJson;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n } else {\r\n // There is no layer to publish? Something is off with this server..\r\n throw new ServerError(IModelStatus.ValidationFailed, \"\");\r\n }\r\n }\r\n\r\n // Make sure we cache layer info (i.e. rendering info)\r\n if (!this._layerMetadata) {\r\n\r\n this._layerMetadata = await this.getLayerMetadata(this._layerId);\r\n if (!this._layerMetadata) {\r\n Logger.logError(loggerCategory, \"Could not layer metadata\");\r\n throw new ServerError(IModelStatus.ValidationFailed, \"\");\r\n }\r\n }\r\n\r\n // Parse server version\r\n let majorVersion: number | undefined;\r\n if (this.serviceJson?.currentVersion) {\r\n try {\r\n majorVersion = Math.trunc(this.serviceJson?.currentVersion);\r\n } catch {\r\n }\r\n }\r\n\r\n // Coordinates Quantization: If supported, server will transform for us the coordinates in the Tile coordinate space (pixels, origin = upper left corner\r\n // If not supported, transformation will be applied client side.\r\n // Note: For some reasons, even though 'supportsCoordinatesQuantization' is set to 'true' on the layer metadata, server will give an error message for server version < 11\r\n if (majorVersion && majorVersion >= 11 && this._layerMetadata.supportsCoordinatesQuantization) {\r\n this._supportsCoordinatesQuantization = true;\r\n }\r\n\r\n // Check supported query formats: JSON and PBF are currently implemented by this provider\r\n // Note: needs to be checked on the layer metadata, service metadata advertises a different set of formats\r\n // Also, since PBF format does not support floating points, there is no point using this format if supportsCoordinatesQuantization is not available.\r\n if (this._layerMetadata.supportedQueryFormats) {\r\n const formats: string[] = this._layerMetadata.supportedQueryFormats.split(\",\").map((s: string) => s.trim().toLowerCase());\r\n if (formats.includes(arcgisFeatureFormats.pbf) && this._supportsCoordinatesQuantization) {\r\n this._format = arcgisFeatureFormats.pbf;\r\n } else if (formats.includes(arcgisFeatureFormats.json)) {\r\n this._format = arcgisFeatureFormats.json;\r\n }\r\n }\r\n\r\n if (!this._format) {\r\n Logger.logError(loggerCategory, \"Could not get request format from service JSON\");\r\n throw new ServerError(IModelStatus.ValidationFailed, \"\");\r\n }\r\n\r\n // Read range using full extent from service metadata\r\n if (this._layerMetadata?.extent) {\r\n const layerExtent = this._layerMetadata.extent;\r\n if (layerExtent.spatialReference.latestWkid === 3857 || layerExtent.spatialReference.wkid === 102100) {\r\n this.setCartoRangeFromExtentJson(layerExtent);\r\n }\r\n }\r\n\r\n if (!this.cartoRange) {\r\n // Range could not be found (or is not in a coordinate system we support), make a request to compute the extent\r\n try {\r\n const extentJson = await this.fetchLayerExtent();\r\n\r\n if (extentJson)\r\n this.setCartoRangeFromExtentJson(extentJson);\r\n else\r\n Logger.logWarning(loggerCategory, `Could not get features extent, disabling extent filtering`);\r\n } catch {\r\n Logger.logError(loggerCategory, `Could not get feature extent`);\r\n }\r\n }\r\n\r\n // Check for minScale / max scale\r\n const minScale = this._layerMetadata?.minScale || undefined; // undefined, 0 -> undefined\r\n const maxScale = this._layerMetadata?.maxScale || undefined; // undefined, 0 -> undefined\r\n const scales = ArcGisUtilities.getZoomLevelsScales(this.defaultMaximumZoomLevel, this.tileSize, minScale, maxScale, 1.0);\r\n if (scales.minLod)\r\n this._minDepthFromLod = scales.minLod;\r\n\r\n // Some servers advertises a max LOD of 0, it should be interpreted as 'not defined' (otherwise a max lod of 0 would would mean never display anything)\r\n this._maxDepthFromLod = (scales.maxLod ? scales.maxLod : this.defaultMaximumZoomLevel);\r\n\r\n try {\r\n this._renderer = EsriRenderer.fromJSON(this._layerMetadata?.drawingInfo?.renderer);\r\n await this._renderer.initialize();\r\n } catch (e) {\r\n Logger.logError(loggerCategory, `Could not initialize symbology renderer for '${this._settings.name}': ${BentleyError.getErrorMessage(e)}`);\r\n }\r\n\r\n // Sanity check: make sure we got default symbology for this geometry type\r\n // if not, it will throw\r\n this._defaultSymbol.getSymbology(this._layerMetadata?.geometryType);\r\n await this._defaultSymbol.initialize(); // images must be loaded upfront\r\n this._symbologyRenderer = ArcGisSymbologyCanvasRenderer.create(this._renderer, this._defaultSymbol, this._layerMetadata?.geometryType);\r\n }\r\n\r\n private async fetchLayerExtent() {\r\n let extentJson: any;\r\n const tmpUrl = new URL(this._settings.url);\r\n tmpUrl.pathname = `${tmpUrl.pathname}/${this._layerId}/query`;\r\n tmpUrl.searchParams.append(\"where\", \"1=1\");\r\n tmpUrl.searchParams.append(\"outSR\", \"3857\");\r\n tmpUrl.searchParams.append(\"returnExtentOnly\", \"true\");\r\n tmpUrl.searchParams.append(\"f\", arcgisFeatureFormats.json);\r\n const cached = ArcGisFeatureProvider._extentCache.get(tmpUrl.toString());\r\n if (cached) {\r\n extentJson = cached;\r\n } else {\r\n // Some server are struggling computing the extent for a layer (outdated spatial index I presume), lets wait 10s max.\r\n // Worst case scenario we will end up with a map-layer with no 'Zoom-To-Layer' functionality.\r\n const opts: RequestInit = { method: \"GET\" };\r\n setRequestTimeout(opts, 10000);\r\n const response = await this.fetch(tmpUrl, opts);\r\n\r\n extentJson = await response.json();\r\n ArcGisFeatureProvider._extentCache.set(tmpUrl.toString(), extentJson);\r\n }\r\n return (extentJson ? extentJson.extent : undefined);\r\n }\r\n\r\n private setCartoRangeFromExtentJson(extent: any) {\r\n const range3857 = Range2d.createFrom({\r\n low: { x: extent.xmin, y: extent.ymin },\r\n high: { x: extent.xmax, y: extent.ymax },\r\n });\r\n\r\n const west = this.getEPSG4326Lon(range3857.xLow);\r\n const south = this.getEPSG4326Lat(range3857.yLow);\r\n const east = this.getEPSG4326Lon(range3857.xHigh);\r\n const north = this.getEPSG4326Lat(range3857.yHigh);\r\n this.cartoRange = MapCartoRectangle.fromDegrees(west, south, east, north);\r\n }\r\n\r\n protected async getLayerMetadata(layerId: number) {\r\n let metadata: ArcGISServiceMetadata | undefined;\r\n try {\r\n const url = new URL(this._settings.url);\r\n url.pathname = `${url.pathname}/${layerId}`;\r\n metadata = await ArcGisUtilities.getServiceJson({\r\n url: url.toString(), formatId: this._settings.formatId,\r\n userName: this._settings.userName, password: this._settings.password,\r\n queryParams: this._settings.collectQueryParams(), requireToken: this._accessTokenRequired});\r\n } catch {\r\n\r\n }\r\n return metadata?.content;\r\n }\r\n\r\n public override get tileSize(): number { return 512; }\r\n public get format(): ArcGisFeatureFormat | undefined { return this._format; }\r\n\r\n // We don't use this method inside this provider (see constructFeatureUrl), but since this is an abstract method, we need to define something\r\n public async constructUrl(_row: number, _column: number, _zoomLevel: number): Promise<string> {\r\n return \"\";\r\n }\r\n\r\n public constructFeatureUrl(row: number, column: number, zoomLevel: number, format: ArcGisFeatureFormat, resultType: ArcGisFeatureResultType, geomOverride?: ArcGisGeometry, outFields?: string, tolerance?: number, returnGeometry?: boolean, maxAllowableOffset?: number): ArcGisFeatureUrl | undefined {\r\n\r\n const tileExtent = this.getEPSG3857Extent(row, column, zoomLevel);\r\n const tileEnvelope = {\r\n xmin: tileExtent.left, ymin: tileExtent.bottom,\r\n xmax: tileExtent.right, ymax: tileExtent.top,\r\n spatialReference: { wkid: 102100, latestWkid: 3857 },\r\n };\r\n\r\n // Actual spatial filter.\r\n // By default, we request the tile extent. If 'cartoPoint' is specified,\r\n // we restrict the spatial to specific point. (i.e. GetFeatureInfo requests)\r\n // If envelope is provided, it has the priority over 'cartoPoint'\r\n let geometry: ArcGisGeometry | undefined;\r\n if (geomOverride) {\r\n geometry = geomOverride;\r\n } else {\r\n geometry = { geom: tileEnvelope, type: \"esriGeometryEnvelope\" };\r\n }\r\n\r\n let quantizationParameters: FeatureQueryQuantizationParams | undefined;\r\n const toleranceWorld = (tileExtent.top - tileExtent.bottom) / this.tileSize;\r\n if (resultType === \"tile\" && this._supportsCoordinatesQuantization) {\r\n quantizationParameters = {\r\n mode: \"view\",\r\n originPosition: \"upperLeft\",\r\n tolerance: toleranceWorld, // pixel size in world units\r\n extent: tileEnvelope,\r\n };\r\n }\r\n const url = new ArcGisFeatureQuery(\r\n this._settings.url,\r\n this._layerId,\r\n format,\r\n this._outSR,\r\n {\r\n geometry,\r\n geometryType: \"esriGeometryEnvelope\",\r\n returnExceededLimitFeatures: false,\r\n maxRecordCountFactor: 3, // This was grabbed from the ESRI web viewer request, not sure where this factor come from\r\n resultType,\r\n quantizationParameters,\r\n outFields,\r\n returnGeometry,\r\n distance: (tolerance ? tolerance * toleranceWorld : undefined),\r\n maxAllowableOffset,\r\n });\r\n\r\n let envelope: ArcGisExtent | undefined;\r\n if (geomOverride && geomOverride.type === \"esriGeometryEnvelope\") {\r\n envelope = geomOverride.geom as ArcGisExtent;\r\n } else {\r\n envelope = tileEnvelope;\r\n }\r\n\r\n return { url: url.toString(), envelope };\r\n\r\n }\r\n\r\n // Makes an identify request to ESRI MapService , and return it as a list MapLayerFeatureInfo object\r\n public override async getFeatureInfo(featureInfos: MapLayerFeatureInfo[], quadId: QuadId, carto: Cartographic, _tree: ImageryMapTileTree, hit: HitDetail, options?: MapFeatureInfoOptions): Promise<void> {\r\n if (!this._querySupported || this.format === undefined)\r\n return;\r\n\r\n const epsg3857X = this.getEPSG3857X(carto.longitudeDegrees);\r\n const epsg3857Y = this.getEPSG3857Y(carto.latitudeDegrees);\r\n\r\n const tileExtent = this.getEPSG3857Extent(quadId.row, quadId.column, quadId.level);\r\n const tilePixelSize = (tileExtent.top - tileExtent.bottom) / this.tileSize;\r\n const tolerancePixel = options?.tolerance ?? 7;\r\n const toleranceWorld = tilePixelSize * tolerancePixel;\r\n\r\n // Note: We used to pass a single point as the query 'geometry' and leverage the 'distance' parameter, turns\r\n // out that approach was a lot slower on some server compared to using a single envelope.\r\n const queryEnvelope: ArcGisGeometry = {\r\n type: \"esriGeometryEnvelope\",\r\n geom: {\r\n xmin: epsg3857X - toleranceWorld, ymin: epsg3857Y - toleranceWorld,\r\n xmax: epsg3857X + toleranceWorld, ymax: epsg3857Y + toleranceWorld,\r\n spatialReference: { wkid: 102100, latestWkid: 3857 },\r\n }};\r\n\r\n const doFeatureInfoQuery = async (format: ArcGisFeatureFormat, outFields?: string, returnGeometry?: boolean) => {\r\n const infoUrl = this.constructFeatureUrl(quadId.row, quadId.column, quadId.level, format, \"standard\", queryEnvelope,\r\n outFields, undefined, returnGeometry, tilePixelSize);\r\n\r\n if (!infoUrl || infoUrl.url.length === 0) {\r\n Logger.logError(loggerCategory, `Could not construct feature info query URL`);\r\n return undefined;\r\n }\r\n\r\n const response = this.fetch(new URL(infoUrl.url), { method: \"GET\" });\r\n\r\n const featureResponse = new ArcGisFeatureResponse(format, response);\r\n return featureResponse.getResponseData();\r\n };\r\n\r\n if (this._debugFeatureGeom) {\r\n try {\r\n let responseData = await doFeatureInfoQuery(arcgisFeatureFormats.pbf, \"\", true);\r\n if (responseData) {\r\n const json = JSON.stringify(responseData.data.toObject());\r\n Logger.logInfo(loggerCategory, json);\r\n }\r\n responseData = await doFeatureInfoQuery(arcgisFeatureFormats.json, \"\", true);\r\n if (responseData) {\r\n const json = JSON.stringify(responseData.data);\r\n Logger.logInfo(loggerCategory, json);\r\n }\r\n } catch (e) {\r\n Logger.logInfo(loggerCategory, `Error occurred with debug FeatureInfo: ${BentleyError.getErrorMessage(e)}`);\r\n }\r\n }\r\n\r\n try {\r\n // Feature Info requests are always made in JSON for now.\r\n const responseData = await doFeatureInfoQuery(arcgisFeatureFormats.json, \"*\", true);\r\n if (!responseData) {\r\n Logger.logError(loggerCategory, `Could not get feature info data`);\r\n return;\r\n }\r\n if (responseData.exceedTransferLimit) {\r\n Logger.logError(loggerCategory, `Could not get feature info : transfer limit exceeded.`);\r\n return;\r\n }\r\n\r\n const featureReader = new ArcGisJsonFeatureReader(this._settings, this._layerMetadata);\r\n\r\n const renderer = new FeatureGraphicsRenderer({viewport: hit.viewport, crs: \"webMercator\"});\r\n await featureReader.readFeatureInfo(responseData, featureInfos, renderer);\r\n\r\n } catch (e) {\r\n Logger.logError(loggerCategory, `Exception occurred while loading feature info data : ${BentleyError.getErrorMessage(e)}`);\r\n return;\r\n }\r\n\r\n return;\r\n }\r\n\r\n private async fetchTile(row: number, column: number, zoomLevel: number, refineEnvelope?: ArcGisExtent): Promise<ArcGisFeatureResponse | undefined> {\r\n if (!this.format) {\r\n return undefined;\r\n }\r\n\r\n const geomOverride: ArcGisGeometry | undefined = (refineEnvelope ? { geom: refineEnvelope, type: \"esriGeometryEnvelope\" } : undefined);\r\n const fields = this._renderer?.fields;\r\n const outFields = fields ? fields.join(\",\") : undefined;\r\n const tileUrl = this.constructFeatureUrl(row, column, zoomLevel, this.format, \"tile\", geomOverride, outFields);\r\n if (!tileUrl || tileUrl.url.length === 0) {\r\n Logger.logError(loggerCategory, `Could not construct feature query URL for tile ${zoomLevel}/${row}/${column}`);\r\n return undefined;\r\n }\r\n\r\n const response = this.fetch(new URL(tileUrl.url), { method: \"GET\" });\r\n return new ArcGisFeatureResponse(this.format, response, tileUrl.envelope);\r\n }\r\n\r\n public drawTileDebugInfo(row: number, column: number, zoomLevel: number, context: CanvasRenderingContext2D) {\r\n context.fillStyle = \"cyan\";\r\n context.strokeRect(0, 0, this.tileSize, this.tileSize);\r\n context.font = \"30px Arial\";\r\n context.lineWidth = 5;\r\n context.fillText(`${zoomLevel}-${row}-${column}`, 10, 50);\r\n }\r\n\r\n // Compute transform that provides coordinates in the canvas coordinate system (pixels, origin = top-left)\r\n // from coordinate in world (i.e EPSG:3857)\r\n protected computeTileWorld2CanvasTransform(row: number, column: number, zoomLevel: number) {\r\n\r\n const tileExtentWorld3857 = this.getEPSG3857Extent(row, column, zoomLevel);\r\n const worldTileWidth = tileExtentWorld3857.right - tileExtentWorld3857.left;\r\n const canvasTileWidth = this.tileSize;\r\n const world2CanvasRatio = canvasTileWidth / worldTileWidth;\r\n const worldTileOrigin = Point3d.create(tileExtentWorld3857.left, tileExtentWorld3857.bottom);\r\n const worldTileExtent = Point3d.create(tileExtentWorld3857.right, tileExtentWorld3857.top);\r\n const canvasTileOriginOffset = worldTileOrigin.clone();\r\n const canvasTileExtentOffset = worldTileExtent.clone();\r\n canvasTileOriginOffset.scaleInPlace(world2CanvasRatio);\r\n canvasTileExtentOffset.scaleInPlace(world2CanvasRatio);\r\n const xTranslate = -1 * canvasTileOriginOffset.x;\r\n\r\n // Canvas origin is uppler left corner, so we need to flip the y axsis\r\n const yTranslate = canvasTileExtentOffset.y; // y-axis flip\r\n const yWorld2CanvasRatio = -1 * world2CanvasRatio; // y-axis flip\r\n\r\n const matrix = Matrix4d.createTranslationAndScaleXYZ(xTranslate, yTranslate, 0, world2CanvasRatio, yWorld2CanvasRatio, 1);\r\n return matrix.asTransform;\r\n }\r\n\r\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\r\n\r\n if ((this.status === MapLayerImageryProviderStatus.RequireAuth)) {\r\n return undefined;\r\n }\r\n const canvas = document.createElement(\"canvas\");\r\n canvas.width = this.tileSize;\r\n canvas.height = this.tileSize;\r\n\r\n const ctx = canvas.getContext(\"2d\");\r\n if (ctx == null) {\r\n Logger.logError(loggerCategory, \"No canvas context available for loading tile.\");\r\n return undefined;\r\n }\r\n\r\n try {\r\n\r\n // Compute transform if CoordinatesQuantization is not supported by service\r\n let transfo: Transform | undefined;\r\n if (!this._supportsCoordinatesQuantization) {\r\n transfo = this.computeTileWorld2CanvasTransform(row, column, zoomLevel);\r\n if (!transfo) {\r\n Logger.logError(loggerCategory, `Could not compute data transformation for tile (${zoomLevel}/${row}/${column})`);\r\n }\r\n }\r\n\r\n // Create the renderer\r\n if (!this._symbologyRenderer) {\r\n Logger.logError(loggerCategory, `Unable to load tile: symbology renderer not aailable.`);\r\n return undefined;\r\n }\r\n\r\n const renderer = new FeatureCanvasRenderer(ctx, this._symbologyRenderer, transfo);\r\n const featureReader: ArcGisFeatureReader = this.format === arcgisFeatureFormats.pbf\r\n ? new ArcGisPbfFeatureReader(this._settings, this._layerMetadata)\r\n : new ArcGisJsonFeatureReader(this._settings, this._layerMetadata);\r\n\r\n const getSubEnvelopes = (envelope: ArcGisExtent): ArcGisExtent[] => {\r\n const dx = (envelope.xmax - envelope.xmin) * 0.5;\r\n const dy = (envelope.xmax - envelope.xmin) * 0.5;\r\n const subEnvelopes: ArcGisExtent[] = [];\r\n for (let posX = 0; posX < ArcGisFeatureProvider._nbSubTiles; posX++) {\r\n for (let posY = 0; posY < ArcGisFeatureProvider._nbSubTiles; posY++) {\r\n subEnvelopes.push({\r\n xmin: envelope.xmin + (dx * posX), ymin: envelope.ymin + (dy * posY),\r\n xmax: envelope.xmin + (dx * (posX + 1)), ymax: envelope.ymin + (dy * (posY + 1)),\r\n spatialReference: { wkid: 102100, latestWkid: 3857 },\r\n });\r\n }\r\n }\r\n return subEnvelopes;\r\n };\r\n\r\n // The strategy here is simple: we make a request for an area that represents the current tile (i.e envelope),\r\n // the server will either return the requested data OR a 'exceedTransferLimit' message (too much data to transfers).\r\n // In the latter case, we subdivide the previous request envelope in for 4 sub-envelopes,\r\n // and repeat again until we get data.\r\n const renderData = async (envelope?: ArcGisExtent) => {\r\n let response: ArcGisFeatureResponse | undefined;\r\n let responseData: ArcGisResponseData | undefined;\r\n try {\r\n response = await this.fetchTile(row, column, zoomLevel, envelope);\r\n\r\n if (!response) {\r\n Logger.logError(loggerCategory, `Error occurred while fetching tile (${zoomLevel}/${row}/${column})`);\r\n return;\r\n }\r\n\r\n responseData = await response.getResponseData();\r\n if (!responseData) {\r\n Logger.logError(loggerCategory, `Could not get response data for tile (${zoomLevel}/${row}/${column})`);\r\n return;\r\n }\r\n } catch (e) {\r\n Logger.logError(loggerCategory, `Exception occurred while loading tile (${zoomLevel}/${row}/${column}) : ${BentleyError.getErrorMessage(e)}`);\r\n return;\r\n }\r\n\r\n if (responseData.exceedTransferLimit) {\r\n if (response.envelope) {\r\n const subEnvelopes = getSubEnvelopes(response.envelope);\r\n const renderPromises = [];\r\n for (const subEnvelope of subEnvelopes) {\r\n renderPromises.push(renderData(subEnvelope));\r\n }\r\n await Promise.all(renderPromises);\r\n } else {\r\n Logger.logError(loggerCategory, `Request exceeded transfer limit, could not refine request`);\r\n }\r\n } else {\r\n await featureReader.readAndRender(responseData, renderer);\r\n }\r\n };\r\n await renderData();\r\n if (this._drawDebugInfo)\r\n this.drawTileDebugInfo(row, column, zoomLevel, ctx);\r\n } catch (e) {\r\n Logger.logError(loggerCategory, `Exception occurred while loading tile (${zoomLevel}/${row}/${column}) : ${BentleyError.getErrorMessage(e)}`);\r\n }\r\n\r\n try {\r\n const dataUrl = canvas.toDataURL(\"image/png\");\r\n const header = \"data:image/png;base64,\";\r\n const dataUrl2 = dataUrl.substring(header.length);\r\n return new ImageSource(base64StringToUint8Array(dataUrl2), ImageSourceFormat.Png);\r\n } catch (e) {\r\n Logger.logError(loggerCategory, `Exception occurred while rendering tile (${zoomLevel}/${row}/${column}) : ${BentleyError.getErrorMessage(e)}.`);\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n}\r\n\r\n"]}
1
+ {"version":3,"file":"ArcGisFeatureProvider.js","sourceRoot":"","sources":["../../../src/ArcGisFeature/ArcGisFeatureProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAmG;AACnG,oDAAsH;AACtH,wDAAwW;AACxW,wDAA6E;AAC7E,kFAA4E;AAE5E,mEAA+L;AAE/L,yEAAuF;AACvF,6EAAuE;AACvE,2EAAqE;AACrE,6EAA6E;AAC7E,yDAAuG;AAEvG,MAAM,cAAc,GAAG,gCAAgC,CAAC;AAUxD;;EAEE;AACF,MAAa,qBAAqB;IACzB,MAAM,CAAU,UAAU,GAAG,0BAAO,CAAC,QAAQ,CAAE;QACpD,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,EAAE;QACP,WAAW,EAAE,WAAW;QACxB,SAAS,EAAE,04BAA04B;QACr5B,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,CAAC,CAAC;QACX,OAAO,EAAE,CAAC,EAAE;KACb,CAAC,CAAC;IAEI,MAAM,CAAU,eAAe,GAAiB;QACrD,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC;QACvB,KAAK,EAAE,CAAC;QACR,KAAK,EAAE,cAAc;KACtB,CAAC;IACK,MAAM,CAAU,UAAU,GAAG,0BAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAEpE,MAAM,CAAU,UAAU,GAAG,0BAAO,CAAC,QAAQ,CAAC;QACnD,IAAI,EAAE,SAAS;QACf,KAAK,EAAG,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAI,YAAY;QACxC,KAAK,EAAE,cAAc;QACrB,OAAO,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C,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;gBAC5D,CAAC;YACH,CAAC,CAAC;YACF,MAAM,UAAU,EAAE,CAAC;YACnB,IAAI,IAAI,CAAC,cAAc;gBACrB,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,qBAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,0CAA0C,SAAS,IAAI,GAAG,IAAI,MAAM,OAAO,2BAAY,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAChJ,CAAC;QAED,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YAC9C,MAAM,MAAM,GAAG,wBAAwB,CAAC;YACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAClD,OAAO,IAAI,yBAAW,CAAC,IAAA,uCAAwB,EAAC,QAAQ,CAAC,EAAE,+BAAiB,CAAC,GAAG,CAAC,CAAC;QACpF,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,qBAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,4CAA4C,SAAS,IAAI,GAAG,IAAI,MAAM,OAAO,2BAAY,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACnJ,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;;AA3jBH,sDA6jBC","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 { base64StringToUint8Array, BentleyError, IModelStatus, Logger } from \"@itwin/core-bentley\";\r\nimport { Cartographic, ImageMapLayerSettings, ImageSource, ImageSourceFormat, ServerError } from \"@itwin/core-common\";\r\nimport { ArcGisErrorCode, ArcGISImageryProvider, ArcGISServiceMetadata, ArcGisUtilities, FeatureGraphicsRenderer, HitDetail, ImageryMapTileTree, MapCartoRectangle, MapFeatureInfoOptions, MapLayerAuthenticationFailedError, MapLayerFeatureInfo, MapLayerImageryProviderStatus, MapLayerUntrustedOriginError, QuadId, setRequestTimeout } from \"@itwin/core-frontend\";\r\nimport { Matrix4d, Point3d, Range2d, Transform } from \"@itwin/core-geometry\";\r\nimport { FeatureCanvasRenderer } from \"../Feature/FeatureCanvasRenderer.js\";\r\nimport { FeatureDefaultSymbology } from \"../Feature/FeatureSymbology.js\";\r\nimport { ArcGisExtent, ArcGisFeatureFormat, arcgisFeatureFormats, ArcGisFeatureQuery, ArcGisFeatureResultType, ArcGisGeometry, FeatureQueryQuantizationParams } from \"./ArcGisFeatureQuery.js\";\r\nimport { ArcGisFeatureReader } from \"./ArcGisFeatureReader.js\";\r\nimport { ArcGisFeatureResponse, ArcGisResponseData } from \"./ArcGisFeatureResponse.js\";\r\nimport { ArcGisJsonFeatureReader } from \"./ArcGisJsonFeatureReader.js\";\r\nimport { ArcGisPbfFeatureReader } from \"./ArcGisPbfFeatureReader.js\";\r\nimport { ArcGisSymbologyCanvasRenderer } from \"./ArcGisSymbologyRenderer.js\";\r\nimport { EsriPMS, EsriRenderer, EsriSFS, EsriSLS, EsriSLSProps, EsriSymbol } from \"./EsriSymbology.js\";\r\n\r\nconst loggerCategory = \"MapLayersFormats.ArcGISFeature\";\r\n\r\n/**\r\n* @internal\r\n*/\r\ninterface ArcGisFeatureUrl {\r\n url: string;\r\n envelope?: ArcGisExtent; // envelope representing the current computed URL, required to refine request.\r\n}\r\n\r\n/**\r\n* @internal\r\n*/\r\nexport class DefaultArcGiSymbology implements FeatureDefaultSymbology {\r\n public static readonly defaultPMS = EsriPMS.fromJSON( {\r\n type: \"esriPMS\",\r\n url: \"\",\r\n contentType: \"image/png\",\r\n imageData: \"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAmBJREFUOE+Nk01IVFEUx//n3jfvOZOaJkMtiiJ7o9RG3LgoqKhFSFJBTS1ahFBBi0ijfJXCIyQr+hBbSIsoW7iQoKKFCw2CkAI3tZAgy8Ei+xhoTCbnje/NPfHGnA816KzuPR+/c8/HJRQJE7o+VUhym0DcCOYGgBQEXjOLlyqo+nHanCkMoaL4rslKjZwOQLT4ek3Mmz3FACFNLB67ut6M1nWphbg8wI6VyJK5KEH0EQFVJRKbwzokAW++p/ErraAYSQK3u47bC3vLnA+ZB9i2gHF0oyQMCfCGNaUa+vauxs71wWz2V18cnBj8gQ8J1/eeBnHUa4sMFQDGdGno+4gwEAoQzjVUon3rqlx1KY9x7+0MWobjAPg3QJ2eZV4tAEyFNCN5FkSXyw2B3j1hRGvLcgBXMV5MptA4MOXr0gT0u5bZnAf0jBsyiSgJPAxqhON1K3FlRxUMvwFAtv7u0Wl0jvwEmJNEuOhakTt5wKEBifr6Oo14BIBRpgt07w6jcVMIngKGY7NofR5HwlF+zDcpsC193vyYB/innvHywCzdZfAR/+onX1segBTAxHzzfPE7/8yzzIPLjJE1LTixHZx5CtCK4gXLzovBiDPUsYxVM7gUkB3nWKlm6DYEnQGzXARxCOK+a1WfKtQXb6LNAvr7iCboCUA1Ocdsdv5KLPe7F6pH/w3wLbc+BwOuc5IZ1wEE/jonQbjptZn24tKKX7BgvR2r0NKZRwDvAqCI+Z30VJPTURv7P4A9psuQcYAUPwAoReBLrmX2Lmls7i8sZ7kWLwuoxA1FVJGxzMPLufi6P2r+2xFbOUjGAAAAAElFTkSuQmCC\",\r\n width: 16,\r\n height: 16,\r\n xoffset: -8,\r\n yoffset: -16,\r\n });\r\n\r\n public static readonly defaultSLSProps: EsriSLSProps = {\r\n type: \"esriSLS\",\r\n color: [0, 0, 255, 255],\r\n width: 1,\r\n style: \"esriSLSSolid\",\r\n };\r\n public static readonly defaultSLS = EsriSLS.fromJSON(this.defaultSLSProps);\r\n\r\n public static readonly defaultSFS = EsriSFS.fromJSON({\r\n type: \"esriSFS\",\r\n color: [0, 0, 255, 100], // blue fill\r\n style: \"esriSFSSolid\",\r\n outline: this.defaultSLSProps,\r\n });\r\n\r\n public async initialize() {\r\n // Marker image need to be loaded upfront;\r\n await DefaultArcGiSymbology.defaultPMS.loadImage();\r\n }\r\n\r\n public getSymbology(geomType: string): EsriSymbol {\r\n if (geomType === \"esriGeometryPoint\" || geomType === \"esriGeometryMultipoint\") {\r\n return DefaultArcGiSymbology.defaultPMS;\r\n } else if (geomType === \"esriGeometryLine\" || geomType === \"esriGeometryPolyline\") {\r\n return DefaultArcGiSymbology.defaultSLS;\r\n } else if (geomType === \"esriGeometryPolygon\") {\r\n return DefaultArcGiSymbology.defaultSFS;\r\n }\r\n\r\n throw new Error(`Could not get default symbology for geometry type: '${geomType}'`);\r\n }\r\n}\r\n\r\n/** Provide tiles from a ESRI ArcGIS Feature service\r\n* @internal\r\n*/\r\nexport class ArcGisFeatureProvider extends ArcGISImageryProvider {\r\n // Debug flags, should always be committed to FALSE !\r\n private _drawDebugInfo = false;\r\n private _debugFeatureGeom = false;\r\n\r\n private _supportsCoordinatesQuantization = false;\r\n\r\n private _layerId = 0;\r\n private _layerMetadata: any;\r\n private _format: ArcGisFeatureFormat | undefined;\r\n private _outSR = 102100;\r\n\r\n private _maxDepthFromLod = 0;\r\n private _minDepthFromLod = 0;\r\n\r\n private _defaultSymbol = new DefaultArcGiSymbology();\r\n private _renderer: EsriRenderer|undefined;\r\n private _symbologyRenderer: ArcGisSymbologyCanvasRenderer|undefined;\r\n\r\n private static readonly _nbSubTiles = 2; // Number of subtiles for a single axis\r\n public serviceJson: any;\r\n\r\n public override get minimumZoomLevel(): number { return this._minDepthFromLod; }\r\n public override get maximumZoomLevel(): number { return this._maxDepthFromLod; }\r\n\r\n private static _extentCache = new Map<string, any>();\r\n\r\n constructor(settings: ImageMapLayerSettings) {\r\n super(settings, true);\r\n }\r\n\r\n public override async initialize(): Promise<void> {\r\n const metadata = await this.getServiceJson();\r\n const json = metadata?.content;\r\n\r\n if (json === undefined) {\r\n // By returning (i.e., not throwing), we ensure the tile tree gets created and the current provider is preserved to report status.\r\n if (this.status === MapLayerImageryProviderStatus.UntrustedOrigin || this.status === MapLayerImageryProviderStatus.RequireAuth)\r\n return;\r\n Logger.logError(loggerCategory, \"Could not get service JSON\");\r\n throw new ServerError(IModelStatus.ValidationFailed, \"\");\r\n }\r\n\r\n const errorCode = metadata?.errorCode;\r\n if (errorCode === ArcGisErrorCode.TokenRequired\r\n || errorCode === ArcGisErrorCode.InvalidToken\r\n || errorCode === ArcGisErrorCode.MissingPermissions\r\n ) {\r\n // Check again layer status, it might have change during await.\r\n if (this.status === MapLayerImageryProviderStatus.Valid) {\r\n this.setStatus(MapLayerImageryProviderStatus.RequireAuth);\r\n return;\r\n }\r\n }\r\n\r\n if (json.capabilities) {\r\n this._querySupported = json.capabilities.indexOf(\"Query\") >= 0;\r\n if (!this._querySupported)\r\n throw new ServerError(IModelStatus.ValidationFailed, \"\");\r\n }\r\n\r\n this.serviceJson = json;\r\n\r\n let foundVisibleSubLayer = false;\r\n if (this._settings.subLayers.length >= 0) {\r\n // There is more than sub-layer for this layer, pick the first visible one.\r\n for (const layer of this._settings.subLayers) {\r\n if (layer.visible && typeof layer.id === \"number\") {\r\n this._layerId = layer.id;\r\n foundVisibleSubLayer = true;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (!foundVisibleSubLayer && json !== undefined) {\r\n // No suitable sublayer was specified on the layerSettings object, lets find a default one in the capabilities\r\n\r\n // Check layer metadata\r\n if (Array.isArray(this.serviceJson.layers) && this.serviceJson.layers.length >= 1) {\r\n\r\n const hasDefaultVisibility = Object.keys(this.serviceJson.layers[0]).includes(\"defaultVisibility\");\r\n if (hasDefaultVisibility) {\r\n for (const layer of this.serviceJson.layers) {\r\n if (layer.defaultVisibility) {\r\n this._layerId = layer.id;\r\n break;\r\n }\r\n }\r\n } else {\r\n // On some older servers, the default visiblity is on the layer capabilities (i.e. not the service capabilities)\r\n for (const layer of this.serviceJson.layers) {\r\n const layerJson = await this.getLayerMetadata(layer.id);\r\n if (!layerJson) {\r\n continue;\r\n }\r\n\r\n if (layerJson.defaultVisibility) {\r\n this._layerId = layer.id;\r\n this._layerMetadata = layerJson;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n } else {\r\n // There is no layer to publish? Something is off with this server..\r\n throw new ServerError(IModelStatus.ValidationFailed, \"\");\r\n }\r\n }\r\n\r\n // Make sure we cache layer info (i.e. rendering info)\r\n if (!this._layerMetadata) {\r\n\r\n this._layerMetadata = await this.getLayerMetadata(this._layerId);\r\n if (!this._layerMetadata) {\r\n // By returning (i.e., not throwing), we ensure the tile tree gets created and the current provider is preserved to report status.\r\n if (this.status === MapLayerImageryProviderStatus.UntrustedOrigin || this.status === MapLayerImageryProviderStatus.RequireAuth)\r\n return;\r\n Logger.logError(loggerCategory, \"Could not layer metadata\");\r\n throw new ServerError(IModelStatus.ValidationFailed, \"\");\r\n }\r\n }\r\n\r\n // Parse server version\r\n let majorVersion: number | undefined;\r\n if (this.serviceJson?.currentVersion) {\r\n try {\r\n majorVersion = Math.trunc(this.serviceJson?.currentVersion);\r\n } catch {\r\n }\r\n }\r\n\r\n // Coordinates Quantization: If supported, server will transform for us the coordinates in the Tile coordinate space (pixels, origin = upper left corner\r\n // If not supported, transformation will be applied client side.\r\n // Note: For some reasons, even though 'supportsCoordinatesQuantization' is set to 'true' on the layer metadata, server will give an error message for server version < 11\r\n if (majorVersion && majorVersion >= 11 && this._layerMetadata.supportsCoordinatesQuantization) {\r\n this._supportsCoordinatesQuantization = true;\r\n }\r\n\r\n // Check supported query formats: JSON and PBF are currently implemented by this provider\r\n // Note: needs to be checked on the layer metadata, service metadata advertises a different set of formats\r\n // Also, since PBF format does not support floating points, there is no point using this format if supportsCoordinatesQuantization is not available.\r\n if (this._layerMetadata.supportedQueryFormats) {\r\n const formats: string[] = this._layerMetadata.supportedQueryFormats.split(\",\").map((s: string) => s.trim().toLowerCase());\r\n if (formats.includes(arcgisFeatureFormats.pbf) && this._supportsCoordinatesQuantization) {\r\n this._format = arcgisFeatureFormats.pbf;\r\n } else if (formats.includes(arcgisFeatureFormats.json)) {\r\n this._format = arcgisFeatureFormats.json;\r\n }\r\n }\r\n\r\n if (!this._format) {\r\n Logger.logError(loggerCategory, \"Could not get request format from service JSON\");\r\n throw new ServerError(IModelStatus.ValidationFailed, \"\");\r\n }\r\n\r\n // Read range using full extent from service metadata\r\n if (this._layerMetadata?.extent) {\r\n const layerExtent = this._layerMetadata.extent;\r\n if (layerExtent.spatialReference.latestWkid === 3857 || layerExtent.spatialReference.wkid === 102100) {\r\n this.setCartoRangeFromExtentJson(layerExtent);\r\n }\r\n }\r\n\r\n if (!this.cartoRange) {\r\n // Range could not be found (or is not in a coordinate system we support), make a request to compute the extent\r\n try {\r\n const extentJson = await this.fetchLayerExtent();\r\n\r\n if (extentJson)\r\n this.setCartoRangeFromExtentJson(extentJson);\r\n else\r\n Logger.logWarning(loggerCategory, `Could not get features extent, disabling extent filtering`);\r\n } catch {\r\n Logger.logError(loggerCategory, `Could not get feature extent`);\r\n }\r\n }\r\n\r\n // Check for minScale / max scale\r\n const minScale = this._layerMetadata?.minScale || undefined; // undefined, 0 -> undefined\r\n const maxScale = this._layerMetadata?.maxScale || undefined; // undefined, 0 -> undefined\r\n const scales = ArcGisUtilities.getZoomLevelsScales(this.defaultMaximumZoomLevel, this.tileSize, minScale, maxScale, 1.0);\r\n if (scales.minLod)\r\n this._minDepthFromLod = scales.minLod;\r\n\r\n // Some servers advertises a max LOD of 0, it should be interpreted as 'not defined' (otherwise a max lod of 0 would would mean never display anything)\r\n this._maxDepthFromLod = (scales.maxLod ? scales.maxLod : this.defaultMaximumZoomLevel);\r\n\r\n try {\r\n this._renderer = EsriRenderer.fromJSON(this._layerMetadata?.drawingInfo?.renderer);\r\n await this._renderer.initialize();\r\n } catch (e) {\r\n Logger.logError(loggerCategory, `Could not initialize symbology renderer for '${this._settings.name}': ${BentleyError.getErrorMessage(e)}`);\r\n }\r\n\r\n // Sanity check: make sure we got default symbology for this geometry type\r\n // if not, it will throw\r\n this._defaultSymbol.getSymbology(this._layerMetadata?.geometryType);\r\n await this._defaultSymbol.initialize(); // images must be loaded upfront\r\n this._symbologyRenderer = ArcGisSymbologyCanvasRenderer.create(this._renderer, this._defaultSymbol, this._layerMetadata?.geometryType);\r\n }\r\n\r\n private async fetchLayerExtent() {\r\n let extentJson: any;\r\n const tmpUrl = new URL(this._settings.url);\r\n tmpUrl.pathname = `${tmpUrl.pathname}/${this._layerId}/query`;\r\n tmpUrl.searchParams.append(\"where\", \"1=1\");\r\n tmpUrl.searchParams.append(\"outSR\", \"3857\");\r\n tmpUrl.searchParams.append(\"returnExtentOnly\", \"true\");\r\n tmpUrl.searchParams.append(\"f\", arcgisFeatureFormats.json);\r\n // The cache is keyed by URL only, so responses customized by the fetch handler (e.g.\r\n // header-authenticated) must not be shared with or served from differently-customized requests.\r\n // Reads are skipped on registration state; writes on the actual provenance of the response, since a\r\n // handler may be registered while the request awaits token acquisition or the first-request gate.\r\n const cached = this.hasFetchHandler ? undefined : ArcGisFeatureProvider._extentCache.get(tmpUrl.toString());\r\n if (cached) {\r\n extentJson = cached;\r\n } else {\r\n // Some server are struggling computing the extent for a layer (outdated spatial index I presume), lets wait 10s max.\r\n // Worst case scenario we will end up with a map-layer with no 'Zoom-To-Layer' functionality.\r\n const opts: RequestInit = { method: \"GET\" };\r\n setRequestTimeout(opts, 10000);\r\n const response = await this.fetch(tmpUrl, opts);\r\n\r\n extentJson = await response.json();\r\n if (!this.isManagedByHandler(response))\r\n ArcGisFeatureProvider._extentCache.set(tmpUrl.toString(), extentJson);\r\n }\r\n return (extentJson ? extentJson.extent : undefined);\r\n }\r\n\r\n private setCartoRangeFromExtentJson(extent: any) {\r\n const range3857 = Range2d.createFrom({\r\n low: { x: extent.xmin, y: extent.ymin },\r\n high: { x: extent.xmax, y: extent.ymax },\r\n });\r\n\r\n const west = this.getEPSG4326Lon(range3857.xLow);\r\n const south = this.getEPSG4326Lat(range3857.yLow);\r\n const east = this.getEPSG4326Lon(range3857.xHigh);\r\n const north = this.getEPSG4326Lat(range3857.yHigh);\r\n this.cartoRange = MapCartoRectangle.fromDegrees(west, south, east, north);\r\n }\r\n\r\n protected async getLayerMetadata(layerId: number) {\r\n let metadata: ArcGISServiceMetadata | undefined;\r\n try {\r\n const url = new URL(this._settings.url);\r\n url.pathname = `${url.pathname}/${layerId}`;\r\n metadata = await ArcGisUtilities.getServiceJson({\r\n url: url.toString(), layerUrl: this._settings.url, layerProperties: this._settings.properties, formatId: this._settings.formatId,\r\n userName: this._settings.userName, password: this._settings.password,\r\n queryParams: this._settings.collectQueryParams(), requireToken: this._accessTokenRequired});\r\n } catch (err) {\r\n // Same status transitions as for the root service metadata; anything else yields no metadata.\r\n if (err instanceof MapLayerAuthenticationFailedError)\r\n this.reportAuthenticationFailure();\r\n else if (err instanceof MapLayerUntrustedOriginError)\r\n this.reportBlockedOrigin(err.url);\r\n }\r\n return metadata?.content;\r\n }\r\n\r\n public override get tileSize(): number { return 512; }\r\n public get format(): ArcGisFeatureFormat | undefined { return this._format; }\r\n\r\n // We don't use this method inside this provider (see constructFeatureUrl), but since this is an abstract method, we need to define something\r\n public async constructUrl(_row: number, _column: number, _zoomLevel: number): Promise<string> {\r\n return \"\";\r\n }\r\n\r\n public constructFeatureUrl(row: number, column: number, zoomLevel: number, format: ArcGisFeatureFormat, resultType: ArcGisFeatureResultType, geomOverride?: ArcGisGeometry, outFields?: string, tolerance?: number, returnGeometry?: boolean, maxAllowableOffset?: number): ArcGisFeatureUrl | undefined {\r\n\r\n const tileExtent = this.getEPSG3857Extent(row, column, zoomLevel);\r\n const tileEnvelope = {\r\n xmin: tileExtent.left, ymin: tileExtent.bottom,\r\n xmax: tileExtent.right, ymax: tileExtent.top,\r\n spatialReference: { wkid: 102100, latestWkid: 3857 },\r\n };\r\n\r\n // Actual spatial filter.\r\n // By default, we request the tile extent. If 'cartoPoint' is specified,\r\n // we restrict the spatial to specific point. (i.e. GetFeatureInfo requests)\r\n // If envelope is provided, it has the priority over 'cartoPoint'\r\n let geometry: ArcGisGeometry | undefined;\r\n if (geomOverride) {\r\n geometry = geomOverride;\r\n } else {\r\n geometry = { geom: tileEnvelope, type: \"esriGeometryEnvelope\" };\r\n }\r\n\r\n let quantizationParameters: FeatureQueryQuantizationParams | undefined;\r\n const toleranceWorld = (tileExtent.top - tileExtent.bottom) / this.tileSize;\r\n if (resultType === \"tile\" && this._supportsCoordinatesQuantization) {\r\n quantizationParameters = {\r\n mode: \"view\",\r\n originPosition: \"upperLeft\",\r\n tolerance: toleranceWorld, // pixel size in world units\r\n extent: tileEnvelope,\r\n };\r\n }\r\n const url = new ArcGisFeatureQuery(\r\n this._settings.url,\r\n this._layerId,\r\n format,\r\n this._outSR,\r\n {\r\n geometry,\r\n geometryType: \"esriGeometryEnvelope\",\r\n returnExceededLimitFeatures: false,\r\n maxRecordCountFactor: 3, // This was grabbed from the ESRI web viewer request, not sure where this factor come from\r\n resultType,\r\n quantizationParameters,\r\n outFields,\r\n returnGeometry,\r\n distance: (tolerance ? tolerance * toleranceWorld : undefined),\r\n maxAllowableOffset,\r\n });\r\n\r\n let envelope: ArcGisExtent | undefined;\r\n if (geomOverride && geomOverride.type === \"esriGeometryEnvelope\") {\r\n envelope = geomOverride.geom as ArcGisExtent;\r\n } else {\r\n envelope = tileEnvelope;\r\n }\r\n\r\n return { url: url.toString(), envelope };\r\n\r\n }\r\n\r\n // Makes an identify request to ESRI MapService , and return it as a list MapLayerFeatureInfo object\r\n public override async getFeatureInfo(featureInfos: MapLayerFeatureInfo[], quadId: QuadId, carto: Cartographic, _tree: ImageryMapTileTree, hit: HitDetail, options?: MapFeatureInfoOptions): Promise<void> {\r\n if (!this._querySupported || this.format === undefined)\r\n return;\r\n\r\n const epsg3857X = this.getEPSG3857X(carto.longitudeDegrees);\r\n const epsg3857Y = this.getEPSG3857Y(carto.latitudeDegrees);\r\n\r\n const tileExtent = this.getEPSG3857Extent(quadId.row, quadId.column, quadId.level);\r\n const tilePixelSize = (tileExtent.top - tileExtent.bottom) / this.tileSize;\r\n const tolerancePixel = options?.tolerance ?? 7;\r\n const toleranceWorld = tilePixelSize * tolerancePixel;\r\n\r\n // Note: We used to pass a single point as the query 'geometry' and leverage the 'distance' parameter, turns\r\n // out that approach was a lot slower on some server compared to using a single envelope.\r\n const queryEnvelope: ArcGisGeometry = {\r\n type: \"esriGeometryEnvelope\",\r\n geom: {\r\n xmin: epsg3857X - toleranceWorld, ymin: epsg3857Y - toleranceWorld,\r\n xmax: epsg3857X + toleranceWorld, ymax: epsg3857Y + toleranceWorld,\r\n spatialReference: { wkid: 102100, latestWkid: 3857 },\r\n }};\r\n\r\n const doFeatureInfoQuery = async (format: ArcGisFeatureFormat, outFields?: string, returnGeometry?: boolean) => {\r\n const infoUrl = this.constructFeatureUrl(quadId.row, quadId.column, quadId.level, format, \"standard\", queryEnvelope,\r\n outFields, undefined, returnGeometry, tilePixelSize);\r\n\r\n if (!infoUrl || infoUrl.url.length === 0) {\r\n Logger.logError(loggerCategory, `Could not construct feature info query URL`);\r\n return undefined;\r\n }\r\n\r\n const response = this.fetch(new URL(infoUrl.url), { method: \"GET\" });\r\n\r\n const featureResponse = new ArcGisFeatureResponse(format, response);\r\n return featureResponse.getResponseData();\r\n };\r\n\r\n if (this._debugFeatureGeom) {\r\n try {\r\n let responseData = await doFeatureInfoQuery(arcgisFeatureFormats.pbf, \"\", true);\r\n if (responseData) {\r\n const json = JSON.stringify(responseData.data.toObject());\r\n Logger.logInfo(loggerCategory, json);\r\n }\r\n responseData = await doFeatureInfoQuery(arcgisFeatureFormats.json, \"\", true);\r\n if (responseData) {\r\n const json = JSON.stringify(responseData.data);\r\n Logger.logInfo(loggerCategory, json);\r\n }\r\n } catch (e) {\r\n Logger.logInfo(loggerCategory, `Error occurred with debug FeatureInfo: ${BentleyError.getErrorMessage(e)}`);\r\n }\r\n }\r\n\r\n try {\r\n // Feature Info requests are always made in JSON for now.\r\n const responseData = await doFeatureInfoQuery(arcgisFeatureFormats.json, \"*\", true);\r\n if (!responseData) {\r\n Logger.logError(loggerCategory, `Could not get feature info data`);\r\n return;\r\n }\r\n if (responseData.exceedTransferLimit) {\r\n Logger.logError(loggerCategory, `Could not get feature info : transfer limit exceeded.`);\r\n return;\r\n }\r\n\r\n const featureReader = new ArcGisJsonFeatureReader(this._settings, this._layerMetadata);\r\n\r\n const renderer = new FeatureGraphicsRenderer({viewport: hit.viewport, crs: \"webMercator\"});\r\n await featureReader.readFeatureInfo(responseData, featureInfos, renderer);\r\n\r\n } catch (e) {\r\n Logger.logError(loggerCategory, `Exception occurred while loading feature info data : ${BentleyError.getErrorMessage(e)}`);\r\n return;\r\n }\r\n\r\n return;\r\n }\r\n\r\n private async fetchTile(row: number, column: number, zoomLevel: number, refineEnvelope?: ArcGisExtent): Promise<ArcGisFeatureResponse | undefined> {\r\n if (!this.format) {\r\n return undefined;\r\n }\r\n\r\n const geomOverride: ArcGisGeometry | undefined = (refineEnvelope ? { geom: refineEnvelope, type: \"esriGeometryEnvelope\" } : undefined);\r\n const fields = this._renderer?.fields;\r\n const outFields = fields ? fields.join(\",\") : undefined;\r\n const tileUrl = this.constructFeatureUrl(row, column, zoomLevel, this.format, \"tile\", geomOverride, outFields);\r\n if (!tileUrl || tileUrl.url.length === 0) {\r\n Logger.logError(loggerCategory, `Could not construct feature query URL for tile ${zoomLevel}/${row}/${column}`);\r\n return undefined;\r\n }\r\n\r\n const response = this.fetch(new URL(tileUrl.url), { method: \"GET\" });\r\n return new ArcGisFeatureResponse(this.format, response, tileUrl.envelope);\r\n }\r\n\r\n public drawTileDebugInfo(row: number, column: number, zoomLevel: number, context: CanvasRenderingContext2D) {\r\n context.fillStyle = \"cyan\";\r\n context.strokeRect(0, 0, this.tileSize, this.tileSize);\r\n context.font = \"30px Arial\";\r\n context.lineWidth = 5;\r\n context.fillText(`${zoomLevel}-${row}-${column}`, 10, 50);\r\n }\r\n\r\n // Compute transform that provides coordinates in the canvas coordinate system (pixels, origin = top-left)\r\n // from coordinate in world (i.e EPSG:3857)\r\n protected computeTileWorld2CanvasTransform(row: number, column: number, zoomLevel: number) {\r\n\r\n const tileExtentWorld3857 = this.getEPSG3857Extent(row, column, zoomLevel);\r\n const worldTileWidth = tileExtentWorld3857.right - tileExtentWorld3857.left;\r\n const canvasTileWidth = this.tileSize;\r\n const world2CanvasRatio = canvasTileWidth / worldTileWidth;\r\n const worldTileOrigin = Point3d.create(tileExtentWorld3857.left, tileExtentWorld3857.bottom);\r\n const worldTileExtent = Point3d.create(tileExtentWorld3857.right, tileExtentWorld3857.top);\r\n const canvasTileOriginOffset = worldTileOrigin.clone();\r\n const canvasTileExtentOffset = worldTileExtent.clone();\r\n canvasTileOriginOffset.scaleInPlace(world2CanvasRatio);\r\n canvasTileExtentOffset.scaleInPlace(world2CanvasRatio);\r\n const xTranslate = -1 * canvasTileOriginOffset.x;\r\n\r\n // Canvas origin is uppler left corner, so we need to flip the y axsis\r\n const yTranslate = canvasTileExtentOffset.y; // y-axis flip\r\n const yWorld2CanvasRatio = -1 * world2CanvasRatio; // y-axis flip\r\n\r\n const matrix = Matrix4d.createTranslationAndScaleXYZ(xTranslate, yTranslate, 0, world2CanvasRatio, yWorld2CanvasRatio, 1);\r\n return matrix.asTransform;\r\n }\r\n\r\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\r\n\r\n if ((this.status === MapLayerImageryProviderStatus.RequireAuth)) {\r\n return undefined;\r\n }\r\n const canvas = document.createElement(\"canvas\");\r\n canvas.width = this.tileSize;\r\n canvas.height = this.tileSize;\r\n\r\n const ctx = canvas.getContext(\"2d\");\r\n if (ctx == null) {\r\n Logger.logError(loggerCategory, \"No canvas context available for loading tile.\");\r\n return undefined;\r\n }\r\n\r\n try {\r\n\r\n // Compute transform if CoordinatesQuantization is not supported by service\r\n let transfo: Transform | undefined;\r\n if (!this._supportsCoordinatesQuantization) {\r\n transfo = this.computeTileWorld2CanvasTransform(row, column, zoomLevel);\r\n if (!transfo) {\r\n Logger.logError(loggerCategory, `Could not compute data transformation for tile (${zoomLevel}/${row}/${column})`);\r\n }\r\n }\r\n\r\n // Create the renderer\r\n if (!this._symbologyRenderer) {\r\n Logger.logError(loggerCategory, `Unable to load tile: symbology renderer not aailable.`);\r\n return undefined;\r\n }\r\n\r\n const renderer = new FeatureCanvasRenderer(ctx, this._symbologyRenderer, transfo);\r\n const featureReader: ArcGisFeatureReader = this.format === arcgisFeatureFormats.pbf\r\n ? new ArcGisPbfFeatureReader(this._settings, this._layerMetadata)\r\n : new ArcGisJsonFeatureReader(this._settings, this._layerMetadata);\r\n\r\n const getSubEnvelopes = (envelope: ArcGisExtent): ArcGisExtent[] => {\r\n const dx = (envelope.xmax - envelope.xmin) * 0.5;\r\n const dy = (envelope.xmax - envelope.xmin) * 0.5;\r\n const subEnvelopes: ArcGisExtent[] = [];\r\n for (let posX = 0; posX < ArcGisFeatureProvider._nbSubTiles; posX++) {\r\n for (let posY = 0; posY < ArcGisFeatureProvider._nbSubTiles; posY++) {\r\n subEnvelopes.push({\r\n xmin: envelope.xmin + (dx * posX), ymin: envelope.ymin + (dy * posY),\r\n xmax: envelope.xmin + (dx * (posX + 1)), ymax: envelope.ymin + (dy * (posY + 1)),\r\n spatialReference: { wkid: 102100, latestWkid: 3857 },\r\n });\r\n }\r\n }\r\n return subEnvelopes;\r\n };\r\n\r\n // The strategy here is simple: we make a request for an area that represents the current tile (i.e envelope),\r\n // the server will either return the requested data OR a 'exceedTransferLimit' message (too much data to transfers).\r\n // In the latter case, we subdivide the previous request envelope in for 4 sub-envelopes,\r\n // and repeat again until we get data.\r\n const renderData = async (envelope?: ArcGisExtent) => {\r\n let response: ArcGisFeatureResponse | undefined;\r\n let responseData: ArcGisResponseData | undefined;\r\n try {\r\n response = await this.fetchTile(row, column, zoomLevel, envelope);\r\n\r\n if (!response) {\r\n Logger.logError(loggerCategory, `Error occurred while fetching tile (${zoomLevel}/${row}/${column})`);\r\n return;\r\n }\r\n\r\n responseData = await response.getResponseData();\r\n if (!responseData) {\r\n Logger.logError(loggerCategory, `Could not get response data for tile (${zoomLevel}/${row}/${column})`);\r\n return;\r\n }\r\n } catch (e) {\r\n Logger.logError(loggerCategory, `Exception occurred while loading tile (${zoomLevel}/${row}/${column}) : ${BentleyError.getErrorMessage(e)}`);\r\n return;\r\n }\r\n\r\n if (responseData.exceedTransferLimit) {\r\n if (response.envelope) {\r\n const subEnvelopes = getSubEnvelopes(response.envelope);\r\n const renderPromises = [];\r\n for (const subEnvelope of subEnvelopes) {\r\n renderPromises.push(renderData(subEnvelope));\r\n }\r\n await Promise.all(renderPromises);\r\n } else {\r\n Logger.logError(loggerCategory, `Request exceeded transfer limit, could not refine request`);\r\n }\r\n } else {\r\n await featureReader.readAndRender(responseData, renderer);\r\n }\r\n };\r\n await renderData();\r\n if (this._drawDebugInfo)\r\n this.drawTileDebugInfo(row, column, zoomLevel, ctx);\r\n } catch (e) {\r\n Logger.logError(loggerCategory, `Exception occurred while loading tile (${zoomLevel}/${row}/${column}) : ${BentleyError.getErrorMessage(e)}`);\r\n }\r\n\r\n try {\r\n const dataUrl = canvas.toDataURL(\"image/png\");\r\n const header = \"data:image/png;base64,\";\r\n const dataUrl2 = dataUrl.substring(header.length);\r\n return new ImageSource(base64StringToUint8Array(dataUrl2), ImageSourceFormat.Png);\r\n } catch (e) {\r\n Logger.logError(loggerCategory, `Exception occurred while rendering tile (${zoomLevel}/${row}/${column}) : ${BentleyError.getErrorMessage(e)}.`);\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n}\r\n\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AzureMapsImageryProvider.d.ts","sourceRoot":"","sources":["../../../src/AzureMaps/AzureMapsImageryProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,E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AM,iCAAiC,qBAAqB,CAAC;AAEpE,gBAAgB;AAChB,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,WAAW,GAAG,SAAS,EAAE,uBAAuB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOpI;AAQD;;;GAGG;AACH,qBAAa,6BAA8B,SAAQ,uBAAuB;IACpB,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC;gBAAnE,QAAQ,EAAE,qBAAqB,EAAmB,gBAAgB,CAAC,EAAE,MAAM,YAAA;IAI9F,OAAO,CAAC,sBAAsB;IAWR,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAuB1F,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQvF,kGAAkG;IAClF,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAOrC,eAAe,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAInG"}
@@ -51,7 +51,8 @@ class AzureMapsLayerImageryProvider extends core_frontend_1.MapLayerImageryProvi
51
51
  if (tileUrl.length === 0)
52
52
  return undefined;
53
53
  const tileResponse = await this.makeTileRequest(tileUrl);
54
- if (tileResponse.status === 401 || tileResponse.status === 403) {
54
+ // A status in a response managed by the fetch handler is not classified here.
55
+ if (!this.isManagedByHandler(tileResponse) && (tileResponse.status === 401 || tileResponse.status === 403)) {
55
56
  this.reportAzureAuthFailure();
56
57
  return undefined;
57
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AzureMapsImageryProvider.js","sourceRoot":"","sources":["../../../src/AzureMaps/AzureMapsImageryProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAS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AO,CAAC,iBAAiB,GAAG,MAAM,CAAC;YACzC,KAAK,CAAC,WAAW,CAAC,yBAAS,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,yBAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,2CAA2C,CAAC,EAAE,CAAC,CAAC,CAAC;QACvK,CAAC;IACH,CAAC;IAEe,KAAK,CAAC,eAAe,CAAC,KAAuB,EAAE,GAAmB;QAChF,4DAA4D;QAC5D,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACnD,CAAC;CACF;AA1DD,sEA0DC","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 MapLayersFormats\r\n */\r\n\r\nimport { ImageMapLayerSettings, type ImageSource, type MapLayerKey } from \"@itwin/core-common\";\r\nimport { IModelApp, MapLayerImageryProvider, MapLayerImageryProviderStatus, NotifyMessageDetails, OutputMessagePriority, ScreenViewport } from \"@itwin/core-frontend\";\r\n\r\n/** @internal */\r\nexport const azureMapsSubscriptionKeyParameter = \"subscription-key\";\r\n\r\n/** @internal */\r\nexport function getAzureMapsSubscriptionKey(accessKey: MapLayerKey | undefined, fallbackSubscriptionKey?: string): string | undefined {\r\n // A layer access key takes precedence, but an empty value falls through to the configured fallback\r\n // rather than disabling auth outright.\r\n if (accessKey !== undefined && accessKey.value.length > 0)\r\n return accessKey.value;\r\n\r\n return fallbackSubscriptionKey !== undefined && fallbackSubscriptionKey.length > 0 ? fallbackSubscriptionKey : undefined;\r\n}\r\n\r\nclass AzureMapsRequireAuthError extends Error {\r\n public constructor() {\r\n super(`Azure Maps requires a non-empty ${azureMapsSubscriptionKeyParameter} credential`);\r\n }\r\n}\r\n\r\n/**\r\n * Azure Maps imagery provider.\r\n * @beta\r\n */\r\nexport class AzureMapsLayerImageryProvider extends MapLayerImageryProvider {\r\n public constructor(settings: ImageMapLayerSettings, private readonly _subscriptionKey?: string) {\r\n super(settings, true);\r\n }\r\n\r\n private reportAzureAuthFailure(): void {\r\n this.setStatus(MapLayerImageryProviderStatus.RequireAuth);\r\n if (this._hasSuccessfullyFetchedTile) {\r\n const msg = IModelApp.localization.getLocalizedString(\"iModelJs:MapLayers.Messages.LoadTileTokenError\", { layerName: this._settings.name });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Warning, msg));\r\n }\r\n }\r\n\r\n // The base loadTile marks `_hasSuccessfullyFetchedTile` as soon as a response is received, before\r\n // inspecting its status. Azure returns 401/403 for missing/invalid credentials, so this override\r\n // detects that before the success is recorded, ensuring no spurious token warning on the first fetch.\r\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\r\n try {\r\n const tileUrl = await this.constructUrl(row, column, zoomLevel);\r\n if (tileUrl.length === 0)\r\n return undefined;\r\n\r\n const tileResponse = await this.makeTileRequest(tileUrl);\r\n if (tileResponse.status === 401 || tileResponse.status === 403) {\r\n this.reportAzureAuthFailure();\r\n return undefined;\r\n }\r\n\r\n this._hasSuccessfullyFetchedTile = true;\r\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\r\n } catch (error) {\r\n if (error instanceof AzureMapsRequireAuthError)\r\n this.reportAzureAuthFailure();\r\n\r\n return undefined;\r\n }\r\n }\r\n\r\n public override async constructUrl(y: number, x: number, zoom: number): Promise<string> {\r\n const subscriptionKey = getAzureMapsSubscriptionKey(this._settings.accessKey, this._subscriptionKey);\r\n if (undefined === subscriptionKey)\r\n throw new AzureMapsRequireAuthError();\r\n\r\n return `${this._settings.url}&${azureMapsSubscriptionKeyParameter}=${encodeURIComponent(subscriptionKey)}&api-version=2.0&zoom=${zoom}&x=${x}&y=${y}`;\r\n }\r\n\r\n /** @deprecated in 5.0 - might be removed in next major version. Use [addAttributions] instead. */\r\n public override addLogoCards(cards: HTMLTableElement): void {\r\n if (!cards.dataset.azureMapsLogoCard) {\r\n cards.dataset.azureMapsLogoCard = \"true\";\r\n cards.appendChild(IModelApp.makeLogoCard({ heading: \"Azure Maps\", notice: IModelApp.localization.getLocalizedString(\"iModelJs:BackgroundMap.AzureMapsCopyright\") }));\r\n }\r\n }\r\n\r\n public override async addAttributions(cards: HTMLTableElement, _vp: ScreenViewport): Promise<void> {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return Promise.resolve(this.addLogoCards(cards));\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"AzureMapsImageryProvider.js","sourceRoot":"","sources":["../../../src/AzureMaps/AzureMapsImageryProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AASH,kEAOC;AAbD,wDAAsK;AAEtK,gBAAgB;AACH,QAAA,iCAAiC,GAAG,kBAAkB,CAAC;AAEpE,gBAAgB;AAChB,SAAgB,2BAA2B,CAAC,SAAkC,EAAE,uBAAgC;IAC9G,mGAAmG;IACnG,uCAAuC;IACvC,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;QACvD,OAAO,SAAS,CAAC,KAAK,CAAC;IAEzB,OAAO,uBAAuB,KAAK,SAAS,IAAI,uBAAuB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3H,CAAC;AAED,MAAM,yBAA0B,SAAQ,KAAK;IAC3C;QACE,KAAK,CAAC,mCAAmC,yCAAiC,aAAa,CAAC,CAAC;IAC3F,CAAC;CACF;AAED;;;GAGG;AACH,MAAa,6BAA8B,SAAQ,uCAAuB;IACH;IAArE,YAAmB,QAA+B,EAAmB,gBAAyB;QAC5F,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAD6C,qBAAgB,GAAhB,gBAAgB,CAAS;IAE9F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,sBAAsB,EAAE,CAAC;YAEhC,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAEe,KAAK,CAAC,YAAY,CAAC,CAAS,EAAE,CAAS,EAAE,IAAY;QACnE,MAAM,eAAe,GAAG,2BAA2B,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACrG,IAAI,SAAS,KAAK,eAAe;YAC/B,MAAM,IAAI,yBAAyB,EAAE,CAAC;QAExC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,yCAAiC,IAAI,kBAAkB,CAAC,eAAe,CAAC,yBAAyB,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IACxJ,CAAC;IAED,kGAAkG;IAClF,YAAY,CAAC,KAAuB;QAClD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;YACrC,KAAK,CAAC,OAAO,CAAC,iBAAiB,GAAG,MAAM,CAAC;YACzC,KAAK,CAAC,WAAW,CAAC,yBAAS,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,yBAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,2CAA2C,CAAC,EAAE,CAAC,CAAC,CAAC;QACvK,CAAC;IACH,CAAC;IAEe,KAAK,CAAC,eAAe,CAAC,KAAuB,EAAE,GAAmB;QAChF,4DAA4D;QAC5D,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACnD,CAAC;CACF;AA3DD,sEA2DC","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 MapLayersFormats\r\n */\r\n\r\nimport { ImageMapLayerSettings, type ImageSource, type MapLayerKey } from \"@itwin/core-common\";\r\nimport { IModelApp, MapLayerImageryProvider, MapLayerImageryProviderStatus, NotifyMessageDetails, OutputMessagePriority, ScreenViewport } from \"@itwin/core-frontend\";\r\n\r\n/** @internal */\r\nexport const azureMapsSubscriptionKeyParameter = \"subscription-key\";\r\n\r\n/** @internal */\r\nexport function getAzureMapsSubscriptionKey(accessKey: MapLayerKey | undefined, fallbackSubscriptionKey?: string): string | undefined {\r\n // A layer access key takes precedence, but an empty value falls through to the configured fallback\r\n // rather than disabling auth outright.\r\n if (accessKey !== undefined && accessKey.value.length > 0)\r\n return accessKey.value;\r\n\r\n return fallbackSubscriptionKey !== undefined && fallbackSubscriptionKey.length > 0 ? fallbackSubscriptionKey : undefined;\r\n}\r\n\r\nclass AzureMapsRequireAuthError extends Error {\r\n public constructor() {\r\n super(`Azure Maps requires a non-empty ${azureMapsSubscriptionKeyParameter} credential`);\r\n }\r\n}\r\n\r\n/**\r\n * Azure Maps imagery provider.\r\n * @beta\r\n */\r\nexport class AzureMapsLayerImageryProvider extends MapLayerImageryProvider {\r\n public constructor(settings: ImageMapLayerSettings, private readonly _subscriptionKey?: string) {\r\n super(settings, true);\r\n }\r\n\r\n private reportAzureAuthFailure(): void {\r\n this.setStatus(MapLayerImageryProviderStatus.RequireAuth);\r\n if (this._hasSuccessfullyFetchedTile) {\r\n const msg = IModelApp.localization.getLocalizedString(\"iModelJs:MapLayers.Messages.LoadTileTokenError\", { layerName: this._settings.name });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Warning, msg));\r\n }\r\n }\r\n\r\n // The base loadTile marks `_hasSuccessfullyFetchedTile` as soon as a response is received, before\r\n // inspecting its status. Azure returns 401/403 for missing/invalid credentials, so this override\r\n // detects that before the success is recorded, ensuring no spurious token warning on the first fetch.\r\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\r\n try {\r\n const tileUrl = await this.constructUrl(row, column, zoomLevel);\r\n if (tileUrl.length === 0)\r\n return undefined;\r\n\r\n const tileResponse = await this.makeTileRequest(tileUrl);\r\n // A status in a response managed by the fetch handler is not classified here.\r\n if (!this.isManagedByHandler(tileResponse) && (tileResponse.status === 401 || tileResponse.status === 403)) {\r\n this.reportAzureAuthFailure();\r\n return undefined;\r\n }\r\n\r\n this._hasSuccessfullyFetchedTile = true;\r\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\r\n } catch (error) {\r\n if (error instanceof AzureMapsRequireAuthError)\r\n this.reportAzureAuthFailure();\r\n\r\n return undefined;\r\n }\r\n }\r\n\r\n public override async constructUrl(y: number, x: number, zoom: number): Promise<string> {\r\n const subscriptionKey = getAzureMapsSubscriptionKey(this._settings.accessKey, this._subscriptionKey);\r\n if (undefined === subscriptionKey)\r\n throw new AzureMapsRequireAuthError();\r\n\r\n return `${this._settings.url}&${azureMapsSubscriptionKeyParameter}=${encodeURIComponent(subscriptionKey)}&api-version=2.0&zoom=${zoom}&x=${x}&y=${y}`;\r\n }\r\n\r\n /** @deprecated in 5.0 - might be removed in next major version. Use [addAttributions] instead. */\r\n public override addLogoCards(cards: HTMLTableElement): void {\r\n if (!cards.dataset.azureMapsLogoCard) {\r\n cards.dataset.azureMapsLogoCard = \"true\";\r\n cards.appendChild(IModelApp.makeLogoCard({ heading: \"Azure Maps\", notice: IModelApp.localization.getLocalizedString(\"iModelJs:BackgroundMap.AzureMapsCopyright\") }));\r\n }\r\n }\r\n\r\n public override async addAttributions(cards: HTMLTableElement, _vp: ScreenViewport): Promise<void> {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return Promise.resolve(this.addLogoCards(cards));\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleMapsImageryProvider.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,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,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAIxD,OAAO,CAAC,gBAAgB;IAIF,eAAe,CAAC,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAiClG"}
@@ -182,7 +182,10 @@ class GoogleMapsImageryProvider extends core_frontend_1.MapLayerImageryProvider
182
182
  else {
183
183
  core_bentley_1.Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);
184
184
  }
185
- this._hadUnrecoverableError = true; // Prevent from doing more invalid requests
185
+ // A response managed by the fetch handler is not classified here: the handler reports failures
186
+ // by throwing MapLayerAuthenticationFailedError, and must not have the layer given up on.
187
+ if (!this.isManagedByHandler(tileResponse))
188
+ this._hadUnrecoverableError = true; // Prevent from doing more invalid requests
186
189
  return undefined;
187
190
  }
188
191
  }
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleMapsImageryProvider.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA0E;AAE1E,wDAA+K;AAE/K,uFAAwF;AACxF,uEAAiE;AAEjE,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAErD;;;EAGE;AACF,MAAa,yBAA0B,SAAQ,uCAAuB;IAE5D,UAAU,CAAsB;IAChC,sBAAsB,GAAG,KAAK,CAAC;IAC/B,SAAS,GAAG,GAAG,CAAC;IAChB,eAAe,CAA4B;IAC3C,eAAe,CAA2C;IAC1D,cAAc,CAAqB;IAC3C,YAAY,QAA+B,EAAE,cAAyC;QACpF,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,mCAAmB,EAAE,CAAC;QAC5C,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IACxC,CAAC;IACD,IAAoB,QAAQ,KAAa,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,C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G,MAAM,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;gBACrD,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;oBAC5B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;wBAC/B,4DAA4D;wBAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;wBAC5B,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;4BAC7C,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;4BAClB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;wBACtB,CAAC;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YACD,OAAO,KAAU,EAAE,CAAC;gBAClB,qBAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,qCAAqC,KAAK,EAAE,OAAO,IAAE,eAAe,EAAE,CAAC,CAAC;YAC1G,CAAC;QACH,CAAC;QAED,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,GAAG,GAAG,yBAAS,CAAC,UAAU,iCAAiC,CAAC;QACvE,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,oBAAoB,CAAC;QAE7C,KAAK,CAAC,WAAW,CAAC,yBAAS,CAAC,YAAY,CAAC;YACvC,OAAO;YACP,OAAO,EAAE,aAAa;YACtB,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AAxPD,8DAwPC","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 MapLayersFormats\r\n */\r\n\r\nimport { BentleyError, BentleyStatus, Logger } from \"@itwin/core-bentley\";\r\nimport { ImageMapLayerSettings, ImageSource } from \"@itwin/core-common\";\r\nimport { DecorateContext, GoogleMapsDecorator, IModelApp, MapCartoRectangle, MapLayerImageryProvider, MapTile, QuadIdProps, ScreenViewport, Tile } from \"@itwin/core-frontend\";\r\nimport { GoogleMapsCreateSessionOptions, GoogleMapsSession, GoogleMapsSessionManager, ViewportInfo } from \"./GoogleMapsSession.js\";\r\nimport { NativeGoogleMapsSessionManager } from \"../internal/NativeGoogleMapsSession.js\";\r\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils.js\";\r\n\r\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\r\n\r\n/*\r\n* Google Maps imagery provider\r\n* @beta\r\n*/\r\nexport class GoogleMapsImageryProvider extends MapLayerImageryProvider {\r\n\r\n private _decorator: GoogleMapsDecorator;\r\n private _hadUnrecoverableError = false;\r\n private _tileSize = 256;\r\n private _sessionManager?: GoogleMapsSessionManager;\r\n private _sessionOptions: GoogleMapsCreateSessionOptions|undefined;\r\n private _activeSession?: GoogleMapsSession;\r\n constructor(settings: ImageMapLayerSettings, sessionManager?: GoogleMapsSessionManager) {\r\n super(settings, true);\r\n this._decorator = new GoogleMapsDecorator();\r\n this._sessionManager = sessionManager;\r\n }\r\n public override get tileSize(): number { return this._tileSize; }\r\n\r\n public override async initialize(): Promise<void> {\r\n const sessionOptions = GoogleMapsUtils.getSessionOptionsFromMapLayer(this._settings);\r\n this._sessionOptions = sessionOptions;\r\n this._sessionManager = await this.getSessionManager();\r\n this._activeSession = await this._sessionManager.createSession(sessionOptions);\r\n this._tileSize = this._activeSession.getTileSize();\r\n const isActivated = await this._decorator.activate(sessionOptions.mapType);\r\n if (!isActivated) {\r\n const msg = `Failed to activate decorator`;\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n }\r\n\r\n protected async getSessionManager(): Promise<GoogleMapsSessionManager> {\r\n if (this._sessionManager)\r\n return this._sessionManager;\r\n\r\n if (this._settings.accessKey?.value) {\r\n return new NativeGoogleMapsSessionManager(this._settings.accessKey.value);\r\n } else {\r\n const msg = `Missing GoogleMaps api key`;\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n }\r\n\r\n protected createCreateSessionOptions(settings: ImageMapLayerSettings): GoogleMapsCreateSessionOptions {\r\n const requestedProperties = settings.properties;\r\n if (requestedProperties === undefined) {\r\n const msg = \"Missing session options\";\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n\r\n const layerPropertyKeys = Object.keys(requestedProperties);\r\n if (!layerPropertyKeys.includes(\"mapType\") ||\r\n !layerPropertyKeys.includes(\"language\") ||\r\n !layerPropertyKeys.includes(\"region\")) {\r\n const msg = \"Missing session options\";\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n\r\n const properties = this._settings.properties;\r\n if (properties === undefined) {\r\n const msg = \"Missing session options\";\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n\r\n const createSessionOptions: GoogleMapsCreateSessionOptions = {\r\n mapType: requestedProperties.mapType as GoogleMapsCreateSessionOptions[\"mapType\"],\r\n region: properties.region as string,\r\n language: properties.language as string,\r\n };\r\n\r\n if (Array.isArray(properties.layerTypes) && properties.layerTypes.length > 0) {\r\n createSessionOptions.layerTypes = properties.layerTypes as GoogleMapsCreateSessionOptions[\"layerTypes\"];\r\n }\r\n\r\n if (properties.scale !== undefined) {\r\n createSessionOptions.scale = properties.scale as GoogleMapsCreateSessionOptions[\"scale\"];\r\n }\r\n\r\n if (properties.overlay !== undefined) {\r\n createSessionOptions.overlay = properties.overlay as boolean;\r\n }\r\n\r\n if (properties.apiOptions !== undefined) {\r\n createSessionOptions.apiOptions = properties.apiOptions as string[];\r\n }\r\n\r\n return createSessionOptions;\r\n }\r\n\r\n // not used, see loadTile\r\n public async constructUrl(_row: number, _column: number, _level: number): Promise<string> {\r\n return \"\";\r\n }\r\n\r\n public async fetchViewportInfo(rectangle: MapCartoRectangle, zoomLevel: number): Promise<ViewportInfo> {\r\n if (!this._activeSession) {\r\n Logger.logError(loggerCategory, `Session is not initialized`);\r\n throw new BentleyError(BentleyStatus.ERROR, \"Session is not initialized\");\r\n }\r\n\r\n const req = this._activeSession.getViewportInfoRequest(rectangle, zoomLevel);\r\n const request = new Request(req.url, {method: \"GET\"});\r\n if (req.authorization) {\r\n request.headers.set(\"Authorization\", req.authorization);\r\n }\r\n // Add the session token to the request\r\n const response = await fetch(request);\r\n if (!response.ok) {\r\n Logger.logError(loggerCategory, `Error while loading viewport info: ${response.statusText}`);\r\n throw new BentleyError(BentleyStatus.ERROR, `Error while loading viewport info: ${response.statusText}`);\r\n }\r\n return response.json() as Promise<ViewportInfo>;\r\n }\r\n\r\n private async fetchAttributions(tiles: Set<Tile>): Promise<string[]> {\r\n const zooms = new Set<number>();\r\n const matchingAttributions: string[] = [];\r\n\r\n // Viewport info requests must be made for a specific zoom level\r\n tiles.forEach((tile) => zooms.add(tile.depth));\r\n\r\n for (const zoom of zooms) {\r\n let cartoRect: MapCartoRectangle|undefined;\r\n for (const tile of tiles) {\r\n if (tile.depth === zoom && tile instanceof MapTile) {\r\n const extent = this.getEPSG4326Extent(tile.quadId.row, tile.quadId.column, tile.depth);\r\n const rect = MapCartoRectangle.fromDegrees(extent.longitudeLeft, extent.latitudeBottom, extent.longitudeRight, extent.latitudeTop)\r\n if (cartoRect)\r\n cartoRect.union(rect);\r\n else\r\n cartoRect = rect;\r\n }\r\n }\r\n if (cartoRect && this._activeSession) {\r\n try {\r\n const viewportInfo = await this.fetchViewportInfo(cartoRect, zoom);\r\n if (viewportInfo?.copyright) {\r\n matchingAttributions.push(viewportInfo.copyright);\r\n }\r\n } catch (error:any) {\r\n Logger.logError(loggerCategory, `Error while loading viewport info: ${error?.message??\"Unknown error\"}`);\r\n }\r\n }\r\n }\r\n\r\n return matchingAttributions;\r\n }\r\n private async logJsonError(tileResponse: Response) {\r\n try {\r\n const error = await tileResponse.json();\r\n Logger.logError(loggerCategory, `Error while loading tile: ${error?.message}`);\r\n } catch {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n }\r\n }\r\n\r\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\r\n const tilePos: QuadIdProps = {row, column, level: zoomLevel};\r\n if (this._hadUnrecoverableError)\r\n return undefined;\r\n\r\n if (this._activeSession === undefined || this._sessionOptions === undefined) {\r\n Logger.logError(loggerCategory, `Session manager is not initialized`);\r\n return undefined;\r\n }\r\n\r\n try {\r\n let tileRequest = this._activeSession.getTileRequest(tilePos);\r\n let tileResponse: Response = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\r\n if (!tileResponse.ok) {\r\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\") && this._sessionManager) {\r\n try {\r\n // Session might have expired, lets try to refresh it\r\n this._activeSession = await this._sessionManager.createSession(this._sessionOptions);\r\n tileRequest = this._activeSession.getTileRequest(tilePos);\r\n tileResponse = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\r\n if (!tileResponse.ok) {\r\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\")) {\r\n await this.logJsonError(tileResponse);\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n }\r\n this._hadUnrecoverableError = true; // Prevent from doing more invalid requests\r\n return undefined;\r\n }\r\n }\r\n catch {\r\n await this.logJsonError(tileResponse);\r\n }\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n return undefined;\r\n }\r\n }\r\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\r\n } catch (error: any) {\r\n if (error?.code === 401) {\r\n Logger.logError(loggerCategory, `Authorize to load tile: ${error.message}`);\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${error.message}`);\r\n }\r\n return undefined;\r\n }\r\n }\r\n\r\n public override decorate(context: DecorateContext): void {\r\n this._decorator.decorate(context);\r\n }\r\n\r\n private getSelectedTiles(vp: ScreenViewport) {\r\n return IModelApp.tileAdmin.getTilesForUser(vp)?.selected;\r\n }\r\n\r\n public override async addAttributions(cards: HTMLTableElement, vp: ScreenViewport): Promise<void> {\r\n const lines: string[] = [];\r\n const seen = new Set<string>();\r\n const tiles = this.getSelectedTiles(vp);\r\n if (tiles) {\r\n try {\r\n const attrList = await this.fetchAttributions(tiles);\r\n for (const attr of attrList) {\r\n attr.split(\",\").forEach((line) => {\r\n // The same info is often returned for multiple zoom levels.\r\n const trimmed = line.trim();\r\n if (trimmed.length > 0 && !seen.has(trimmed)) {\r\n seen.add(trimmed);\r\n lines.push(trimmed);\r\n }\r\n });\r\n }\r\n }\r\n catch (error: any) {\r\n Logger.logError(loggerCategory, `Error while loading attributions: ${error?.message??\"Unknown error\"}`);\r\n }\r\n }\r\n\r\n const iconSrc = document.createElement(\"img\");\r\n iconSrc.src = `${IModelApp.publicPath}images/GoogleMaps_Logo_Gray.svg`;\r\n iconSrc.style.padding = \"10px 10px 5px 10px\";\r\n\r\n cards.appendChild(IModelApp.makeLogoCard({\r\n iconSrc,\r\n heading: \"Google Maps\",\r\n noticeLines: lines\r\n }));\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"GoogleMapsImageryProvider.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA0E;AAE1E,wDAA+K;AAE/K,uFAAwF;AACxF,uEAAiE;AAEjE,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAErD;;;EAGE;AACF,MAAa,yBAA0B,SAAQ,uCAAuB;IAE5D,UAAU,CAAsB;IAChC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AAC,GAAG,GAAG,GAAG,yBAAS,CAAC,UAAU,iCAAiC,CAAC;QACvE,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,oBAAoB,CAAC;QAE7C,KAAK,CAAC,WAAW,CAAC,yBAAS,CAAC,YAAY,CAAC;YACvC,OAAO;YACP,OAAO,EAAE,aAAa;YACtB,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AA3PD,8DA2PC","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 MapLayersFormats\r\n */\r\n\r\nimport { BentleyError, BentleyStatus, Logger } from \"@itwin/core-bentley\";\r\nimport { ImageMapLayerSettings, ImageSource } from \"@itwin/core-common\";\r\nimport { DecorateContext, GoogleMapsDecorator, IModelApp, MapCartoRectangle, MapLayerImageryProvider, MapTile, QuadIdProps, ScreenViewport, Tile } from \"@itwin/core-frontend\";\r\nimport { GoogleMapsCreateSessionOptions, GoogleMapsSession, GoogleMapsSessionManager, ViewportInfo } from \"./GoogleMapsSession.js\";\r\nimport { NativeGoogleMapsSessionManager } from \"../internal/NativeGoogleMapsSession.js\";\r\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils.js\";\r\n\r\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\r\n\r\n/*\r\n* Google Maps imagery provider\r\n* @beta\r\n*/\r\nexport class GoogleMapsImageryProvider extends MapLayerImageryProvider {\r\n\r\n private _decorator: GoogleMapsDecorator;\r\n private _hadUnrecoverableError = false;\r\n private _tileSize = 256;\r\n private _sessionManager?: GoogleMapsSessionManager;\r\n private _sessionOptions: GoogleMapsCreateSessionOptions|undefined;\r\n private _activeSession?: GoogleMapsSession;\r\n constructor(settings: ImageMapLayerSettings, sessionManager?: GoogleMapsSessionManager) {\r\n super(settings, true);\r\n this._decorator = new GoogleMapsDecorator();\r\n this._sessionManager = sessionManager;\r\n }\r\n public override get tileSize(): number { return this._tileSize; }\r\n\r\n public override async initialize(): Promise<void> {\r\n const sessionOptions = GoogleMapsUtils.getSessionOptionsFromMapLayer(this._settings);\r\n this._sessionOptions = sessionOptions;\r\n this._sessionManager = await this.getSessionManager();\r\n this._activeSession = await this._sessionManager.createSession(sessionOptions);\r\n this._tileSize = this._activeSession.getTileSize();\r\n const isActivated = await this._decorator.activate(sessionOptions.mapType);\r\n if (!isActivated) {\r\n const msg = `Failed to activate decorator`;\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n }\r\n\r\n protected async getSessionManager(): Promise<GoogleMapsSessionManager> {\r\n if (this._sessionManager)\r\n return this._sessionManager;\r\n\r\n if (this._settings.accessKey?.value) {\r\n return new NativeGoogleMapsSessionManager(this._settings.accessKey.value);\r\n } else {\r\n const msg = `Missing GoogleMaps api key`;\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n }\r\n\r\n protected createCreateSessionOptions(settings: ImageMapLayerSettings): GoogleMapsCreateSessionOptions {\r\n const requestedProperties = settings.properties;\r\n if (requestedProperties === undefined) {\r\n const msg = \"Missing session options\";\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n\r\n const layerPropertyKeys = Object.keys(requestedProperties);\r\n if (!layerPropertyKeys.includes(\"mapType\") ||\r\n !layerPropertyKeys.includes(\"language\") ||\r\n !layerPropertyKeys.includes(\"region\")) {\r\n const msg = \"Missing session options\";\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n\r\n const properties = this._settings.properties;\r\n if (properties === undefined) {\r\n const msg = \"Missing session options\";\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n\r\n const createSessionOptions: GoogleMapsCreateSessionOptions = {\r\n mapType: requestedProperties.mapType as GoogleMapsCreateSessionOptions[\"mapType\"],\r\n region: properties.region as string,\r\n language: properties.language as string,\r\n };\r\n\r\n if (Array.isArray(properties.layerTypes) && properties.layerTypes.length > 0) {\r\n createSessionOptions.layerTypes = properties.layerTypes as GoogleMapsCreateSessionOptions[\"layerTypes\"];\r\n }\r\n\r\n if (properties.scale !== undefined) {\r\n createSessionOptions.scale = properties.scale as GoogleMapsCreateSessionOptions[\"scale\"];\r\n }\r\n\r\n if (properties.overlay !== undefined) {\r\n createSessionOptions.overlay = properties.overlay as boolean;\r\n }\r\n\r\n if (properties.apiOptions !== undefined) {\r\n createSessionOptions.apiOptions = properties.apiOptions as string[];\r\n }\r\n\r\n return createSessionOptions;\r\n }\r\n\r\n // not used, see loadTile\r\n public async constructUrl(_row: number, _column: number, _level: number): Promise<string> {\r\n return \"\";\r\n }\r\n\r\n public async fetchViewportInfo(rectangle: MapCartoRectangle, zoomLevel: number): Promise<ViewportInfo> {\r\n if (!this._activeSession) {\r\n Logger.logError(loggerCategory, `Session is not initialized`);\r\n throw new BentleyError(BentleyStatus.ERROR, \"Session is not initialized\");\r\n }\r\n\r\n const req = this._activeSession.getViewportInfoRequest(rectangle, zoomLevel);\r\n const request = new Request(req.url, {method: \"GET\"});\r\n if (req.authorization) {\r\n request.headers.set(\"Authorization\", req.authorization);\r\n }\r\n // Add the session token to the request\r\n const response = await fetch(request);\r\n if (!response.ok) {\r\n Logger.logError(loggerCategory, `Error while loading viewport info: ${response.statusText}`);\r\n throw new BentleyError(BentleyStatus.ERROR, `Error while loading viewport info: ${response.statusText}`);\r\n }\r\n return response.json() as Promise<ViewportInfo>;\r\n }\r\n\r\n private async fetchAttributions(tiles: Set<Tile>): Promise<string[]> {\r\n const zooms = new Set<number>();\r\n const matchingAttributions: string[] = [];\r\n\r\n // Viewport info requests must be made for a specific zoom level\r\n tiles.forEach((tile) => zooms.add(tile.depth));\r\n\r\n for (const zoom of zooms) {\r\n let cartoRect: MapCartoRectangle|undefined;\r\n for (const tile of tiles) {\r\n if (tile.depth === zoom && tile instanceof MapTile) {\r\n const extent = this.getEPSG4326Extent(tile.quadId.row, tile.quadId.column, tile.depth);\r\n const rect = MapCartoRectangle.fromDegrees(extent.longitudeLeft, extent.latitudeBottom, extent.longitudeRight, extent.latitudeTop)\r\n if (cartoRect)\r\n cartoRect.union(rect);\r\n else\r\n cartoRect = rect;\r\n }\r\n }\r\n if (cartoRect && this._activeSession) {\r\n try {\r\n const viewportInfo = await this.fetchViewportInfo(cartoRect, zoom);\r\n if (viewportInfo?.copyright) {\r\n matchingAttributions.push(viewportInfo.copyright);\r\n }\r\n } catch (error:any) {\r\n Logger.logError(loggerCategory, `Error while loading viewport info: ${error?.message??\"Unknown error\"}`);\r\n }\r\n }\r\n }\r\n\r\n return matchingAttributions;\r\n }\r\n private async logJsonError(tileResponse: Response) {\r\n try {\r\n const error = await tileResponse.json();\r\n Logger.logError(loggerCategory, `Error while loading tile: ${error?.message}`);\r\n } catch {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n }\r\n }\r\n\r\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\r\n const tilePos: QuadIdProps = {row, column, level: zoomLevel};\r\n if (this._hadUnrecoverableError)\r\n return undefined;\r\n\r\n if (this._activeSession === undefined || this._sessionOptions === undefined) {\r\n Logger.logError(loggerCategory, `Session manager is not initialized`);\r\n return undefined;\r\n }\r\n\r\n try {\r\n let tileRequest = this._activeSession.getTileRequest(tilePos);\r\n let tileResponse: Response = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\r\n if (!tileResponse.ok) {\r\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\") && this._sessionManager) {\r\n try {\r\n // Session might have expired, lets try to refresh it\r\n this._activeSession = await this._sessionManager.createSession(this._sessionOptions);\r\n tileRequest = this._activeSession.getTileRequest(tilePos);\r\n tileResponse = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\r\n if (!tileResponse.ok) {\r\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\")) {\r\n await this.logJsonError(tileResponse);\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n }\r\n // A response managed by the fetch handler is not classified here: the handler reports failures\r\n // by throwing MapLayerAuthenticationFailedError, and must not have the layer given up on.\r\n if (!this.isManagedByHandler(tileResponse))\r\n this._hadUnrecoverableError = true; // Prevent from doing more invalid requests\r\n return undefined;\r\n }\r\n }\r\n catch {\r\n await this.logJsonError(tileResponse);\r\n }\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n return undefined;\r\n }\r\n }\r\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\r\n } catch (error: any) {\r\n if (error?.code === 401) {\r\n Logger.logError(loggerCategory, `Authorize to load tile: ${error.message}`);\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${error.message}`);\r\n }\r\n return undefined;\r\n }\r\n }\r\n\r\n public override decorate(context: DecorateContext): void {\r\n this._decorator.decorate(context);\r\n }\r\n\r\n private getSelectedTiles(vp: ScreenViewport) {\r\n return IModelApp.tileAdmin.getTilesForUser(vp)?.selected;\r\n }\r\n\r\n public override async addAttributions(cards: HTMLTableElement, vp: ScreenViewport): Promise<void> {\r\n const lines: string[] = [];\r\n const seen = new Set<string>();\r\n const tiles = this.getSelectedTiles(vp);\r\n if (tiles) {\r\n try {\r\n const attrList = await this.fetchAttributions(tiles);\r\n for (const attr of attrList) {\r\n attr.split(\",\").forEach((line) => {\r\n // The same info is often returned for multiple zoom levels.\r\n const trimmed = line.trim();\r\n if (trimmed.length > 0 && !seen.has(trimmed)) {\r\n seen.add(trimmed);\r\n lines.push(trimmed);\r\n }\r\n });\r\n }\r\n }\r\n catch (error: any) {\r\n Logger.logError(loggerCategory, `Error while loading attributions: ${error?.message??\"Unknown error\"}`);\r\n }\r\n }\r\n\r\n const iconSrc = document.createElement(\"img\");\r\n iconSrc.src = `${IModelApp.publicPath}images/GoogleMaps_Logo_Gray.svg`;\r\n iconSrc.style.padding = \"10px 10px 5px 10px\";\r\n\r\n cards.appendChild(IModelApp.makeLogoCard({\r\n iconSrc,\r\n heading: \"Google Maps\",\r\n noticeLines: lines\r\n }));\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"OgcApiFeaturesFormat.d.ts","sourceRoot":"","sources":["../../../src/OgcApiFeatures/OgcApiFeaturesFormat.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAoB,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAqB,qBAAqB,EAAa,uBAAuB,EAAwB,wBAAwB,EAAyB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/M,gBAAgB;AAChB,qBAAa,4BAA6B,SAAQ,qBAAqB;IACrE,OAAuB,QAAQ,SAAoB;WAC5B,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,uBAAuB,GAAG,SAAS;WAErF,QAAQ,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,wBAAwB,CAAC;CAiInG"}
1
+ {"version":3,"file":"OgcApiFeaturesFormat.d.ts","sourceRoot":"","sources":["../../../src/OgcApiFeatures/OgcApiFeaturesFormat.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAoB,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAsE,qBAAqB,EAAqE,uBAAuB,EAAwB,wBAAwB,EAAyB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAGxT,gBAAgB;AAChB,qBAAa,4BAA6B,SAAQ,qBAAqB;IACrE,OAAuB,QAAQ,SAAoB;WAC5B,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,uBAAuB,GAAG,SAAS;WAErF,QAAQ,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,wBAAwB,CAAC;CAmJnG"}