Index: Core/Components/src/Core.Components.DotSpatial/Converter/FeatureBasedMapDataConverter.cs
===================================================================
diff -u -r9d24ac09af3f8bb26b9ac80a7f934572f5d1388f -r36ad62b60021e13af670bac0b725c1e2e960efd0
--- Core/Components/src/Core.Components.DotSpatial/Converter/FeatureBasedMapDataConverter.cs (.../FeatureBasedMapDataConverter.cs) (revision 9d24ac09af3f8bb26b9ac80a7f934572f5d1388f)
+++ Core/Components/src/Core.Components.DotSpatial/Converter/FeatureBasedMapDataConverter.cs (.../FeatureBasedMapDataConverter.cs) (revision 36ad62b60021e13af670bac0b725c1e2e960efd0)
@@ -54,16 +54,74 @@
var layer = CreateLayer();
- ConvertLayerFeatures(data, layer);
- ConvertLayerProperties(data, layer);
+ ConvertLayerFeaturesInternal(data, layer);
+ ConvertLayerPropertiesInternal(data, layer);
return layer;
}
- public void ConvertLayerFeatures(FeatureBasedMapData data, IFeatureLayer layer)
+ public void ConvertLayerFeatures(FeatureBasedMapData data, IMapFeatureLayer layer)
{
ValidateParameters(data);
+ ConvertLayerFeaturesInternal(data, layer);
+ }
+
+ public void ConvertLayerProperties(FeatureBasedMapData data, IMapFeatureLayer layer)
+ {
+ ValidateParameters(data);
+
+ ConvertLayerPropertiesInternal(data, layer);
+ }
+
+ ///
+ /// Creates a new .
+ ///
+ /// The newly created .
+ protected abstract IMapFeatureLayer CreateLayer();
+
+ ///
+ /// Creates an of based on .
+ ///
+ /// The to create features for.
+ /// An of .
+ protected abstract IEnumerable CreateFeatures(MapFeature mapFeature);
+
+ ///
+ /// Creates a new .
+ ///
+ /// The map data to create the symbolizer for.
+ /// The newly created .
+ /// Null should never be returned as this will break DotSpatial.
+ protected abstract IFeatureSymbolizer CreateSymbolizer(TFeatureBasedMapData mapData);
+
+ ///
+ /// Converts an of to an
+ /// of .
+ ///
+ /// The of to convert.
+ /// The converted of .
+ protected static IEnumerable ConvertPoint2DElementsToCoordinates(IEnumerable points)
+ {
+ return points.Select(point => new Coordinate(point.X, point.Y));
+ }
+
+ private void ValidateParameters(FeatureBasedMapData data)
+ {
+ if (data == null)
+ {
+ throw new ArgumentNullException("data", @"Null data cannot be converted into a feature layer.");
+ }
+
+ 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 ConvertLayerFeaturesInternal(FeatureBasedMapData data, IFeatureLayer layer)
+ {
ClearLayerData(layer);
SetDataTableColumns(data, layer);
@@ -88,34 +146,15 @@
layer.AssignFastDrawnStates();
}
- public void ConvertLayerProperties(FeatureBasedMapData data, IFeatureLayer layer)
+ private void ConvertLayerPropertiesInternal(FeatureBasedMapData data, IFeatureLayer layer)
{
- ValidateParameters(data);
-
layer.IsVisible = data.IsVisible;
((TMapFeatureLayer) layer).Name = data.Name;
layer.ShowLabels = data.ShowLabels;
layer.LabelLayer = GetLabelLayer(GetColumnNameLookup(data), layer.DataSet, data.ShowLabels, data.SelectedMetaDataAttribute);
layer.Symbolizer = CreateSymbolizer((TFeatureBasedMapData) data);
}
- protected abstract IMapFeatureLayer CreateLayer();
-
- protected abstract IEnumerable CreateFeatures(MapFeature mapFeature);
-
- protected abstract IFeatureSymbolizer CreateSymbolizer(TFeatureBasedMapData mapData);
-
- ///
- /// Converts an of to an
- /// of .
- ///
- /// The of to convert.
- /// The converted of .
- protected static IEnumerable ConvertPoint2DElementsToCoordinates(IEnumerable points)
- {
- return points.Select(point => new Coordinate(point.X, point.Y));
- }
-
private static void ClearLayerData(IFeatureLayer layer)
{
layer.DataSet.Features.Clear();
@@ -130,20 +169,16 @@
}
}
+ ///
+ /// 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 GetColumnNameLookup(FeatureBasedMapData data)
{
return Enumerable.Range(0, data.MetaData.Count())
.ToDictionary(md => data.MetaData.ElementAt(md), mdi => mdi + 1);
}
- ///
- /// Gets a new .
- ///
- /// The lookup to use for determining the label layer expression.
- /// The to add the to.
- /// Indicator whether to show the labels or not.
- /// The key of the attribute to show the labels for.
- /// A new .
private static MapLabelLayer GetLabelLayer(IDictionary metaDataLookup, IFeatureSet featureSet, bool showLabels, string labelToShow)
{
var labelLayer = new MapLabelLayer();
@@ -160,19 +195,5 @@
return labelLayer;
}
-
- private void ValidateParameters(FeatureBasedMapData data)
- {
- if (data == null)
- {
- throw new ArgumentNullException("data", @"Null data cannot be converted into a feature layer.");
- }
-
- if (!CanConvertMapData(data))
- {
- var message = string.Format("The data of type {0} cannot be converted by this converter.", data.GetType());
- throw new ArgumentException(message);
- }
- }
}
}
\ No newline at end of file
Index: Core/Components/src/Core.Components.DotSpatial/Converter/IFeatureBasedMapDataConverter.cs
===================================================================
diff -u -rf1533826e584432afb90f50645bad20a803eeac1 -r36ad62b60021e13af670bac0b725c1e2e960efd0
--- Core/Components/src/Core.Components.DotSpatial/Converter/IFeatureBasedMapDataConverter.cs (.../IFeatureBasedMapDataConverter.cs) (revision f1533826e584432afb90f50645bad20a803eeac1)
+++ Core/Components/src/Core.Components.DotSpatial/Converter/IFeatureBasedMapDataConverter.cs (.../IFeatureBasedMapDataConverter.cs) (revision 36ad62b60021e13af670bac0b725c1e2e960efd0)
@@ -22,12 +22,11 @@
using System;
using Core.Components.Gis.Data;
using DotSpatial.Controls;
-using DotSpatial.Symbology;
namespace Core.Components.DotSpatial.Converter
{
///
- /// The interface for a converter which converts into .
+ /// Interface for converting into .
///
public interface IFeatureBasedMapDataConverter
{
@@ -53,14 +52,18 @@
///
/// The data to convert the feature related data from.
/// The layer to convert the feature related data to.
- void ConvertLayerFeatures(FeatureBasedMapData data, IFeatureLayer layer);
+ /// Thrown when returns false.
+ /// Thrown when is null.
+ void ConvertLayerFeatures(FeatureBasedMapData data, IMapFeatureLayer layer);
///
/// Converts all general properties (like and )
/// from to .
///
/// The data to convert the general properties from.
/// The layer to convert the general properties to.
- void ConvertLayerProperties(FeatureBasedMapData data, IFeatureLayer layer);
+ /// Thrown when returns false.
+ /// Thrown when is null.
+ void ConvertLayerProperties(FeatureBasedMapData data, IMapFeatureLayer layer);
}
}
\ No newline at end of file
Index: Core/Components/src/Core.Components.DotSpatial/Converter/MapLineDataConverter.cs
===================================================================
diff -u -r9d24ac09af3f8bb26b9ac80a7f934572f5d1388f -r36ad62b60021e13af670bac0b725c1e2e960efd0
--- Core/Components/src/Core.Components.DotSpatial/Converter/MapLineDataConverter.cs (.../MapLineDataConverter.cs) (revision 9d24ac09af3f8bb26b9ac80a7f934572f5d1388f)
+++ Core/Components/src/Core.Components.DotSpatial/Converter/MapLineDataConverter.cs (.../MapLineDataConverter.cs) (revision 36ad62b60021e13af670bac0b725c1e2e960efd0)
@@ -50,8 +50,8 @@
protected override IFeatureSymbolizer CreateSymbolizer(MapLineData mapData)
{
return mapData.Style != null
- ? new LineSymbolizer(mapData.Style.Color, mapData.Style.Color, mapData.Style.Width, mapData.Style.Style, LineCap.Round)
- : new LineSymbolizer();
+ ? new LineSymbolizer(mapData.Style.Color, mapData.Style.Color, mapData.Style.Width, mapData.Style.Style, LineCap.Round)
+ : new LineSymbolizer();
}
private static IBasicGeometry GetGeometry(MapFeature mapFeature)
Index: Core/Components/src/Core.Components.DotSpatial/Converter/MapPointDataConverter.cs
===================================================================
diff -u -r9d24ac09af3f8bb26b9ac80a7f934572f5d1388f -r36ad62b60021e13af670bac0b725c1e2e960efd0
--- Core/Components/src/Core.Components.DotSpatial/Converter/MapPointDataConverter.cs (.../MapPointDataConverter.cs) (revision 9d24ac09af3f8bb26b9ac80a7f934572f5d1388f)
+++ Core/Components/src/Core.Components.DotSpatial/Converter/MapPointDataConverter.cs (.../MapPointDataConverter.cs) (revision 36ad62b60021e13af670bac0b725c1e2e960efd0)
@@ -48,8 +48,8 @@
protected override IFeatureSymbolizer CreateSymbolizer(MapPointData mapData)
{
return mapData.Style != null
- ? new PointSymbolizer(mapData.Style.Color, MapDataHelper.Convert(mapData.Style.Symbol), mapData.Style.Size)
- : new PointSymbolizer();
+ ? new PointSymbolizer(mapData.Style.Color, MapDataHelper.Convert(mapData.Style.Symbol), mapData.Style.Size)
+ : new PointSymbolizer();
}
private static IEnumerable GetAllMapFeatureCoordinates(MapFeature feature)