@itwin/core-frontend 4.4.0-dev.8 → 4.5.0-dev.0

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 (204) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/lib/cjs/DisplayStyleState.d.ts +3 -0
  3. package/lib/cjs/DisplayStyleState.d.ts.map +1 -1
  4. package/lib/cjs/DisplayStyleState.js +10 -0
  5. package/lib/cjs/DisplayStyleState.js.map +1 -1
  6. package/lib/cjs/Viewport.d.ts +5 -0
  7. package/lib/cjs/Viewport.d.ts.map +1 -1
  8. package/lib/cjs/Viewport.js +6 -0
  9. package/lib/cjs/Viewport.js.map +1 -1
  10. package/lib/cjs/common/gltf/GltfSchema.d.ts +20 -3
  11. package/lib/cjs/common/gltf/GltfSchema.d.ts.map +1 -1
  12. package/lib/cjs/common/gltf/GltfSchema.js.map +1 -1
  13. package/lib/cjs/common/imdl/ImdlModel.d.ts +15 -1
  14. package/lib/cjs/common/imdl/ImdlModel.d.ts.map +1 -1
  15. package/lib/cjs/common/imdl/ImdlModel.js +11 -3
  16. package/lib/cjs/common/imdl/ImdlModel.js.map +1 -1
  17. package/lib/cjs/common/imdl/ParseImdlDocument.d.ts +3 -1
  18. package/lib/cjs/common/imdl/ParseImdlDocument.d.ts.map +1 -1
  19. package/lib/cjs/common/imdl/ParseImdlDocument.js +66 -11
  20. package/lib/cjs/common/imdl/ParseImdlDocument.js.map +1 -1
  21. package/lib/cjs/render/GraphicBranch.d.ts +10 -0
  22. package/lib/cjs/render/GraphicBranch.d.ts.map +1 -1
  23. package/lib/cjs/render/GraphicBranch.js.map +1 -1
  24. package/lib/cjs/render/webgl/BranchState.d.ts +2 -0
  25. package/lib/cjs/render/webgl/BranchState.d.ts.map +1 -1
  26. package/lib/cjs/render/webgl/BranchState.js +2 -0
  27. package/lib/cjs/render/webgl/BranchState.js.map +1 -1
  28. package/lib/cjs/render/webgl/Graphic.d.ts.map +1 -1
  29. package/lib/cjs/render/webgl/Graphic.js +3 -0
  30. package/lib/cjs/render/webgl/Graphic.js.map +1 -1
  31. package/lib/cjs/render/webgl/InstancedGeometry.d.ts +1 -0
  32. package/lib/cjs/render/webgl/InstancedGeometry.d.ts.map +1 -1
  33. package/lib/cjs/render/webgl/InstancedGeometry.js +1 -0
  34. package/lib/cjs/render/webgl/InstancedGeometry.js.map +1 -1
  35. package/lib/cjs/request/utils.d.ts +18 -0
  36. package/lib/cjs/request/utils.d.ts.map +1 -0
  37. package/lib/cjs/request/utils.js +45 -0
  38. package/lib/cjs/request/utils.js.map +1 -0
  39. package/lib/cjs/tile/BatchedTileIdMap.d.ts +1 -2
  40. package/lib/cjs/tile/BatchedTileIdMap.d.ts.map +1 -1
  41. package/lib/cjs/tile/BatchedTileIdMap.js +3 -3
  42. package/lib/cjs/tile/BatchedTileIdMap.js.map +1 -1
  43. package/lib/cjs/tile/GltfReader.d.ts +4 -1
  44. package/lib/cjs/tile/GltfReader.d.ts.map +1 -1
  45. package/lib/cjs/tile/GltfReader.js +125 -26
  46. package/lib/cjs/tile/GltfReader.js.map +1 -1
  47. package/lib/cjs/tile/ImdlDecoder.d.ts +7 -1
  48. package/lib/cjs/tile/ImdlDecoder.d.ts.map +1 -1
  49. package/lib/cjs/tile/ImdlDecoder.js.map +1 -1
  50. package/lib/cjs/tile/ImdlGraphicsCreator.d.ts.map +1 -1
  51. package/lib/cjs/tile/ImdlGraphicsCreator.js +28 -17
  52. package/lib/cjs/tile/ImdlGraphicsCreator.js.map +1 -1
  53. package/lib/cjs/tile/ImdlReader.d.ts +2 -1
  54. package/lib/cjs/tile/ImdlReader.d.ts.map +1 -1
  55. package/lib/cjs/tile/ImdlReader.js +1 -0
  56. package/lib/cjs/tile/ImdlReader.js.map +1 -1
  57. package/lib/cjs/tile/RealityModelTileTree.d.ts.map +1 -1
  58. package/lib/cjs/tile/RealityModelTileTree.js +2 -3
  59. package/lib/cjs/tile/RealityModelTileTree.js.map +1 -1
  60. package/lib/cjs/tile/RealityTileTree.d.ts +31 -0
  61. package/lib/cjs/tile/RealityTileTree.d.ts.map +1 -1
  62. package/lib/cjs/tile/RealityTileTree.js +6 -0
  63. package/lib/cjs/tile/RealityTileTree.js.map +1 -1
  64. package/lib/cjs/tile/TileDrawArgs.d.ts +6 -0
  65. package/lib/cjs/tile/TileDrawArgs.d.ts.map +1 -1
  66. package/lib/cjs/tile/TileDrawArgs.js +7 -0
  67. package/lib/cjs/tile/TileDrawArgs.js.map +1 -1
  68. package/lib/cjs/tile/TileTreeReference.d.ts +2 -0
  69. package/lib/cjs/tile/TileTreeReference.d.ts.map +1 -1
  70. package/lib/cjs/tile/TileTreeReference.js +5 -0
  71. package/lib/cjs/tile/TileTreeReference.js.map +1 -1
  72. package/lib/cjs/tile/map/ArcGISTileMap.d.ts +6 -2
  73. package/lib/cjs/tile/map/ArcGISTileMap.d.ts.map +1 -1
  74. package/lib/cjs/tile/map/ArcGISTileMap.js +127 -69
  75. package/lib/cjs/tile/map/ArcGISTileMap.js.map +1 -1
  76. package/lib/cjs/tile/map/ArcGisUtilities.d.ts.map +1 -1
  77. package/lib/cjs/tile/map/ArcGisUtilities.js +5 -0
  78. package/lib/cjs/tile/map/ArcGisUtilities.js.map +1 -1
  79. package/lib/cjs/tile/map/ImageryProviders/ArcGISImageryProvider.d.ts.map +1 -1
  80. package/lib/cjs/tile/map/ImageryProviders/ArcGISImageryProvider.js +61 -39
  81. package/lib/cjs/tile/map/ImageryProviders/ArcGISImageryProvider.js.map +1 -1
  82. package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +1 -1
  83. package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
  84. package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts +6 -0
  85. package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts.map +1 -1
  86. package/lib/cjs/tile/map/MapLayerImageryProvider.js +47 -7
  87. package/lib/cjs/tile/map/MapLayerImageryProvider.js.map +1 -1
  88. package/lib/cjs/tile/map/WmsCapabilities.d.ts.map +1 -1
  89. package/lib/cjs/tile/map/WmsCapabilities.js +1 -15
  90. package/lib/cjs/tile/map/WmsCapabilities.js.map +1 -1
  91. package/lib/cjs/tile/map/WmsUtilities.d.ts +7 -0
  92. package/lib/cjs/tile/map/WmsUtilities.d.ts.map +1 -1
  93. package/lib/cjs/tile/map/WmsUtilities.js +22 -0
  94. package/lib/cjs/tile/map/WmsUtilities.js.map +1 -1
  95. package/lib/cjs/tile/map/WmtsCapabilities.d.ts.map +1 -1
  96. package/lib/cjs/tile/map/WmtsCapabilities.js +2 -16
  97. package/lib/cjs/tile/map/WmtsCapabilities.js.map +1 -1
  98. package/lib/cjs/tools/SelectTool.d.ts +1 -0
  99. package/lib/cjs/tools/SelectTool.d.ts.map +1 -1
  100. package/lib/cjs/tools/SelectTool.js +19 -13
  101. package/lib/cjs/tools/SelectTool.js.map +1 -1
  102. package/lib/esm/DisplayStyleState.d.ts +3 -0
  103. package/lib/esm/DisplayStyleState.d.ts.map +1 -1
  104. package/lib/esm/DisplayStyleState.js +10 -0
  105. package/lib/esm/DisplayStyleState.js.map +1 -1
  106. package/lib/esm/Viewport.d.ts +5 -0
  107. package/lib/esm/Viewport.d.ts.map +1 -1
  108. package/lib/esm/Viewport.js +6 -0
  109. package/lib/esm/Viewport.js.map +1 -1
  110. package/lib/esm/common/gltf/GltfSchema.d.ts +20 -3
  111. package/lib/esm/common/gltf/GltfSchema.d.ts.map +1 -1
  112. package/lib/esm/common/gltf/GltfSchema.js.map +1 -1
  113. package/lib/esm/common/imdl/ImdlModel.d.ts +15 -1
  114. package/lib/esm/common/imdl/ImdlModel.d.ts.map +1 -1
  115. package/lib/esm/common/imdl/ImdlModel.js +11 -3
  116. package/lib/esm/common/imdl/ImdlModel.js.map +1 -1
  117. package/lib/esm/common/imdl/ParseImdlDocument.d.ts +3 -1
  118. package/lib/esm/common/imdl/ParseImdlDocument.d.ts.map +1 -1
  119. package/lib/esm/common/imdl/ParseImdlDocument.js +67 -12
  120. package/lib/esm/common/imdl/ParseImdlDocument.js.map +1 -1
  121. package/lib/esm/render/GraphicBranch.d.ts +10 -0
  122. package/lib/esm/render/GraphicBranch.d.ts.map +1 -1
  123. package/lib/esm/render/GraphicBranch.js.map +1 -1
  124. package/lib/esm/render/webgl/BranchState.d.ts +2 -0
  125. package/lib/esm/render/webgl/BranchState.d.ts.map +1 -1
  126. package/lib/esm/render/webgl/BranchState.js +2 -0
  127. package/lib/esm/render/webgl/BranchState.js.map +1 -1
  128. package/lib/esm/render/webgl/Graphic.d.ts.map +1 -1
  129. package/lib/esm/render/webgl/Graphic.js +3 -0
  130. package/lib/esm/render/webgl/Graphic.js.map +1 -1
  131. package/lib/esm/render/webgl/InstancedGeometry.d.ts +1 -0
  132. package/lib/esm/render/webgl/InstancedGeometry.d.ts.map +1 -1
  133. package/lib/esm/render/webgl/InstancedGeometry.js +1 -0
  134. package/lib/esm/render/webgl/InstancedGeometry.js.map +1 -1
  135. package/lib/esm/request/utils.d.ts +18 -0
  136. package/lib/esm/request/utils.d.ts.map +1 -0
  137. package/lib/esm/request/utils.js +40 -0
  138. package/lib/esm/request/utils.js.map +1 -0
  139. package/lib/esm/tile/BatchedTileIdMap.d.ts +1 -2
  140. package/lib/esm/tile/BatchedTileIdMap.d.ts.map +1 -1
  141. package/lib/esm/tile/BatchedTileIdMap.js +3 -3
  142. package/lib/esm/tile/BatchedTileIdMap.js.map +1 -1
  143. package/lib/esm/tile/GltfReader.d.ts +4 -1
  144. package/lib/esm/tile/GltfReader.d.ts.map +1 -1
  145. package/lib/esm/tile/GltfReader.js +126 -27
  146. package/lib/esm/tile/GltfReader.js.map +1 -1
  147. package/lib/esm/tile/ImdlDecoder.d.ts +7 -1
  148. package/lib/esm/tile/ImdlDecoder.d.ts.map +1 -1
  149. package/lib/esm/tile/ImdlDecoder.js.map +1 -1
  150. package/lib/esm/tile/ImdlGraphicsCreator.d.ts.map +1 -1
  151. package/lib/esm/tile/ImdlGraphicsCreator.js +28 -17
  152. package/lib/esm/tile/ImdlGraphicsCreator.js.map +1 -1
  153. package/lib/esm/tile/ImdlReader.d.ts +2 -1
  154. package/lib/esm/tile/ImdlReader.d.ts.map +1 -1
  155. package/lib/esm/tile/ImdlReader.js +1 -0
  156. package/lib/esm/tile/ImdlReader.js.map +1 -1
  157. package/lib/esm/tile/RealityModelTileTree.d.ts.map +1 -1
  158. package/lib/esm/tile/RealityModelTileTree.js +2 -3
  159. package/lib/esm/tile/RealityModelTileTree.js.map +1 -1
  160. package/lib/esm/tile/RealityTileTree.d.ts +31 -0
  161. package/lib/esm/tile/RealityTileTree.d.ts.map +1 -1
  162. package/lib/esm/tile/RealityTileTree.js +6 -0
  163. package/lib/esm/tile/RealityTileTree.js.map +1 -1
  164. package/lib/esm/tile/TileDrawArgs.d.ts +6 -0
  165. package/lib/esm/tile/TileDrawArgs.d.ts.map +1 -1
  166. package/lib/esm/tile/TileDrawArgs.js +8 -1
  167. package/lib/esm/tile/TileDrawArgs.js.map +1 -1
  168. package/lib/esm/tile/TileTreeReference.d.ts +2 -0
  169. package/lib/esm/tile/TileTreeReference.d.ts.map +1 -1
  170. package/lib/esm/tile/TileTreeReference.js +5 -0
  171. package/lib/esm/tile/TileTreeReference.js.map +1 -1
  172. package/lib/esm/tile/map/ArcGISTileMap.d.ts +6 -2
  173. package/lib/esm/tile/map/ArcGISTileMap.d.ts.map +1 -1
  174. package/lib/esm/tile/map/ArcGISTileMap.js +130 -71
  175. package/lib/esm/tile/map/ArcGISTileMap.js.map +1 -1
  176. package/lib/esm/tile/map/ArcGisUtilities.d.ts.map +1 -1
  177. package/lib/esm/tile/map/ArcGisUtilities.js +5 -0
  178. package/lib/esm/tile/map/ArcGisUtilities.js.map +1 -1
  179. package/lib/esm/tile/map/ImageryProviders/ArcGISImageryProvider.d.ts.map +1 -1
  180. package/lib/esm/tile/map/ImageryProviders/ArcGISImageryProvider.js +61 -39
  181. package/lib/esm/tile/map/ImageryProviders/ArcGISImageryProvider.js.map +1 -1
  182. package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +1 -1
  183. package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
  184. package/lib/esm/tile/map/MapLayerImageryProvider.d.ts +6 -0
  185. package/lib/esm/tile/map/MapLayerImageryProvider.d.ts.map +1 -1
  186. package/lib/esm/tile/map/MapLayerImageryProvider.js +48 -8
  187. package/lib/esm/tile/map/MapLayerImageryProvider.js.map +1 -1
  188. package/lib/esm/tile/map/WmsCapabilities.d.ts.map +1 -1
  189. package/lib/esm/tile/map/WmsCapabilities.js +1 -15
  190. package/lib/esm/tile/map/WmsCapabilities.js.map +1 -1
  191. package/lib/esm/tile/map/WmsUtilities.d.ts +7 -0
  192. package/lib/esm/tile/map/WmsUtilities.d.ts.map +1 -1
  193. package/lib/esm/tile/map/WmsUtilities.js +22 -0
  194. package/lib/esm/tile/map/WmsUtilities.js.map +1 -1
  195. package/lib/esm/tile/map/WmtsCapabilities.d.ts.map +1 -1
  196. package/lib/esm/tile/map/WmtsCapabilities.js +2 -16
  197. package/lib/esm/tile/map/WmtsCapabilities.js.map +1 -1
  198. package/lib/esm/tools/SelectTool.d.ts +1 -0
  199. package/lib/esm/tools/SelectTool.d.ts.map +1 -1
  200. package/lib/esm/tools/SelectTool.js +19 -13
  201. package/lib/esm/tools/SelectTool.js.map +1 -1
  202. package/lib/public/scripts/parse-imdl-worker.js +1 -1
  203. package/lib/workers/webpack/parse-imdl-worker.js +1 -1
  204. package/package.json +20 -19
@@ -11,6 +11,7 @@ exports.ArcGISImageryProvider = void 0;
11
11
  const internal_1 = require("../../internal");
12
12
  const IModelApp_1 = require("../../../IModelApp");
13
13
  const NotificationManager_1 = require("../../../NotificationManager");
14
+ const utils_1 = require("../../../request/utils");
14
15
  /** Base class for ArcGIS map-layer imagery providers.
15
16
  *
16
17
  * The initial purpose of this class is to offer shared methods
@@ -90,50 +91,71 @@ class ArcGISImageryProvider extends internal_1.MapLayerImageryProvider {
90
91
  password: this._settings.password
91
92
  });
92
93
  }
93
- let response = await fetch(urlObj.toString(), options);
94
- if ((this._lastAccessToken && response.status === 400)
95
- || response.headers.get("content-type")?.toLowerCase().includes("htm")) {
96
- // For some reasons when we make a request with the fetch() api and there is a token error
97
- // we receive a status 400 instead of proper json response. (i.e doing the same request in the browser gives a different response)
98
- // For some other request, we also seen error message in html.
99
- // When it occurs, we fall back to root service request so we get a proper JSON response with error code.
100
- const tmpUrl = new URL(this._settings.url);
101
- if (this._lastAccessToken && this._accessTokenRequired)
102
- tmpUrl.searchParams.append("token", this._lastAccessToken.token);
103
- tmpUrl.searchParams.append("f", "json");
104
- response = await fetch(tmpUrl.toString(), options);
105
- }
106
- errorCode = await internal_1.ArcGisUtilities.checkForResponseErrorCode(response);
107
- if (errorCode !== undefined &&
108
- (errorCode === internal_1.ArcGisErrorCode.TokenRequired || errorCode === internal_1.ArcGisErrorCode.InvalidToken)) {
109
- if (this._settings.userName && this._settings.userName.length > 0 && this._lastAccessToken) {
110
- // **** Legacy token ONLY ***
111
- // Token might have expired, make a second attempt by forcing new token.
112
- if (this._accessClient?.invalidateToken !== undefined && this._lastAccessToken !== undefined)
113
- this._accessClient.invalidateToken(this._lastAccessToken);
114
- const urlObj2 = new URL(url);
115
- if (this._accessClient) {
116
- try {
117
- this._lastAccessToken = await internal_1.ArcGisUtilities.appendSecurityToken(urlObj, this._accessClient, { mapLayerUrl: urlObj, userName: this._settings.userName, password: this._settings.password });
118
- }
119
- catch {
120
- }
94
+ // We want to complete the first request before letting other requests go;
95
+ // this done to avoid flooding server with requests missing credentials
96
+ if (!this._firstRequestPromise)
97
+ this._firstRequestPromise = new Promise((resolve) => this.onFirstRequestCompleted.addOnce(() => resolve()));
98
+ else
99
+ await this._firstRequestPromise;
100
+ let response;
101
+ try {
102
+ response = await fetch(urlObj.toString(), { ...options, credentials: this._includeUserCredentials ? "include" : undefined });
103
+ if (response.status === 401 && !this._lastAccessToken && (0, utils_1.headersIncludeAuthMethod)(response.headers, ["ntlm", "negotiate"])) {
104
+ // We got a http 401 challenge, lets try again with SSO enabled (i.e. Windows Authentication)
105
+ response = await fetch(url, { ...options, credentials: "include" });
106
+ if (response.status === 200) {
107
+ this._includeUserCredentials = true; // avoid going through 401 challenges over and over
121
108
  }
122
- // Make a second attempt with refreshed token
123
- response = await fetch(urlObj2.toString(), options);
124
- errorCode = await internal_1.ArcGisUtilities.checkForResponseErrorCode(response);
125
109
  }
126
- if (errorCode === internal_1.ArcGisErrorCode.TokenRequired || errorCode === internal_1.ArcGisErrorCode.InvalidToken) {
127
- // Looks like the initially generated token has expired.
128
- if (this.status === internal_1.MapLayerImageryProviderStatus.Valid) {
129
- // Only report new status change to avoid spamming the UI
130
- this.setStatus(internal_1.MapLayerImageryProviderStatus.RequireAuth);
131
- this.onStatusChanged.raiseEvent(this);
132
- const msg = IModelApp_1.IModelApp.localization.getLocalizedString("iModelJs:MapLayers.Messages.FetchTooltipTokenError", { layerName: this._settings.name });
133
- IModelApp_1.IModelApp.notifications.outputMessage(new NotificationManager_1.NotifyMessageDetails(NotificationManager_1.OutputMessagePriority.Warning, msg));
110
+ if ((this._lastAccessToken && response.status === 400)
111
+ || response.headers.get("content-type")?.toLowerCase().includes("htm")) {
112
+ // For some reasons when we make a request with the fetch() api and there is a token error
113
+ // we receive a status 400 instead of proper json response. (i.e doing the same request in the browser gives a different response)
114
+ // For some other request, we also seen error message in html.
115
+ // When it occurs, we fall back to root service request so we get a proper JSON response with error code.
116
+ const tmpUrl = new URL(this._settings.url);
117
+ if (this._lastAccessToken && this._accessTokenRequired)
118
+ tmpUrl.searchParams.append("token", this._lastAccessToken.token);
119
+ tmpUrl.searchParams.append("f", "json");
120
+ response = await fetch(tmpUrl.toString(), options);
121
+ }
122
+ errorCode = await internal_1.ArcGisUtilities.checkForResponseErrorCode(response);
123
+ if (errorCode !== undefined &&
124
+ (errorCode === internal_1.ArcGisErrorCode.TokenRequired || errorCode === internal_1.ArcGisErrorCode.InvalidToken)) {
125
+ if (this._settings.userName && this._settings.userName.length > 0 && this._lastAccessToken) {
126
+ // **** Legacy token ONLY ***
127
+ // Token might have expired, make a second attempt by forcing new token.
128
+ if (this._accessClient?.invalidateToken !== undefined && this._lastAccessToken !== undefined)
129
+ this._accessClient.invalidateToken(this._lastAccessToken);
130
+ const urlObj2 = new URL(url);
131
+ if (this._accessClient) {
132
+ try {
133
+ this._lastAccessToken = await internal_1.ArcGisUtilities.appendSecurityToken(urlObj, this._accessClient, { mapLayerUrl: urlObj, userName: this._settings.userName, password: this._settings.password });
134
+ }
135
+ catch {
136
+ }
137
+ }
138
+ // Make a second attempt with refreshed token
139
+ response = await fetch(urlObj2.toString(), options);
140
+ errorCode = await internal_1.ArcGisUtilities.checkForResponseErrorCode(response);
141
+ }
142
+ if (errorCode === internal_1.ArcGisErrorCode.TokenRequired || errorCode === internal_1.ArcGisErrorCode.InvalidToken) {
143
+ // Looks like the initially generated token has expired.
144
+ if (this.status === internal_1.MapLayerImageryProviderStatus.Valid) {
145
+ // Only report new status change to avoid spamming the UI
146
+ this.setStatus(internal_1.MapLayerImageryProviderStatus.RequireAuth);
147
+ this.onStatusChanged.raiseEvent(this);
148
+ const msg = IModelApp_1.IModelApp.localization.getLocalizedString("iModelJs:MapLayers.Messages.FetchTooltipTokenError", { layerName: this._settings.name });
149
+ IModelApp_1.IModelApp.notifications.outputMessage(new NotificationManager_1.NotifyMessageDetails(NotificationManager_1.OutputMessagePriority.Warning, msg));
150
+ }
134
151
  }
135
152
  }
136
153
  }
154
+ finally {
155
+ this.onFirstRequestCompleted.raiseEvent();
156
+ }
157
+ if (response === undefined)
158
+ throw new Error("fetch call failed");
137
159
  return response;
138
160
  }
139
161
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ArcGISImageryProvider.js","sourceRoot":"","sources":["../../../../../src/tile/map/ImageryProviders/ArcGISImageryProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/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,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;oBAChJ,qBAAS,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,0CAAoB,CAAC,2CAAqB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;iBACrG;aACF;SACF;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA3ID,sDA2IC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tiles\n */\n\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\nimport { ArcGisErrorCode, ArcGISServiceMetadata, ArcGisUtilities, MapLayerAccessClient, MapLayerAccessToken, MapLayerImageryProvider, MapLayerImageryProviderStatus } from \"../../internal\";\nimport { IModelApp } from \"../../../IModelApp\";\nimport { NotifyMessageDetails, OutputMessagePriority } from \"../../../NotificationManager\";\n\n/** Base class for ArcGIS map-layer imagery providers.\n *\n * The initial purpose of this class is to offer shared methods\n * to query ArcGIS services and apply the appropriate security token.\n * @see [[ArcGISMapLayerImageryProvider]]\n * @internal\n */\nexport abstract class ArcGISImageryProvider extends MapLayerImageryProvider {\n\n protected _accessClient: MapLayerAccessClient|undefined;\n protected _lastAccessToken: MapLayerAccessToken|undefined;\n\n /** Flag indicating if access token should be added to request.\n * @note We assume a service to require access token for the entire viewing session.\n */\n protected _accessTokenRequired = false;\n\n protected _querySupported = false;\n\n public override get supportsMapFeatureInfo() { return this._querySupported;}\n\n constructor(settings: ImageMapLayerSettings, usesCachedTiles: boolean) {\n super(settings, usesCachedTiles);\n this._accessClient = IModelApp.mapLayerFormatRegistry?.getAccessClient(settings.formatId);\n }\n\n /** Updates the accessClient token state whenever the status of the provider change.\n * @internal\n * */\n protected override onStatusUpdated(status: MapLayerImageryProviderStatus) {\n if (status === MapLayerImageryProviderStatus.RequireAuth) {\n\n // Invalidate the token, so a new one get generated\n if (this._accessClient?.invalidateToken !== undefined && this._lastAccessToken !== undefined) {\n this._accessClient.invalidateToken(this._lastAccessToken);\n }\n\n // Make sure we don't re-use this token again (i.e force login process)\n this._lastAccessToken = undefined;\n }\n }\n\n /**\n * Fetch an ArcGIS service metadata, and returns its JSON representation.\n * This wrapper maintains token state and should be used instead of the the ArcGisUtilities version.\n */\n protected async getServiceJson() {\n let metadata: ArcGISServiceMetadata|undefined;\n try {\n metadata = await ArcGisUtilities.getServiceJson({url: this._settings.url, formatId: this._settings.formatId, userName: this._settings.userName, password: this._settings.password, queryParams: this._settings.collectQueryParams()});\n\n } catch (_e) {\n }\n if (metadata && metadata.accessTokenRequired) {\n const accessClient = IModelApp.mapLayerFormatRegistry.getAccessClient(this._settings.formatId);\n if (accessClient) {\n try {\n // Keep track of last used access token, so we can invalidate it later when an errors occurs\n const accessToken = await accessClient.getAccessToken({mapLayerUrl: new URL(this._settings.url)});\n this._lastAccessToken = accessToken;\n } catch {\n }\n }\n // By turning this ON, tiles requests will include security token\n this._accessTokenRequired = metadata.accessTokenRequired;\n }\n return metadata;\n }\n\n /**\n * Make a request to an ArcGIS service using the provided URL and init parameters.\n * @param url URL to query\n * @param options Custom settings to apply to the request.\n * Refer to fetch API for more details (https://developer.mozilla.org/en-US/docs/Web/API/fetch)\n */\n protected async fetch(url: URL, options?: RequestInit) {\n\n let errorCode: number | undefined;\n const urlObj = new URL(url);\n const queryParams = this._settings.collectQueryParams();\n Object.keys(queryParams).forEach((paramKey) => {\n if (!urlObj.searchParams.has(paramKey))\n urlObj.searchParams.append(paramKey, queryParams[paramKey]);\n });\n\n if (this._accessTokenRequired && this._accessClient) {\n this._lastAccessToken = await ArcGisUtilities.appendSecurityToken(urlObj, this._accessClient, {\n mapLayerUrl: new URL(this._settings.url),\n userName: this._settings.userName,\n password: this._settings.password });\n }\n\n let response = await fetch(urlObj.toString(), options);\n\n if ((this._lastAccessToken && response.status === 400)\n || response.headers.get(\"content-type\")?.toLowerCase().includes(\"htm\")) {\n // For some reasons when we make a request with the fetch() api and there is a token error\n // we receive a status 400 instead of proper json response. (i.e doing the same request in the browser gives a different response)\n // For some other request, we also seen error message in html.\n // When it occurs, we fall back to root service request so we get a proper JSON response with error code.\n const tmpUrl = new URL(this._settings.url);\n if (this._lastAccessToken && this._accessTokenRequired)\n tmpUrl.searchParams.append(\"token\", this._lastAccessToken.token);\n tmpUrl.searchParams.append(\"f\",\"json\");\n response = await fetch(tmpUrl.toString(), options);\n }\n\n errorCode = await ArcGisUtilities.checkForResponseErrorCode(response);\n\n if (errorCode !== undefined &&\n (errorCode === ArcGisErrorCode.TokenRequired || errorCode === ArcGisErrorCode.InvalidToken) ) {\n\n if (this._settings.userName && this._settings.userName.length > 0 && this._lastAccessToken ) {\n // **** Legacy token ONLY ***\n\n // Token might have expired, make a second attempt by forcing new token.\n if (this._accessClient?.invalidateToken !== undefined && this._lastAccessToken !== undefined)\n this._accessClient.invalidateToken(this._lastAccessToken);\n\n const urlObj2 = new URL(url);\n if (this._accessClient) {\n try {\n this._lastAccessToken = await ArcGisUtilities.appendSecurityToken(urlObj, this._accessClient, {mapLayerUrl: urlObj, userName: this._settings.userName, password: this._settings.password });\n } catch {\n }\n }\n\n // Make a second attempt with refreshed token\n response = await fetch(urlObj2.toString(), options);\n errorCode = await ArcGisUtilities.checkForResponseErrorCode(response);\n }\n\n if (errorCode === ArcGisErrorCode.TokenRequired || errorCode === ArcGisErrorCode.InvalidToken) {\n // Looks like the initially generated token has expired.\n\n if (this.status === MapLayerImageryProviderStatus.Valid ) {\n // Only report new status change to avoid spamming the UI\n this.setStatus(MapLayerImageryProviderStatus.RequireAuth);\n this.onStatusChanged.raiseEvent(this);\n const msg = IModelApp.localization.getLocalizedString(\"iModelJs:MapLayers.Messages.FetchTooltipTokenError\", { layerName: this._settings.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Warning, msg));\n }\n }\n }\n return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,CAAC,uBAAuB,CAAC,UAAU,EAAE,CAAC;SAC3C;QAED,IAAI,QAAQ,KAAK,SAAS;YACxB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAEvC,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAnKD,sDAmKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tiles\n */\n\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\nimport { ArcGisErrorCode, ArcGISServiceMetadata, ArcGisUtilities, MapLayerAccessClient, MapLayerAccessToken, MapLayerImageryProvider, MapLayerImageryProviderStatus } from \"../../internal\";\nimport { IModelApp } from \"../../../IModelApp\";\nimport { NotifyMessageDetails, OutputMessagePriority } from \"../../../NotificationManager\";\nimport { headersIncludeAuthMethod } from \"../../../request/utils\";\n\n/** Base class for ArcGIS map-layer imagery providers.\n *\n * The initial purpose of this class is to offer shared methods\n * to query ArcGIS services and apply the appropriate security token.\n * @see [[ArcGISMapLayerImageryProvider]]\n * @internal\n */\nexport abstract class ArcGISImageryProvider extends MapLayerImageryProvider {\n\n protected _accessClient: MapLayerAccessClient|undefined;\n protected _lastAccessToken: MapLayerAccessToken|undefined;\n\n /** Flag indicating if access token should be added to request.\n * @note We assume a service to require access token for the entire viewing session.\n */\n protected _accessTokenRequired = false;\n\n protected _querySupported = false;\n\n public override get supportsMapFeatureInfo() { return this._querySupported;}\n\n constructor(settings: ImageMapLayerSettings, usesCachedTiles: boolean) {\n super(settings, usesCachedTiles);\n this._accessClient = IModelApp.mapLayerFormatRegistry?.getAccessClient(settings.formatId);\n }\n\n /** Updates the accessClient token state whenever the status of the provider change.\n * @internal\n * */\n protected override onStatusUpdated(status: MapLayerImageryProviderStatus) {\n if (status === MapLayerImageryProviderStatus.RequireAuth) {\n\n // Invalidate the token, so a new one get generated\n if (this._accessClient?.invalidateToken !== undefined && this._lastAccessToken !== undefined) {\n this._accessClient.invalidateToken(this._lastAccessToken);\n }\n\n // Make sure we don't re-use this token again (i.e force login process)\n this._lastAccessToken = undefined;\n }\n }\n\n /**\n * Fetch an ArcGIS service metadata, and returns its JSON representation.\n * This wrapper maintains token state and should be used instead of the the ArcGisUtilities version.\n */\n protected async getServiceJson() {\n let metadata: ArcGISServiceMetadata|undefined;\n try {\n metadata = await ArcGisUtilities.getServiceJson({url: this._settings.url, formatId: this._settings.formatId, userName: this._settings.userName, password: this._settings.password, queryParams: this._settings.collectQueryParams()});\n\n } catch (_e) {\n }\n if (metadata && metadata.accessTokenRequired) {\n const accessClient = IModelApp.mapLayerFormatRegistry.getAccessClient(this._settings.formatId);\n if (accessClient) {\n try {\n // Keep track of last used access token, so we can invalidate it later when an errors occurs\n const accessToken = await accessClient.getAccessToken({mapLayerUrl: new URL(this._settings.url)});\n this._lastAccessToken = accessToken;\n } catch {\n }\n }\n // By turning this ON, tiles requests will include security token\n this._accessTokenRequired = metadata.accessTokenRequired;\n }\n return metadata;\n }\n\n /**\n * Make a request to an ArcGIS service using the provided URL and init parameters.\n * @param url URL to query\n * @param options Custom settings to apply to the request.\n * Refer to fetch API for more details (https://developer.mozilla.org/en-US/docs/Web/API/fetch)\n */\n protected async fetch(url: URL, options?: RequestInit) {\n\n let errorCode: number | undefined;\n const urlObj = new URL(url);\n const queryParams = this._settings.collectQueryParams();\n Object.keys(queryParams).forEach((paramKey) => {\n if (!urlObj.searchParams.has(paramKey))\n urlObj.searchParams.append(paramKey, queryParams[paramKey]);\n });\n\n if (this._accessTokenRequired && this._accessClient) {\n this._lastAccessToken = await ArcGisUtilities.appendSecurityToken(urlObj, this._accessClient, {\n mapLayerUrl: new URL(this._settings.url),\n userName: this._settings.userName,\n password: this._settings.password });\n }\n\n // We want to complete the first request before letting other requests go;\n // this done to avoid flooding server with requests missing credentials\n if (!this._firstRequestPromise)\n this._firstRequestPromise = new Promise<void>((resolve: any) => this.onFirstRequestCompleted.addOnce(()=>resolve()));\n else\n await this._firstRequestPromise;\n\n let response: Response|undefined;\n try {\n response = await fetch(urlObj.toString(), {...options, credentials: this._includeUserCredentials ? \"include\" : undefined});\n\n if (response.status === 401 && !this._lastAccessToken && headersIncludeAuthMethod(response.headers, [\"ntlm\", \"negotiate\"])) {\n // We got a http 401 challenge, lets try again with SSO enabled (i.e. Windows Authentication)\n response = await fetch(url, {...options, credentials: \"include\" });\n if (response.status === 200) {\n this._includeUserCredentials = true; // avoid going through 401 challenges over and over\n }\n }\n\n if ((this._lastAccessToken && response.status === 400)\n || response.headers.get(\"content-type\")?.toLowerCase().includes(\"htm\")) {\n // For some reasons when we make a request with the fetch() api and there is a token error\n // we receive a status 400 instead of proper json response. (i.e doing the same request in the browser gives a different response)\n // For some other request, we also seen error message in html.\n // When it occurs, we fall back to root service request so we get a proper JSON response with error code.\n const tmpUrl = new URL(this._settings.url);\n if (this._lastAccessToken && this._accessTokenRequired)\n tmpUrl.searchParams.append(\"token\", this._lastAccessToken.token);\n tmpUrl.searchParams.append(\"f\",\"json\");\n response = await fetch(tmpUrl.toString(), options);\n }\n\n errorCode = await ArcGisUtilities.checkForResponseErrorCode(response);\n\n if (errorCode !== undefined &&\n (errorCode === ArcGisErrorCode.TokenRequired || errorCode === ArcGisErrorCode.InvalidToken) ) {\n\n if (this._settings.userName && this._settings.userName.length > 0 && this._lastAccessToken ) {\n // **** Legacy token ONLY ***\n\n // Token might have expired, make a second attempt by forcing new token.\n if (this._accessClient?.invalidateToken !== undefined && this._lastAccessToken !== undefined)\n this._accessClient.invalidateToken(this._lastAccessToken);\n\n const urlObj2 = new URL(url);\n if (this._accessClient) {\n try {\n this._lastAccessToken = await ArcGisUtilities.appendSecurityToken(urlObj, this._accessClient, {mapLayerUrl: urlObj, userName: this._settings.userName, password: this._settings.password });\n } catch {\n }\n }\n\n // Make a second attempt with refreshed token\n response = await fetch(urlObj2.toString(), options);\n errorCode = await ArcGisUtilities.checkForResponseErrorCode(response);\n }\n\n if (errorCode === ArcGisErrorCode.TokenRequired || errorCode === ArcGisErrorCode.InvalidToken) {\n // Looks like the initially generated token has expired.\n\n if (this.status === MapLayerImageryProviderStatus.Valid ) {\n // Only report new status change to avoid spamming the UI\n this.setStatus(MapLayerImageryProviderStatus.RequireAuth);\n this.onStatusChanged.raiseEvent(this);\n const msg = IModelApp.localization.getLocalizedString(\"iModelJs:MapLayers.Messages.FetchTooltipTokenError\", { layerName: this._settings.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Warning, msg));\n }\n }\n }\n } finally {\n this.onFirstRequestCompleted.raiseEvent();\n }\n\n if (response === undefined)\n throw new Error(\"fetch call failed\");\n\n return response;\n }\n}\n"]}
@@ -174,7 +174,7 @@ class ArcGISMapLayerImageryProvider extends internal_1.ArcGISImageryProvider {
174
174
  const fetch = async (url, options) => {
175
175
  return this.fetch(url, options);
176
176
  };
177
- this._tileMap = new internal_1.ArcGISTileMap(this._settings.url, this._settings, fetch, json.tileInfo?.lods?.length);
177
+ this._tileMap = new internal_1.ArcGISTileMap(this._settings.url, this._settings, fetch);
178
178
  }
179
179
  }
180
180
  // Read range using fullextent from service metadata
@@ -1 +1 @@
1
- {"version":3,"file":"ArcGISMapLayerImageryProvider.js","sourceRoot":"","sources":["../../../../../src/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,oDAAiH;AACjH,kDAA+C;AAC/C,6CAIwB;AACxB,0DAA+E;AAC/E,wDAA+E;AAC/E,sDAA6C;AAG7C,MAAM,cAAc,GAAI,uDAAuD,CAAC;AA6DhF,gBAAgB;AAChB,MAAa,wBAAwB;IAC5B,MAAM,CAAC,QAAQ,CAAC,OAAmB,EAAE,IAAmC,EAAE,gBAAyB;QAExG,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QAChC,MAAM,CAAC,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,CAAC,gBAAgB,EAAE;YACzB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,SAAS,SAAS,IAAI,GAAG,IAAI,MAAM,GAAG,CAAC;SACtE;aAAM;YACL,MAAM,UAAU,GAAG,GAAG,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,cAAc,CAAC;YACzF,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,gBAAgB,UAAU,SAAS,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,WAAW,IAAI,CAAC,cAAc,EAAE,2BAA2B,IAAI,CAAC,2BAA2B,+BAA+B,CAAC;SAC3N;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAnUD,sEAmUC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tiles\n */\nimport { Cartographic, ImageMapLayerSettings, ImageSource, IModelStatus, ServerError } from \"@itwin/core-common\";\nimport { IModelApp } from \"../../../IModelApp\";\nimport {\n ArcGisErrorCode, ArcGisGeometryReaderJSON, ArcGisGraphicsRenderer, ArcGISImageryProvider, ArcGISTileMap,\n ArcGisUtilities, ImageryMapTileTree, MapCartoRectangle, MapFeatureInfoOptions, MapLayerFeature,\n MapLayerFeatureInfo, MapLayerImageryProviderStatus, MapSubLayerFeatureInfo, QuadId,\n} from \"../../internal\";\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport { Point2d, Range2d, Range2dProps, XYProps } from \"@itwin/core-geometry\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport { HitDetail } from \"../../../HitDetail\";\n\nconst loggerCategory = \"MapLayerImageryProvider.ArcGISMapLayerImageryProvider\";\n\n/** @internal */\nexport interface ArcGISIdentifyImageDisplayProps {\n width: number;\n height: number;\n dpi: number;\n}\n\n/** @internal */\nexport interface ArcGISIdentifyLayersProps {\n prefix: \"top\"|\"visible\"|\"all\";\n layerIds?: string[];\n}\n\n/** @internal */\nexport interface ArcGISIdentifyRequestUrlProps {\n /** The geometry to identify on. Point only support */\n geometry: XYProps;\n\n /** The type of geometry specified by the geometry parameter. Point only support */\n geometryType: \"esriGeometryPoint\";\n\n /** The well-known ID of the spatial reference of the input and output geometries as well as the mapExtent. */\n sr?: number;\n\n /** The layers to perform the identify operation on. The default value is top.\n * Format: [top | visible | all]:layerId1,layerId2\n */\n layers?: ArcGISIdentifyLayersProps;\n\n /** The distance in screen pixels from the specified geometry within which the identify operation should be performed.\n * The value for the tolerance is an integer.\n */\n tolerance: number;\n\n /** The extent or bounding box of the map currently being viewed.\n * Format: <xmin>, <ymin>, <xmax>, <ymax>\n */\n mapExtent: Range2dProps;\n\n /** The screen image display parameters (width, height, and DPI) of the map being currently viewed. T\n * Format: <width>,<height>,<dpi>\n */\n imageDisplay: ArcGISIdentifyImageDisplayProps;\n\n /** If true, the result set will include the geometries associated with each result. The default is true.\n */\n returnGeometry?: boolean;\n\n /** This option can be used to specify the maximum allowable offset to be used for generalizing geometries returned by the identify operation.\n * The maxAllowableOffset is in the units of the sr.\n */\n maxAllowableOffset?: number;\n\n /** The response format. The default response format is html.\n */\n f?: \"json\"|\"html\";\n\n}\n\n/** @internal */\nexport class ArcGISIdentifyRequestUrl {\n public static fromJSON(baseUrl: URL|string, json: ArcGISIdentifyRequestUrlProps, srFractionDigits?: number): URL {\n\n const newUrl = new URL(baseUrl);\n newUrl.pathname = `${newUrl.pathname}/identify`;\n\n if (json.f) {\n newUrl.searchParams.append(\"f\", json.f);\n }\n\n const geomPt = Point2d.fromJSON(json.geometry);\n newUrl.searchParams.append(\"geometry\", `${this.toFixed(geomPt.x, srFractionDigits)},${this.toFixed(geomPt.y, srFractionDigits)}`);\n newUrl.searchParams.append(\"geometryType\", json.geometryType);\n\n if (json.sr) {\n newUrl.searchParams.append(\"sr\", `${json.sr}`);\n }\n\n if (json.layers) {\n newUrl.searchParams.append(\"layers\", `${json.layers.prefix}${json.layers.layerIds?.length ? `: ${json.layers.layerIds.join(\",\")}` : \"\"}`);\n }\n\n newUrl.searchParams.append(\"tolerance\", `${json.tolerance}`);\n\n newUrl.searchParams.append(\"mapExtent\", ArcGISIdentifyRequestUrl.getExtentString(json.mapExtent, srFractionDigits));\n\n newUrl.searchParams.append(\"imageDisplay\", `${json.imageDisplay.width},${json.imageDisplay.height},${json.imageDisplay.dpi}`);\n\n if (json.returnGeometry !== undefined) {\n newUrl.searchParams.append(\"returnGeometry\", json.returnGeometry ? \"true\" : \"false\");\n }\n\n if (json.maxAllowableOffset !== undefined) {\n newUrl.searchParams.append(\"maxAllowableOffset\", `${this.toFixed(json.maxAllowableOffset, srFractionDigits)}`);\n }\n\n return newUrl;\n }\n\n public static toFixed(value: number, srFractionDigits?: number) {\n return srFractionDigits === undefined ? value.toString() : value.toFixed(srFractionDigits);\n }\n\n public static getExtentString(range: Range2dProps, srFractionDigits?: number) {\n const extent = Range2d.fromJSON(range);\n const extentStringArray: string[] = [];\n extent.toFloat64Array().forEach((value) => extentStringArray.push(this.toFixed(value, srFractionDigits)));\n return extentStringArray.join(\",\");\n }\n}\n\n/** @internal */\nexport class ArcGISMapLayerImageryProvider extends ArcGISImageryProvider {\n private _maxDepthFromLod = 0;\n private _minDepthFromLod = 0;\n private _copyrightText = \"Copyright\";\n private _tileMapSupported = false;\n private _mapSupported = false;\n private _tilesOnly = false;\n private _tileMap: ArcGISTileMap|undefined;\n\n public serviceJson: any;\n constructor(settings: ImageMapLayerSettings) {\n super(settings, false);\n this._accessClient = IModelApp.mapLayerFormatRegistry.getAccessClient(settings.formatId);\n }\n\n protected override get _filterByCartoRange() { return false; } // Can't trust footprint ranges (USGS Hydro)\n\n public override get minimumZoomLevel() { return Math.max(super.minimumZoomLevel, this._minDepthFromLod); }\n public override get maximumZoomLevel() { return this._maxDepthFromLod > 0 ? this._maxDepthFromLod : super.maximumZoomLevel; }\n\n public uintToString(uintArray: any) {\n return Buffer.from(uintArray).toJSON();\n\n }\n\n private async fetchTile(row: number, column: number, zoomLevel: number) {\n const tileUrl: string = await this.constructUrl(row, column, zoomLevel);\n if (tileUrl.length === 0)\n return undefined;\n return this.fetch(new URL(tileUrl), { method: \"GET\" });\n }\n\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\n if ((this.status === MapLayerImageryProviderStatus.RequireAuth)) {\n return undefined;\n }\n\n try {\n const tileResponse = await this.fetchTile(row, column, zoomLevel);\n if (tileResponse === undefined)\n return undefined;\n\n if (!this._hasSuccessfullyFetchedTile) {\n this._hasSuccessfullyFetchedTile = true;\n }\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\n } catch (error) {\n Logger.logError(loggerCategory, `Error occurred when loading tile(${row},${column},${zoomLevel}) : ${error}`);\n return undefined;\n }\n }\n\n protected override _generateChildIds(quadId: QuadId, resolveChildren: (childIds: QuadId[]) => void) {\n const childIds = this.getPotentialChildIds(quadId);\n if (quadId.level < Math.max(1, this.minimumZoomLevel-1)) {\n resolveChildren(childIds);\n return;\n }\n\n if (this._tileMap) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._tileMap.getChildrenAvailability(childIds).then((availability) => {\n const availableChildIds = new Array<QuadId>();\n for (let i = 0; i < availability.length; i++)\n if (availability[i])\n availableChildIds.push(childIds[i]);\n\n resolveChildren (availableChildIds);\n });\n } else if (this._usesCachedTiles && this.cartoRange) {\n // Filter children by range\n const availableChildIds = new Array<QuadId>();\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < childIds.length; i++) {\n const childExtent = this.getEPSG4326Extent(childIds[i].row, childIds[i].column, childIds[i].level);\n\n const childRange = MapCartoRectangle.fromDegrees(childExtent.longitudeLeft, childExtent.latitudeBottom, childExtent.longitudeRight, childExtent.latitudeTop);\n if (childRange.intersectsRange(this.cartoRange)) {\n availableChildIds.push(childIds[i]);\n }\n }\n resolveChildren (availableChildIds);\n } else {\n resolveChildren (childIds); // Resolve all children\n }\n }\n\n public override async initialize(): Promise<void> {\n\n const metadata = await this.getServiceJson();\n\n if (metadata?.content === undefined)\n throw new ServerError(IModelStatus.ValidationFailed, \"\");\n\n const json = metadata.content;\n if (json?.error?.code === ArcGisErrorCode.TokenRequired || json?.error?.code === ArcGisErrorCode.InvalidToken) {\n // Check again layer status, it might have change during await.\n if (this.status === MapLayerImageryProviderStatus.Valid) {\n this.setStatus(MapLayerImageryProviderStatus.RequireAuth);\n return; // By returning (i.e not throwing), we ensure the tileTree get created and current provider is preserved to report status.\n }\n }\n\n this.serviceJson = json;\n\n if (json.capabilities) {\n const capabilities = json.capabilities.split(\",\");\n\n this._querySupported = capabilities.includes(\"Query\");\n this._tileMapSupported = capabilities.includes(\"Tilemap\");\n this._mapSupported = capabilities.includes(\"Map\");\n this._tilesOnly = capabilities.includes(\"TilesOnly\");\n }\n\n if (json.copyrightText)\n this._copyrightText = json.copyrightText;\n\n this._usesCachedTiles = !!json.tileInfo;\n\n if (this._usesCachedTiles) {\n // Only EPSG:3857 is supported with pre-rendered tiles. Fall back to 'Export' queries if possible otherwise throw.\n if (!ArcGisUtilities.isEpsg3857Compatible(json.tileInfo)) {\n if (this._mapSupported && !this._tilesOnly) {\n this._usesCachedTiles = false;\n } else {\n throw new ServerError(IModelStatus.ValidationFailed, \"Invalid coordinate system\");\n }\n }\n }\n\n if (this._usesCachedTiles) {\n // Read max LOD\n if (json.maxScale !== undefined && json.maxScale !== 0 && Array.isArray(json.tileInfo.lods)) {\n for (; this._maxDepthFromLod < json.tileInfo.lods.length && json.tileInfo.lods[this._maxDepthFromLod].scale > json.maxScale; this._maxDepthFromLod++)\n ;\n }\n\n // Create tile map object only if we are going to request tiles from this server and it support tilemap requests.\n if (this._tileMapSupported) {\n const fetch = async (url: URL, options?: RequestInit): Promise<Response> => {\n return this.fetch(url, options);\n };\n this._tileMap = new ArcGISTileMap(this._settings.url, this._settings, fetch, json.tileInfo?.lods?.length);\n }\n }\n\n // Read range using fullextent from service metadata\n if (json.fullExtent) {\n if (json.fullExtent.spatialReference.latestWkid === 3857 || json.fullExtent.spatialReference.wkid === 102100) {\n const range3857 = Range2d.createFrom({\n low: {x: json.fullExtent.xmin, y: json.fullExtent.ymin},\n high: {x: json.fullExtent.xmax, y: json.fullExtent.ymax} });\n\n const west = this.getEPSG4326Lon(range3857.xLow);\n const south = this.getEPSG4326Lat(range3857.yLow);\n const east = this.getEPSG4326Lon(range3857.xHigh);\n const north = this.getEPSG4326Lat(range3857.yHigh);\n this.cartoRange = MapCartoRectangle.fromDegrees(west, south, east, north);\n }\n }\n\n // Read minLOD if available\n if (json.minLOD !== undefined) {\n const minLod = parseInt(json.minLOD, 10);\n if (!Number.isNaN(minLod)) {\n this._minDepthFromLod = minLod;\n }\n } else if (json.minScale) {\n // Read min LOD using minScale\n const minScale = json.minScale;\n if (json.tileInfo?.lods !== undefined && Array.isArray(json.tileInfo.lods)) {\n for (const lod of json.tileInfo.lods) {\n if (lod.scale < minScale) {\n this._minDepthFromLod = lod.level;\n break;\n }\n }\n }\n }\n\n }\n\n public override addLogoCards(cards: HTMLTableElement): void {\n if (!cards.dataset.arcGisLogoCard) {\n cards.dataset.arcGisLogoCard = \"true\";\n cards.appendChild(IModelApp.makeLogoCard({ heading: \"ArcGIS\", notice: this._copyrightText }));\n }\n }\n\n // Translates the provided Cartographic into a EPSG:3857 point, and retrieve information.\n // tolerance is in pixels\n private async getIdentifyData(quadId: QuadId, carto: Cartographic, tolerance: number, returnGeometry?: boolean, maxAllowableOffset?: number): Promise<any> {\n\n const bbox = this.getEPSG3857Extent(quadId.row, quadId.column, quadId.level);\n const layerIds = new Array<string>();\n this._settings.subLayers.forEach((subLayer) => {\n if (this._settings.isSubLayerVisible(subLayer))\n layerIds.push(subLayer.idString);\n });\n const urlObj = ArcGISIdentifyRequestUrl.fromJSON(this._settings.url, {\n f: \"json\",\n geometry: {x: this.getEPSG3857X(carto.longitudeDegrees), y: this.getEPSG3857Y(carto.latitudeDegrees)},\n geometryType: \"esriGeometryPoint\",\n tolerance,\n mapExtent: {low: {x: bbox.left, y: bbox.bottom}, high: {x: bbox.right, y: bbox.top}},\n sr: 3857,\n imageDisplay: {width: this.tileSize, height: this.tileSize, dpi: 96},\n layers: {prefix: \"top\", layerIds},\n returnGeometry,\n maxAllowableOffset}, 3 /* 1mm accuracy*/);\n\n const response = await this.fetch(urlObj, { method: \"GET\" } );\n return response.json();\n }\n\n // Makes an identify request to ESRI MapService server, and return it as a list of formatted strings\n public override async getToolTip(strings: string[], quadId: QuadId, carto: Cartographic, tree: ImageryMapTileTree): Promise<void> {\n await super.getToolTip(strings, quadId, carto, tree);\n\n if (!this._querySupported)\n return;\n\n const stringSet = new Set<string>();\n const json = await this.getIdentifyData(quadId, carto, 1);\n\n if (json && Array.isArray(json.results)) {\n for (const result of json.results) {\n if (result.attributes !== undefined && result.attributes[result.displayFieldName] !== undefined) {\n const thisString = `${result.displayFieldName}: ${result.attributes[result.displayFieldName]}`;\n if (!stringSet.has(thisString)) {\n strings.push(thisString);\n stringSet.add(thisString);\n }\n }\n }\n }\n }\n\n // Makes an identify request to ESRI MapService , and return it as a list MapLayerFeatureInfo object\n public override async getFeatureInfo(featureInfos: MapLayerFeatureInfo[], quadId: QuadId, carto: Cartographic, _tree: ImageryMapTileTree, hit: HitDetail, options?: MapFeatureInfoOptions): Promise<void> {\n if (!this._querySupported)\n return;\n\n const tileExtent = this.getEPSG3857Extent(quadId.row, quadId.column, quadId.level);\n const toleranceWorld = (tileExtent.top - tileExtent.bottom) / this.tileSize;\n const maxAllowableOffsetFactor = 2;\n const maxAllowableOffset = maxAllowableOffsetFactor*toleranceWorld;\n\n const tolerancePixel = options?.tolerance ?? 7;\n const json = await this.getIdentifyData(quadId, carto, tolerancePixel, true, maxAllowableOffset);\n if (json && Array.isArray(json.results)) {\n const renderer = new ArcGisGraphicsRenderer({viewport: hit.viewport});\n\n const layerInfo: MapLayerFeatureInfo = { layerName: this._settings.name, subLayerInfos: [] };\n\n // The 'identify' service returns us a flat/unordered list of records..\n // results may represent features for the a common subLayer.\n // For simplicity, we group together features for a given sub-layer.\n const subLayers = new Map<string, MapSubLayerFeatureInfo> ();\n\n for (const result of json.results) {\n\n let subLayerInfo = subLayers.get(result.layerName);\n if (!subLayerInfo) {\n subLayerInfo = {\n subLayerName: result.layerName ?? \"\",\n displayFieldName: result.displayFieldName,\n features: [],\n };\n subLayers.set(result.layerName, subLayerInfo);\n }\n const feature: MapLayerFeature = {geometries: [], attributes: []};\n\n // Read all feature attributes\n for (const [key, value] of Object.entries(result.attributes)) {\n // Convert everything to string for now\n const strValue = String(value);\n feature.attributes.push({\n value: { valueFormat: PropertyValueFormat.Primitive, value: strValue, displayValue: strValue },\n property: { name: key, displayLabel: key, typename: StandardTypeNames.String },\n });\n }\n\n // Read feature geometries\n const geomReader = new ArcGisGeometryReaderJSON(result.geometryType, renderer);\n await geomReader.readGeometry(result.geometry);\n const graphics = renderer.moveGraphics();\n feature.geometries = graphics.map((graphic) => {\n return {graphic};\n });\n subLayerInfo.features.push(feature);\n\n }\n\n for ( const value of subLayers.values()) {\n layerInfo.subLayerInfos!.push(value);\n }\n\n featureInfos.push(layerInfo);\n }\n }\n\n protected getLayerString(prefix = \"show\"): string {\n const layers = new Array<string>();\n this._settings.subLayers.forEach((subLayer) => {\n if (this._settings.isSubLayerVisible(subLayer))\n layers.push(subLayer.idString);\n });\n\n return `${prefix}: ${layers.join(\",\")} `;\n }\n\n // construct the Url from the desired Tile\n public async constructUrl(row: number, column: number, zoomLevel: number): Promise<string> {\n let tmpUrl;\n if (this._usesCachedTiles) {\n tmpUrl = `${this._settings.url}/tile/${zoomLevel}/${row}/${column} `;\n } else {\n const bboxString = `${this.getEPSG3857ExtentString(row, column, zoomLevel)}&bboxSR=3857`;\n tmpUrl = `${this._settings.url}/export?bbox=${bboxString}&size=${this.tileSize},${this.tileSize}&layers=${this.getLayerString()}&format=png&transparent=${this.transparentBackgroundString}&f=image&sr=3857&imagesr=3857`;\n }\n return tmpUrl;\n }\n}\n"]}
1
+ {"version":3,"file":"ArcGISMapLayerImageryProvider.js","sourceRoot":"","sources":["../../../../../src/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,oDAAiH;AACjH,kDAA+C;AAC/C,6CAIwB;AACxB,0DAA+E;AAC/E,wDAA+E;AAC/E,sDAA6C;AAG7C,MAAM,cAAc,GAAI,uDAAuD,CAAC;AA6DhF,gBAAgB;AAChB,MAAa,wBAAwB;IAC5B,MAAM,CAAC,QAAQ,CAAC,OAAmB,EAAE,IAAmC,EAAE,gBAAyB;QAExG,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QAChC,MAAM,CAAC,QAAQ,GAAG,GAAG,MAAM,CAAC,QAAQ,WAAW,CAAC;QAEhD,IAAI,IAAI,CAAC,CAAC,EAAE;YACV,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;SACzC;QAED,MAAM,MAAM,GAAG,uBAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/C,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,gBAAgB,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC;QAClI,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAE9D,IAAI,IAAI,CAAC,EAAE,EAAE;YACX,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,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AAM,GAAG,MAAM;QACtC,MAAM,MAAM,GAAG,IAAI,KAAK,EAAU,CAAC;QACnC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC5C,IAAI,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,QAAQ,CAAC;gBAC5C,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAC3C,CAAC;IAED,0CAA0C;IACnC,KAAK,CAAC,YAAY,CAAC,GAAW,EAAE,MAAc,EAAE,SAAiB;QACtE,IAAI,MAAM,CAAC;QACX,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACzB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,SAAS,SAAS,IAAI,GAAG,IAAI,MAAM,GAAG,CAAC;SACtE;aAAM;YACL,MAAM,UAAU,GAAG,GAAG,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,cAAc,CAAC;YACzF,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,gBAAgB,UAAU,SAAS,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,WAAW,IAAI,CAAC,cAAc,EAAE,2BAA2B,IAAI,CAAC,2BAA2B,+BAA+B,CAAC;SAC3N;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAnUD,sEAmUC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tiles\n */\nimport { Cartographic, ImageMapLayerSettings, ImageSource, IModelStatus, ServerError } from \"@itwin/core-common\";\nimport { IModelApp } from \"../../../IModelApp\";\nimport {\n ArcGisErrorCode, ArcGisGeometryReaderJSON, ArcGisGraphicsRenderer, ArcGISImageryProvider, ArcGISTileMap,\n ArcGisUtilities, ImageryMapTileTree, MapCartoRectangle, MapFeatureInfoOptions, MapLayerFeature,\n MapLayerFeatureInfo, MapLayerImageryProviderStatus, MapSubLayerFeatureInfo, QuadId,\n} from \"../../internal\";\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport { Point2d, Range2d, Range2dProps, XYProps } from \"@itwin/core-geometry\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport { HitDetail } from \"../../../HitDetail\";\n\nconst loggerCategory = \"MapLayerImageryProvider.ArcGISMapLayerImageryProvider\";\n\n/** @internal */\nexport interface ArcGISIdentifyImageDisplayProps {\n width: number;\n height: number;\n dpi: number;\n}\n\n/** @internal */\nexport interface ArcGISIdentifyLayersProps {\n prefix: \"top\"|\"visible\"|\"all\";\n layerIds?: string[];\n}\n\n/** @internal */\nexport interface ArcGISIdentifyRequestUrlProps {\n /** The geometry to identify on. Point only support */\n geometry: XYProps;\n\n /** The type of geometry specified by the geometry parameter. Point only support */\n geometryType: \"esriGeometryPoint\";\n\n /** The well-known ID of the spatial reference of the input and output geometries as well as the mapExtent. */\n sr?: number;\n\n /** The layers to perform the identify operation on. The default value is top.\n * Format: [top | visible | all]:layerId1,layerId2\n */\n layers?: ArcGISIdentifyLayersProps;\n\n /** The distance in screen pixels from the specified geometry within which the identify operation should be performed.\n * The value for the tolerance is an integer.\n */\n tolerance: number;\n\n /** The extent or bounding box of the map currently being viewed.\n * Format: <xmin>, <ymin>, <xmax>, <ymax>\n */\n mapExtent: Range2dProps;\n\n /** The screen image display parameters (width, height, and DPI) of the map being currently viewed. T\n * Format: <width>,<height>,<dpi>\n */\n imageDisplay: ArcGISIdentifyImageDisplayProps;\n\n /** If true, the result set will include the geometries associated with each result. The default is true.\n */\n returnGeometry?: boolean;\n\n /** This option can be used to specify the maximum allowable offset to be used for generalizing geometries returned by the identify operation.\n * The maxAllowableOffset is in the units of the sr.\n */\n maxAllowableOffset?: number;\n\n /** The response format. The default response format is html.\n */\n f?: \"json\"|\"html\";\n\n}\n\n/** @internal */\nexport class ArcGISIdentifyRequestUrl {\n public static fromJSON(baseUrl: URL|string, json: ArcGISIdentifyRequestUrlProps, srFractionDigits?: number): URL {\n\n const newUrl = new URL(baseUrl);\n newUrl.pathname = `${newUrl.pathname}/identify`;\n\n if (json.f) {\n newUrl.searchParams.append(\"f\", json.f);\n }\n\n const geomPt = Point2d.fromJSON(json.geometry);\n newUrl.searchParams.append(\"geometry\", `${this.toFixed(geomPt.x, srFractionDigits)},${this.toFixed(geomPt.y, srFractionDigits)}`);\n newUrl.searchParams.append(\"geometryType\", json.geometryType);\n\n if (json.sr) {\n newUrl.searchParams.append(\"sr\", `${json.sr}`);\n }\n\n if (json.layers) {\n newUrl.searchParams.append(\"layers\", `${json.layers.prefix}${json.layers.layerIds?.length ? `: ${json.layers.layerIds.join(\",\")}` : \"\"}`);\n }\n\n newUrl.searchParams.append(\"tolerance\", `${json.tolerance}`);\n\n newUrl.searchParams.append(\"mapExtent\", ArcGISIdentifyRequestUrl.getExtentString(json.mapExtent, srFractionDigits));\n\n newUrl.searchParams.append(\"imageDisplay\", `${json.imageDisplay.width},${json.imageDisplay.height},${json.imageDisplay.dpi}`);\n\n if (json.returnGeometry !== undefined) {\n newUrl.searchParams.append(\"returnGeometry\", json.returnGeometry ? \"true\" : \"false\");\n }\n\n if (json.maxAllowableOffset !== undefined) {\n newUrl.searchParams.append(\"maxAllowableOffset\", `${this.toFixed(json.maxAllowableOffset, srFractionDigits)}`);\n }\n\n return newUrl;\n }\n\n public static toFixed(value: number, srFractionDigits?: number) {\n return srFractionDigits === undefined ? value.toString() : value.toFixed(srFractionDigits);\n }\n\n public static getExtentString(range: Range2dProps, srFractionDigits?: number) {\n const extent = Range2d.fromJSON(range);\n const extentStringArray: string[] = [];\n extent.toFloat64Array().forEach((value) => extentStringArray.push(this.toFixed(value, srFractionDigits)));\n return extentStringArray.join(\",\");\n }\n}\n\n/** @internal */\nexport class ArcGISMapLayerImageryProvider extends ArcGISImageryProvider {\n private _maxDepthFromLod = 0;\n private _minDepthFromLod = 0;\n private _copyrightText = \"Copyright\";\n private _tileMapSupported = false;\n private _mapSupported = false;\n private _tilesOnly = false;\n private _tileMap: ArcGISTileMap|undefined;\n\n public serviceJson: any;\n constructor(settings: ImageMapLayerSettings) {\n super(settings, false);\n this._accessClient = IModelApp.mapLayerFormatRegistry.getAccessClient(settings.formatId);\n }\n\n protected override get _filterByCartoRange() { return false; } // Can't trust footprint ranges (USGS Hydro)\n\n public override get minimumZoomLevel() { return Math.max(super.minimumZoomLevel, this._minDepthFromLod); }\n public override get maximumZoomLevel() { return this._maxDepthFromLod > 0 ? this._maxDepthFromLod : super.maximumZoomLevel; }\n\n public uintToString(uintArray: any) {\n return Buffer.from(uintArray).toJSON();\n\n }\n\n private async fetchTile(row: number, column: number, zoomLevel: number) {\n const tileUrl: string = await this.constructUrl(row, column, zoomLevel);\n if (tileUrl.length === 0)\n return undefined;\n return this.fetch(new URL(tileUrl), { method: \"GET\" });\n }\n\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\n if ((this.status === MapLayerImageryProviderStatus.RequireAuth)) {\n return undefined;\n }\n\n try {\n const tileResponse = await this.fetchTile(row, column, zoomLevel);\n if (tileResponse === undefined)\n return undefined;\n\n if (!this._hasSuccessfullyFetchedTile) {\n this._hasSuccessfullyFetchedTile = true;\n }\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\n } catch (error) {\n Logger.logError(loggerCategory, `Error occurred when loading tile(${row},${column},${zoomLevel}) : ${error}`);\n return undefined;\n }\n }\n\n protected override _generateChildIds(quadId: QuadId, resolveChildren: (childIds: QuadId[]) => void) {\n const childIds = this.getPotentialChildIds(quadId);\n if (quadId.level < Math.max(1, this.minimumZoomLevel-1)) {\n resolveChildren(childIds);\n return;\n }\n\n if (this._tileMap) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._tileMap.getChildrenAvailability(childIds).then((availability) => {\n const availableChildIds = new Array<QuadId>();\n for (let i = 0; i < availability.length; i++)\n if (availability[i])\n availableChildIds.push(childIds[i]);\n\n resolveChildren (availableChildIds);\n });\n } else if (this._usesCachedTiles && this.cartoRange) {\n // Filter children by range\n const availableChildIds = new Array<QuadId>();\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < childIds.length; i++) {\n const childExtent = this.getEPSG4326Extent(childIds[i].row, childIds[i].column, childIds[i].level);\n\n const childRange = MapCartoRectangle.fromDegrees(childExtent.longitudeLeft, childExtent.latitudeBottom, childExtent.longitudeRight, childExtent.latitudeTop);\n if (childRange.intersectsRange(this.cartoRange)) {\n availableChildIds.push(childIds[i]);\n }\n }\n resolveChildren (availableChildIds);\n } else {\n resolveChildren (childIds); // Resolve all children\n }\n }\n\n public override async initialize(): Promise<void> {\n\n const metadata = await this.getServiceJson();\n\n if (metadata?.content === undefined)\n throw new ServerError(IModelStatus.ValidationFailed, \"\");\n\n const json = metadata.content;\n if (json?.error?.code === ArcGisErrorCode.TokenRequired || json?.error?.code === ArcGisErrorCode.InvalidToken) {\n // Check again layer status, it might have change during await.\n if (this.status === MapLayerImageryProviderStatus.Valid) {\n this.setStatus(MapLayerImageryProviderStatus.RequireAuth);\n return; // By returning (i.e not throwing), we ensure the tileTree get created and current provider is preserved to report status.\n }\n }\n\n this.serviceJson = json;\n\n if (json.capabilities) {\n const capabilities = json.capabilities.split(\",\");\n\n this._querySupported = capabilities.includes(\"Query\");\n this._tileMapSupported = capabilities.includes(\"Tilemap\");\n this._mapSupported = capabilities.includes(\"Map\");\n this._tilesOnly = capabilities.includes(\"TilesOnly\");\n }\n\n if (json.copyrightText)\n this._copyrightText = json.copyrightText;\n\n this._usesCachedTiles = !!json.tileInfo;\n\n if (this._usesCachedTiles) {\n // Only EPSG:3857 is supported with pre-rendered tiles. Fall back to 'Export' queries if possible otherwise throw.\n if (!ArcGisUtilities.isEpsg3857Compatible(json.tileInfo)) {\n if (this._mapSupported && !this._tilesOnly) {\n this._usesCachedTiles = false;\n } else {\n throw new ServerError(IModelStatus.ValidationFailed, \"Invalid coordinate system\");\n }\n }\n }\n\n if (this._usesCachedTiles) {\n // Read max LOD\n if (json.maxScale !== undefined && json.maxScale !== 0 && Array.isArray(json.tileInfo.lods)) {\n for (; this._maxDepthFromLod < json.tileInfo.lods.length && json.tileInfo.lods[this._maxDepthFromLod].scale > json.maxScale; this._maxDepthFromLod++)\n ;\n }\n\n // Create tile map object only if we are going to request tiles from this server and it support tilemap requests.\n if (this._tileMapSupported) {\n const fetch = async (url: URL, options?: RequestInit): Promise<Response> => {\n return this.fetch(url, options);\n };\n this._tileMap = new ArcGISTileMap(this._settings.url, this._settings, fetch);\n }\n }\n\n // Read range using fullextent from service metadata\n if (json.fullExtent) {\n if (json.fullExtent.spatialReference.latestWkid === 3857 || json.fullExtent.spatialReference.wkid === 102100) {\n const range3857 = Range2d.createFrom({\n low: {x: json.fullExtent.xmin, y: json.fullExtent.ymin},\n high: {x: json.fullExtent.xmax, y: json.fullExtent.ymax} });\n\n const west = this.getEPSG4326Lon(range3857.xLow);\n const south = this.getEPSG4326Lat(range3857.yLow);\n const east = this.getEPSG4326Lon(range3857.xHigh);\n const north = this.getEPSG4326Lat(range3857.yHigh);\n this.cartoRange = MapCartoRectangle.fromDegrees(west, south, east, north);\n }\n }\n\n // Read minLOD if available\n if (json.minLOD !== undefined) {\n const minLod = parseInt(json.minLOD, 10);\n if (!Number.isNaN(minLod)) {\n this._minDepthFromLod = minLod;\n }\n } else if (json.minScale) {\n // Read min LOD using minScale\n const minScale = json.minScale;\n if (json.tileInfo?.lods !== undefined && Array.isArray(json.tileInfo.lods)) {\n for (const lod of json.tileInfo.lods) {\n if (lod.scale < minScale) {\n this._minDepthFromLod = lod.level;\n break;\n }\n }\n }\n }\n\n }\n\n public override addLogoCards(cards: HTMLTableElement): void {\n if (!cards.dataset.arcGisLogoCard) {\n cards.dataset.arcGisLogoCard = \"true\";\n cards.appendChild(IModelApp.makeLogoCard({ heading: \"ArcGIS\", notice: this._copyrightText }));\n }\n }\n\n // Translates the provided Cartographic into a EPSG:3857 point, and retrieve information.\n // tolerance is in pixels\n private async getIdentifyData(quadId: QuadId, carto: Cartographic, tolerance: number, returnGeometry?: boolean, maxAllowableOffset?: number): Promise<any> {\n\n const bbox = this.getEPSG3857Extent(quadId.row, quadId.column, quadId.level);\n const layerIds = new Array<string>();\n this._settings.subLayers.forEach((subLayer) => {\n if (this._settings.isSubLayerVisible(subLayer))\n layerIds.push(subLayer.idString);\n });\n const urlObj = ArcGISIdentifyRequestUrl.fromJSON(this._settings.url, {\n f: \"json\",\n geometry: {x: this.getEPSG3857X(carto.longitudeDegrees), y: this.getEPSG3857Y(carto.latitudeDegrees)},\n geometryType: \"esriGeometryPoint\",\n tolerance,\n mapExtent: {low: {x: bbox.left, y: bbox.bottom}, high: {x: bbox.right, y: bbox.top}},\n sr: 3857,\n imageDisplay: {width: this.tileSize, height: this.tileSize, dpi: 96},\n layers: {prefix: \"top\", layerIds},\n returnGeometry,\n maxAllowableOffset}, 3 /* 1mm accuracy*/);\n\n const response = await this.fetch(urlObj, { method: \"GET\" } );\n return response.json();\n }\n\n // Makes an identify request to ESRI MapService server, and return it as a list of formatted strings\n public override async getToolTip(strings: string[], quadId: QuadId, carto: Cartographic, tree: ImageryMapTileTree): Promise<void> {\n await super.getToolTip(strings, quadId, carto, tree);\n\n if (!this._querySupported)\n return;\n\n const stringSet = new Set<string>();\n const json = await this.getIdentifyData(quadId, carto, 1);\n\n if (json && Array.isArray(json.results)) {\n for (const result of json.results) {\n if (result.attributes !== undefined && result.attributes[result.displayFieldName] !== undefined) {\n const thisString = `${result.displayFieldName}: ${result.attributes[result.displayFieldName]}`;\n if (!stringSet.has(thisString)) {\n strings.push(thisString);\n stringSet.add(thisString);\n }\n }\n }\n }\n }\n\n // Makes an identify request to ESRI MapService , and return it as a list MapLayerFeatureInfo object\n public override async getFeatureInfo(featureInfos: MapLayerFeatureInfo[], quadId: QuadId, carto: Cartographic, _tree: ImageryMapTileTree, hit: HitDetail, options?: MapFeatureInfoOptions): Promise<void> {\n if (!this._querySupported)\n return;\n\n const tileExtent = this.getEPSG3857Extent(quadId.row, quadId.column, quadId.level);\n const toleranceWorld = (tileExtent.top - tileExtent.bottom) / this.tileSize;\n const maxAllowableOffsetFactor = 2;\n const maxAllowableOffset = maxAllowableOffsetFactor*toleranceWorld;\n\n const tolerancePixel = options?.tolerance ?? 7;\n const json = await this.getIdentifyData(quadId, carto, tolerancePixel, true, maxAllowableOffset);\n if (json && Array.isArray(json.results)) {\n const renderer = new ArcGisGraphicsRenderer({viewport: hit.viewport});\n\n const layerInfo: MapLayerFeatureInfo = { layerName: this._settings.name, subLayerInfos: [] };\n\n // The 'identify' service returns us a flat/unordered list of records..\n // results may represent features for the a common subLayer.\n // For simplicity, we group together features for a given sub-layer.\n const subLayers = new Map<string, MapSubLayerFeatureInfo> ();\n\n for (const result of json.results) {\n\n let subLayerInfo = subLayers.get(result.layerName);\n if (!subLayerInfo) {\n subLayerInfo = {\n subLayerName: result.layerName ?? \"\",\n displayFieldName: result.displayFieldName,\n features: [],\n };\n subLayers.set(result.layerName, subLayerInfo);\n }\n const feature: MapLayerFeature = {geometries: [], attributes: []};\n\n // Read all feature attributes\n for (const [key, value] of Object.entries(result.attributes)) {\n // Convert everything to string for now\n const strValue = String(value);\n feature.attributes.push({\n value: { valueFormat: PropertyValueFormat.Primitive, value: strValue, displayValue: strValue },\n property: { name: key, displayLabel: key, typename: StandardTypeNames.String },\n });\n }\n\n // Read feature geometries\n const geomReader = new ArcGisGeometryReaderJSON(result.geometryType, renderer);\n await geomReader.readGeometry(result.geometry);\n const graphics = renderer.moveGraphics();\n feature.geometries = graphics.map((graphic) => {\n return {graphic};\n });\n subLayerInfo.features.push(feature);\n\n }\n\n for ( const value of subLayers.values()) {\n layerInfo.subLayerInfos!.push(value);\n }\n\n featureInfos.push(layerInfo);\n }\n }\n\n protected getLayerString(prefix = \"show\"): string {\n const layers = new Array<string>();\n this._settings.subLayers.forEach((subLayer) => {\n if (this._settings.isSubLayerVisible(subLayer))\n layers.push(subLayer.idString);\n });\n\n return `${prefix}: ${layers.join(\",\")} `;\n }\n\n // construct the Url from the desired Tile\n public async constructUrl(row: number, column: number, zoomLevel: number): Promise<string> {\n let tmpUrl;\n if (this._usesCachedTiles) {\n tmpUrl = `${this._settings.url}/tile/${zoomLevel}/${row}/${column} `;\n } else {\n const bboxString = `${this.getEPSG3857ExtentString(row, column, zoomLevel)}&bboxSR=3857`;\n tmpUrl = `${this._settings.url}/export?bbox=${bboxString}&size=${this.tileSize},${this.tileSize}&layers=${this.getLayerString()}&format=png&transparent=${this.transparentBackgroundString}&f=image&sr=3857&imagesr=3857`;\n }\n return tmpUrl;\n }\n}\n"]}
@@ -29,6 +29,12 @@ export declare abstract class MapLayerImageryProvider {
29
29
  /** @internal */
30
30
  private _status;
31
31
  /** @internal */
32
+ protected _includeUserCredentials: boolean;
33
+ /** @internal */
34
+ protected readonly onFirstRequestCompleted: BeEvent<() => void>;
35
+ /** @internal */
36
+ protected _firstRequestPromise: Promise<void> | undefined;
37
+ /** @internal */
32
38
  get status(): MapLayerImageryProviderStatus;
33
39
  /** @alpha */
34
40
  get supportsMapFeatureInfo(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"MapLayerImageryProvider.d.ts","sourceRoot":"","sources":["../../../../src/tile/map/MapLayerImageryProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAuB,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAqB,MAAM,oBAAoB,CAAC;AAI9H,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAA0B,cAAc,EAAE,kBAAkB,EAAE,iBAA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,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAK7E,gBAAgB;IACT,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE,OAAO;IAW3G;;;OAGG;IACH,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,MAAM;CAyCzC"}
@@ -14,6 +14,7 @@ const core_geometry_1 = require("@itwin/core-geometry");
14
14
  const IModelApp_1 = require("../../IModelApp");
15
15
  const NotificationManager_1 = require("../../NotificationManager");
16
16
  const internal_1 = require("../internal");
17
+ const utils_1 = require("../../request/utils");
17
18
  /** @internal */
18
19
  const tileImageSize = 256, untiledImageSize = 256;
19
20
  const earthRadius = 6378137;
@@ -60,6 +61,10 @@ class MapLayerImageryProvider {
60
61
  this._geographicTilingScheme = new internal_1.GeographicTilingScheme();
61
62
  /** @internal */
62
63
  this._status = MapLayerImageryProviderStatus.Valid;
64
+ /** @internal */
65
+ this._includeUserCredentials = false;
66
+ /** @internal */
67
+ this.onFirstRequestCompleted = new core_bentley_1.BeEvent();
63
68
  /**
64
69
  * This value is used internally for various computations, this should not get overriden.
65
70
  * @internal
@@ -179,17 +184,48 @@ class MapLayerImageryProvider {
179
184
  /** @internal */
180
185
  setRequestAuthorization(headers) {
181
186
  if (this._settings.userName && this._settings.password) {
182
- headers.set("Authorization", `Basic ${core_common_1.Base64EncodedString.encode(`${this._settings.userName}:${this._settings.password}`)}`);
187
+ (0, utils_1.setBasicAuthorization)(headers, this._settings.userName, this._settings.password);
183
188
  }
184
189
  }
185
190
  /** @internal */
186
191
  async makeTileRequest(url) {
187
- let headers;
188
- if (this._settings.userName && this._settings.password) {
189
- headers = new Headers();
190
- this.setRequestAuthorization(headers);
192
+ // We want to complete the first request before letting other requests go;
193
+ // this done to avoid flooding server with requests missing credentials
194
+ if (!this._firstRequestPromise)
195
+ this._firstRequestPromise = new Promise((resolve) => this.onFirstRequestCompleted.addOnce(() => resolve()));
196
+ else
197
+ await this._firstRequestPromise;
198
+ let response;
199
+ try {
200
+ let headers;
201
+ let hasCreds = false;
202
+ if (this._settings.userName && this._settings.password) {
203
+ hasCreds = true;
204
+ headers = new Headers();
205
+ this.setRequestAuthorization(headers);
206
+ }
207
+ response = await fetch(url, {
208
+ method: "GET",
209
+ headers,
210
+ credentials: this._includeUserCredentials ? "include" : undefined,
211
+ });
212
+ if (response.status === 401
213
+ && (0, utils_1.headersIncludeAuthMethod)(response.headers, ["ntlm", "negotiate"])
214
+ && !this._includeUserCredentials
215
+ && !hasCreds) {
216
+ // We got a http 401 challenge, lets try again with SSO enabled (i.e. Windows Authentication)
217
+ response = await fetch(url, { method: "GET", credentials: "include" });
218
+ if (response.status === 200) {
219
+ this._includeUserCredentials = true; // avoid going through 401 challenges over and over
220
+ }
221
+ }
191
222
  }
192
- return fetch(url, { method: "GET", headers });
223
+ finally {
224
+ this.onFirstRequestCompleted.raiseEvent();
225
+ }
226
+ if (response === undefined)
227
+ throw new Error("fetch call failed");
228
+ return response;
193
229
  }
194
230
  /** Returns a map layer tile at the specified settings. */
195
231
  async loadTile(row, column, zoomLevel) {
@@ -222,7 +258,11 @@ class MapLayerImageryProvider {
222
258
  const headers = new Headers();
223
259
  this.setRequestAuthorization(headers);
224
260
  try {
225
- const response = await fetch(url, { method: "GET", headers });
261
+ const response = await fetch(url, {
262
+ method: "GET",
263
+ headers,
264
+ credentials: this._includeUserCredentials ? "include" : undefined,
265
+ });
226
266
  const text = await response.text();
227
267
  if (undefined !== text) {
228
268
  strings.push(text);