Index: Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs
===================================================================
diff -u -rb89eebcea2923640c50590ddc8c9f9b1120c0ea1 -red62f6b66a9884ae4ac854f0bc1131425567b0af
--- Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision b89eebcea2923640c50590ddc8c9f9b1120c0ea1)
+++ Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision ed62f6b66a9884ae4ac854f0bc1131425567b0af)
@@ -27,7 +27,6 @@
using Core.Components.DotSpatial.Layer;
using Core.Components.DotSpatial.MapFunctions;
using Core.Components.Gis.Data;
-using Core.Components.Gis.Features;
using Core.Components.Gis.Forms;
using DotSpatial.Controls;
using DotSpatial.Data;
@@ -265,7 +264,6 @@
var drawnMapData = new DrawnMapData
{
FeatureBasedMapData = featureBasedMapData,
- Features = featureBasedMapData.Features,
FeatureBasedMapDataLayer = featureBasedMapDataLayer
};
@@ -340,8 +338,6 @@
{
public FeatureBasedMapData FeatureBasedMapData { get; set; }
- public MapFeature[] Features { get; set; }
-
public IFeatureBasedMapDataLayer FeatureBasedMapDataLayer { get; set; }
public Observer Observer { get; set; }
Index: Core/Components/src/Core.Components.DotSpatial/Converter/FeatureBasedMapDataConverter.cs
===================================================================
diff -u -rb89eebcea2923640c50590ddc8c9f9b1120c0ea1 -red62f6b66a9884ae4ac854f0bc1131425567b0af
--- Core/Components/src/Core.Components.DotSpatial/Converter/FeatureBasedMapDataConverter.cs (.../FeatureBasedMapDataConverter.cs) (revision b89eebcea2923640c50590ddc8c9f9b1120c0ea1)
+++ Core/Components/src/Core.Components.DotSpatial/Converter/FeatureBasedMapDataConverter.cs (.../FeatureBasedMapDataConverter.cs) (revision ed62f6b66a9884ae4ac854f0bc1131425567b0af)
@@ -44,27 +44,17 @@
where TMapFeatureLayer : FeatureLayer, IMapFeatureLayer
{
///
- /// Checks whether the can convert the .
- ///
- /// The to check for.
- /// true if the can be converted by the
- /// ,
- /// false otherwise.
- public bool CanConvertMapData(FeatureBasedMapData data)
- {
- return data is TFeatureBasedMapData;
- }
-
- ///
/// Creates a based on the that was given.
///
/// The data to transform into a .
/// A new .
- /// Thrown when returns false.
/// Thrown when is null.
- public IMapFeatureLayer Convert(FeatureBasedMapData data)
+ public IMapFeatureLayer Convert(TFeatureBasedMapData data)
{
- ValidateParameters(data);
+ if (data == null)
+ {
+ throw new ArgumentNullException("data", @"Null data cannot be converted into a feature layer data.");
+ }
var layer = CreateLayer();
@@ -79,9 +69,8 @@
///
/// The data to convert the feature related data from.
/// The layer to convert the feature related data to.
- /// Thrown when returns false.
/// Thrown when or is null.
- public void ConvertLayerFeatures(FeatureBasedMapData data, IMapFeatureLayer layer)
+ public void ConvertLayerFeatures(TFeatureBasedMapData data, IMapFeatureLayer layer)
{
ValidateParameters(data, layer);
@@ -94,9 +83,8 @@
///
/// The data to convert the general properties from.
/// The layer to convert the general properties to.
- /// Thrown when returns false.
/// Thrown when or is null.
- public void ConvertLayerProperties(FeatureBasedMapData data, IMapFeatureLayer layer)
+ public void ConvertLayerProperties(TFeatureBasedMapData data, IMapFeatureLayer layer)
{
ValidateParameters(data, layer);
@@ -135,31 +123,20 @@
return points.Select(point => new Coordinate(point.X, point.Y));
}
- private void ValidateParameters(FeatureBasedMapData data)
+ private static void ValidateParameters(TFeatureBasedMapData data, IMapFeatureLayer layer)
{
if (data == null)
{
throw new ArgumentNullException("data", @"Null data cannot be converted into a feature layer data.");
}
- if (!CanConvertMapData(data))
- {
- var message = string.Format("The data of type {0} cannot be converted by this converter.", data.GetType());
- throw new ArgumentException(message);
- }
- }
-
- private void ValidateParameters(FeatureBasedMapData data, IMapFeatureLayer layer)
- {
- ValidateParameters(data);
-
if (layer == null)
{
throw new ArgumentNullException("layer", @"Null data cannot be used as conversion target.");
}
}
- private void ConvertLayerFeaturesInternal(FeatureBasedMapData data, IFeatureLayer layer)
+ private void ConvertLayerFeaturesInternal(TFeatureBasedMapData data, IFeatureLayer layer)
{
ClearLayerData(layer);
SetDataTableColumns(data, layer);
@@ -185,13 +162,13 @@
layer.AssignFastDrawnStates();
}
- private void ConvertLayerPropertiesInternal(FeatureBasedMapData data, IFeatureLayer layer)
+ private void ConvertLayerPropertiesInternal(TFeatureBasedMapData data, IFeatureLayer layer)
{
layer.IsVisible = data.IsVisible;
((TMapFeatureLayer) layer).Name = data.Name;
layer.ShowLabels = data.ShowLabels;
layer.LabelLayer = GetLabelLayer(GetAttributeMapping(data), layer.DataSet, data.SelectedMetaDataAttribute);
- layer.Symbolizer = CreateSymbolizer((TFeatureBasedMapData) data);
+ layer.Symbolizer = CreateSymbolizer(data);
}
private static void ClearLayerData(IFeatureLayer layer)
@@ -200,7 +177,7 @@
layer.DataSet.DataTable.Reset();
}
- private static void SetDataTableColumns(FeatureBasedMapData data, IFeatureLayer layer)
+ private static void SetDataTableColumns(TFeatureBasedMapData data, IFeatureLayer layer)
{
for (var i = 1; i <= data.MetaData.Count(); i++)
{
@@ -212,7 +189,7 @@
/// This method is used for obtaining a mapping between map data attribute names and DotSpatial
/// attribute names. This mapping is needed because DotSpatial can't handle special characters.
///
- private static Dictionary GetAttributeMapping(FeatureBasedMapData data)
+ private static Dictionary GetAttributeMapping(TFeatureBasedMapData data)
{
return Enumerable.Range(0, data.MetaData.Count())
.ToDictionary(md => data.MetaData.ElementAt(md), mdi => mdi + 1);
Index: Core/Components/test/Core.Components.DotSpatial.Test/Converter/FeatureBasedMapDataConverterTest.cs
===================================================================
diff -u -r1496f669024aeba114c77af3276e54f35642521f -red62f6b66a9884ae4ac854f0bc1131425567b0af
--- Core/Components/test/Core.Components.DotSpatial.Test/Converter/FeatureBasedMapDataConverterTest.cs (.../FeatureBasedMapDataConverterTest.cs) (revision 1496f669024aeba114c77af3276e54f35642521f)
+++ Core/Components/test/Core.Components.DotSpatial.Test/Converter/FeatureBasedMapDataConverterTest.cs (.../FeatureBasedMapDataConverterTest.cs) (revision ed62f6b66a9884ae4ac854f0bc1131425567b0af)
@@ -40,23 +40,6 @@
public class FeatureBasedMapDataConverterTest
{
[Test]
- public void CanConvertMapData_DifferentInheritingTypes_OnlySupportsExactType()
- {
- // Setup
- var testConverter = new TestFeatureBasedMapDataConverter();
-
- // Call
- var featureBasedMapDataResult = testConverter.CanConvertMapData(new TestFeatureBasedMapData("test data"));
- var classResult = testConverter.CanConvertMapData(new Class("test data"));
- var childResult = testConverter.CanConvertMapData(new Child("test data"));
-
- // Assert
- Assert.IsFalse(featureBasedMapDataResult);
- Assert.IsTrue(classResult);
- Assert.IsTrue(childResult);
- }
-
- [Test]
public void Convert_DataNull_ThrowsArgumentNullException()
{
// Setup
@@ -71,24 +54,6 @@
}
[Test]
- public void Convert_DataCannotBeConverted_ThrowsArgumentException()
- {
- // Setup
- var testConverter = new TestFeatureBasedMapDataConverter();
- var testFeatureBasedMapData = new TestFeatureBasedMapData("test data");
-
- // Precondition
- Assert.IsFalse(testConverter.CanConvertMapData(testFeatureBasedMapData));
-
- // Call
- TestDelegate test = () => testConverter.Convert(testFeatureBasedMapData);
-
- // Assert
- var expectedMessage = string.Format("The data of type {0} cannot be converted by this converter.", testFeatureBasedMapData.GetType());
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
- }
-
- [Test]
public void ConvertLayerFeatures_DataNull_ThrowsArgumentNullException()
{
// Setup
@@ -103,24 +68,6 @@
}
[Test]
- public void ConvertLayerFeatures_DataCannotBeConverted_ThrowsArgumentException()
- {
- // Setup
- var testConverter = new TestFeatureBasedMapDataConverter();
- var testFeatureBasedMapData = new TestFeatureBasedMapData("test data");
-
- // Precondition
- Assert.IsFalse(testConverter.CanConvertMapData(testFeatureBasedMapData));
-
- // Call
- TestDelegate test = () => testConverter.ConvertLayerFeatures(testFeatureBasedMapData, new MapPointLayer());
-
- // Assert
- var expectedMessage = string.Format("The data of type {0} cannot be converted by this converter.", testFeatureBasedMapData.GetType());
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
- }
-
- [Test]
public void ConvertLayerFeatures_TargetLayerNull_ThrowsArgumentNullException()
{
// Setup
@@ -150,24 +97,6 @@
}
[Test]
- public void ConvertLayerProperties_DataCannotBeConverted_ThrowsArgumentException()
- {
- // Setup
- var testConverter = new TestFeatureBasedMapDataConverter();
- var testFeatureBasedMapData = new TestFeatureBasedMapData("test data");
-
- // Precondition
- Assert.IsFalse(testConverter.CanConvertMapData(testFeatureBasedMapData));
-
- // Call
- TestDelegate test = () => testConverter.ConvertLayerProperties(testFeatureBasedMapData, new MapPointLayer());
-
- // Assert
- var expectedMessage = string.Format("The data of type {0} cannot be converted by this converter.", testFeatureBasedMapData.GetType());
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
- }
-
- [Test]
public void ConvertLayerProperties_TargetLayerNull_ThrowsArgumentNullException()
{
// Setup
@@ -402,11 +331,6 @@
public Class(string name) : base(name) {}
}
- private class Child : Class
- {
- public Child(string name) : base(name) {}
- }
-
private class TestFeatureBasedMapDataConverter : FeatureBasedMapDataConverter
where TFeatureBasedMapData : FeatureBasedMapData
{