Index: Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs
===================================================================
diff -u -r0280af2522389e4f1291c22e0cbea677995e3fba -rf245fcfc202b53559917a5b89810a30c42949303
--- Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision 0280af2522389e4f1291c22e0cbea677995e3fba)
+++ Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision f245fcfc202b53559917a5b89810a30c42949303)
@@ -25,6 +25,7 @@
using System.Windows.Forms;
using Core.Common.Base;
using Core.Components.DotSpatial.Converter;
+using Core.Components.DotSpatial.Layer;
using Core.Components.DotSpatial.MapFunctions;
using Core.Components.Gis.Data;
using Core.Components.Gis.Features;
@@ -260,7 +261,7 @@
private void DrawMapData(FeatureBasedMapData featureBasedMapData)
{
- var mapFeatureLayer = MapFeatureLayerFactory.Create(featureBasedMapData);
+ var mapFeatureLayer = MapFeatureLayerFactory.CreateLayer(featureBasedMapData);
var drawnMapData = new DrawnMapData
{
@@ -271,14 +272,7 @@
drawnMapData.Observer = new Observer(() =>
{
- if (!ReferenceEquals(drawnMapData.FeatureBasedMapData.Features, drawnMapData.Features))
- {
- MapFeatureLayerFactory.ConvertLayerFeatures(drawnMapData.FeatureBasedMapData, drawnMapData.MapFeatureLayer);
-
- drawnMapData.Features = drawnMapData.FeatureBasedMapData.Features;
- }
-
- MapFeatureLayerFactory.ConvertLayerProperties(drawnMapData.FeatureBasedMapData, drawnMapData.MapFeatureLayer);
+ drawnMapData.MapFeatureLayer.Update();
})
{
Observable = featureBasedMapData
@@ -352,7 +346,7 @@
public MapFeature[] Features { get; set; }
- public IMapFeatureLayer MapFeatureLayer { get; set; }
+ public IFeatureBasedMapDataLayer MapFeatureLayer { get; set; }
public Observer Observer { get; set; }
}
Index: Core/Components/src/Core.Components.DotSpatial/Converter/MapFeatureLayerFactory.cs
===================================================================
diff -u -rc600c9837e2b119fc8881a312a1404e7a9d04288 -rf245fcfc202b53559917a5b89810a30c42949303
--- Core/Components/src/Core.Components.DotSpatial/Converter/MapFeatureLayerFactory.cs (.../MapFeatureLayerFactory.cs) (revision c600c9837e2b119fc8881a312a1404e7a9d04288)
+++ Core/Components/src/Core.Components.DotSpatial/Converter/MapFeatureLayerFactory.cs (.../MapFeatureLayerFactory.cs) (revision f245fcfc202b53559917a5b89810a30c42949303)
@@ -22,6 +22,7 @@
using System;
using System.Collections.ObjectModel;
using System.Linq;
+using Core.Components.DotSpatial.Layer;
using Core.Components.Gis.Data;
using DotSpatial.Controls;
@@ -39,59 +40,44 @@
new MapPolygonDataConverter()
};
- ///
- /// Creates a from the given .
- ///
- /// The to base the creation of upon.
- /// A new layer based on .
- /// Thrown when the given type is not supported.
- public static IMapFeatureLayer Create(FeatureBasedMapData data)
+ public static IFeatureBasedMapDataLayer CreateLayer(FeatureBasedMapData data)
{
- var converter = converters.FirstOrDefault(c => c.CanConvertMapData(data));
- if (converter != null)
+ var mapPointData = data as MapPointData;
+ if (mapPointData != null)
{
- return converter.Convert(data);
+ return new MapPointDataLayer(mapPointData);
}
- throw new NotSupportedException(string.Format("FeatureBasedMapData of type {0} is not supported.", data.GetType().Name));
- }
-
- ///
- /// Converts all feature related data from to .
- ///
- /// The data to convert the feature related data from.
- /// The layer to convert the feature related data to.
- /// Thrown when the given type is not supported.
- public static void ConvertLayerFeatures(FeatureBasedMapData data, IMapFeatureLayer layer)
- {
- var converter = converters.FirstOrDefault(c => c.CanConvertMapData(data));
- if (converter != null)
+ var mapLineData = data as MapLineData;
+ if (mapLineData != null)
{
- converter.ConvertLayerFeatures(data, layer);
+ return new MapLineDataLayer(mapLineData);
}
- else
+
+ var mapPolygonData = data as MapPolygonData;
+ if (mapPolygonData != null)
{
- throw new NotSupportedException(string.Format("FeatureBasedMapData of type {0} is not supported.", data.GetType().Name));
+ return new MapPolygonDataLayer(mapPolygonData);
}
+
+ throw new NotSupportedException(string.Format("FeatureBasedMapData of type {0} is not supported.", data.GetType().Name));
}
///
- /// Converts all general properties (like and )
- /// from to .
+ /// Creates a from the given .
///
- /// The data to convert the general properties from.
- /// The layer to convert the general properties to.
- public static void ConvertLayerProperties(FeatureBasedMapData data, IMapFeatureLayer layer)
+ /// The to base the creation of upon.
+ /// A new layer based on .
+ /// Thrown when the given type is not supported.
+ public static IMapFeatureLayer Create(FeatureBasedMapData data)
{
var converter = converters.FirstOrDefault(c => c.CanConvertMapData(data));
if (converter != null)
{
- converter.ConvertLayerProperties(data, layer);
+ return converter.Convert(data);
}
- else
- {
- throw new NotSupportedException(string.Format("FeatureBasedMapData of type {0} is not supported.", data.GetType().Name));
- }
+
+ throw new NotSupportedException(string.Format("FeatureBasedMapData of type {0} is not supported.", data.GetType().Name));
}
}
}
\ No newline at end of file
Index: Core/Components/src/Core.Components.DotSpatial/Core.Components.DotSpatial.csproj
===================================================================
diff -u -rd72d28f9d51c5bc4c7bb0f49509e3656465cc22c -rf245fcfc202b53559917a5b89810a30c42949303
--- Core/Components/src/Core.Components.DotSpatial/Core.Components.DotSpatial.csproj (.../Core.Components.DotSpatial.csproj) (revision d72d28f9d51c5bc4c7bb0f49509e3656465cc22c)
+++ Core/Components/src/Core.Components.DotSpatial/Core.Components.DotSpatial.csproj (.../Core.Components.DotSpatial.csproj) (revision f245fcfc202b53559917a5b89810a30c42949303)
@@ -44,6 +44,7 @@
False
..\..\..\..\lib\DotSpatial.1.8\DotSpatial.Extensions.dll
+
False
..\..\..\..\lib\DotSpatial.1.8\DotSpatial.Symbology.dll
@@ -65,11 +66,15 @@
+
+
+
+
Index: Core/Components/src/Core.Components.DotSpatial/Layer/IFeatureBasedMapDataLayer.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.DotSpatial/Layer/IFeatureBasedMapDataLayer.cs (revision 0)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/IFeatureBasedMapDataLayer.cs (revision f245fcfc202b53559917a5b89810a30c42949303)
@@ -0,0 +1,36 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using DotSpatial.Controls;
+
+namespace Core.Components.DotSpatial.Layer
+{
+ ///
+ /// Interface for feature based map data layers.
+ ///
+ public interface IFeatureBasedMapDataLayer : IMapLayer
+ {
+ ///
+ /// Updates the map data layer.
+ ///
+ void Update();
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.DotSpatial/Layer/MapLineDataLayer.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.DotSpatial/Layer/MapLineDataLayer.cs (revision 0)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/MapLineDataLayer.cs (revision f245fcfc202b53559917a5b89810a30c42949303)
@@ -0,0 +1,68 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using Core.Components.DotSpatial.Converter;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Features;
+using DotSpatial.Controls;
+
+namespace Core.Components.DotSpatial.Layer
+{
+ ///
+ /// A based on and updated according to the wrapped .
+ ///
+ public class MapLineDataLayer : MapLineLayer, IFeatureBasedMapDataLayer
+ {
+ private readonly MapLineData mapLineData;
+ private readonly MapLineDataConverter converter = new MapLineDataConverter();
+
+ private MapFeature[] drawnFeatures;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The which the map line layer is based upon.
+ public MapLineDataLayer(MapLineData mapLineData)
+ {
+ if (mapLineData == null)
+ {
+ throw new ArgumentNullException("mapLineData");
+ }
+
+ this.mapLineData = mapLineData;
+
+ Update();
+ }
+
+ public void Update()
+ {
+ if (!ReferenceEquals(mapLineData.Features, drawnFeatures))
+ {
+ converter.ConvertLayerFeatures(mapLineData, this);
+
+ drawnFeatures = mapLineData.Features;
+ }
+
+ converter.ConvertLayerProperties(mapLineData, this);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.DotSpatial/Layer/MapPointDataLayer.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.DotSpatial/Layer/MapPointDataLayer.cs (revision 0)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/MapPointDataLayer.cs (revision f245fcfc202b53559917a5b89810a30c42949303)
@@ -0,0 +1,47 @@
+using System;
+using Core.Components.DotSpatial.Converter;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Features;
+using DotSpatial.Controls;
+
+namespace Core.Components.DotSpatial.Layer
+{
+ ///
+ /// A based on and updated according to the wrapped .
+ ///
+ public class MapPointDataLayer : MapPointLayer, IFeatureBasedMapDataLayer
+ {
+ private readonly MapPointData mapPointData;
+ private readonly MapPointDataConverter converter = new MapPointDataConverter();
+
+ private MapFeature[] drawnFeatures;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The which the map point layer is based upon.
+ public MapPointDataLayer(MapPointData mapPointData)
+ {
+ if (mapPointData == null)
+ {
+ throw new ArgumentNullException("mapPointData");
+ }
+
+ this.mapPointData = mapPointData;
+
+ Update();
+ }
+
+ public void Update()
+ {
+ if (!ReferenceEquals(mapPointData.Features, drawnFeatures))
+ {
+ converter.ConvertLayerFeatures(mapPointData, this);
+
+ drawnFeatures = mapPointData.Features;
+ }
+
+ converter.ConvertLayerProperties(mapPointData, this);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.DotSpatial/Layer/MapPolygonDataLayer.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.DotSpatial/Layer/MapPolygonDataLayer.cs (revision 0)
+++ Core/Components/src/Core.Components.DotSpatial/Layer/MapPolygonDataLayer.cs (revision f245fcfc202b53559917a5b89810a30c42949303)
@@ -0,0 +1,68 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using Core.Components.DotSpatial.Converter;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Features;
+using DotSpatial.Controls;
+
+namespace Core.Components.DotSpatial.Layer
+{
+ ///
+ /// A based on and updated according to the wrapped .
+ ///
+ public class MapPolygonDataLayer : MapPolygonLayer, IFeatureBasedMapDataLayer
+ {
+ private readonly MapPolygonData mapPolygonData;
+ private readonly MapPolygonDataConverter converter = new MapPolygonDataConverter();
+
+ private MapFeature[] drawnFeatures;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The which the map polygon layer is based upon.
+ public MapPolygonDataLayer(MapPolygonData mapPolygonData)
+ {
+ if (mapPolygonData == null)
+ {
+ throw new ArgumentNullException("mapPolygonData");
+ }
+
+ this.mapPolygonData = mapPolygonData;
+
+ Update();
+ }
+
+ public void Update()
+ {
+ if (!ReferenceEquals(mapPolygonData.Features, drawnFeatures))
+ {
+ converter.ConvertLayerFeatures(mapPolygonData, this);
+
+ drawnFeatures = mapPolygonData.Features;
+ }
+
+ converter.ConvertLayerProperties(mapPolygonData, this);
+ }
+ }
+}
\ No newline at end of file