@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.
- package/CHANGELOG.md +8 -1
- package/lib/cjs/DisplayStyleState.d.ts +3 -0
- package/lib/cjs/DisplayStyleState.d.ts.map +1 -1
- package/lib/cjs/DisplayStyleState.js +10 -0
- package/lib/cjs/DisplayStyleState.js.map +1 -1
- package/lib/cjs/Viewport.d.ts +5 -0
- package/lib/cjs/Viewport.d.ts.map +1 -1
- package/lib/cjs/Viewport.js +6 -0
- package/lib/cjs/Viewport.js.map +1 -1
- package/lib/cjs/common/gltf/GltfSchema.d.ts +20 -3
- package/lib/cjs/common/gltf/GltfSchema.d.ts.map +1 -1
- package/lib/cjs/common/gltf/GltfSchema.js.map +1 -1
- package/lib/cjs/common/imdl/ImdlModel.d.ts +15 -1
- package/lib/cjs/common/imdl/ImdlModel.d.ts.map +1 -1
- package/lib/cjs/common/imdl/ImdlModel.js +11 -3
- package/lib/cjs/common/imdl/ImdlModel.js.map +1 -1
- package/lib/cjs/common/imdl/ParseImdlDocument.d.ts +3 -1
- package/lib/cjs/common/imdl/ParseImdlDocument.d.ts.map +1 -1
- package/lib/cjs/common/imdl/ParseImdlDocument.js +66 -11
- package/lib/cjs/common/imdl/ParseImdlDocument.js.map +1 -1
- package/lib/cjs/render/GraphicBranch.d.ts +10 -0
- package/lib/cjs/render/GraphicBranch.d.ts.map +1 -1
- package/lib/cjs/render/GraphicBranch.js.map +1 -1
- package/lib/cjs/render/webgl/BranchState.d.ts +2 -0
- package/lib/cjs/render/webgl/BranchState.d.ts.map +1 -1
- package/lib/cjs/render/webgl/BranchState.js +2 -0
- package/lib/cjs/render/webgl/BranchState.js.map +1 -1
- package/lib/cjs/render/webgl/Graphic.d.ts.map +1 -1
- package/lib/cjs/render/webgl/Graphic.js +3 -0
- package/lib/cjs/render/webgl/Graphic.js.map +1 -1
- package/lib/cjs/render/webgl/InstancedGeometry.d.ts +1 -0
- package/lib/cjs/render/webgl/InstancedGeometry.d.ts.map +1 -1
- package/lib/cjs/render/webgl/InstancedGeometry.js +1 -0
- package/lib/cjs/render/webgl/InstancedGeometry.js.map +1 -1
- package/lib/cjs/request/utils.d.ts +18 -0
- package/lib/cjs/request/utils.d.ts.map +1 -0
- package/lib/cjs/request/utils.js +45 -0
- package/lib/cjs/request/utils.js.map +1 -0
- package/lib/cjs/tile/BatchedTileIdMap.d.ts +1 -2
- package/lib/cjs/tile/BatchedTileIdMap.d.ts.map +1 -1
- package/lib/cjs/tile/BatchedTileIdMap.js +3 -3
- package/lib/cjs/tile/BatchedTileIdMap.js.map +1 -1
- package/lib/cjs/tile/GltfReader.d.ts +4 -1
- package/lib/cjs/tile/GltfReader.d.ts.map +1 -1
- package/lib/cjs/tile/GltfReader.js +125 -26
- package/lib/cjs/tile/GltfReader.js.map +1 -1
- package/lib/cjs/tile/ImdlDecoder.d.ts +7 -1
- package/lib/cjs/tile/ImdlDecoder.d.ts.map +1 -1
- package/lib/cjs/tile/ImdlDecoder.js.map +1 -1
- package/lib/cjs/tile/ImdlGraphicsCreator.d.ts.map +1 -1
- package/lib/cjs/tile/ImdlGraphicsCreator.js +28 -17
- package/lib/cjs/tile/ImdlGraphicsCreator.js.map +1 -1
- package/lib/cjs/tile/ImdlReader.d.ts +2 -1
- package/lib/cjs/tile/ImdlReader.d.ts.map +1 -1
- package/lib/cjs/tile/ImdlReader.js +1 -0
- package/lib/cjs/tile/ImdlReader.js.map +1 -1
- package/lib/cjs/tile/RealityModelTileTree.d.ts.map +1 -1
- package/lib/cjs/tile/RealityModelTileTree.js +2 -3
- package/lib/cjs/tile/RealityModelTileTree.js.map +1 -1
- package/lib/cjs/tile/RealityTileTree.d.ts +31 -0
- package/lib/cjs/tile/RealityTileTree.d.ts.map +1 -1
- package/lib/cjs/tile/RealityTileTree.js +6 -0
- package/lib/cjs/tile/RealityTileTree.js.map +1 -1
- package/lib/cjs/tile/TileDrawArgs.d.ts +6 -0
- package/lib/cjs/tile/TileDrawArgs.d.ts.map +1 -1
- package/lib/cjs/tile/TileDrawArgs.js +7 -0
- package/lib/cjs/tile/TileDrawArgs.js.map +1 -1
- package/lib/cjs/tile/TileTreeReference.d.ts +2 -0
- package/lib/cjs/tile/TileTreeReference.d.ts.map +1 -1
- package/lib/cjs/tile/TileTreeReference.js +5 -0
- package/lib/cjs/tile/TileTreeReference.js.map +1 -1
- package/lib/cjs/tile/map/ArcGISTileMap.d.ts +6 -2
- package/lib/cjs/tile/map/ArcGISTileMap.d.ts.map +1 -1
- package/lib/cjs/tile/map/ArcGISTileMap.js +127 -69
- package/lib/cjs/tile/map/ArcGISTileMap.js.map +1 -1
- package/lib/cjs/tile/map/ArcGisUtilities.d.ts.map +1 -1
- package/lib/cjs/tile/map/ArcGisUtilities.js +5 -0
- package/lib/cjs/tile/map/ArcGisUtilities.js.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/ArcGISImageryProvider.d.ts.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/ArcGISImageryProvider.js +61 -39
- package/lib/cjs/tile/map/ImageryProviders/ArcGISImageryProvider.js.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +1 -1
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
- package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts +6 -0
- package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapLayerImageryProvider.js +47 -7
- package/lib/cjs/tile/map/MapLayerImageryProvider.js.map +1 -1
- package/lib/cjs/tile/map/WmsCapabilities.d.ts.map +1 -1
- package/lib/cjs/tile/map/WmsCapabilities.js +1 -15
- package/lib/cjs/tile/map/WmsCapabilities.js.map +1 -1
- package/lib/cjs/tile/map/WmsUtilities.d.ts +7 -0
- package/lib/cjs/tile/map/WmsUtilities.d.ts.map +1 -1
- package/lib/cjs/tile/map/WmsUtilities.js +22 -0
- package/lib/cjs/tile/map/WmsUtilities.js.map +1 -1
- package/lib/cjs/tile/map/WmtsCapabilities.d.ts.map +1 -1
- package/lib/cjs/tile/map/WmtsCapabilities.js +2 -16
- package/lib/cjs/tile/map/WmtsCapabilities.js.map +1 -1
- package/lib/cjs/tools/SelectTool.d.ts +1 -0
- package/lib/cjs/tools/SelectTool.d.ts.map +1 -1
- package/lib/cjs/tools/SelectTool.js +19 -13
- package/lib/cjs/tools/SelectTool.js.map +1 -1
- package/lib/esm/DisplayStyleState.d.ts +3 -0
- package/lib/esm/DisplayStyleState.d.ts.map +1 -1
- package/lib/esm/DisplayStyleState.js +10 -0
- package/lib/esm/DisplayStyleState.js.map +1 -1
- package/lib/esm/Viewport.d.ts +5 -0
- package/lib/esm/Viewport.d.ts.map +1 -1
- package/lib/esm/Viewport.js +6 -0
- package/lib/esm/Viewport.js.map +1 -1
- package/lib/esm/common/gltf/GltfSchema.d.ts +20 -3
- package/lib/esm/common/gltf/GltfSchema.d.ts.map +1 -1
- package/lib/esm/common/gltf/GltfSchema.js.map +1 -1
- package/lib/esm/common/imdl/ImdlModel.d.ts +15 -1
- package/lib/esm/common/imdl/ImdlModel.d.ts.map +1 -1
- package/lib/esm/common/imdl/ImdlModel.js +11 -3
- package/lib/esm/common/imdl/ImdlModel.js.map +1 -1
- package/lib/esm/common/imdl/ParseImdlDocument.d.ts +3 -1
- package/lib/esm/common/imdl/ParseImdlDocument.d.ts.map +1 -1
- package/lib/esm/common/imdl/ParseImdlDocument.js +67 -12
- package/lib/esm/common/imdl/ParseImdlDocument.js.map +1 -1
- package/lib/esm/render/GraphicBranch.d.ts +10 -0
- package/lib/esm/render/GraphicBranch.d.ts.map +1 -1
- package/lib/esm/render/GraphicBranch.js.map +1 -1
- package/lib/esm/render/webgl/BranchState.d.ts +2 -0
- package/lib/esm/render/webgl/BranchState.d.ts.map +1 -1
- package/lib/esm/render/webgl/BranchState.js +2 -0
- package/lib/esm/render/webgl/BranchState.js.map +1 -1
- package/lib/esm/render/webgl/Graphic.d.ts.map +1 -1
- package/lib/esm/render/webgl/Graphic.js +3 -0
- package/lib/esm/render/webgl/Graphic.js.map +1 -1
- package/lib/esm/render/webgl/InstancedGeometry.d.ts +1 -0
- package/lib/esm/render/webgl/InstancedGeometry.d.ts.map +1 -1
- package/lib/esm/render/webgl/InstancedGeometry.js +1 -0
- package/lib/esm/render/webgl/InstancedGeometry.js.map +1 -1
- package/lib/esm/request/utils.d.ts +18 -0
- package/lib/esm/request/utils.d.ts.map +1 -0
- package/lib/esm/request/utils.js +40 -0
- package/lib/esm/request/utils.js.map +1 -0
- package/lib/esm/tile/BatchedTileIdMap.d.ts +1 -2
- package/lib/esm/tile/BatchedTileIdMap.d.ts.map +1 -1
- package/lib/esm/tile/BatchedTileIdMap.js +3 -3
- package/lib/esm/tile/BatchedTileIdMap.js.map +1 -1
- package/lib/esm/tile/GltfReader.d.ts +4 -1
- package/lib/esm/tile/GltfReader.d.ts.map +1 -1
- package/lib/esm/tile/GltfReader.js +126 -27
- package/lib/esm/tile/GltfReader.js.map +1 -1
- package/lib/esm/tile/ImdlDecoder.d.ts +7 -1
- package/lib/esm/tile/ImdlDecoder.d.ts.map +1 -1
- package/lib/esm/tile/ImdlDecoder.js.map +1 -1
- package/lib/esm/tile/ImdlGraphicsCreator.d.ts.map +1 -1
- package/lib/esm/tile/ImdlGraphicsCreator.js +28 -17
- package/lib/esm/tile/ImdlGraphicsCreator.js.map +1 -1
- package/lib/esm/tile/ImdlReader.d.ts +2 -1
- package/lib/esm/tile/ImdlReader.d.ts.map +1 -1
- package/lib/esm/tile/ImdlReader.js +1 -0
- package/lib/esm/tile/ImdlReader.js.map +1 -1
- package/lib/esm/tile/RealityModelTileTree.d.ts.map +1 -1
- package/lib/esm/tile/RealityModelTileTree.js +2 -3
- package/lib/esm/tile/RealityModelTileTree.js.map +1 -1
- package/lib/esm/tile/RealityTileTree.d.ts +31 -0
- package/lib/esm/tile/RealityTileTree.d.ts.map +1 -1
- package/lib/esm/tile/RealityTileTree.js +6 -0
- package/lib/esm/tile/RealityTileTree.js.map +1 -1
- package/lib/esm/tile/TileDrawArgs.d.ts +6 -0
- package/lib/esm/tile/TileDrawArgs.d.ts.map +1 -1
- package/lib/esm/tile/TileDrawArgs.js +8 -1
- package/lib/esm/tile/TileDrawArgs.js.map +1 -1
- package/lib/esm/tile/TileTreeReference.d.ts +2 -0
- package/lib/esm/tile/TileTreeReference.d.ts.map +1 -1
- package/lib/esm/tile/TileTreeReference.js +5 -0
- package/lib/esm/tile/TileTreeReference.js.map +1 -1
- package/lib/esm/tile/map/ArcGISTileMap.d.ts +6 -2
- package/lib/esm/tile/map/ArcGISTileMap.d.ts.map +1 -1
- package/lib/esm/tile/map/ArcGISTileMap.js +130 -71
- package/lib/esm/tile/map/ArcGISTileMap.js.map +1 -1
- package/lib/esm/tile/map/ArcGisUtilities.d.ts.map +1 -1
- package/lib/esm/tile/map/ArcGisUtilities.js +5 -0
- package/lib/esm/tile/map/ArcGisUtilities.js.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/ArcGISImageryProvider.d.ts.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/ArcGISImageryProvider.js +61 -39
- package/lib/esm/tile/map/ImageryProviders/ArcGISImageryProvider.js.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +1 -1
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
- package/lib/esm/tile/map/MapLayerImageryProvider.d.ts +6 -0
- package/lib/esm/tile/map/MapLayerImageryProvider.d.ts.map +1 -1
- package/lib/esm/tile/map/MapLayerImageryProvider.js +48 -8
- package/lib/esm/tile/map/MapLayerImageryProvider.js.map +1 -1
- package/lib/esm/tile/map/WmsCapabilities.d.ts.map +1 -1
- package/lib/esm/tile/map/WmsCapabilities.js +1 -15
- package/lib/esm/tile/map/WmsCapabilities.js.map +1 -1
- package/lib/esm/tile/map/WmsUtilities.d.ts +7 -0
- package/lib/esm/tile/map/WmsUtilities.d.ts.map +1 -1
- package/lib/esm/tile/map/WmsUtilities.js +22 -0
- package/lib/esm/tile/map/WmsUtilities.js.map +1 -1
- package/lib/esm/tile/map/WmtsCapabilities.d.ts.map +1 -1
- package/lib/esm/tile/map/WmtsCapabilities.js +2 -16
- package/lib/esm/tile/map/WmtsCapabilities.js.map +1 -1
- package/lib/esm/tools/SelectTool.d.ts +1 -0
- package/lib/esm/tools/SelectTool.d.ts.map +1 -1
- package/lib/esm/tools/SelectTool.js +19 -13
- package/lib/esm/tools/SelectTool.js.map +1 -1
- package/lib/public/scripts/parse-imdl-worker.js +1 -1
- package/lib/workers/webpack/parse-imdl-worker.js +1 -1
- package/package.json +20 -19
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { ArcGisErrorCode, ArcGisUtilities, MapLayerImageryProvider, MapLayerImageryProviderStatus } from "../../internal";
|
|
9
9
|
import { IModelApp } from "../../../IModelApp";
|
|
10
10
|
import { NotifyMessageDetails, OutputMessagePriority } from "../../../NotificationManager";
|
|
11
|
+
import { headersIncludeAuthMethod } from "../../../request/utils";
|
|
11
12
|
/** Base class for ArcGIS map-layer imagery providers.
|
|
12
13
|
*
|
|
13
14
|
* The initial purpose of this class is to offer shared methods
|
|
@@ -87,50 +88,71 @@ export class ArcGISImageryProvider extends MapLayerImageryProvider {
|
|
|
87
88
|
password: this._settings.password
|
|
88
89
|
});
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (errorCode !== undefined &&
|
|
105
|
-
(errorCode === ArcGisErrorCode.TokenRequired || errorCode === ArcGisErrorCode.InvalidToken)) {
|
|
106
|
-
if (this._settings.userName && this._settings.userName.length > 0 && this._lastAccessToken) {
|
|
107
|
-
// **** Legacy token ONLY ***
|
|
108
|
-
// Token might have expired, make a second attempt by forcing new token.
|
|
109
|
-
if (this._accessClient?.invalidateToken !== undefined && this._lastAccessToken !== undefined)
|
|
110
|
-
this._accessClient.invalidateToken(this._lastAccessToken);
|
|
111
|
-
const urlObj2 = new URL(url);
|
|
112
|
-
if (this._accessClient) {
|
|
113
|
-
try {
|
|
114
|
-
this._lastAccessToken = await ArcGisUtilities.appendSecurityToken(urlObj, this._accessClient, { mapLayerUrl: urlObj, userName: this._settings.userName, password: this._settings.password });
|
|
115
|
-
}
|
|
116
|
-
catch {
|
|
117
|
-
}
|
|
91
|
+
// We want to complete the first request before letting other requests go;
|
|
92
|
+
// this done to avoid flooding server with requests missing credentials
|
|
93
|
+
if (!this._firstRequestPromise)
|
|
94
|
+
this._firstRequestPromise = new Promise((resolve) => this.onFirstRequestCompleted.addOnce(() => resolve()));
|
|
95
|
+
else
|
|
96
|
+
await this._firstRequestPromise;
|
|
97
|
+
let response;
|
|
98
|
+
try {
|
|
99
|
+
response = await fetch(urlObj.toString(), { ...options, credentials: this._includeUserCredentials ? "include" : undefined });
|
|
100
|
+
if (response.status === 401 && !this._lastAccessToken && headersIncludeAuthMethod(response.headers, ["ntlm", "negotiate"])) {
|
|
101
|
+
// We got a http 401 challenge, lets try again with SSO enabled (i.e. Windows Authentication)
|
|
102
|
+
response = await fetch(url, { ...options, credentials: "include" });
|
|
103
|
+
if (response.status === 200) {
|
|
104
|
+
this._includeUserCredentials = true; // avoid going through 401 challenges over and over
|
|
118
105
|
}
|
|
119
|
-
// Make a second attempt with refreshed token
|
|
120
|
-
response = await fetch(urlObj2.toString(), options);
|
|
121
|
-
errorCode = await ArcGisUtilities.checkForResponseErrorCode(response);
|
|
122
106
|
}
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
107
|
+
if ((this._lastAccessToken && response.status === 400)
|
|
108
|
+
|| response.headers.get("content-type")?.toLowerCase().includes("htm")) {
|
|
109
|
+
// For some reasons when we make a request with the fetch() api and there is a token error
|
|
110
|
+
// we receive a status 400 instead of proper json response. (i.e doing the same request in the browser gives a different response)
|
|
111
|
+
// For some other request, we also seen error message in html.
|
|
112
|
+
// When it occurs, we fall back to root service request so we get a proper JSON response with error code.
|
|
113
|
+
const tmpUrl = new URL(this._settings.url);
|
|
114
|
+
if (this._lastAccessToken && this._accessTokenRequired)
|
|
115
|
+
tmpUrl.searchParams.append("token", this._lastAccessToken.token);
|
|
116
|
+
tmpUrl.searchParams.append("f", "json");
|
|
117
|
+
response = await fetch(tmpUrl.toString(), options);
|
|
118
|
+
}
|
|
119
|
+
errorCode = await ArcGisUtilities.checkForResponseErrorCode(response);
|
|
120
|
+
if (errorCode !== undefined &&
|
|
121
|
+
(errorCode === ArcGisErrorCode.TokenRequired || errorCode === ArcGisErrorCode.InvalidToken)) {
|
|
122
|
+
if (this._settings.userName && this._settings.userName.length > 0 && this._lastAccessToken) {
|
|
123
|
+
// **** Legacy token ONLY ***
|
|
124
|
+
// Token might have expired, make a second attempt by forcing new token.
|
|
125
|
+
if (this._accessClient?.invalidateToken !== undefined && this._lastAccessToken !== undefined)
|
|
126
|
+
this._accessClient.invalidateToken(this._lastAccessToken);
|
|
127
|
+
const urlObj2 = new URL(url);
|
|
128
|
+
if (this._accessClient) {
|
|
129
|
+
try {
|
|
130
|
+
this._lastAccessToken = await ArcGisUtilities.appendSecurityToken(urlObj, this._accessClient, { mapLayerUrl: urlObj, userName: this._settings.userName, password: this._settings.password });
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Make a second attempt with refreshed token
|
|
136
|
+
response = await fetch(urlObj2.toString(), options);
|
|
137
|
+
errorCode = await ArcGisUtilities.checkForResponseErrorCode(response);
|
|
138
|
+
}
|
|
139
|
+
if (errorCode === ArcGisErrorCode.TokenRequired || errorCode === ArcGisErrorCode.InvalidToken) {
|
|
140
|
+
// Looks like the initially generated token has expired.
|
|
141
|
+
if (this.status === MapLayerImageryProviderStatus.Valid) {
|
|
142
|
+
// Only report new status change to avoid spamming the UI
|
|
143
|
+
this.setStatus(MapLayerImageryProviderStatus.RequireAuth);
|
|
144
|
+
this.onStatusChanged.raiseEvent(this);
|
|
145
|
+
const msg = IModelApp.localization.getLocalizedString("iModelJs:MapLayers.Messages.FetchTooltipTokenError", { layerName: this._settings.name });
|
|
146
|
+
IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Warning, msg));
|
|
147
|
+
}
|
|
131
148
|
}
|
|
132
149
|
}
|
|
133
150
|
}
|
|
151
|
+
finally {
|
|
152
|
+
this.onFirstRequestCompleted.raiseEvent();
|
|
153
|
+
}
|
|
154
|
+
if (response === undefined)
|
|
155
|
+
throw new Error("fetch call failed");
|
|
134
156
|
return response;
|
|
135
157
|
}
|
|
136
158
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArcGISImageryProvider.js","sourceRoot":"","sources":["../../../../../src/tile/map/ImageryProviders/ArcGISImageryProvider.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAyB,eAAe,EAA6C,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC5L,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE3F;;;;;;GAMG;AACH,MAAM,OAAgB,qBAAsB,SAAQ,uBAAuB;IAYzE,IAAoB,sBAAsB,KAAK,OAAO,IAAI,CAAC,eAAe,CAAC,CAAA,CAAC;IAE5E,YAAY,QAA+B,EAAE,eAAwB;QACnE,KAAK,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QAVnC;;UAEE;QACQ,yBAAoB,GAAG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AC,GAAG,CAAC,CAAC;gBAC7B,IAAI,IAAI,CAAC,aAAa,EAAE;oBACtB,IAAI;wBACF,IAAI,CAAC,gBAAgB,GAAG,MAAM,eAAe,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,EAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;qBAC7L;oBAAC,MAAM;qBACP;iBACF;gBAED,6CAA6C;gBAC7C,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;gBACpD,SAAS,GAAI,MAAM,eAAe,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC;aACxE;YAED,IAAI,SAAS,KAAK,eAAe,CAAC,aAAa,IAAI,SAAS,KAAK,eAAe,CAAC,YAAY,EAAE;gBAC/F,wDAAwD;gBAEtD,IAAI,IAAI,CAAC,MAAM,KAAK,6BAA6B,CAAC,KAAK,EAAG;oBAC1D,yDAAyD;oBACvD,IAAI,CAAC,SAAS,CAAC,6BAA6B,CAAC,WAAW,CAAC,CAAC;oBAC1D,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;oBACtC,MAAM,GAAG,GAAG,SAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,oDAAoD,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;oBAChJ,SAAS,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,oBAAoB,CAAC,qBAAqB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;iBACrG;aACF;SACF;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF","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 response;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ArcGISImageryProvider.js","sourceRoot":"","sources":["../../../../../src/tile/map/ImageryProviders/ArcGISImageryProvider.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAyB,eAAe,EAA6C,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC5L,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,oBAAo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AAO,QAAQ,CAAC;IAClB,CAAC;CACF","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"]}
|
|
@@ -170,7 +170,7 @@ export class ArcGISMapLayerImageryProvider extends ArcGISImageryProvider {
|
|
|
170
170
|
const fetch = async (url, options) => {
|
|
171
171
|
return this.fetch(url, options);
|
|
172
172
|
};
|
|
173
|
-
this._tileMap = new ArcGISTileMap(this._settings.url, this._settings, fetch
|
|
173
|
+
this._tileMap = new ArcGISTileMap(this._settings.url, this._settings, fetch);
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
// 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,OAAO,EAAoD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EACL,eAAe,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,aAAa,EACvG,eAAe,EAAsB,iBAAiB,EACjC,6BAA6B,GACnD,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAyB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MA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C,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","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,OAAO,EAAoD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EACL,eAAe,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,aAAa,EACvG,eAAe,EAAsB,iBAAiB,EACjC,6BAA6B,GACnD,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAyB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,MAAM,cAAc,GAAI,uDAAuD,CAAC;AA6DhF,gBAAgB;AAChB,MAAM,OAAO,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,YA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B,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","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,
|
|
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,EAAE,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAqB,MAAM,oBAAoB,CAAC;AAIzG,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAA0B,cAAc,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,EAA2B,MAAM,aAAa,CAAC;AAC1M,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQ5C;;GAEG;AACH,oBAAY,6BAA6B;IACvC,KAAK,IAAA;IACL,WAAW,IAAA;CACZ;AAED;;;GAGG;AACH,8BAAsB,uBAAuB;IAiE/B,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,qBAAqB;IAAE,SAAS,CAAC,gBAAgB,EAAE,OAAO;IAhEpG,SAAS,CAAC,2BAA2B,UAAS;IAC9C,SAAgB,eAAe,qBAA0B,uBAAuB,KAAK,IA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,CAAC,GAAG,EAAE,MAAM,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"}
|
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
* @module MapLayers
|
|
7
7
|
*/
|
|
8
8
|
import { assert, BeEvent } from "@itwin/core-bentley";
|
|
9
|
-
import {
|
|
9
|
+
import { ImageSource, ImageSourceFormat } from "@itwin/core-common";
|
|
10
10
|
import { Angle } from "@itwin/core-geometry";
|
|
11
11
|
import { IModelApp } from "../../IModelApp";
|
|
12
12
|
import { NotifyMessageDetails, OutputMessagePriority } from "../../NotificationManager";
|
|
13
13
|
import { GeographicTilingScheme, WebMercatorTilingScheme } from "../internal";
|
|
14
|
+
import { headersIncludeAuthMethod, setBasicAuthorization } from "../../request/utils";
|
|
14
15
|
/** @internal */
|
|
15
16
|
const tileImageSize = 256, untiledImageSize = 256;
|
|
16
17
|
const earthRadius = 6378137;
|
|
@@ -57,6 +58,10 @@ export class MapLayerImageryProvider {
|
|
|
57
58
|
this._geographicTilingScheme = new GeographicTilingScheme();
|
|
58
59
|
/** @internal */
|
|
59
60
|
this._status = MapLayerImageryProviderStatus.Valid;
|
|
61
|
+
/** @internal */
|
|
62
|
+
this._includeUserCredentials = false;
|
|
63
|
+
/** @internal */
|
|
64
|
+
this.onFirstRequestCompleted = new BeEvent();
|
|
60
65
|
/**
|
|
61
66
|
* This value is used internally for various computations, this should not get overriden.
|
|
62
67
|
* @internal
|
|
@@ -176,17 +181,48 @@ export class MapLayerImageryProvider {
|
|
|
176
181
|
/** @internal */
|
|
177
182
|
setRequestAuthorization(headers) {
|
|
178
183
|
if (this._settings.userName && this._settings.password) {
|
|
179
|
-
headers
|
|
184
|
+
setBasicAuthorization(headers, this._settings.userName, this._settings.password);
|
|
180
185
|
}
|
|
181
186
|
}
|
|
182
187
|
/** @internal */
|
|
183
188
|
async makeTileRequest(url) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
this.
|
|
189
|
+
// We want to complete the first request before letting other requests go;
|
|
190
|
+
// this done to avoid flooding server with requests missing credentials
|
|
191
|
+
if (!this._firstRequestPromise)
|
|
192
|
+
this._firstRequestPromise = new Promise((resolve) => this.onFirstRequestCompleted.addOnce(() => resolve()));
|
|
193
|
+
else
|
|
194
|
+
await this._firstRequestPromise;
|
|
195
|
+
let response;
|
|
196
|
+
try {
|
|
197
|
+
let headers;
|
|
198
|
+
let hasCreds = false;
|
|
199
|
+
if (this._settings.userName && this._settings.password) {
|
|
200
|
+
hasCreds = true;
|
|
201
|
+
headers = new Headers();
|
|
202
|
+
this.setRequestAuthorization(headers);
|
|
203
|
+
}
|
|
204
|
+
response = await fetch(url, {
|
|
205
|
+
method: "GET",
|
|
206
|
+
headers,
|
|
207
|
+
credentials: this._includeUserCredentials ? "include" : undefined,
|
|
208
|
+
});
|
|
209
|
+
if (response.status === 401
|
|
210
|
+
&& headersIncludeAuthMethod(response.headers, ["ntlm", "negotiate"])
|
|
211
|
+
&& !this._includeUserCredentials
|
|
212
|
+
&& !hasCreds) {
|
|
213
|
+
// We got a http 401 challenge, lets try again with SSO enabled (i.e. Windows Authentication)
|
|
214
|
+
response = await fetch(url, { method: "GET", credentials: "include" });
|
|
215
|
+
if (response.status === 200) {
|
|
216
|
+
this._includeUserCredentials = true; // avoid going through 401 challenges over and over
|
|
217
|
+
}
|
|
218
|
+
}
|
|
188
219
|
}
|
|
189
|
-
|
|
220
|
+
finally {
|
|
221
|
+
this.onFirstRequestCompleted.raiseEvent();
|
|
222
|
+
}
|
|
223
|
+
if (response === undefined)
|
|
224
|
+
throw new Error("fetch call failed");
|
|
225
|
+
return response;
|
|
190
226
|
}
|
|
191
227
|
/** Returns a map layer tile at the specified settings. */
|
|
192
228
|
async loadTile(row, column, zoomLevel) {
|
|
@@ -219,7 +255,11 @@ export class MapLayerImageryProvider {
|
|
|
219
255
|
const headers = new Headers();
|
|
220
256
|
this.setRequestAuthorization(headers);
|
|
221
257
|
try {
|
|
222
|
-
const response = await fetch(url, {
|
|
258
|
+
const response = await fetch(url, {
|
|
259
|
+
method: "GET",
|
|
260
|
+
headers,
|
|
261
|
+
credentials: this._includeUserCredentials ? "include" : undefined,
|
|
262
|
+
});
|
|
223
263
|
const text = await response.text();
|
|
224
264
|
if (undefined !== text) {
|
|
225
265
|
strings.push(text);
|