DHI.Services.MIKECloud for Meshes — Internal Developer Guide¶
MIKECloud provider for Multidimensional datasets (dfs2/dfsu imported to MIKECloud). For platform/auth/path rules, see MIKECloud Core. Note: The Meshes module does not support the Connections module yet (no
connections.jsonentry).
What you get¶
Repository
DHI.Services.Provider.MIKECloud.GroupedMeshRepository : BaseGroupedMeshRepository<string>Backed by MIKECloudMultidimensionaldatasets.
Supported operations
- Discover meshes (grouped), read MeshInfo (items, unit/quantity, projection WKT, date range)
- List timestamps (regular temporal domain)
- Point values →
ITimeSeriesData<double>over a time range - Aggregations (whole mesh / polygon / many polygons; range or instant): Average, Minimum, Maximum
- Import dfs2/dfsu streams (creates dataset via Transfer)
- Remove dataset
Not a contour provider: GetMeshData(...) is not implemented (contours unsupported).
Identity & path rules¶
- Groups map to MIKECloud Subprojects; full name:
"Group/Subgroup/DatasetName". - Geometry CRS: pass WGS84 (EPSG:4326)
Point/Polygon. Provider serializes to WKT + SRID=4326 for queries. - Timestamps come from Regular temporal domain:
Start + n * Step.
Vertical domain: if present, queries use layer index 0.
Capabilities (at a glance)¶
| Operation | Supported | Notes |
|---|---|---|
| Get MeshInfo | ✓ | Populates items (EUM), projection WKT (via SRID lookup), and temporal coverage |
| GetDateTimes | ✓ | Exact timestamps derived from the regular domain |
| GetValues at point (range) | ✓ | Geometry in WGS84 |
| AggregatedValues (whole mesh / polygon / many) | ✓ | Range or instant; Average / Min / Max |
| Import dfs2/dfsu (Add stream) | ✓ | Transfer: Dfs2Reader / DfsuReader → MDWriter |
| Remove dataset | ✓ | Hard delete |
| GetMeshData (contours/raw snapshot) | ✗ | Not implemented |
Connecting¶
A) Manually via ServiceLocator.Register¶
using DHI.Services.Provider.MIKECloud;
using DHI.Services.Meshes;
var repo = new GroupedMeshRepository(
"apiKey=<APIKEY>;projectId=<PROJECTID>;environment=Prod");
var meshSvc = new DHI.Services.Meshes.GroupedMeshService<string>(repo);
ServiceLocator.Register(meshSvc, "mc-meshes");
B) Via Connections module¶
If your application uses the Connections module, register the MIKECloud connection like this:
{
"$type": "System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[DHI.Services.IConnection, DHI.Services]], mscorlib",
"mc-meshes": {
"$type": "DHI.Services.Meshes.WebApi.GroupedMeshServiceConnection,DHI.Services.Meshes.WebApi",
"ConnectionString": "apiKey=[env:MIKECLOUD_APIKEY];projectId=[env:MIKECLOUD_PROJECT];environment=Prod",
"RepositoryType": "DHI.Services.Provider.MIKECloud.GroupedMeshRepository,DHI.Services.Provider.MIKECloud",
"Name": "MIKECloud providers",
"Id": "mc-meshes"
}
}
Code recipes¶
Import dfs2/dfsu¶
using var fs = File.OpenRead(@"C:\Data\Result.dfs2"); // or .dfsu
repo.Add(fs, "Models/Baltic/Result.dfs2");
Timestamps & point series¶
var id = "Models/Baltic/Result.dfs2";
var times = repo.GetDateTimes(id).ToArray();
var p = new DHI.Services.Spatial.Point(12.34, 55.67); // lon,lat (WGS84)
var range = new DHI.Services.TimeSeries.DateRange(times.First(), times.First().AddDays(3));
var wl = repo.GetValues(id, "Water Level", p, range);
Aggregations¶
var t0 = repo.GetDateTimes(id).First();
var poly = DHI.Services.Spatial.Polygon.FromWKT("POLYGON((12 55,12.5 55,12.5 55.5,12 55.5,12 55))");
var whole = repo.GetAggregatedValue(id, DHI.Services.TimeSeries.AggregationType.Maximum, "Water Level", t0);
var avgPolyRange = repo.GetAggregatedValues(id, DHI.Services.TimeSeries.AggregationType.Average,
"Water Level", poly, range);
// Many polygons at an instant (preserves input order)
var many = repo.GetAggregatedValues(id, DHI.Services.TimeSeries.AggregationType.Average,
"Water Level", new [] { poly1, poly2 }, t0);
How queries work (under the hood)¶
- Provider queries by time indices (derived from
GetDateTimes), not arbitrary timestamps:- For instants, pass exact values from
GetDateTimes(id). - For ranges, align
From/Toto exact steps (provider maps toTemporalIndexFilter).
- For instants, pass exact values from
- Spatial filter is WKT (SRID=4326). If a vertical domain exists, provider sets
VerticalIndexFilterto layer 0.
Troubleshooting & notes¶
- Invalid time (not aligned to regular steps) → platform may error; always use
GetDateTimes. - Unsupported file type on import → throws
ArgumentException(“Unknown file type …”). - Bad credentials/project → constructor validation throws; other SDK exceptions bubble up from queries.
- Performance tips: Cache
GetDateTimes(id)per dataset; for many polygons at one instant, use the dedicated batch method (parallelized internally).
Service surface (cheat sheet)¶
- Discovery:
GetAll,GetByGroup,GetFullNames,ContainsGroup - Mesh metadata:
Get(fullName)→MeshInfo<string> - Time:
GetDateTimes(fullName)→IEnumerable<DateTime> - Point values:
GetValues(fullName, item, Point, DateRange) - Aggregations:
GetAggregatedValue(s)(mesh / polygon / many polygons; instant or range) - Import/Remove:
Add(Stream, fullName),Remove(fullName)