Skip to content

Meshes Providers – Guide & Recipes

Applies to MIKECloud (Multidimensional datasets) and MIKECore/DFSU (local files). Use this to pick a provider fast, wire it, and avoid foot-guns.


See also (deep dives)


Quick map of the providers (big picture)

Provider Type “Groups” meaning Where data lives Highlights
DHI.Services.Provider.MIKECloud.GroupedMeshRepository Grouped MIKECloud Projects/Subprojects MIKECloud Multidimensional sets Discover metadata, timestamps, point values, aggregations (whole/polygon/many), import dfs2/dfsu
DHI.Services.Provider.MIKECore.DfsuMeshRepository Grouped File system folders Local/remote DFSU files Discover, timestamps, point values, aggregations, contouring (mesh + element values)

Both expose the same Meshes service surface (discover, timestamps, point series, aggregations).


Which one should I pick?

  • Your results are already in MIKECloud or you want cloud-side compute + import → MIKECloud
  • You have raw DFSU files on disk/object storage and need contours too → DFSU

Capabilities at a glance

Capability / API MIKECloud DFSU
Discover meshes / read MeshInfo
GetDateTimes(fullName)
Point values → ITimeSeriesData<double>
Aggregations (mesh / polygon / many polygons)
Instantaneous aggregation (single timestamp)
Import dfs2/dfsu streams
Contours / raw snapshot (GetMeshData)

CRS rules

  • MIKECloud: pass WGS84 (EPSG:4326) for Point/Polygon.
  • DFSU: pass lon/lat; provider projects to mesh CRS internally. Z on points not supported.

Time rules

  • MIKECloud: timestamps come from a regular temporal domain → always use exact values returned by GetDateTimes.
  • DFSU: same: exact timestamps from GetDateTimes.

Registering providers (minimal wiring)

A) MIKECloud (grouped)

using DHI.Services.Meshes;
using DHI.Services.Provider.MIKECloud;

var repo = new GroupedMeshRepository("apiKey=<KEY>;projectId=<PROJECT>;environment=Prod");
ServiceLocator.Register(new GroupedMeshService<string>(repo), "mc-meshes"); // connectionId

B) DFSU (grouped)

using DHI.Services.Meshes;
using DHI.Services.Provider.MIKECore;

var fs   = new FileSource(@"C:\data\meshes");            // or your IFileSource
var repo = new DfsuMeshRepository(fs, filePathOrPrefix: "dfsu");
ServiceLocator.Register(new GroupedMeshService<string>(repo), "dfsu");      // connectionId

After registration your host exposes /api/meshes/{connectionId}/… routes (per your Meshes Web API).


IDs & groups (mental model)

  • MIKECloud: "Group/Subgroup/DatasetName" maps to Subprojects under a root project.
  • DFSU: Full file path (under your filePathOrPrefix) becomes the Id; group is the relative folder.
  • Groups are hierarchical: you can list by group (recursive) and use tree-options if your host exposes them.

Copy-paste recipes

A) MIKECloud — import, timestamps, point values, aggregations

var svc = Services.Get<GroupedMeshService<string>>("mc-meshes");

// Import dfs2/dfsu stream
using var fs = File.OpenRead(@"C:\data\Result.dfs2");
svc.Repository.Add(fs, "Models/Baltic/Result.dfs2");

// Timestamps
var id    = "Models/Baltic/Result.dfs2";
var times = svc.Repository.GetDateTimes(id).ToArray();

// Point series (lon,lat in WGS84)
var p     = new DHI.Services.Spatial.Point(12.34, 55.67);
var range = new DHI.Services.TimeSeries.DateRange(times.First(), times.First().AddDays(2));
var wl    = svc.Repository.GetValues(id, "Water Level", p, range);

// Aggregations
var poly = DHI.Services.Spatial.Polygon.FromWKT("POLYGON((12 55,12.5 55,12.5 55.5,12 55.5,12 55))");
var avg  = svc.Repository.GetAggregatedValues(id, AggregationType.Average, "Water Level", poly, range);

B) DFSU — timestamps, point values, polygon/mesh aggregates, contours

var svc   = Services.Get<GroupedMeshService<string>>("dfsu");
var id    = @"Scenarios/Coast/mesh01.dfsu";                 // relative under your prefix
var times = svc.Repository.GetDateTimes(id).ToArray();

// Point values
var point = new Spatial.Point(12.345, 55.678);              // lon,lat
var dr    = new DateRange(times[0], times[0].AddHours(6));
var ts    = svc.Repository.GetValues(id, "Water Level", point, dr);

// Whole-mesh max at an instant
var maxAt = svc.Repository.GetAggregatedValue(id, AggregationType.Maximum, "Water Level", times[0]);

// Many polygons at an instant (order preserved)
var polys = new [] {
  Spatial.Polygon.FromWKT("POLYGON((12 55,12.5 55,12.5 55.5,12 55.5,12 55))"),
  Spatial.Polygon.FromWKT("POLYGON((12.6 55.2,12.8 55.2,12.8 55.4,12.6 55.4,12.6 55.2))")
};
var many  = svc.Repository.GetAggregatedValues(id, AggregationType.Average, "Water Level", polys, times[1]);

// Contours (DFSU only): mesh + element values → build in service layer
var fc = svc.GetContours(id, "Water Level", new double[] { -1, 0, 1, 2 }, times[2]);

What you’ll actually call (service surface)

  • Discovery: GetAll(), GetByGroup(group), GetFullNames(), ContainsGroup(group)
  • Metadata: Get(fullName)MeshInfo<string> (items, units, WKT/projection, bbox, date range)
  • Time: GetDateTimes(fullName) → timestamps (ascending)
  • Point values: GetValues(fullName, item, Point, DateRange)
  • Aggregations:
    • Whole mesh: GetAggregatedValues(fullName, aggregation, item, DateRange) / GetAggregatedValue(..., dateTime)
    • Polygon(s): GetAggregatedValues(fullName, aggregation, item, Polygon|IEnumerable<Polygon>, DateRange|DateTime)
  • Import/remove (MIKECloud only): Add(Stream, fullName), Remove(fullName)
  • Contours (DFSU only): GetMeshData (repo) → GetContours (service convenience)

Foot-guns & best practices

Time alignment

  • Always use timestamps returned by GetDateTimes(id). Both providers index by exact match.

CRS

  • MIKECloud expects WGS84 geometries; DFSU accepts lon/lat and projects internally.
  • Z on points is not supported in DFSU point extraction.

MIKECloud

  • No contours: GetMeshData is not implemented.
  • If a vertical domain exists, queries use layer index 0.

DFSU

  • Polygon–mesh intersection can be expensive; the repo precomputes weights once per request and reuses them.
  • Missing element values (delete value) are filtered before aggregations; for point series they’re kept as-is.
  • For “all items” time series, item order is by item number to minimize file seeking.

Performance

  • Cache GetDateTimes(id) per dataset.
  • Prefer batch polygon aggregation for many polygons at one instant (dedicated API).

TL;DR

  • MIKECloud → cloud datasets, imports, point/area analytics (no contours).
  • DFSU → local files, same analytics plus contours.
  • Both are grouped; register in code; drive everything via GroupedMeshService<string>.