Skip to content

Commit

Permalink
Merge pull request #12094 from CesiumGS/bing-imagery-fix
Browse files Browse the repository at this point in the history
Add check for valid imagery provider structure for Bing Imagery
  • Loading branch information
ggetz authored Jul 29, 2024
2 parents 3cdc3e1 + 688f71e commit 32d0410
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Corrected calculation of diffuse component in image-based lighting. [#12082](https://github.com/CesiumGS/cesium/pull/12082)
- Updated specular BRDF for image-based lighting. [#12083](https://github.com/CesiumGS/cesium/pull/12083)
- Fixed environment map transform for image-based lighting. [#12091](https://github.com/CesiumGS/cesium/pull/12091)
- Prevent Bing Imagery API format issues from throwing errors [#12094](https://github.com/CesiumGS/cesium/pull/12094)

### 1.119 - 2024-07-01

Expand Down
11 changes: 10 additions & 1 deletion packages/engine/Source/Scene/BingMapsImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,16 @@ function metadataSuccess(data, imageryProviderBuilder) {
imageryProviderBuilder.maximumLevel = resource.zoomMax - 1;
imageryProviderBuilder.imageUrlSubdomains = resource.imageUrlSubdomains;
imageryProviderBuilder.imageUrlTemplate = resource.imageUrl;
imageryProviderBuilder.attributionList = resource.imageryProviders;

let validProviders = resource.imageryProviders;
if (defined(resource.imageryProviders)) {
// prevent issues with the imagery API from crashing the viewer when the expected properties are not there
// See https://github.com/CesiumGS/cesium/issues/12088
validProviders = resource.imageryProviders.filter((provider) =>
provider.coverageAreas?.some((area) => defined(area.bbox))
);
}
imageryProviderBuilder.attributionList = validProviders;
}

function metadataFailure(metadataResource, error, provider) {
Expand Down
8 changes: 5 additions & 3 deletions packages/engine/Specs/Scene/BingMapsImageryProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ describe("Scene/BingMapsImageryProvider", function () {
});

//These are the same instance only if the cache has been used
expect(provider._attributionList).toBe(provider2._attributionList);
expect(provider._imageUrlSubdomains).toBe(provider2._imageUrlSubdomains);

installFakeMetadataRequest(url, BingMapsStyle.AERIAL);
installFakeImageRequest();
Expand All @@ -253,8 +253,10 @@ describe("Scene/BingMapsImageryProvider", function () {
mapStyle: BingMapsStyle.AERIAL,
});

// Because the road is different, a non-cached request should have happened
expect(provider3._attributionList).not.toBe(provider._attributionList);
// Because the style is different, a non-cached request should have happened
expect(provider3._imageUrlSubdomains).not.toBe(
provider._imageUrlSubdomains
);
});

it("fromUrl resolves with a path", async function () {
Expand Down

0 comments on commit 32d0410

Please sign in to comment.