MDAL C# API

The MDAL C# integration allows you to access and manipulation geospatial mesh data sets in C#.

Currently, this integration can:

  1. read all MDAL compatible file formats,

  2. access the metadata for the source,

  3. access the vertex, face and edge data,

  4. access ‘double’ datasets (both scalar and vector), and

  5. convert the MDAL source mesh into a Geometry3sharp DMesh3 mesh object.

This version does not currently allow the MDAL source mesh to be written or ammended.

This integration is not intended to be generic and should be used as an example or starting point.

Installation

The integration script can downloaded from:

https://github.com/ViRGIS-Team/mdal-upm/blob/main/Runtime/Scripts/Mdal.cs

The integration is not currently available as a package. Integrate this script into your application manually.

Documentation

https://virgis-team.github.io/mdal-upm/html/annotated.html

Development

Submit issues and PRs to :

https://github.com/ViRGIS-Team/mdal-upm

Example Usage

using Mdal;
using g3;

List<DMesh3> features = new List<DMesh3>();

// for MDAL files - load the mesh directly
ds = Datasource.Load("...SourceFileName");

for (int i = 0; i < ds.meshes.Length; i++) {
    DMesh3 mesh = ds.GetMesh(i);
    mesh.RemoveMetadata("properties");
    mesh.AttachMetadata("properties", new Dictionary<string, object>{
    { "Name", ds.meshes[i] }
});
    // set the CRS based on what is known
    if (proj != null) {
        mesh.RemoveMetadata("CRS");
        mesh.AttachMetadata("CRS", proj);
    }
    if (layer.ContainsKey("Crs") && layer.Crs != null) {
        mesh.RemoveMetadata("CRS");
        mesh.AttachMetadata("CRS", layer.Crs);
    };
    features.Add(mesh);
}