MDAL Unity API

The MDAL Unity integration allows you to access and manipulation geospatial mesh data sets in C# amd includes integration to access them as Unity objects (thought the Geometry3sharp to Unity integration)

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.

Installation

Available as a Unity Package Manager package from OpenUPM :

https://openupm.com/packages/com.virgis.mdal/

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);
}