Uploading Assets to Cesium ion

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

As of FME 2022.0, Python 2.7 has been deprecated and is no longer available within FME. Please see the Python 2.7 Deprecation article. This article has not yet been updated to use Python 3+, to continue with this article, please use FME 2020 or older.

Overview

In this article, you will learn how to install the CesiumIonConnector in FME 2019.0, authenticate the Cesium ion Web Service, and upload assets to your Cesium ion account. Currently, the CesiumIonConnector only supports uploading CityGML, GeoTIFF, LAS, and OBJ files.

The first exercise will introduce the process of uploading assets from one of the supported formats, CityGML. Similarly, the second exercise will help you understand how to use FME to convert your data into one of the supported formats then upload the asset to Cesium ion in a single workspace.
 

Prerequisites

Before installing and using the CesiumIonConnector transformer, open up FME Workbench and navigate to Tools > FME Options > Translation. You need to ensure your Preferred Python Interpreter is set to FME Python 2.7. Once the Cesium ion Connector package has been installed (in Exercise 1 below), you can launch FME Workbench and return the Preferred Python Interpreter to your preferred Python version. 
 

Downloads

sample-data.zip

uploading-assets.fmwt


Exercise 1 - Uploading CityGML Assets

Create a New Workspace

To get started, launch FME Workbench and create a new workspace. The CesiumIonConnector transformer does not require data to be read into the workspace, a single feature needs to be created in order to kick off the translation.

create-workspace.png

Add a Creator transformer to the workspace. This will create a single feature which will tell the CesiumIonConnector to fetch data from the Source Folder and upload it as a new asset to your Cesium ion account. It is important to note that the CesiumIonConnector will upload 1 asset per feature that is passed into the CesiumIonConnector (i.e. if 10 features pass through the CesiumIonConnector, 10 assets will be uploaded to your Cesium ion account).

Install/Add a Cesium ion Connector

Add the Cesium ion Connector by typing CesiumIonConnector on your workspace canvas to bring up the Quick Add menu:

quickadd-cesiumionconnector.png

If this is your first time using the CesiumIonConnector, you will see it listed under FME Hub Transformers. Simply double click on CesiumIonConnector to install and add it to your workspace. More information and alternative installation options for the Cesium ion connector are available on FME Hub.

  • If you have previously installed the Cesium ion Connector, you will see it listed under Custom Transformers. Double click on CesiumIonConnector to add it to your workspace.

Connect the Creator to the CesiumIonConnector. Double click on the CesiumIonConnector to open the associated Parameters.

cesiumionconnector-parameters.png

For the Cesium ion Account parameter, select the Add Web Connection option from the drop-down list - this will open a new dialog.

In the Cesium ion Connection dialog, leave the Web Service as the default value (Cesium ion) and set your Connection Name (for example “Cesium ion - Personal” or your Cesium ion username).

new-web-connection.png

Next, click the Authenticate button. Sign in to your Cesium ion Account in the Web Service Authentication dialog and allow access to FME.

cesium-ion-allow-access.pngOnce you have successfully added your Cesium ion Account, set the Source Folder parameter to a directory containing one of the following data types:

  • a CityGML file and a textures subdirectory
  • GeoTIFF file
  • LAS file
  • OBJ file

If you downloaded the provided sample data to your Downloads folder, the Source Folder parameter should look something like "~\Downloads\Sample Data\CityGML\Exercise 1". The Election_Boundaries.gml file contained in the Election Boundaries folder will be uploaded by the Cesium ion Connector.

Next, set the Asset Name to “Exercise 1” which will help you identify your assets easier in the My Assets tab on your Cesium ion account. Leave the remaining parameters as default and click OK to return to the workspace.

Obtain your Asset URL

The last step in this basic translation is to attach an Inspector to the output port of the CesiumIonConnector and run the workspace.

exercise-1.png

This will automatically open the output summary in the Visual Preview window (2019+) in FME Workbench which contains the URL to your Cesium ion asset. By inspecting the results of the CesiumIonConnector, you will be able to copy the value of the _cesiumion_url attribute into a web browser for direct access to your new asset.

exercise-1-url.pngOpen your Cesium Account

Now that your data has been uploaded to your Cesium ion account, it’s time to view it on the web. Copy the _cesiumion_url attribute value into a web browser or log on to your Cesium ion account - this is where you can style your assets or add components such as an infobox using JavaScript.

exercise-1-cesium-ion-asset.png


Exercise 2 - Creating New Assets

Create a New Workspace

To get started, create a New workspace in FME Workbench. In this case, you will read in the source 2D Election Boundaries shapefile, convert features to 3D, write to one of the Cesium ion Connector’s supported formats, then upload your assets to Cesium ion.

create-workspace.png

Add an ESRI Shapefile Reader to the workspace and connect to the provided Election Boundaries Shapefile.

shapefile-reader.png

Convert to 3D

The dataset we are working with is a 2D polygon dataset, we will need to extrude our features in order to convert them to 3D.

Add an Extruder to the workspace and connect it to the Shapefile Reader Feature Type. Once you have made the connection, open the Extruder parameters, click the drop-down arrow for the Distance parameter and select Open Arithmetic Editor.

Since the source dataset does not have a height attribute, we set the extrusion distance to an existing attribute value. In this case, we want to extrude the polygons dynamically based on the value of the DIVISION attribute using the expression:

(@pow(@Value(DIVISION),2))/4

extruder.png

This will help separate dynamically set the extrusion distance for each polygon based on the Distance equation. Note: extrusion height is based on the units of the source data.

Write to a Supported Format with the FeatureWriter

Now that we have 3D features, we can write our data to one of the formats supported by the CesiumIonConnector into a new directory.

Add a FeatureWriter to the canvas, connect it to the Extruder:Extruded port, then open the FeatureWriter parameters. Set the Format to CityGML and save the CityGML file in a new directory. For example: “~\Documents\CityGML\Exercise 2\Election_Boundaries.gml”

featurewriter.png

Add a CesiumIonConnector

Add a CesiumIonConnector to the canvas, connect it to the FeatureWriter:Summary port, and open the CesiumIonConnector parameters. Since we already set up our Cesium ion Web connection in Exercise 1, you can simply select your Cesium ion Account from the drop-down list.

Next, set the Source Folder to the directory we created in the previous step: “~\Documents\CityGML\Exercise 2\”. Note: you can also create a user parameter or create a dynamic source folder by constructing the path from FME Feature Attributes in the Text Editor.

Lastly, set the Asset name to “Exercise 2”.

Obtain your Asset URL

Finally, attach an Inspector to the Output port of the CesiumIonConnector and run the workspace.

 

exercise-2.pngThe output summary will automatically open in the new Visual Preview window which contains the URL to your Cesium ion asset. By inspecting the results of the CesiumIonConnector, you will be able to copy the value of the _cesiumion_url attribute into a web browser for direct access to your new asset.

exercise-2-url.pngOpen your Cesium Account

Now that your data has been uploaded to your Cesium ion account, it’s time to view it on the web. Copy the _cesiumion_url attribute value into a web browser or log on to your Cesium ion account - this is where you can style your assets or add components such as an infobox using JavaScript.

exercise-2-cesium-ion-asset.pngData Attribution

Data used in this tutorial originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.