Skip to content

MIKE Core SDK

The MIKE Core is a set of basic components that is central throughout the MIKE suite of software. Amongst other, it includes libraries to access the MIKE native file formats, DFS and PFS.

These core components can all be accessed from .NET/C#, while some of the components can also be accessed from "native enviroments" like C/C++/Delphi/Pascal.

They are also available in various scripting environments. For examples, check out Derivations below.

How to get it

The MIKE Core components are available in the following forms:

The "MIKE SDK" installer will install all required components in the Program Files folders. This makes them avaialble e.g. in scripting environments.

For building your own applications based on the MIKE Core components, using the NuGet packages offers a lot of flexibility.

The NuGet packages can be used directly from within Visual Studio. It is also possible to use the nuget.exe from nuget.org/downloads to retrieve the content of the packages.

More details on this is available on the NuGet access page.

Derivations

The MIKE Core components are also basis for a set of toolboxes and packages in other enviroments, most noticeable:

Content

The MIKE Core includes the following:

  • DHI.DFS: The DFS API (Data File System) allows the user to create, read and edit the dfs0, dfs1, dfs2, dfs3 and dfsu file formats.

  • DHI.EUM: The EUM API (Engineering Unit Management) allows conversion between units within the MIKE Zero system.

  • DHI.PFS: The PFS API (Program File System) can read, edit and write files in the DHI PFS format. Files in the PFS format typically serves as configuration files to the MIKE models, including MIKE21, MIKE3, MIKE SHE, MIKE HYDRO, MZ Toolbox, the Plot composer and many others.

  • DHI.Projections: The Projections API provide various map projection functionality, conversion between different projection systems and different coordinate systems.

  • DHI.Chart.Map: The DHI.Chart.Map is a .NET wrapper around the MzChart library, which is the underlying chart component used in most MIKE ZERO charts and maps, including the Grid editor and Plot composer. When used as a stand-alone component, it allows the user to generate and style maps (bitmaps) generated from a range of dfs and mesh file formats.

  • DHI.Mike.Install: This library helps locating libraries included with the installation of various MIKE products. For .NET/C# applications it helps locate .NET assemblies, and it also adds to the path variable in order to locate native (C/C++) libraries.

Getting Started

A series of examples for using the MIKE Core API's, and various test data, are available from GitHub at:

Creating a Project in Visual Studio or SharpDevelop

This section describes how to make a small console program in Visual Studio that loads a dfs file. The procedure for the two developer environments are very similar

Prerequisites:

  • Visual Studio, the free Community version should suffice.

To create and setup a project in Visual Studio (this may very slightly, depending on the version of Visual Studio):

  1. Open Visual Studio

  2. Visual Studio: Select ‘File’ – ‘New’ – ‘Project’ and select a ‘Visual C#’, ‘Windows Desktop’, ‘Console App (.NET Framework)’. Find an appropriate name and location for your project.

  3. Right click on the ‘References’ and select ‘Manage NuGet Packages’. Search for ‘DHI.DFS’ and install the latest version

  4. Do the same for ‘DHI.EUM’

  5. The solution must be build for x64:

    • Right-click the project and select "Properties"
    • Go to "Build" tab, find "Platform Target" and set to "x64"
    • Do that for both "Release" and "Debug"
  6. Now the project is ready. It has created a ‘Program.cs’ file containing a Program class with a Main function. When adding the appropriate using directives, the DFS API is readily available and you can start coding.

Example, modify the ‘Program.cs’, to contain:

   using System;
   using DHI.Generic.MikeZero.DFS;
   using DHI.Generic.MikeZero.DFS.dfs123;
   namespace ConsoleApplication
   {
    class Program
    {
        static void Main(string[] args)   
        {
            Dfs2File dfs2File =
            DfsFileFactory.Dfs2FileOpen(\@"c:\\Work\\test\\MyFile.dfs2");
            IDfsAxisEqD2 axis = (IDfsAxisEqD2)dfs2File.SpatialAxis;
            Console.Out.WriteLine("Size of grid: {0} x {1}", axis.XCount, axis.YCount);
        }
    }
   }

This will print out the size of a 2D equidistant axis of the file located in c:\Work\test\MyFile.dfs2.

  1. Build the application. That will download all the nuget packages and copy all required files to build output folder, typically bin\debug or bin\release folder.

  2. Run the application (.exe) located in the build output folder.

The build output folder contains all files required for running the application. To share with a colleague or use on another machine, just copy all the files of the build output folder.

Various notes:

  • Check out the "NuGet Access" section for some details on the NuGet packages and their requirements.
  • When building for .NET Core, a publish step is also required