Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
scrollbar

...

Panel
borderStylesolid

Contents

Page Tree
rootTOOLS:Tutorial
startDepth3

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.

Wiki Markup
*\[TODO\]*
Add links to some wiki pages?

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.cs:

Code Block
using DeltaShell.PluginPlugins.DemoAppVolumeModel.Layers;

and

Code Block
        public override IMapLayerProvider MapLayerProvider
        {
            get { return new VolumeModelMapLayerProvider(); }
        }

Delta Shell should now be able to open a map view for volume models, containing both their catchment basin input data and their volume output data (if present).

Exercise results

Setup Set up a volume model as described in the results of a previous exercise (see Create a simple hydrological model).

Directly after After creating the volume model, a the corresponding map view should have been opened automatically.Even after running the volume model, though, no  However, the data will not be visible in the view; two more actions are neededimmediately shown in this view, even after running the volume model. Two further actions are required.

First of all, the input part of the volume model data is actually present, but the map is simply misalignedzooming into a different area. To solve the this problem, open the Map Ribbon tab and click the Zoom to map extent button as shown in the following image:

Wiki Markup
*\[TODO\]*
Add screenshot of the Zoom to map extent Ribbon button

:

Image Added

Secondly, the output part data of the volume model data is present too but it is initially hidden. To solve the this problem, expand  expand the volume model group layer in the Map window and check tick the check box of the Volume layer as shown in the following image:

Wiki Markup
*\[TODO\]*
Add screenshot of checked Volume layer checkbox in the Map window

Now both the input and the output data of the volume model should be visible on the map.

Image Added

Info

The ordering order of the different data layers in a map view can be changed via adjusted using the context menus of the layers in the Map window (right click on a data layer | Order | ... ).In order to inspect time dependent (output) data, open the Time Navigator window and move the slider or click one of the auto play buttons.

Additionally, WMS layers can be included to help identifying the actual geographical location of map data. Follow these steps:

  1. Add a new WMS layer to the map using the Map window (click the Add New Wms Layer ... button). In the Open web link ... dialog, select Microsoft Bing Maps - Satellite Hybrid. A new map layer will be added to the view. However, this layer is initially projected using a different coordinate system than the one for the volume output data:

    Image Added


  2. Select the same coordinate systems for the different map layers in the Map window (right click on the map group layer | Change Map Coordinate System ...). In the corresponding dialog, look for the coordinate system WGS_1984_Web_Mercator and assign it to all layers in the group. The map view should now represent all layers using the same coordinate system. Zoom to the volume group layer (right click on the volume model group layer in the Map window | Zoom to Extend) to see all data at their appropriate location:

    Image Added



scrollbar