From ee44f2f6e77dd6bcb2e9dba8f9434fb513d3899d Mon Sep 17 00:00:00 2001 From: Robyn Thiessen-Bock Date: Tue, 8 Aug 2023 16:26:12 -0400 Subject: [PATCH] Fix to commit 50ce947...9838b9 --- docs/docs/Cesium3DTileset.html | 234 ++++++++++-------- docs/docs/CesiumTerrain.html | 216 +++++++++------- ...models_maps_assets_Cesium3DTileset.js.html | 58 ++--- ...s_models_maps_assets_CesiumTerrain.js.html | 45 ++-- src/js/models/maps/assets/Cesium3DTileset.js | 58 ++--- src/js/models/maps/assets/CesiumTerrain.js | 45 ++-- 6 files changed, 351 insertions(+), 305 deletions(-) diff --git a/docs/docs/Cesium3DTileset.html b/docs/docs/Cesium3DTileset.html index 3e69f1fef..c28c6f181 100644 --- a/docs/docs/Cesium3DTileset.html +++ b/docs/docs/Cesium3DTileset.html @@ -2035,7 +2035,7 @@

Source:
@@ -2204,7 +2204,7 @@

Parameters:
Source:
@@ -2389,6 +2389,126 @@
Returns:
+

+ + + + + getCesiumURL() → {string} +

+ + + + + + +
+ Checks whether there is an asset ID for a Cesium Ion resource and if +so, return the URL to the resource. +
+ + + + + + + + + + + + + +
+ + + + +
Since:
+
  • 2.26.0
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + +
+ The URL to the Cesium Ion resource +
+ + + +
+
+ Type +
+
+ +string + + +
+
+ + + + + + + + + + + + +

@@ -2626,7 +2746,7 @@

Source:
@@ -2968,7 +3088,7 @@

Parameters:
Source:
@@ -3136,7 +3256,7 @@

Parameters:
Source:
@@ -3302,7 +3422,7 @@
Parameters:
Source:
@@ -4079,102 +4199,6 @@
Parameters:
- - - - - - -

- - - - - setCesiumURL() -

- - - - - - -
- Checks whether there is an asset ID for a Cesium Ion resource set in the cesium -asset options. If there is, then adds or replaces the URL property the cesium -asset options with a URL created by Cesium. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - @@ -4239,7 +4263,7 @@

Source:
@@ -4434,7 +4458,7 @@

Source:
@@ -4530,7 +4554,7 @@

Source:
diff --git a/docs/docs/CesiumTerrain.html b/docs/docs/CesiumTerrain.html index 4ffee3b24..1dd6e7723 100644 --- a/docs/docs/CesiumTerrain.html +++ b/docs/docs/CesiumTerrain.html @@ -1992,6 +1992,126 @@

Returns:
+

+ + + + + getCesiumURL() → {string} +

+ + + + + + +
+ Checks whether there is an asset ID for a Cesium Ion resource and if +so, return the URL to the resource. +
+ + + + + + + + + + + + + +
+ + + + +
Since:
+
  • 2.26.0
+ + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + +
+ The URL to the Cesium Ion resource +
+ + + +
+
+ Type +
+
+ +string + + +
+
+ + + + + + + + + + + + +

@@ -3091,102 +3211,6 @@
Parameters:
- - - - - - -

- - - - - setCesiumURL() -

- - - - - - -
- Checks whether there is an asset ID for a Cesium Ion resource set in the cesium -asset options. If there is, then adds or replaces the URL property the cesium -asset options with a URL created by Cesium. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - diff --git a/docs/docs/src_js_models_maps_assets_Cesium3DTileset.js.html b/docs/docs/src_js_models_maps_assets_Cesium3DTileset.js.html index bda86589b..6d95ae648 100644 --- a/docs/docs/src_js_models_maps_assets_Cesium3DTileset.js.html +++ b/docs/docs/src_js_models_maps_assets_Cesium3DTileset.js.html @@ -171,20 +171,24 @@

Source: src/js/models/maps/assets/Cesium3DTileset.js

try { - var model = this; - var cesiumOptions = this.getCesiumOptions(); - var cesiumModel = null - // If the cesium model already exists, don't create it again unless specified - if (!recreate && this.get('cesiumModel')) { - return this.get('cesiumModel') + const currentModel = this.get('cesiumModel') + if (!recreate && currentModel) return currentModel + + const model = this; + const cesiumOptions = this.getCesiumOptions(); + let cesiumModel = null + + if (!cesiumOptions) { + model.set('status', 'error'); + model.set('statusDetails', 'No options were set for this tileset.'); + return; } model.resetStatus(); - // Check if this tileset is a Cesium Ion resource, and if it is, set the url - // from the asset Id - this.setCesiumURL() + // If this tileset is a Cesium Ion resource set the url from the asset Id + cesiumOptions.url = this.getCesiumURL(cesiumOptions) || cesiumOptions.url; cesiumModel = new Cesium.Cesium3DTileset(cesiumOptions) model.set('cesiumModel', cesiumModel) @@ -221,29 +225,27 @@

Source: src/js/models/maps/assets/Cesium3DTileset.js

} }, + /** - * Checks whether there is an asset ID for a Cesium Ion resource set in the cesium - * asset options. If there is, then adds or replaces the URL property the cesium - * asset options with a URL created by Cesium. + * Checks whether there is an asset ID for a Cesium Ion resource and if + * so, return the URL to the resource. + * @returns {string} The URL to the Cesium Ion resource + * @since 2.26.0 */ - setCesiumURL: function () { + getCesiumURL: function () { try { - - var cesiumOptions = this.getCesiumOptions(); - - // Set the asset URL if this is a Cesium Ion 3D tileset or terrain - if (cesiumOptions && cesiumOptions.ionAssetId) { - // The Cesium Ion ID of the resource to access - var assetId = Number(cesiumOptions.ionAssetId) - // Options to pass to Cesium's fromAssetId function - var ionResourceOptions = {} - // Access token needs to be set before requesting cesium ion resources - ionResourceOptions.accessToken = - cesiumOptions.cesiumToken || MetacatUI.appModel.get('cesiumToken'); - // Create the new URL and set it on the model options - cesiumOptions.url = Cesium.IonResource.fromAssetId(assetId, ionResourceOptions) - + const cesiumOptions = this.getCesiumOptions(); + if (!cesiumOptions || !cesiumOptions.ionAssetId) return null + // The Cesium Ion ID of the resource to access + const assetId = Number(cesiumOptions.ionAssetId) + // Options to pass to Cesium's fromAssetId function. Access token + // needs to be set before requesting cesium ion resources + const ionResourceOptions = { + accessToken: cesiumOptions.cesiumToken || + MetacatUI.appModel.get('cesiumToken') } + // Create the new URL and set it on the model options + return Cesium.IonResource.fromAssetId(assetId, ionResourceOptions); } catch (error) { console.log( diff --git a/docs/docs/src_js_models_maps_assets_CesiumTerrain.js.html b/docs/docs/src_js_models_maps_assets_CesiumTerrain.js.html index 2fe10de39..2b7ceaa7a 100644 --- a/docs/docs/src_js_models_maps_assets_CesiumTerrain.js.html +++ b/docs/docs/src_js_models_maps_assets_CesiumTerrain.js.html @@ -150,7 +150,7 @@

Source: src/js/models/maps/assets/CesiumTerrain.js

createCesiumModel: function (recreate = false) { var model = this; - var cesiumOptions = model.get('cesiumOptions'); + var cesiumOptions = model.getCesiumOptions(); var type = this.get('type') var terrainFunction = Cesium[type] @@ -161,9 +161,9 @@

Source: src/js/models/maps/assets/CesiumTerrain.js

model.resetStatus(); - // Check if this tileset is a Cesium Ion resource, and if it is, set the url - // from the asset Id - this.setCesiumURL() + // If this tileset is a Cesium Ion resource, set the url from the + // asset Id + cesiumOptions.url = this.getCesiumURL(cesiumOptions) || cesiumOptions.url; if (terrainFunction && typeof terrainFunction === 'function') { let terrain = new terrainFunction(cesiumOptions) @@ -184,32 +184,29 @@

Source: src/js/models/maps/assets/CesiumTerrain.js

}, /** - * Checks whether there is an asset ID for a Cesium Ion resource set in the cesium - * asset options. If there is, then adds or replaces the URL property the cesium - * asset options with a URL created by Cesium. + * Checks whether there is an asset ID for a Cesium Ion resource and if + * so, return the URL to the resource. + * @returns {string} The URL to the Cesium Ion resource + * @since 2.26.0 */ - setCesiumURL: function () { + getCesiumURL: function () { try { - - var cesiumOptions = this.get('cesiumOptions'); - - // Set the asset URL if this is a Cesium Ion 3D tileset or terrain - if (cesiumOptions && cesiumOptions.ionAssetId) { - // The Cesium Ion ID of the resource to access - var assetId = Number(cesiumOptions.ionAssetId) - // Options to pass to Cesium's fromAssetId function - var ionResourceOptions = {} - // Access token needs to be set before requesting cesium ion resources - ionResourceOptions.accessToken = - cesiumOptions.cesiumToken || MetacatUI.appModel.get('cesiumToken'); - // Create the new URL and set it on the model options - cesiumOptions.url = Cesium.IonResource.fromAssetId(assetId, ionResourceOptions) - + const cesiumOptions = this.getCesiumOptions(); + if (!cesiumOptions || !cesiumOptions.ionAssetId) return null + // The Cesium Ion ID of the resource to access + const assetId = Number(cesiumOptions.ionAssetId) + // Options to pass to Cesium's fromAssetId function. Access token + // needs to be set before requesting cesium ion resources + const ionResourceOptions = { + accessToken: cesiumOptions.cesiumToken || + MetacatUI.appModel.get('cesiumToken') } + // Create the new URL and set it on the model options + return Cesium.IonResource.fromAssetId(assetId, ionResourceOptions); } catch (error) { console.log( - 'There was an error settings a Cesium URL in a 3DTileset' + + 'There was an error settings a Cesium URL in a Cesium3DTileset' + '. Error details: ' + error ); } diff --git a/src/js/models/maps/assets/Cesium3DTileset.js b/src/js/models/maps/assets/Cesium3DTileset.js index 980ee3d44..0968dda8e 100644 --- a/src/js/models/maps/assets/Cesium3DTileset.js +++ b/src/js/models/maps/assets/Cesium3DTileset.js @@ -125,20 +125,24 @@ define( try { - var model = this; - var cesiumOptions = this.getCesiumOptions(); - var cesiumModel = null - // If the cesium model already exists, don't create it again unless specified - if (!recreate && this.get('cesiumModel')) { - return this.get('cesiumModel') + const currentModel = this.get('cesiumModel') + if (!recreate && currentModel) return currentModel + + const model = this; + const cesiumOptions = this.getCesiumOptions(); + let cesiumModel = null + + if (!cesiumOptions) { + model.set('status', 'error'); + model.set('statusDetails', 'No options were set for this tileset.'); + return; } model.resetStatus(); - // Check if this tileset is a Cesium Ion resource, and if it is, set the url - // from the asset Id - this.setCesiumURL() + // If this tileset is a Cesium Ion resource set the url from the asset Id + cesiumOptions.url = this.getCesiumURL(cesiumOptions) || cesiumOptions.url; cesiumModel = new Cesium.Cesium3DTileset(cesiumOptions) model.set('cesiumModel', cesiumModel) @@ -175,29 +179,27 @@ define( } }, + /** - * Checks whether there is an asset ID for a Cesium Ion resource set in the cesium - * asset options. If there is, then adds or replaces the URL property the cesium - * asset options with a URL created by Cesium. + * Checks whether there is an asset ID for a Cesium Ion resource and if + * so, return the URL to the resource. + * @returns {string} The URL to the Cesium Ion resource + * @since 2.26.0 */ - setCesiumURL: function () { + getCesiumURL: function () { try { - - var cesiumOptions = this.getCesiumOptions(); - - // Set the asset URL if this is a Cesium Ion 3D tileset or terrain - if (cesiumOptions && cesiumOptions.ionAssetId) { - // The Cesium Ion ID of the resource to access - var assetId = Number(cesiumOptions.ionAssetId) - // Options to pass to Cesium's fromAssetId function - var ionResourceOptions = {} - // Access token needs to be set before requesting cesium ion resources - ionResourceOptions.accessToken = - cesiumOptions.cesiumToken || MetacatUI.appModel.get('cesiumToken'); - // Create the new URL and set it on the model options - cesiumOptions.url = Cesium.IonResource.fromAssetId(assetId, ionResourceOptions) - + const cesiumOptions = this.getCesiumOptions(); + if (!cesiumOptions || !cesiumOptions.ionAssetId) return null + // The Cesium Ion ID of the resource to access + const assetId = Number(cesiumOptions.ionAssetId) + // Options to pass to Cesium's fromAssetId function. Access token + // needs to be set before requesting cesium ion resources + const ionResourceOptions = { + accessToken: cesiumOptions.cesiumToken || + MetacatUI.appModel.get('cesiumToken') } + // Create the new URL and set it on the model options + return Cesium.IonResource.fromAssetId(assetId, ionResourceOptions); } catch (error) { console.log( diff --git a/src/js/models/maps/assets/CesiumTerrain.js b/src/js/models/maps/assets/CesiumTerrain.js index 1d0f4159a..fdc641245 100644 --- a/src/js/models/maps/assets/CesiumTerrain.js +++ b/src/js/models/maps/assets/CesiumTerrain.js @@ -104,7 +104,7 @@ define( createCesiumModel: function (recreate = false) { var model = this; - var cesiumOptions = model.get('cesiumOptions'); + var cesiumOptions = model.getCesiumOptions(); var type = this.get('type') var terrainFunction = Cesium[type] @@ -115,9 +115,9 @@ define( model.resetStatus(); - // Check if this tileset is a Cesium Ion resource, and if it is, set the url - // from the asset Id - this.setCesiumURL() + // If this tileset is a Cesium Ion resource, set the url from the + // asset Id + cesiumOptions.url = this.getCesiumURL(cesiumOptions) || cesiumOptions.url; if (terrainFunction && typeof terrainFunction === 'function') { let terrain = new terrainFunction(cesiumOptions) @@ -138,32 +138,29 @@ define( }, /** - * Checks whether there is an asset ID for a Cesium Ion resource set in the cesium - * asset options. If there is, then adds or replaces the URL property the cesium - * asset options with a URL created by Cesium. + * Checks whether there is an asset ID for a Cesium Ion resource and if + * so, return the URL to the resource. + * @returns {string} The URL to the Cesium Ion resource + * @since 2.26.0 */ - setCesiumURL: function () { + getCesiumURL: function () { try { - - var cesiumOptions = this.get('cesiumOptions'); - - // Set the asset URL if this is a Cesium Ion 3D tileset or terrain - if (cesiumOptions && cesiumOptions.ionAssetId) { - // The Cesium Ion ID of the resource to access - var assetId = Number(cesiumOptions.ionAssetId) - // Options to pass to Cesium's fromAssetId function - var ionResourceOptions = {} - // Access token needs to be set before requesting cesium ion resources - ionResourceOptions.accessToken = - cesiumOptions.cesiumToken || MetacatUI.appModel.get('cesiumToken'); - // Create the new URL and set it on the model options - cesiumOptions.url = Cesium.IonResource.fromAssetId(assetId, ionResourceOptions) - + const cesiumOptions = this.getCesiumOptions(); + if (!cesiumOptions || !cesiumOptions.ionAssetId) return null + // The Cesium Ion ID of the resource to access + const assetId = Number(cesiumOptions.ionAssetId) + // Options to pass to Cesium's fromAssetId function. Access token + // needs to be set before requesting cesium ion resources + const ionResourceOptions = { + accessToken: cesiumOptions.cesiumToken || + MetacatUI.appModel.get('cesiumToken') } + // Create the new URL and set it on the model options + return Cesium.IonResource.fromAssetId(assetId, ionResourceOptions); } catch (error) { console.log( - 'There was an error settings a Cesium URL in a 3DTileset' + + 'There was an error settings a Cesium URL in a Cesium3DTileset' + '. Error details: ' + error ); }