Loading Layers in Cesium Clients

Cesium clients can load mesh, point cloud, and imagery layers from SkylineGlobe Server using either Skyline's SGSProvider or Cesium API. Elevation layers can only be loaded via Skyline's SGSProvider:

§  Loading Layers Using Skyline's SGSProvider

§  Loading Layers Using Cesium API

Loading Layers in Cesium Clients Using Skyline's SGSProvider

Cesium clients can load mesh, point cloud, imagery, and elevation layers from SkylineGlobe Server using Skyline's SGSProvider:

§  Mesh and point cloud layers – Exposed as 3D Tiles. Only the original data format is stored on the server.

§  Imagery layers – Served as WMS.

§  Elevation layers – Served via SGSTerrainProvider, SkylineGlobe Server's custom Cesium terrain provider.

Note:    When a project is loaded, SkylineGlobe Server's custom terrain provider, "SGSTerrainProvider", overrides the Cesium terrainProvider set in the Cesium client project, and its MPT or TBP is set as the base terrain. If the loaded project also contains elevation layers or other elevation layers from a different project are loaded, the last elevation layer loaded is set as the base terrain. If you do not want a project's elevation layers to replace your base terrain, set the layerType only to layer types other than elevation, i.e., _LayerType.MESH, _LayerType.IMAGERY, or _LayerType.POINT_CLOUD or any combination of these. See below for more information.

 

To load your layers in a Cesium client using Skyline's SGSProvider:

Note:    SGSProvider is supported in Cesium 1.62 and above.

1.     Open .\SG\Resources, and copy the CesiumJS folder to your .\Cesium\Apps folder.

2.     Add the SGSProvider.v2.js in your main HTML to start using the SGSProvider library.

<script src="CesiumJS/SGSProvider.v2.js" type="text/javascript"></script>

3.     Connect to SGS using the SGSProvider.connect method.

Note:        After the initial connection to SGS, there is no need to reconnect before loading additional layers.

SGSProvider.connect (URL, username, password)

The following connection options are available:

§  Connect as a guest user only to public layers, e.g.,

SGSProvider.connect("https://cloud.skylineglobe.com/sg/demos");

§  Connect with a token, e.g.,

SGSProvider.connect("https://cloud.skylineglobe.com/sg/demos/[TOKEN]");

§  Connect with a user and password, e.g.,

SGSProvider.connect("https://cloud.skylineglobe.com/sg/demos", "Username", "Password");

4.     Load layers in either of the following ways:

§  Load all Layers in a Project - Load all layers in a specific Cesium project. The layerType parameter can be left empty to load all supported layer types in the project, or a specific layer type can be passed to load only layers of that type. More than one layer type can be passed in a single call. The supported layer types are: _LayerType.MESH, _LayerType.POINT_CLOUD, _LayerType.IMAGERY, and _LayerType.ELEVATION.

SGSProvider.loadLayersFromProject(project, layerType)

 

The following example loads all mesh and imagery layers in the SampleProject project:

SGSProvider.loadLayersFromProject("SampleProject", [_LayerType.MESH, _LayerType.IMAGERY]);

 

§  Load Individual Layers - Load individual layers by ID, alias, or tag. For loading by tag, set the resourceType to _ResourceType.TAG.

SGSProvider.loadLayers(resourceID, resourceType, layerType)

·         This example loads a single layer by ID.

SGSProvider.loadLayers("123456");

·         This example loads a single layer by alias.

SGSProvider.loadLayers("SomeAlias);

·         This example loads all layers of a specified LayerType that share a common tag. The supported layer types are: MESH, POINT_CLOUD, IMAGERY, and ELEVATION. For loading by tag, set the resourceType to _ResourceType.TAG.

SGSProvider.loadLayers("TagName", _ResourceType.TAG, [_LayerType.POINT_CLOUD]);

Loading Layers in Cesium Clients Using Cesium API

Cesium clients can load mesh, point cloud, and imagery layers from SkylineGlobe Server using Cesium API. SGS exposes 3DML mesh and point cloud data as 3D Tiles for access by Cesium clients, while storing only the original data format on the server. Imagery layers are served as WMS.

Notes

§  The 3D Tiles version is determined by the Default 3D Tiles Version setting on the Settings page unless it is explicitly defined by a 3DML’s b3dmversion tag (see below). See "Setting SkylineGlobe Server Settings" in the "SkylineGlobe Server Settings" chapter for more information.

§  The connection to SkylineGlobe Server is a Guest connection, so only publicly shared layers, i.e., layers whose permission level was set to "Everyone", can be loaded. See "Granting Edit or View Access" in the "Working with Layers" chapter for more information.

§  Elevation layers can be loaded using Skyline's SGSProvider. See "Loading Layers in Cesium Clients Using Skyline's SGSProvider" in this chapter for information.

Loading Mesh Layers in Cesium Clients

To load your mesh layer in a Cesium client using Cesium API:

1.     Add a Cesium3DTileset element:

var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({

url : "https://cloud.skylineglobe.com/SG/demos/b3dm/Frederick/tileset.json"

}));

2.     Use the following path format for the layer to load:

E.g., https://cloud.skylineglobe.com/SG/demos/b3dm/Frederick/tileset.json

Example:

var viewer = new Cesium.Viewer("cesiumContainer");

var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({

url: "https://cloud.skylineglobe.com/SG/demos/b3dm/Frederick/tileset.json"

}));

tileset.readyPromise.then(function(tileset) {

viewer.camera.flyToBoundingSphere( tileset.boundingSphere);

});

Note:    You can also interactively browse, edit and run this code example in Cesium Sandcastle.

3.     You can set the OGC 3D Tiles version in which to expose the mesh layer, by appending the 3D Tiles version (b3dmversion) query parameter to the end of your 3D Tile URL. Leave the parameter value empty to use the latest version. Use the following format:

b3dmversion=[version #]

E.g., https://cloud.skylineglobe.com/SG/demos/b3dm/Frederick/tileset.json?b3dmversion=V0.2

 

Note:        If a b3dmversion query parameter is not appended to the URL, the 3D Tiles version is determined by the Default 3D Tiles Version setting on the Settings page. See "Setting SkylineGlobe Server Settings" in the "SkylineGlobe Server Settings" chapter for more information.

4.     If you want to define how to handle the 3DML’s elevation values, append the vertical datum (vdatum) parameter to the end of your 3D Tile URL. The vdatum parameter can have either of the following values:

§  convert_z: Reproject to ellipsoid (as required by the OGC 3D Tiles standard) for compatibility with terrain that uses true ellipsoid elevation.

§  copy_z: Maintain elevation values as geoid, while declaring them as ellipsoid.

Note:        Most input coordinate systems and terrain data, including MPT, use geoid elevation values even though they are declared as ellipsoid when delivered to Cesium, and thus they are actually compatible without reprojection.

Use the following format:

?vdatum=[reprojection value: either copy_z. OR convert_z]

E.g., https://cloud.skylineglobe.com/SG/demos/b3dm/Frederick/tileset.json?b3dmversion=V0.2&vdatum=copy_z

Loading Point Cloud Layers in Cesium Clients

To load your point cloud layer in a Cesium client using Cesium API:

1.     Add a Cesium3DTileset element:

var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({

url: "https://cloud.skylineglobe.com/SG/demos/pnts/625698/tileset.json"

}));

2.     Use the following path format for the layer to load:

https://[ServerName]/sg/[SiteName]/pnts/[LayerID]/tileset.json

E.g., https://cloud.skylineglobe.com/SG/demos/pnts/625698/tileset.json

Example:

var viewer = new Cesium.Viewer("cesiumContainer");
var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({

url: "https://cloud.skylineglobe.com/SG/demos/pnts/625698/tileset.json"

}));

tileset.readyPromise.then(function(tileset) {

viewer.camera.flyToBoundingSphere(tileset.boundingSphere);

});

Note:    You can also interactively browse, edit and run this code example in Cesium Sandcastle.

3.     If you want to define how to handle the point cloud's elevation values, append the vertical datum (vdatum) parameter to the end of your 3D Tile URL. The vdatum parameter can have either of the following values:

§  convert_z: Reproject to ellipsoid (as required by the OGC 3D Tiles standard) for compatibility with terrain that uses true ellipsoid elevation.

§  copy_z: Maintain elevation values as geoid, while declaring them as ellipsoid.

Note:        Most input coordinate systems and terrain data, including MPT, use geoid elevation values even though they are declared as ellipsoid when delivered to Cesium, and thus they are actually compatible without reprojection.

Use the following format:

?vdatum=[reprojection value: either copy_z. OR convert_z]

E.g., https://cloud.skylineglobe.com/SG/demos/pnts/625698/tileset.json?vdatum=copy_z

 

Loading Imagery Layers in Cesium Clients

SGS serves imagery layers to Cesium viewers.

To load imagery data in a Cesium client using Cesium API:

1.     Add a Cesium ImageryProvider element.

var imageryLayers = viewer.imageryLayers;

imageryLayers.addImageryProvider();

2.     Create a new Cesium WebMapServiceImageryProvider object.

new Cesium.WebMapServiceImageryProvider({});

Example:

var viewer = new Cesium.Viewer("cesiumContainer");
var imageryLayers = viewer.imageryLayers;

Cesium.when(imageryLayers.addImageryProvider(

  new Cesium.WebMapServiceImageryProvider({

    url: "https://cloud.skylineglobe.com/SG/Demos/Streamer.ashx",

    layer: "Caterpillar_Ortho3cm.ii.625696",

rectangle: Cesium.Rectangle.fromDegrees(-158.38508605957,21.2051582336426,-157.554759979248,21.8001365661621),

    parameters: {

      transparent: true,

      format: "image/png",

    },

  })),function(a){viewer.camera.flyTo({destination: new Cesium.Rectangle.fromDegrees(-158.38523979, 21.8002224, -157.55467415, 21.2050724)});});