Add Cesium ion support to the Add Data panel #7193
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a new "Cesium ion" option to the My Data -> Add web data panel:
Clicking the "Connect to Cesium ion" button pops up a separate window to sign in to Cesium ion:
![image](https://private-user-images.githubusercontent.com/924374/337956487-f80e1c1d-dd5e-41bb-8d9b-bd34649baf40.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMwNjAzNzcsIm5iZiI6MTcyMzA2MDA3NywicGF0aCI6Ii85MjQzNzQvMzM3OTU2NDg3LWY4MGUxYzFkLWRkNWUtNDFiYi04ZDliLWJkMzQ2NDliYWY0MC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgwN1QxOTQ3NTdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kNjE2MmYxNjM3NWI3ZGNjYmM5MTRiMDIxZTM1NzhhZjkxOGQ1ODgzOWYwNDQ2MjdlNDczYTBhYWIzNDQ1NzA0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.4sp68rLtW8CFWa5d8XNWkAVdbhEG7wqpebcxkdGWedQ)
Press "Allow", and Terria will query your Cesium ion account for tokens and assets:
![image](https://private-user-images.githubusercontent.com/924374/337956522-207acc7b-5d41-467c-8a5e-937448658041.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMwNjAzNzcsIm5iZiI6MTcyMzA2MDA3NywicGF0aCI6Ii85MjQzNzQvMzM3OTU2NTIyLTIwN2FjYzdiLTVkNDEtNDY3Yy04YTVlLTkzNzQ0ODY1ODA0MS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgwN1QxOTQ3NTdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xZTIwZGYzMzdiZmIyYWFmMTAxYmE4OTlmODk5Yjg0ZjZmNDU2OWY0NTcyMDNlNmI4NzA4MmUzMWUxNmE3MTlmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.BMELnN1ch1annCnNF77MRUPhH6dwzrsD1tJiZzMVI4o)
Choose an appropriate token and then click the
![image](https://private-user-images.githubusercontent.com/924374/337956563-85f79bb3-502b-4264-8f97-c484a287e20e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMwNjAzNzcsIm5iZiI6MTcyMzA2MDA3NywicGF0aCI6Ii85MjQzNzQvMzM3OTU2NTYzLTg1Zjc5YmIzLTUwMmItNDI2NC04Zjk3LWM0ODRhMjg3ZTIwZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgwN1QxOTQ3NTdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05MTMwMGFiNzA2YWYwZGZkZTQxZWFiMmMyYzQ2ZWJmMzNmNDMzNDA0YWRkNzkxYjVkZWFlNDJiOGIwY2Y1NWY2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.i9FaIrteGZsG4JtJx492ND2zOaXzj04gHk4dx0FG1sQ)
+
next to a dataset. The dataset is added to the Workbench and the My Data list as usual:Just like in the normal Terria catalog, you can hold down shift or control to keep the panel open so you can quickly add multiple datasets.
The token selection is important because this token is used to access the asset, which means that if you create a Share URL, that token will be embedded in it and available to anyone that has the Share URL. You probably don't want to use a token that has access to all of your assets.
To set this up in your Terria Map, you need to first create an OAuth2 Application on Cesium ion. Here's the one I set up for local testing:
You can use this same one for testing on localhost. Open up your TerriaMap config.json and add this to the
parameters
section:For a TerriaMap not running on localhost, though, you'll need to set up your own. The Redirect URI should be
Replace
https://example.com/TerriaMap
with the base URL of your TerriaMap, of course. And then put the "ClientID" that Cesium ion provides in thecesiumIonOAuth2ApplicationID
property in config.json.Note that the Cesium ion support will only work on localhost and on
https
URLs, so it can't work onci.terria.io
because it only supportshttp
. This is because it uses crypto.subtle.All of the Cesium ion asset types can be imported, including 3D Tiles, glTF, KML, CZML, GeoJSON, Terrain, and Imagery. I had to extend some of these CatalogItem types to support Cesium ion, which I did via a
CesiumIonMixin
.There's one quirk with glTF, though. I'm currently importing models to be located at null island, because that's better than the center of the Earth. It should probably integrate with the Model Editor instead, but I didn't explore this.
Sort of fixes #6388