Working on c++ with cesium-native from github

I’m trying to work with cesium-native repo for reading and getting data from DTED files.
I didn’t manage to find the functions to do so.
Is it even possible? Am I trying to do something impossible or I’m just missing something?
is the cesium-native just a base for the other APIs or is it a usable library?
Thanks for the help!

1. Setting up cesium-native

Before we can work with DTED data in cesium-native, we need to ensure cesium-native is set up correctly:

  1. Clone the Repository:

bashCopy code

git clone
  1. Build the Project: Navigate to the cloned directory and create a build directory:

bashCopy code

mkdir build && cd build

Configure and build the project with CMake:

bashCopy code

cmake ..
make -j4  # Adjust '4' to the number of CPU cores you want to use for the build.

2. Integrating a DTED Reader with cesium-native

cesium-native doesn’t have built-in support for DTED. You’d need to either:

  • Use an existing DTED reading library.
  • Write your own DTED parser.

For the sake of this guide, let’s assume you’re going with the first option.

Find a DTED Reading Library: There are several open-source libraries that can read DTED files. One such option is GDAL. Once you’ve chosen a library, integrate it into your cesium-native project. This might involve including the library’s headers, linking against its binaries, and adding any necessary initialization code.

3. Reading DTED Data

With your DTED reader integrated:

  1. Load the DTED File: Use the DTED reading library to open and read your DTED file.
  2. Extract Elevation Data: The primary data of interest in a DTED file is its elevation data. Extract this data into a format that you can work with in cesium-native. This will typically be a 2D array of elevation values.

4. Convert DTED Data to Desired Output

Depending on your needs, you might want to:

  • Convert to Quantized Mesh: If you’re aiming to display the terrain in CesiumJS, you might want to convert the elevation data to the Quantized Mesh format, which is optimized for CesiumJS rendering.
  • Generate 3D Tiles: Another option for CesiumJS is to convert the DTED data into 3D Tiles, which is a format optimized for streaming and rendering 3D data.

5. Displaying the Data in CesiumJS

Once you’ve processed the DTED data:

  1. Serve the Data: If you’ve converted the data to Quantized Mesh or 3D Tiles, you’ll need to serve it from a web server or a specialized tile server.
  2. Load in CesiumJS: In your CesiumJS application, add a new terrain provider pointing to your served DTED data.

Caveats & Considerations

  1. Performance: DTED files can be large, especially if you’re working with high-resolution data. Ensure that your processing pipeline is optimized, especially if you’re planning to process many files.
  2. Accuracy: Ensure that the DTED reading library you choose is accurate and can handle any quirks or variations in the DTED format.
  3. Licensing: Some DTED data might come with licensing restrictions. Ensure that you have the necessary permissions to use and distribute the data.

This is a high-level overview of the process. Each step can be quite involved, especially when it comes to integrating a new library with cesium-native or converting the DTED data into another format. If you run into specific issues or have questions about a particular step, please let me know!

When working with DTED data, the most recommended and widely-used library is GDAL (Geospatial Data Abstraction Library). GDAL provides the ability to read, write, and transform a wide variety of raster and vector geospatial datasets, including DTED.

Here’s a step-by-step guide to using GDAL to read DTED data:

1. Installing GDAL

Using a Package Manager: If you’re on a Linux system, you can often install GDAL using your package manager:

bashCopy code

# For Ubuntu/Debian:
sudo apt-get install libgdal-dev

# For Fedora:
sudo dnf install gdal-devel

# For CentOS:
sudo yum install gdal-devel

From Source: You can also download GDAL’s source and compile it yourself.

2. Integrating GDAL with cesium-native

Once you’ve installed GDAL, you’ll need to make sure your project knows where to find its headers and libraries:

  • Add the GDAL include path to your project’s include directories.
  • Link your project against the GDAL library.

3. Reading DTED Data with GDAL

Here’s a basic code snippet to read a DTED file using GDAL:

cppCopy code

#include "gdal_priv.h"

int main() {
    GDALAllRegister();  // Register all available file formats

    GDALDataset *dataset = (GDALDataset*) GDALOpen("path_to_your_dted_file.dt0", GA_ReadOnly);
    if(dataset == nullptr) {
        // Handle error
        return 1;

    // Get the elevation band (usually the first band in a DTED file)
    GDALRasterBand *band = dataset->GetRasterBand(1);

    int width = band->GetXSize();
    int height = band->GetYSize();

    float *elevations = new float[width * height];
    band->RasterIO(GF_Read, 0, 0, width, height, elevations, width, height, GDT_Float32, 0, 0);

    // At this point, 'elevations' contains the elevation data from the DTED file.
    // Do something with the data...

    delete[] elevations;

    return 0;

This code opens a DTED file, reads its elevation data into an array, and then closes the file. You can then use this elevation data as needed in your application.

4. Additional Considerations

  • Error Handling: The above code is a basic example and doesn’t include thorough error handling. In a real-world scenario, you’d want to check for errors at every step and handle them appropriately.
  • Coordinate Systems: DTED data is typically in a geographic coordinate system (latitude and longitude). Depending on your needs, you might need to reproject the data to a different coordinate system.
  • Dependencies: Ensure you’ve linked against all required GDAL dependencies when building your project.

This should give you a starting point to work with DTED data in your cesium-native project using GDAL. If you have further questions or run into issues, let me know!

Step 4, a simple matter of programming… not. cesium-native does not write Quantized Mesh. There is a writer for 3D Tiles, but I hesitate to say that you can generate 3D Tiles as such.