@itwin/core-frontend 4.3.2 → 4.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,25 @@
1
1
  # Change Log - @itwin/core-frontend
2
2
 
3
- This log was last generated on Thu, 14 Dec 2023 20:23:02 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 25 Mar 2024 16:54:36 GMT and should not be manually modified.
4
+
5
+ ## 4.3.5
6
+ Mon, 25 Mar 2024 16:54:36 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 4.3.4
11
+ Fri, 22 Mar 2024 13:30:31 GMT
12
+
13
+ ### Updates
14
+
15
+ - Bump @itwin/object-storage-core
16
+
17
+ ## 4.3.3
18
+ Wed, 03 Jan 2024 19:28:38 GMT
19
+
20
+ ### Updates
21
+
22
+ - Fixed an issue preventing tiles published by some specific ArcGIS MapServer to be correctly displayed in the view.
4
23
 
5
24
  ## 4.3.2
6
25
  Thu, 14 Dec 2023 20:23:02 GMT
@@ -8,20 +8,24 @@ export type FetchFunction = (url: URL, options?: RequestInit) => Promise<Respons
8
8
  /** @internal */
9
9
  export declare class ArcGISTileMap {
10
10
  tileMapRequestSize: number;
11
+ private static maxLod;
12
+ get tileMapOffset(): number;
11
13
  fallbackTileMapRequestSize: number;
12
14
  private _callQueues;
13
15
  private _tilesCache;
14
16
  private _restBaseUrl;
15
17
  private _fetchFunc;
16
18
  private _settings;
17
- constructor(restBaseUrl: string, settings: ImageMapLayerSettings, fetchFunc: FetchFunction, nbLods?: number);
19
+ constructor(restBaseUrl: string, settings: ImageMapLayerSettings, fetchFunc: FetchFunction);
18
20
  protected fetchTileMapFromServer(level: number, row: number, column: number, width: number, height: number): Promise<any>;
19
21
  protected getAvailableTilesFromCache(tiles: QuadId[]): {
20
22
  allTilesFound: boolean;
21
23
  available: boolean[];
22
24
  };
23
25
  getChildrenAvailability(childIds: QuadId[]): Promise<boolean[]>;
24
- protected fetchAndReadTilemap(queryTiles: QuadId[], reqWidth: number, reqHeight: number): Promise<boolean[]>;
26
+ private isCacheMissingTile;
27
+ private collectTilesMissingFromCache;
28
+ fetchAndReadTilemap(queryTiles: QuadId[], reqWidth: number, reqHeight: number): Promise<boolean[]>;
25
29
  protected getChildrenAvailabilityFromServer(childIds: QuadId[]): Promise<boolean[]>;
26
30
  }
27
31
  //# sourceMappingURL=ArcGISTileMap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ArcGISTileMap.d.ts","sourceRoot":"","sources":["../../../../src/tile/map/ArcGISTileMap.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,gBAAgB;AAChB,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAInF,gBAAgB;AAChB,qBAAa,aAAa;IAChB,kBAAkB,SAAM;IACxB,0BAA0B,SAAK;IAEvC,OAAO,CAAC,WAAW,CAAwC;IAC3D,OAAO,CAAC,WAAW,CAA2E;IAC9F,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,SAAS,CAAwB;gBAE7B,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,qBAAqB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,MAAM;cAS3F,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAM/H,SAAS,CAAC,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG;QAAC,aAAa,EAAE,OAAO,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AAC,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG;QAAC,aAAa,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,OAAO,EAAE,CAAA;KAAC;IAexF,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAiC5E,OAAO,CAAC,kBAAkB;IAmB1B,OAAO,CAAC,4BAA4B;IAcvB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;cAyH1E,iCAAiC,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAa1F"}
@@ -10,19 +10,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.ArcGISTileMap = void 0;
11
11
  const core_bentley_1 = require("@itwin/core-bentley");
12
12
  const internal_1 = require("../internal");
13
+ const loggerCategory = "ArcGISTileMap";
13
14
  const nonVisibleChildren = [false, false, false, false];
14
15
  /** @internal */
15
16
  class ArcGISTileMap {
16
- constructor(restBaseUrl, settings, fetchFunc, nbLods) {
17
- this.tileMapRequestSize = 32;
17
+ // We want to query a tile map that covers an area all around the top-lef missing tile, we offset the top-left corner position of the tilemap.
18
+ // We used to create a 32x32 tiles area around the missing tiles, but this was causing the tilemap top-left position
19
+ // to fall outside the dataset bundle of the remote server, thus giving invalid response.
20
+ get tileMapOffset() { return (this.tileMapRequestSize * 0.5); }
21
+ constructor(restBaseUrl, settings, fetchFunc) {
22
+ // For similar reasons as the corner offset, we need to keep the tile map size not too big to avoid covering multiple bundles.
23
+ this.tileMapRequestSize = 8;
18
24
  this.fallbackTileMapRequestSize = 2;
19
25
  this._tilesCache = new core_bentley_1.Dictionary((lhs, rhs) => (0, core_bentley_1.compareStrings)(lhs, rhs));
20
26
  this._restBaseUrl = restBaseUrl;
21
27
  this._fetchFunc = fetchFunc;
22
28
  this._settings = settings;
23
- if (nbLods !== undefined && nbLods > 0) {
24
- this._callQueues = new Array(nbLods).fill(Promise.resolve(nonVisibleChildren));
25
- }
29
+ this._callQueues = new Array(ArcGISTileMap.maxLod).fill(Promise.resolve(nonVisibleChildren));
26
30
  }
27
31
  async fetchTileMapFromServer(level, row, column, width, height) {
28
32
  const tmpUrl = `${this._restBaseUrl}/tilemap/${level}/${row}/${column}/${width}/${height}?f=json`;
@@ -44,10 +48,12 @@ class ArcGISTileMap {
44
48
  async getChildrenAvailability(childIds) {
45
49
  if (!childIds.length)
46
50
  return [];
47
- // We need to check cache again:
48
- // Tiles we are looking for may have been added to cache while we were waiting in the call queue.
51
+ // Before entering the queue for a backend request,
52
+ // let check if cache doesn't already contain what we are looking for.
49
53
  const cacheInfo = this.getAvailableTilesFromCache(childIds);
50
54
  if (cacheInfo.allTilesFound) {
55
+ if (cacheInfo.available.includes(false))
56
+ return cacheInfo.available;
51
57
  return cacheInfo.available;
52
58
  }
53
59
  // If we never encountered this tile level before, then a tilemap request must be made to get tiles visibility.
@@ -56,48 +62,115 @@ class ArcGISTileMap {
56
62
  // before making another one.
57
63
  const childLevel = childIds[0].level + 1;
58
64
  if (this._callQueues && childLevel < this._callQueues.length) {
59
- const res = this._callQueues[childLevel].then(async () => this.getChildrenAvailabilityFromServer(childIds));
65
+ const res = this._callQueues[childLevel].then(async () => {
66
+ return this.getChildrenAvailabilityFromServer(childIds);
67
+ });
60
68
  this._callQueues[childLevel] = res.catch(() => nonVisibleChildren);
61
69
  return res;
62
70
  }
63
71
  else {
64
72
  // We should not be in this case, probably because server info is missing LODs in the capabilities?!
73
+ core_bentley_1.Logger.logWarning(loggerCategory, `Skipped request queue for child level ${childLevel}`);
65
74
  return this.getChildrenAvailabilityFromServer(childIds);
66
75
  }
67
76
  }
77
+ isCacheMissingTile(level, startRow, startColumn, endRow, endColumn) {
78
+ let missingTileFound = false;
79
+ if (endRow <= startRow || endColumn <= startColumn)
80
+ return missingTileFound;
81
+ for (let j = startColumn; j <= endColumn && !missingTileFound; j++) {
82
+ for (let i = startRow; i <= endRow && !missingTileFound; i++) {
83
+ if (j >= 0 && i >= 0) {
84
+ const contentId = internal_1.QuadId.getTileContentId(level, j, i);
85
+ if (this._tilesCache.get(contentId) === undefined) {
86
+ missingTileFound = true;
87
+ }
88
+ }
89
+ }
90
+ }
91
+ return missingTileFound;
92
+ }
93
+ collectTilesMissingFromCache(missingQueryTiles) {
94
+ const missingTiles = [];
95
+ for (const quad of missingQueryTiles) {
96
+ const contentId = internal_1.QuadId.getTileContentId(quad.level, quad.column, quad.row);
97
+ const avail = this._tilesCache.get(contentId);
98
+ if (avail === undefined)
99
+ missingTiles.push(quad);
100
+ }
101
+ return missingTiles;
102
+ }
68
103
  // Query tiles are tiles that we need to check availability
69
104
  // The array is assumed to be in in row major orientation, i.e.: [TileRow0Col0, TileRow0Col1, TileRow1Col0, TileRow1Col1,]
70
105
  async fetchAndReadTilemap(queryTiles, reqWidth, reqHeight) {
71
- let available = [];
106
+ let available = queryTiles.map(() => false);
72
107
  if (queryTiles.length === 0) {
73
108
  return available;
74
109
  }
75
- const row = queryTiles[0].row;
76
- const column = queryTiles[0].column;
77
- const level = queryTiles[0].level;
78
- let reqRow, reqColumn;
79
- if (reqWidth === this.fallbackTileMapRequestSize && reqHeight === this.fallbackTileMapRequestSize) {
80
- reqRow = row;
81
- reqColumn = column;
82
- }
83
- else {
84
- // If tile map if big enough. create offset that will place the current tile in the middle of the tilemap.
85
- // If we place the first query tile in the top-left corner (i.e. without offset), any query for a tile located above or on the left
86
- // will trigger a new request.
87
- const offsetRow = (reqHeight / 2.0) - 1;
88
- const offsetColumn = (reqWidth / 2.0) - 1;
89
- reqRow = Math.max(row - offsetRow, 0);
90
- reqColumn = Math.max(column - offsetColumn, 0);
91
- }
92
- try {
93
- // console.log(`Tilemap request: ${level},${reqRow},${reqColumn},${reqWidth},${reqHeight}`);
94
- const json = await this.fetchTileMapFromServer(level, reqRow, reqColumn, reqWidth, reqHeight);
110
+ // console.log(`queryTiles: ${queryTiles.map((quad) => quad.contentId)}`);
111
+ // Find the top-left most corner of the extent covering the query tiles.
112
+ const getTopLeftCorner = (tiles) => {
113
+ let row;
114
+ let column;
115
+ for (const quad of tiles) {
116
+ if (row === undefined || quad.row <= row)
117
+ row = quad.row;
118
+ if (column === undefined || quad.column <= column) {
119
+ column = quad.column;
120
+ }
121
+ }
122
+ return { row, column };
123
+ };
124
+ const level = queryTiles[0].level; // We assume all tiles to be on the same level
125
+ let missingQueryTiles = this.collectTilesMissingFromCache(queryTiles);
126
+ let gotAdjusted = false;
127
+ let nbAttempt = 0; // Safety: We should never be making more requests than the number of queries tiles (otherwise something is wrong)
128
+ while (missingQueryTiles.length > 0
129
+ && (nbAttempt++ < queryTiles.length)) {
130
+ const tileMapTopLeft = getTopLeftCorner(missingQueryTiles);
131
+ if (tileMapTopLeft.row === undefined || tileMapTopLeft.column === undefined)
132
+ return available; // Should not occurs since missingQueryTiles is non empty
133
+ let tileMapRow = tileMapTopLeft.row;
134
+ let tileMapColumn = tileMapTopLeft.column;
135
+ const logLocationOffset = (newRow, newCol) => `[Row:${newRow !== tileMapTopLeft.row ? `${tileMapTopLeft.row}->${newRow}` : `${newRow}`} Column:${newCol !== tileMapTopLeft.column ? `${tileMapTopLeft.column}->${newCol}` : `${newCol}`}]`;
136
+ // Position the top-left missing tile in the middle of the tilemap; minimizing requests if sibling tiles are requested right after
137
+ // If previous response got adjusted, don't try to optimize tile map location
138
+ if (queryTiles.length < this.tileMapRequestSize && !gotAdjusted) {
139
+ const tileMapOffset = this.tileMapOffset - Math.floor(Math.sqrt(queryTiles.length) * 0.5);
140
+ const missingTileBufferSize = Math.ceil(tileMapOffset * 0.5);
141
+ if (this.isCacheMissingTile(level, tileMapRow - missingTileBufferSize, tileMapColumn - missingTileBufferSize, tileMapRow - 1, tileMapColumn - 1)) {
142
+ tileMapRow = Math.max(tileMapRow - tileMapOffset, 0);
143
+ tileMapColumn = Math.max(tileMapColumn - tileMapOffset, 0);
144
+ core_bentley_1.Logger.logTrace(loggerCategory, `Offset applied to location in top-left direction: ${logLocationOffset(tileMapRow, tileMapColumn)}`);
145
+ }
146
+ else {
147
+ const leftMissingTiles = this.isCacheMissingTile(level, tileMapRow, tileMapColumn - missingTileBufferSize, tileMapRow + missingTileBufferSize, tileMapColumn - 1);
148
+ const topMissingTiles = this.isCacheMissingTile(level, tileMapRow - missingTileBufferSize, tileMapColumn, tileMapRow - 1, tileMapColumn + missingTileBufferSize);
149
+ if (leftMissingTiles && topMissingTiles) {
150
+ tileMapRow = Math.max(tileMapRow - tileMapOffset, 0);
151
+ tileMapColumn = Math.max(tileMapColumn - tileMapOffset, 0);
152
+ core_bentley_1.Logger.logTrace(loggerCategory, `Offset applied to location in top-left direction. ${logLocationOffset(tileMapRow, tileMapColumn)}`);
153
+ }
154
+ else if (leftMissingTiles) {
155
+ tileMapColumn = Math.max(tileMapColumn - tileMapOffset, 0);
156
+ core_bentley_1.Logger.logTrace(loggerCategory, `Offset applied to location in left direction. ${logLocationOffset(tileMapRow, tileMapColumn)}`);
157
+ }
158
+ else if (topMissingTiles) {
159
+ tileMapRow = Math.max(tileMapRow - tileMapOffset, 0);
160
+ core_bentley_1.Logger.logTrace(loggerCategory, `Offset applied to location in top direction: ${logLocationOffset(tileMapRow, tileMapColumn)}`);
161
+ }
162
+ else
163
+ core_bentley_1.Logger.logTrace(loggerCategory, `No offset applied to location: ${logLocationOffset(tileMapRow, tileMapColumn)}`);
164
+ }
165
+ }
166
+ const json = await this.fetchTileMapFromServer(level, tileMapRow, tileMapColumn, reqWidth, reqHeight);
95
167
  let tileMapWidth = reqWidth;
96
168
  let tileMapHeight = reqHeight;
97
169
  if (Array.isArray(json.data)) {
98
170
  // The response width and height might be different than the requested dimensions.
99
171
  // Ref: https://developers.arcgis.com/rest/services-reference/enterprise/tile-map.htm
100
172
  if (json.adjusted) {
173
+ gotAdjusted = true;
101
174
  // If tilemap size got adjusted, I'm expecting to get adjusted size...
102
175
  // otherwise there is something really odd with this server.
103
176
  (0, core_bentley_1.assert)(json.location?.width !== undefined && json.location?.height !== undefined);
@@ -106,70 +179,55 @@ class ArcGISTileMap {
106
179
  tileMapHeight = json.location?.height;
107
180
  }
108
181
  }
109
- let k = 0;
110
- for (let j = 0; j < tileMapWidth; j++) {
111
- for (let i = 0; i < tileMapHeight; i++) {
182
+ // Build cache from tile map response
183
+ for (let j = 0; j < tileMapHeight; j++) {
184
+ for (let i = 0; i < tileMapWidth; i++) {
112
185
  const avail = json.data[(j * tileMapWidth) + i] !== 0;
113
- const curColumn = reqColumn + i;
114
- const curRow = reqRow + j;
115
- // console.log(`Tilemap tile:: ${level},${curRow},${curColumn} => ${avail}`);
186
+ const curColumn = tileMapColumn + i;
187
+ const curRow = tileMapRow + j;
116
188
  this._tilesCache.set(internal_1.QuadId.getTileContentId(level, curColumn, curRow), avail);
117
- // Check if actual tile is among the children we are looking for, if so update the availability array.
118
- if (curColumn >= queryTiles[0].column && curColumn <= queryTiles[queryTiles.length - 1].column
119
- && curRow >= queryTiles[0].row && curRow <= queryTiles[queryTiles.length - 1].row) {
120
- available[k++] = avail;
121
- }
122
189
  }
123
190
  }
191
+ // Collect tile missing from the cache
192
+ // There are 2 reasons why the tile map response would not cover all the missing tiles:
193
+ // 1. The requested tile map size is not large enough to cover all tiles
194
+ // 2. The tile map size has been adjusted by the server (i.e. data bundle limits)
195
+ missingQueryTiles = this.collectTilesMissingFromCache(missingQueryTiles);
196
+ if (missingQueryTiles.length > 0)
197
+ core_bentley_1.Logger.logTrace(loggerCategory, `There are ${missingQueryTiles.length} missing tiles from previous request`);
124
198
  }
125
199
  else {
126
- // If server returns data (i.e. error 422), thats fine we assume all tiles of tilemap are not available.
127
- available = queryTiles.map(() => false);
128
- // Mark all tilemap tiles to non-available in the cache too
200
+ missingQueryTiles = [];
201
+ // Mark all tilemap tiles to non-available in the cache too.
129
202
  for (let j = 0; j < tileMapWidth; j++) {
130
203
  for (let i = 0; i < tileMapHeight; i++) {
131
- this._tilesCache.set(internal_1.QuadId.getTileContentId(level, reqColumn + i, reqRow + j), false);
204
+ this._tilesCache.set(internal_1.QuadId.getTileContentId(level, tileMapColumn + i, tileMapRow + j), false);
132
205
  }
133
206
  }
134
207
  }
208
+ } // end loop missing tiles
209
+ if (nbAttempt > queryTiles.length) {
210
+ core_bentley_1.Logger.logError(loggerCategory, `Request loop was terminated; unable to get missing tiles; `);
135
211
  }
136
- catch (_error) {
137
- available = queryTiles.map(() => false);
138
- }
212
+ // Create final output array from cache
213
+ available = queryTiles.map((quad) => this._tilesCache.get(quad.contentId) ?? false);
214
+ if (available.includes(false))
215
+ return available;
139
216
  return available;
140
217
  }
141
218
  async getChildrenAvailabilityFromServer(childIds) {
142
- // We need to check cache again:
143
- // Tiles we are looking for may have been added to cache while we were waiting in the call queue.
144
- const cacheInfo = this.getAvailableTilesFromCache(childIds);
145
- if (cacheInfo.allTilesFound) {
146
- return cacheInfo.available;
147
- }
148
219
  let available;
149
220
  try {
150
221
  available = await this.fetchAndReadTilemap(childIds, this.tileMapRequestSize, this.tileMapRequestSize);
151
- if (available.length !== childIds.length) {
152
- if (this.tileMapRequestSize > this.fallbackTileMapRequestSize) {
153
- // Maybe we were unlucky and the tilemap got adjusted our the tiles we are looking for got clipped,
154
- // so let try we a smaller tilemap
155
- available = await this.fetchAndReadTilemap(childIds, this.fallbackTileMapRequestSize, this.fallbackTileMapRequestSize);
156
- }
157
- if (available.length < childIds.length) {
158
- // Could not all tiles children tiles, returns what we got and fill any gaps with false.
159
- const tmpAvail = childIds.map(() => false);
160
- for (let i = 0; i < available.length; i++) {
161
- tmpAvail[i] = available[i];
162
- }
163
- available = tmpAvail;
164
- }
165
- }
166
222
  }
167
- catch (_error) {
223
+ catch (err) {
168
224
  // if any error occurs, we assume tiles not to be visible
225
+ core_bentley_1.Logger.logError(loggerCategory, `Error while fetching tile map data : ${err}`);
169
226
  available = childIds.map(() => false);
170
227
  }
171
228
  return available;
172
229
  }
173
230
  }
231
+ ArcGISTileMap.maxLod = 30;
174
232
  exports.ArcGISTileMap = ArcGISTileMap;
175
233
  //# sourceMappingURL=ArcGISTileMap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ArcGISTileMap.js","sourceRoot":"","sources":["../../../../src/tile/map/ArcGISTileMap.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAyE;AACzE,0CAAqC;AAMrC,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAExD,gBAAgB;AAChB,MAAa,aAAa;IAUxB,YAAY,WAAmB,EAAE,QAA+B,EAAE,SAAwB,EAAE,MAAe;QATnG,uBAAkB,GAAG,EAAE,CAAC;QACxB,+BAA0B,GAAG,CAAC,CAAC;QAG/B,gBAAW,GAAG,IAAI,yBAAU,CAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,IAAA,6BAAc,EAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QAM5F,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,GAAG,CAAC,EAAE;YACtC,IAAI,CAAC,WAAW,GAAG,IAAI,KAAK,CAAqB,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAY,kBAAkB,CAAC,CAAC,CAAC;SAC/G;IAEH,CAAC;IACS,KAAK,CAAC,sBAAsB,CAAC,KAAa,EAAE,GAAW,EAAE,MAAc,EAAE,KAAa,EAAE,MAAc;QAC9G,MAAM,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,YAAY,KAAK,IAAI,GAAG,IAAI,MAAM,IAAI,KAAK,IAAI,MAAM,SAAS,CAAC;QAClG,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CA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S,CAAC;SAC5B;QAED,IAAI,SAAS,CAAC;QACd,IAAI;YACF,SAAS,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACvG,IAAI,SAAS,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,EAAE;gBACxC,IAAI,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,0BAA0B,EAAE;oBAC/D,mGAAmG;oBACnG,kCAAkC;oBAChC,SAAS,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,0BAA0B,EAAE,IAAI,CAAC,0BAA0B,CAAC,CAAC;iBACxH;gBAED,IAAI,SAAS,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE;oBACtC,wFAAwF;oBACxF,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAE,EAAE,CAAA,KAAK,CAAC,CAAC;oBACzC,KAAK,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAC,SAAS,CAAC,MAAM,EAAC,CAAC,EAAE,EAAG;wBACrC,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;qBAC5B;oBACD,SAAS,GAAG,QAAQ,CAAC;iBACtB;aACF;SACF;QAAC,OAAO,MAAM,EAAE;YACf,yDAAyD;YACzD,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAE,EAAE,CAAA,KAAK,CAAC,CAAC;SACrC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAnLD,sCAmLC","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 { assert, compareStrings, Dictionary } from \"@itwin/core-bentley\";\nimport { QuadId } from \"../internal\";\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\n\n/** @internal */\nexport type FetchFunction = (url: URL, options?: RequestInit) => Promise<Response>;\n\nconst nonVisibleChildren = [false, false, false, false];\n\n/** @internal */\nexport class ArcGISTileMap {\n public tileMapRequestSize = 32;\n public fallbackTileMapRequestSize = 2;\n\n private _callQueues: Array<Promise<boolean[]>> | undefined;\n private _tilesCache = new Dictionary<string, boolean>((lhs, rhs) => compareStrings(lhs, rhs));\n private _restBaseUrl: string;\n private _fetchFunc: FetchFunction;\n private _settings: ImageMapLayerSettings;\n\n constructor(restBaseUrl: string, settings: ImageMapLayerSettings, fetchFunc: FetchFunction, nbLods?: number ){\n this._restBaseUrl = restBaseUrl;\n this._fetchFunc = fetchFunc;\n this._settings = settings;\n if (nbLods !== undefined && nbLods > 0) {\n this._callQueues = new Array<Promise<boolean[]>>(nbLods).fill(Promise.resolve<boolean[]>(nonVisibleChildren));\n }\n\n }\n protected async fetchTileMapFromServer(level: number, row: number, column: number, width: number, height: number): Promise<any> {\n const tmpUrl = `${this._restBaseUrl}/tilemap/${level}/${row}/${column}/${width}/${height}?f=json`;\n const response = await this._fetchFunc(new URL(tmpUrl));\n return response.json();\n }\n\n protected getAvailableTilesFromCache(tiles: QuadId[]): {allTilesFound: boolean, available: boolean[]} {\n let allTilesFound = true;\n\n // Check children visibility from cache\n const available = tiles.map((tileId) => {\n const avail = this._tilesCache.get(tileId.contentId);\n if (undefined === avail) {\n allTilesFound = false;\n }\n return avail ?? false;\n });\n\n return {allTilesFound, available};\n }\n\n public async getChildrenAvailability(childIds: QuadId[]): Promise<boolean[]> {\n if (!childIds.length)\n return [];\n\n // We need to check cache again:\n // Tiles we are looking for may have been added to cache while we were waiting in the call queue.\n const cacheInfo = this.getAvailableTilesFromCache(childIds);\n if (cacheInfo.allTilesFound) {\n return cacheInfo.available;\n }\n\n // If we never encountered this tile level before, then a tilemap request must be made to get tiles visibility.\n // However, we dont want several overlapping large tilemap request being made simultaneously for tiles on the same level.\n // To avoid this from happening, we 'serialize' async calls so that we wait until the first tilemap request has completed\n // before making another one.\n const childLevel = childIds[0].level+1;\n if (this._callQueues && childLevel < this._callQueues.length ) {\n const res = this._callQueues[childLevel].then(async () => this.getChildrenAvailabilityFromServer(childIds));\n this._callQueues[childLevel] = res.catch(() => nonVisibleChildren);\n return res;\n } else {\n // We should not be in this case, probably because server info is missing LODs in the capabilities?!\n return this.getChildrenAvailabilityFromServer(childIds);\n }\n }\n\n // Query tiles are tiles that we need to check availability\n // The array is assumed to be in in row major orientation, i.e.: [TileRow0Col0, TileRow0Col1, TileRow1Col0, TileRow1Col1,]\n protected async fetchAndReadTilemap(queryTiles: QuadId[], reqWidth: number, reqHeight: number) {\n let available: boolean[] = [];\n if (queryTiles.length === 0) {\n return available;\n }\n\n const row = queryTiles[0].row;\n const column = queryTiles[0].column;\n const level = queryTiles[0].level;\n\n let reqRow, reqColumn;\n if (reqWidth === this.fallbackTileMapRequestSize && reqHeight === this.fallbackTileMapRequestSize){\n reqRow = row;\n reqColumn = column;\n } else {\n // If tile map if big enough. create offset that will place the current tile in the middle of the tilemap.\n // If we place the first query tile in the top-left corner (i.e. without offset), any query for a tile located above or on the left\n // will trigger a new request.\n const offsetRow = (reqHeight/2.0)-1;\n const offsetColumn = (reqWidth/2.0)-1;\n reqRow = Math.max(row - offsetRow, 0);\n reqColumn = Math.max(column - offsetColumn, 0);\n }\n\n try {\n // console.log(`Tilemap request: ${level},${reqRow},${reqColumn},${reqWidth},${reqHeight}`);\n const json = await this.fetchTileMapFromServer(level, reqRow, reqColumn, reqWidth, reqHeight);\n let tileMapWidth = reqWidth;\n let tileMapHeight = reqHeight;\n if (Array.isArray(json.data)){\n\n // The response width and height might be different than the requested dimensions.\n // Ref: https://developers.arcgis.com/rest/services-reference/enterprise/tile-map.htm\n if (json.adjusted) {\n // If tilemap size got adjusted, I'm expecting to get adjusted size...\n // otherwise there is something really odd with this server.\n assert(json.location?.width !== undefined && json.location?.height !== undefined);\n if (json.location?.width !== undefined && json.location?.height !== undefined) {\n tileMapWidth = json.location?.width;\n tileMapHeight = json.location?.height;\n }\n }\n let k = 0;\n for (let j = 0; j < tileMapWidth; j++) {\n for (let i = 0; i < tileMapHeight; i++) {\n const avail = json.data[(j*tileMapWidth)+i] !== 0;\n const curColumn = reqColumn + i;\n const curRow = reqRow + j;\n // console.log(`Tilemap tile:: ${level},${curRow},${curColumn} => ${avail}`);\n this._tilesCache.set(QuadId.getTileContentId(level, curColumn, curRow), avail);\n\n // Check if actual tile is among the children we are looking for, if so update the availability array.\n if ( curColumn >= queryTiles[0].column && curColumn <= queryTiles[queryTiles.length-1].column\n && curRow >= queryTiles[0].row && curRow <= queryTiles[queryTiles.length-1].row ) {\n available[k++] = avail;\n }\n\n }\n }\n } else {\n // If server returns data (i.e. error 422), thats fine we assume all tiles of tilemap are not available.\n available = queryTiles.map(()=>false);\n\n // Mark all tilemap tiles to non-available in the cache too\n for (let j = 0; j < tileMapWidth; j++) {\n for (let i = 0; i < tileMapHeight; i++) {\n this._tilesCache.set(QuadId.getTileContentId(level, reqColumn + i, reqRow + j), false);\n }\n }\n }\n } catch (_error) {\n available = queryTiles.map(()=>false);\n }\n\n return available;\n }\n\n protected async getChildrenAvailabilityFromServer(childIds: QuadId[]): Promise<boolean[]> {\n // We need to check cache again:\n // Tiles we are looking for may have been added to cache while we were waiting in the call queue.\n const cacheInfo = this.getAvailableTilesFromCache(childIds);\n if (cacheInfo.allTilesFound) {\n return cacheInfo.available;\n }\n\n let available;\n try {\n available = await this.fetchAndReadTilemap(childIds, this.tileMapRequestSize, this.tileMapRequestSize);\n if (available.length !== childIds.length) {\n if (this.tileMapRequestSize > this.fallbackTileMapRequestSize) {\n // Maybe we were unlucky and the tilemap got adjusted our the tiles we are looking for got clipped,\n // so let try we a smaller tilemap\n available = await this.fetchAndReadTilemap(childIds, this.fallbackTileMapRequestSize, this.fallbackTileMapRequestSize);\n }\n\n if (available.length < childIds.length) {\n // Could not all tiles children tiles, returns what we got and fill any gaps with false.\n const tmpAvail = childIds.map(()=>false);\n for (let i=0; i<available.length;i++ ) {\n tmpAvail[i] = available[i];\n }\n available = tmpAvail;\n }\n }\n } catch (_error) {\n // if any error occurs, we assume tiles not to be visible\n available = childIds.map(()=>false);\n }\n\n return available;\n }\n}\n"]}
1
+ {"version":3,"file":"ArcGISTileMap.js","sourceRoot":"","sources":["../../../../src/tile/map/ArcGISTileMap.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAiF;AACjF,0CAAqC;AAErC,MAAM,cAAc,GAAG,eAAe,CAAC;AAKvC,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAExD,gBAAgB;AAChB,MAAa,aAAa;IAMxB,8IAA8I;IAC9I,oHAAoH;IACpH,yFAAyF;IACzF,IAAW,aAAa,KAAI,OAAO,CAAC,IAAI,CAAC,kBAAkB,GAAG,GAAG,CAAC,CAAC,CAAA,CAAC;IAUpE,YAAY,WAAmB,EAAE,QAA+B,EAAE,SAAwB;QAjB1F,8HAA8H;QACvH,uBAAkB,GAAG,CAAC,CAAC;QAQtB,+BAA0B,GAAG,CAAC,CAAC;QAG/B,gBAAW,GAAG,IAAI,yBAAU,CAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,IAAA,6BAAc,EAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QAM5F,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,KAAK,CAAqB,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAY,kBAAkB,CAAC,CAAC,CAAC;IAE9H,CAAC;IACS,KAAK,CAAC,sBAAsB,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,CAAC,WAAW,CAAC,GAAG,CAAC,iBAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;qBAChG;iBACF;aACF;SACF,CAAE,yBAAyB;QAE5B,IAAI,SAAS,GAAG,UAAU,CAAC,MAAM,EAAE;YACjC,qBAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,4DAA4D,CAAC,CAAC;SAC/F;QACD,uCAAuC;QACvC,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAC,EAAE,CAAA,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC;QAElF,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC3B,OAAO,SAAS,CAAC;QAEnB,OAAO,SAAS,CAAC;IACnB,CAAC;IAES,KAAK,CAAC,iCAAiC,CAAC,QAAkB;QAElE,IAAI,SAAS,CAAC;QACd,IAAI;YACF,SAAS,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;SACxG;QAAC,OAAO,GAAG,EAAE;YACZ,yDAAyD;YACzD,qBAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,wCAAwC,GAAG,EAAE,CAAC,CAAC;YAC/E,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAE,EAAE,CAAA,KAAK,CAAC,CAAC;SACrC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;;AAlPc,oBAAM,GAAG,EAAE,AAAL,CAAM;AAJhB,sCAAa","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 { assert, compareStrings, Dictionary, Logger } from \"@itwin/core-bentley\";\nimport { QuadId } from \"../internal\";\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\nconst loggerCategory = \"ArcGISTileMap\";\n\n/** @internal */\nexport type FetchFunction = (url: URL, options?: RequestInit) => Promise<Response>;\n\nconst nonVisibleChildren = [false, false, false, false];\n\n/** @internal */\nexport class ArcGISTileMap {\n\n // For similar reasons as the corner offset, we need to keep the tile map size not too big to avoid covering multiple bundles.\n public tileMapRequestSize = 8;\n private static maxLod = 30;\n\n // We want to query a tile map that covers an area all around the top-lef missing tile, we offset the top-left corner position of the tilemap.\n // We used to create a 32x32 tiles area around the missing tiles, but this was causing the tilemap top-left position\n // to fall outside the dataset bundle of the remote server, thus giving invalid response.\n public get tileMapOffset() {return (this.tileMapRequestSize * 0.5);}\n\n public fallbackTileMapRequestSize = 2;\n\n private _callQueues: Array<Promise<boolean[]>> | undefined;\n private _tilesCache = new Dictionary<string, boolean>((lhs, rhs) => compareStrings(lhs, rhs));\n private _restBaseUrl: string;\n private _fetchFunc: FetchFunction;\n private _settings: ImageMapLayerSettings;\n\n constructor(restBaseUrl: string, settings: ImageMapLayerSettings, fetchFunc: FetchFunction ){\n this._restBaseUrl = restBaseUrl;\n this._fetchFunc = fetchFunc;\n this._settings = settings;\n this._callQueues = new Array<Promise<boolean[]>>(ArcGISTileMap.maxLod).fill(Promise.resolve<boolean[]>(nonVisibleChildren));\n\n }\n protected async fetchTileMapFromServer(level: number, row: number, column: number, width: number, height: number): Promise<any> {\n const tmpUrl = `${this._restBaseUrl}/tilemap/${level}/${row}/${column}/${width}/${height}?f=json`;\n const response = await this._fetchFunc(new URL(tmpUrl));\n return response.json();\n }\n\n protected getAvailableTilesFromCache(tiles: QuadId[]): {allTilesFound: boolean, available: boolean[]} {\n let allTilesFound = true;\n\n // Check children visibility from cache\n const available = tiles.map((tileId) => {\n const avail = this._tilesCache.get(tileId.contentId);\n if (undefined === avail) {\n allTilesFound = false;\n }\n return avail ?? false;\n });\n\n return {allTilesFound, available};\n }\n\n public async getChildrenAvailability(childIds: QuadId[]): Promise<boolean[]> {\n if (!childIds.length)\n return [];\n\n // Before entering the queue for a backend request,\n // let check if cache doesn't already contain what we are looking for.\n const cacheInfo = this.getAvailableTilesFromCache(childIds);\n if (cacheInfo.allTilesFound) {\n\n if (cacheInfo.available.includes(false))\n return cacheInfo.available;\n\n return cacheInfo.available;\n }\n\n // If we never encountered this tile level before, then a tilemap request must be made to get tiles visibility.\n // However, we dont want several overlapping large tilemap request being made simultaneously for tiles on the same level.\n // To avoid this from happening, we 'serialize' async calls so that we wait until the first tilemap request has completed\n // before making another one.\n const childLevel = childIds[0].level+1;\n if (this._callQueues && childLevel < this._callQueues.length ) {\n const res = this._callQueues[childLevel].then(async () => {\n return this.getChildrenAvailabilityFromServer(childIds);\n });\n this._callQueues[childLevel] = res.catch(() => nonVisibleChildren);\n return res;\n } else {\n // We should not be in this case, probably because server info is missing LODs in the capabilities?!\n Logger.logWarning(loggerCategory, `Skipped request queue for child level ${childLevel}`);\n return this.getChildrenAvailabilityFromServer(childIds);\n }\n }\n\n private isCacheMissingTile(level: number, startRow: number, startColumn: number, endRow: number, endColumn: number) {\n let missingTileFound = false;\n\n if (endRow <= startRow || endColumn <= startColumn)\n return missingTileFound;\n\n for (let j = startColumn; j <= endColumn && !missingTileFound; j++) {\n for (let i = startRow; i<=endRow && !missingTileFound; i++) {\n if (j >= 0 && i >= 0) {\n const contentId = QuadId.getTileContentId(level, j, i);\n if (this._tilesCache.get(contentId) === undefined) {\n missingTileFound = true;\n }\n }\n }\n }\n return missingTileFound;\n }\n\n private collectTilesMissingFromCache( missingQueryTiles: QuadId[]) {\n const missingTiles: QuadId[] = [];\n for (const quad of missingQueryTiles) {\n const contentId = QuadId.getTileContentId(quad.level, quad.column, quad.row);\n const avail = this._tilesCache.get(contentId);\n if (avail === undefined)\n missingTiles.push(quad);\n\n }\n return missingTiles;\n }\n\n // Query tiles are tiles that we need to check availability\n // The array is assumed to be in in row major orientation, i.e.: [TileRow0Col0, TileRow0Col1, TileRow1Col0, TileRow1Col1,]\n public async fetchAndReadTilemap(queryTiles: QuadId[], reqWidth: number, reqHeight: number) {\n let available = queryTiles.map(()=>false);\n if (queryTiles.length === 0 ) {\n return available;\n }\n\n // console.log(`queryTiles: ${queryTiles.map((quad) => quad.contentId)}`);\n\n // Find the top-left most corner of the extent covering the query tiles.\n const getTopLeftCorner = (tiles: QuadId[]): {row: number|undefined, column: number|undefined} => {\n let row: number|undefined;\n let column: number|undefined;\n for (const quad of tiles) {\n if (row === undefined || quad.row <= row )\n row = quad.row;\n if (column === undefined || quad.column <= column) {\n column = quad.column ;\n }\n }\n return {row, column};\n };\n\n const level = queryTiles[0].level; // We assume all tiles to be on the same level\n\n let missingQueryTiles = this.collectTilesMissingFromCache(queryTiles);\n let gotAdjusted = false;\n let nbAttempt = 0; // Safety: We should never be making more requests than the number of queries tiles (otherwise something is wrong)\n while (missingQueryTiles.length > 0\n && (nbAttempt++ < queryTiles.length) ) {\n const tileMapTopLeft = getTopLeftCorner(missingQueryTiles);\n if (tileMapTopLeft.row === undefined || tileMapTopLeft.column === undefined)\n return available; // Should not occurs since missingQueryTiles is non empty\n\n let tileMapRow = tileMapTopLeft.row;\n let tileMapColumn = tileMapTopLeft.column;\n\n const logLocationOffset = (newRow: number, newCol: number) => `[Row:${newRow !== tileMapTopLeft.row ? `${tileMapTopLeft.row}->${newRow}` : `${newRow}`} Column:${newCol !== tileMapTopLeft.column ? `${tileMapTopLeft.column}->${newCol}` : `${newCol}`}]`;\n\n // Position the top-left missing tile in the middle of the tilemap; minimizing requests if sibling tiles are requested right after\n // If previous response got adjusted, don't try to optimize tile map location\n if (queryTiles.length < this.tileMapRequestSize && !gotAdjusted) {\n const tileMapOffset = this.tileMapOffset - Math.floor(Math.sqrt(queryTiles.length) * 0.5);\n const missingTileBufferSize = Math.ceil(tileMapOffset * 0.5);\n if (this.isCacheMissingTile(level, tileMapRow-missingTileBufferSize, tileMapColumn-missingTileBufferSize, tileMapRow-1, tileMapColumn-1)) {\n tileMapRow = Math.max(tileMapRow - tileMapOffset, 0);\n tileMapColumn = Math.max(tileMapColumn - tileMapOffset, 0);\n Logger.logTrace(loggerCategory, `Offset applied to location in top-left direction: ${logLocationOffset(tileMapRow, tileMapColumn)}`);\n } else {\n const leftMissingTiles = this.isCacheMissingTile(level, tileMapRow, tileMapColumn-missingTileBufferSize, tileMapRow+missingTileBufferSize, tileMapColumn-1);\n const topMissingTiles = this.isCacheMissingTile(level, tileMapRow-missingTileBufferSize, tileMapColumn, tileMapRow-1, tileMapColumn+missingTileBufferSize);\n if (leftMissingTiles && topMissingTiles) {\n tileMapRow = Math.max(tileMapRow - tileMapOffset, 0);\n tileMapColumn = Math.max(tileMapColumn- tileMapOffset, 0);\n Logger.logTrace(loggerCategory, `Offset applied to location in top-left direction. ${logLocationOffset(tileMapRow, tileMapColumn)}`);\n } else if (leftMissingTiles) {\n tileMapColumn = Math.max(tileMapColumn - tileMapOffset, 0);\n Logger.logTrace(loggerCategory, `Offset applied to location in left direction. ${logLocationOffset(tileMapRow, tileMapColumn)}`);\n } else if (topMissingTiles) {\n tileMapRow = Math.max(tileMapRow - tileMapOffset, 0);\n Logger.logTrace(loggerCategory, `Offset applied to location in top direction: ${logLocationOffset(tileMapRow, tileMapColumn)}`);\n } else\n Logger.logTrace(loggerCategory, `No offset applied to location: ${logLocationOffset(tileMapRow, tileMapColumn)}`);\n }\n }\n\n const json = await this.fetchTileMapFromServer(level, tileMapRow, tileMapColumn, reqWidth, reqHeight);\n let tileMapWidth = reqWidth;\n let tileMapHeight = reqHeight;\n if (Array.isArray(json.data)) {\n // The response width and height might be different than the requested dimensions.\n // Ref: https://developers.arcgis.com/rest/services-reference/enterprise/tile-map.htm\n if (json.adjusted) {\n gotAdjusted = true;\n // If tilemap size got adjusted, I'm expecting to get adjusted size...\n // otherwise there is something really odd with this server.\n assert(json.location?.width !== undefined && json.location?.height !== undefined);\n if (json.location?.width !== undefined && json.location?.height !== undefined) {\n tileMapWidth = json.location?.width;\n tileMapHeight = json.location?.height;\n }\n }\n // Build cache from tile map response\n for (let j = 0; j < tileMapHeight; j++) {\n for (let i = 0; i < tileMapWidth; i++) {\n const avail = json.data[(j*tileMapWidth)+i] !== 0;\n const curColumn = tileMapColumn + i;\n const curRow = tileMapRow + j;\n this._tilesCache.set(QuadId.getTileContentId(level, curColumn, curRow), avail);\n }\n }\n\n // Collect tile missing from the cache\n // There are 2 reasons why the tile map response would not cover all the missing tiles:\n // 1. The requested tile map size is not large enough to cover all tiles\n // 2. The tile map size has been adjusted by the server (i.e. data bundle limits)\n missingQueryTiles = this.collectTilesMissingFromCache(missingQueryTiles);\n if (missingQueryTiles.length > 0)\n Logger.logTrace(loggerCategory, `There are ${missingQueryTiles.length} missing tiles from previous request`);\n } else {\n missingQueryTiles = [];\n // Mark all tilemap tiles to non-available in the cache too.\n for (let j = 0; j < tileMapWidth; j++) {\n for (let i = 0; i < tileMapHeight; i++) {\n this._tilesCache.set(QuadId.getTileContentId(level, tileMapColumn + i, tileMapRow + j), false);\n }\n }\n }\n } // end loop missing tiles\n\n if (nbAttempt > queryTiles.length) {\n Logger.logError(loggerCategory, `Request loop was terminated; unable to get missing tiles; `);\n }\n // Create final output array from cache\n available = queryTiles.map((quad)=>this._tilesCache.get(quad.contentId) ?? false);\n\n if (available.includes(false))\n return available;\n\n return available;\n }\n\n protected async getChildrenAvailabilityFromServer(childIds: QuadId[]): Promise<boolean[]> {\n\n let available;\n try {\n available = await this.fetchAndReadTilemap(childIds, this.tileMapRequestSize, this.tileMapRequestSize);\n } catch (err) {\n // if any error occurs, we assume tiles not to be visible\n Logger.logError(loggerCategory, `Error while fetching tile map data : ${err}`);\n available = childIds.map(()=>false);\n }\n\n return available;\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,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,EA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ACvC,SAAS,CAAC,aAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACtC;YAED,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC9B;IACH,CAAC;IAES,cAAc,CAAC,MAAM,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, 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,C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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"]}