Skip to content

Commit

Permalink
Add Search Paramater Re-Insertion to Child Tile URLs in RealityDataSo…
Browse files Browse the repository at this point in the history
…urceTilesetUrlImpl (backport #7352) [release/4.10.x] (#7364)

Co-authored-by: andremig-bentley <[email protected]>
  • Loading branch information
mergify[bot] and andremig-bentley authored Nov 13, 2024
1 parent e20de5f commit 6664113
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/core-frontend",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/core-frontend"
}
16 changes: 14 additions & 2 deletions core/frontend/src/RealityDataSourceTilesetUrlImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export class RealityDataSourceTilesetUrlImpl implements RealityDataSource {
private _tilesetUrl: string | undefined;
/** For use by all Reality Data. For RD stored on PW Context Share, represents the portion from the root of the Azure Blob Container*/
private _baseUrl: string = "";
/** Need to be passed down to child tile requests when requesting from blob storage, e.g. a Cesium export from the Mesh Export Service*/
private _searchParams: string = "";

/** Construct a new reality data source.
* @param props JSON representation of the reality data source
Expand Down Expand Up @@ -69,8 +71,11 @@ export class RealityDataSourceTilesetUrlImpl implements RealityDataSource {
// otherwise the full path to root document is given.
// The base URL contains the base URL from which tile relative path are constructed.
// The tile's path root will need to be reinserted for child tiles to return a 200
// If the original url includes search paramaters, they are stored in _searchParams to be reinserted into child tile requests.
private setBaseUrl(url: string): void {
const urlParts = url.split("/");
const newUrl = new URL(url);
this._searchParams = newUrl.search;
urlParts.pop();
if (urlParts.length === 0)
this._baseUrl = "";
Expand Down Expand Up @@ -105,9 +110,16 @@ export class RealityDataSourceTilesetUrlImpl implements RealityDataSource {
return true;
}

/** Returns the tile URL. If the tile path is a full URL, it is returned as is. Otherwise, the base URL is prepended to the tile path. */
/** Returns the tile URL.
* If the tile path is a relative URL, the base URL is prepended to it.
* For both absolute and relative tile path URLs, the search parameters are checked. If the search params are empty, the base URL's search params are appended to the tile path.
*/
private getTileUrl(tilePath: string){
return this.isValidURL(tilePath) ? tilePath : this._baseUrl + tilePath;
if (this.isValidURL(tilePath)) {
const url = new URL(tilePath);
return url.search === "" ? `${tilePath}${this._searchParams}` : tilePath;
}
return tilePath.includes("?") ? `${this._baseUrl}${tilePath}` : `${this._baseUrl}${tilePath}${this._searchParams}`;
}

/**
Expand Down

0 comments on commit 6664113

Please sign in to comment.