From 1e02de6826f1c361ad5141abefae5b4549e6fb90 Mon Sep 17 00:00:00 2001 From: jjspace <8007967+jjspace@users.noreply.github.com> Date: Thu, 25 Jul 2024 13:36:09 -0400 Subject: [PATCH 1/4] add check for valid provider structure for Bing imagery --- packages/engine/Source/Scene/BingMapsImageryProvider.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/engine/Source/Scene/BingMapsImageryProvider.js b/packages/engine/Source/Scene/BingMapsImageryProvider.js index 5904bc193ce1..85a76392ceb6 100644 --- a/packages/engine/Source/Scene/BingMapsImageryProvider.js +++ b/packages/engine/Source/Scene/BingMapsImageryProvider.js @@ -120,7 +120,12 @@ function metadataSuccess(data, imageryProviderBuilder) { imageryProviderBuilder.maximumLevel = resource.zoomMax - 1; imageryProviderBuilder.imageUrlSubdomains = resource.imageUrlSubdomains; imageryProviderBuilder.imageUrlTemplate = resource.imageUrl; - imageryProviderBuilder.attributionList = resource.imageryProviders; + const validProviders = resource.imageryProviders.filter((provider) => + // 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 + provider.coverageAreas?.some((area) => defined(area.bbox)) + ); + imageryProviderBuilder.attributionList = validProviders; } function metadataFailure(metadataResource, error, provider) { From e61477382f4242b2056bfb948476d5fd30c008a1 Mon Sep 17 00:00:00 2001 From: jjspace <8007967+jjspace@users.noreply.github.com> Date: Thu, 25 Jul 2024 13:40:46 -0400 Subject: [PATCH 2/4] update changes --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index af1c081c3808..2568aa21992a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,7 @@ - Updated geometric self-shadowing function to improve direct lighting on models using physically-based rendering. [#12063](https://github.com/CesiumGS/cesium/pull/12063) - Fixed environment map LOD selection in image-based lighting. [#12070](https://github.com/CesiumGS/cesium/pull/12070) - Corrected calculation of diffuse component in image-based lighting. [#12082](https://github.com/CesiumGS/cesium/pull/12082) +- Prevent Bing Imagery API format issues from throwing errors [#12094](https://github.com/CesiumGS/cesium/pull/12094) ### 1.119 - 2024-07-01 From 481b372a51e92a74343b4f430b629a0742e0214c Mon Sep 17 00:00:00 2001 From: jjspace <8007967+jjspace@users.noreply.github.com> Date: Fri, 26 Jul 2024 13:54:41 -0400 Subject: [PATCH 3/4] fix tests --- .../engine/Source/Scene/BingMapsImageryProvider.js | 12 +++++++----- .../Specs/Scene/BingMapsImageryProviderSpec.js | 8 +++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/engine/Source/Scene/BingMapsImageryProvider.js b/packages/engine/Source/Scene/BingMapsImageryProvider.js index 85a76392ceb6..90c18532d5b3 100644 --- a/packages/engine/Source/Scene/BingMapsImageryProvider.js +++ b/packages/engine/Source/Scene/BingMapsImageryProvider.js @@ -120,11 +120,13 @@ function metadataSuccess(data, imageryProviderBuilder) { imageryProviderBuilder.maximumLevel = resource.zoomMax - 1; imageryProviderBuilder.imageUrlSubdomains = resource.imageUrlSubdomains; imageryProviderBuilder.imageUrlTemplate = resource.imageUrl; - const validProviders = resource.imageryProviders.filter((provider) => - // 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 - provider.coverageAreas?.some((area) => defined(area.bbox)) - ); + const validProviders = !defined(resource.imageryProviders) + ? resource.imageryProviders + : resource.imageryProviders.filter((provider) => + // 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 + provider.coverageAreas?.some((area) => defined(area.bbox)) + ); imageryProviderBuilder.attributionList = validProviders; } diff --git a/packages/engine/Specs/Scene/BingMapsImageryProviderSpec.js b/packages/engine/Specs/Scene/BingMapsImageryProviderSpec.js index ccfb7b37b9e6..8417fdd1e640 100644 --- a/packages/engine/Specs/Scene/BingMapsImageryProviderSpec.js +++ b/packages/engine/Specs/Scene/BingMapsImageryProviderSpec.js @@ -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(); @@ -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 () { From 688f71e452916743a32e9a5f0905c681f38caaf8 Mon Sep 17 00:00:00 2001 From: jjspace <8007967+jjspace@users.noreply.github.com> Date: Mon, 29 Jul 2024 10:50:19 -0400 Subject: [PATCH 4/4] adjust conditional --- .../Source/Scene/BingMapsImageryProvider.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/engine/Source/Scene/BingMapsImageryProvider.js b/packages/engine/Source/Scene/BingMapsImageryProvider.js index 90c18532d5b3..8024cea285de 100644 --- a/packages/engine/Source/Scene/BingMapsImageryProvider.js +++ b/packages/engine/Source/Scene/BingMapsImageryProvider.js @@ -120,13 +120,15 @@ function metadataSuccess(data, imageryProviderBuilder) { imageryProviderBuilder.maximumLevel = resource.zoomMax - 1; imageryProviderBuilder.imageUrlSubdomains = resource.imageUrlSubdomains; imageryProviderBuilder.imageUrlTemplate = resource.imageUrl; - const validProviders = !defined(resource.imageryProviders) - ? resource.imageryProviders - : resource.imageryProviders.filter((provider) => - // 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 - provider.coverageAreas?.some((area) => defined(area.bbox)) - ); + + 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; }