DHI.Services.MIKECloud for GIS — Internal Developer Guide¶
Use MIKECloud as an updatable GIS backend for vector layers. For platform/auth/path rules, see MIKECloud Core.
What you get¶
Repository
DHI.Services.Provider.MIKECloud.GroupedGisRepositoryGrouped, updatable repo overGisvectordata:- Writes: upload
FeatureCollection<string>as GeoJSON via Transfer (GeoJsonReader → GISWriter) - Reads: return
FeatureCollection<string>from MIKECloudIFeatureClass - Groups: projects/subprojects are the “folders”
- Writes: upload
Data flow
Add: FeatureCollection → GisHelpers.GetGeoJsonStream → Transfer (GeoJsonReader→GISWriter) → dataset created/updated
Get: GISClient.GetFeatureClass → GisHelpers.ConvertToFeatureCollection → FeatureCollection<string>
Capabilities & behaviors¶
| Operation / Area | Support | Notes |
|---|---|---|
| Add(FeatureCollection) | ✓ | Creates missing subprojects; dataset created via Transfer import |
| AddFeature(fullName, feature) | ✓ | Requires dataset to exist; adds one feature via GISClient.AddFeaturesAsync |
| Get(fullName, associations?, outSrid?) | ✓ | associations == true → throws (not supported); outSrid must be an int string |
| GetAll / GetByGroup / GetFullNames / GetIds | ✓ | Lists vector datasets; ;nonrecursive supported on group methods |
| Remove(fullName) | ✓ | Deletes dataset |
| ContainsGroup(path) | ✓ | True if dataset or path exists |
| Per-feature CRUD, envelopes, attribute DDL | ✗ | Not implemented (throws); see roadmap below |
Attributes & geometry
- Attribute mapping mirrors platform
AttributeDataType→ .NET types; default values preserved. - Geometry is WKT-based conversion (NTS).
- SRID on write: Embedded
crsis a TODO in code; setfc.Metadata["Projection"]="EPSG:xxxx"for traceability. UseoutSrid:"4326"(etc.) on read to reproject server-side.
Connecting¶
Direct (code)
var repo = new GroupedGisRepository(
"apiKey=<APIKEY>;projectId=<PROJECTID>;environment=Prod");
var svc = new DHI.Services.GIS.GroupedUpdatableGisService(repo);
ServiceLocator.Register(svc, "mc-gis");
Web API (Connections module)
{
"$type": "DHI.Services.GIS.WebApi.GroupedGisServiceConnection, DHI.Services.GIS.WebApi",
"RepositoryType": "DHI.Services.Provider.MIKECloud.GroupedGisRepository, DHI.Services.Provider.MIKECloud",
"ConnectionString": "apiKey=[env:MIKECLOUD_APIKEY];projectId=[env:MIKECLOUD_PROJECT];environment=Prod",
"Name": "GIS via MIKECloud",
"Id": "mc-gis"
}
Routes: /api/gis/mc-gis/... or /api/featurecollections/mc-gis/... (per your host’s routing template).
Code recipes¶
Import a new dataset¶
var fc = new FeatureCollection<string>(Guid.NewGuid().ToString(), "Stations", "/Hydro/Sensors");
fc.Attributes.Add(new Spatial.Attribute("Name", typeof(string), 128));
fc.Attributes.Add(new Spatial.Attribute("Flow", typeof(double), 0));
fc.Features.Add(new Spatial.Feature(Spatial.Geometry.FromWKT("POINT(12.57 55.68)"))
{ AttributeValues = { ["Name"]="A", ["Flow"]=42.3 } });
repo.Add(fc);
Read (with reprojection)¶
var fc3857 = repo.Get("/Hydro/Sensors/Stations", associations:false, outSrid:"3857").Value;
Append a single feature¶
var f = new Spatial.Feature(Spatial.Geometry.FromWKT("POINT(12.58 55.69)"));
f.AttributeValues["Name"] = "B";
repo.AddFeature("/Hydro/Sensors/Stations", f);
Troubleshooting & notes¶
- Associations:
Get(..., associations:true)→ throws (“Time series associations are not supported by the Cloud Platform.”). - outSrid must be parseable as an
intstring; otherwise throws. - SRID at import: not embedded today; prefer server-side reprojection at read time.
- Project not found / bad env: constructor throws
ArgumentException. - Listings: Prefer group-scoped queries and
;nonrecursiveto avoid large traversals.
Roadmap (not implemented yet — throws)
GetFeatureInfo, ContainsFeature, GetEnvelope, GetFeature, GetFeatureIds, GetFootprint(both), Update, Add/Update/RemoveAttribute, UpdateAttributeValues(both), UpdateFeature, RemoveFeature.