Panel | ||
---|---|---|
Panel | ||
| ||
Page Tree | ||
root | TOOLS:Tutorial | startDepth | 3
scrollbar | ||
Exercise outline
The goal of this exercise is to visualize multiple data sets on one single map; doing so, . This makes it possible to compare different data sets can be compared at the same geospatial positionlocation(s) and/or for the same modeling modelling time step(s).
As an example, after With this exercise it should be possible to show, as an example, both the input data and the output data of a volume model in one and the same single map view.
Create a new map layer provider
Add a new folder to the plugin project a new folder named Layers. In this folder, create a new class named VolumeModelLayerProvider.cs and add the following codeadapt the contents as shown below:
Code Block |
---|
using System.Collections.Generic; using DelftTools.Shell.Gui; using DeltaShell.Plugin.DemoApp.Models; using SharpMap.Api.Layers; using SharpMap.Layers; namespace DeltaShell.PluginPlugins.DemoAppVolumeModel.Layers { public class VolumeModelMapLayerProvider : IMapLayerProvider { /// <summary> /// Defines that layers can be provided for volume models /// </summary> public bool CanCreateLayerFor(object data, object parentData) { { return data is Models.VolumeModel; } /// <summary> /// Creates a volume model group layer /// </summary> public ILayer CreateLayer(object data, object parentData) { var volumeModel = data as Models.VolumeModel; if (volumeModel != null) { { return new GroupLayer(volumeModel.Name); } return null; } /// <summary> /// Returns all children for which a child layer should be created in volume model group layers /// </summary> public IEnumerable<object> ChildLayerObjects(object data) { { var volumeModel = data as Models.VolumeModel; if (volumeModel != null) { // In the end a child layer should be created for both the catchmentbasin input data and the volume output data yield return volumeModel.Basin; yield return volumeModel.Volume; } } } } } } |
Info |
---|
The map layer provider class derives is derived from the IMapLayerProvider interface so that it can be registered in the gui plugin (see the next step). Furthermore, the The comments in the code should explain the different parts of the provider implementation. |
Note | ||
---|---|---|
A description on the backgrounds and usage of (group) layers is not part of this tutorial.
|
Fixme
Fixme
Exercise results
Wiki Markup |
---|
*\[TODO\]* Description of the exercise results
\\
\\
\\
\\
\\
1. Create a new class named "DemoAppMapLayerProvider" |
Register the map layer provider in the gui plugin class
Register the map layer provider in the gui plugin by adding the following code to VolumeModelGuiPlugin.cs2. Add the following contents to this class:
Code Block |
---|
using System.Collections.Generic; using System.Linq; using DelftTools.Shell.Gui; using DeltaShell.Plugin.DemoApp.Models; using SharpMap.Api.Layers; using SharpMap.Layers; namespace DeltaShell.Plugin.DemoApp { public class DemoAppMapLayerProvider : IMapLayerProvider {Plugins.VolumeModel.Layers; |
and
Code Block |
---|
public ILayeroverride CreateLayer(object data, object parentData)IMapLayerProvider MapLayerProvider { var myModel = data as VolumeModel; if (myModel != null) { get { return new GroupLayerVolumeModelMapLayerProvider(myModel.Name); } return null; } public bool CanCreateLayerFor(object data, object parentData) { return data is VolumeModel; } public IEnumerable<object> ChildLayerObjects(object data) { var myModel = data as VolumeModel; if (myModel != null) { return myModel.DataItems.Select(d => d.Value); } return Enumerable.Empty<object>(); } } } |
3. Register the map layer provider in the gui plugin class by adding the following code to DemoAppGuiPlugin:
Code Block |
---|
public override IMapLayerProvider MapLayerProvider
{
get { return new DemoAppMapLayerProvider(); }
}
|
...
Delta Shell should now be able to open a map view for volume models, containing both their basin input data and their volume output data (if present).
Exercise results
Set up a volume model as described in the results of a previous exercise (Create a simple hydrological model).
After creating the volume model, the corresponding map view should have been opened automatically. However, the data will not be immediately shown in this view, even after running the volume model. Two further actions are required.
First of all, the input of the volume model data is present, but the map is zooming into a different area. To solve this problem, open the Map Ribbon tab and click the Zoom to map extent button:
Secondly, the output data of the volume model is initially hidden. To solve this problem, expand the volume model group layer in the Map window and tick the check box of the Volume layer:
Info |
---|
The order of the different data layers in a map view can be adjusted using the context menus in the Map window (right click on a data layer | Order | ... ). Additionally, WMS layers can be included to help identifying the actual geographical location of map data. Follow these steps:
|
scrollbar |
---|