Index: Core/Components/src/Core.Components.DotSpatial/Converter/MapDataConverter.cs =================================================================== diff -u -rfff190e93adf8dd50b1badaa7044576ab2a8c4c1 -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad --- Core/Components/src/Core.Components.DotSpatial/Converter/MapDataConverter.cs (.../MapDataConverter.cs) (revision fff190e93adf8dd50b1badaa7044576ab2a8c4c1) +++ Core/Components/src/Core.Components.DotSpatial/Converter/MapDataConverter.cs (.../MapDataConverter.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -21,9 +21,11 @@ using System; using System.Collections.Generic; - +using System.Drawing.Drawing2D; using Core.Components.Gis.Data; +using Core.Components.Gis.Style; using DotSpatial.Controls; +using DotSpatial.Symbology; namespace Core.Components.DotSpatial.Converter { Index: Core/Components/src/Core.Components.DotSpatial/Converter/MapDataHelper.cs =================================================================== diff -u --- Core/Components/src/Core.Components.DotSpatial/Converter/MapDataHelper.cs (revision 0) +++ Core/Components/src/Core.Components.DotSpatial/Converter/MapDataHelper.cs (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -0,0 +1,29 @@ +using System; +using Core.Components.Gis.Style; +using DotSpatial.Symbology; + +namespace Core.Components.DotSpatial.Converter +{ + public static class MapDataHelper + { + public static PointShape Convert(PointSymbol symbol) + { + PointShape shape; + switch (symbol) + { + case PointSymbol.Circle: + shape = PointShape.Undefined; + break; + case PointSymbol.Square: + shape = PointShape.Rectangle; + break; + case PointSymbol.Triangle: + shape = PointShape.Triangle; + break; + default: + throw new NotSupportedException(); + } + return shape; + } + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.DotSpatial/Converter/MapLineDataConverter.cs =================================================================== diff -u -rd2d0c9d6f209b4f3a36da6f8692cd66d8ce767b6 -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad --- Core/Components/src/Core.Components.DotSpatial/Converter/MapLineDataConverter.cs (.../MapLineDataConverter.cs) (revision d2d0c9d6f209b4f3a36da6f8692cd66d8ce767b6) +++ Core/Components/src/Core.Components.DotSpatial/Converter/MapLineDataConverter.cs (.../MapLineDataConverter.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -20,12 +20,15 @@ // All rights reserved. using System.Collections.Generic; +using System.Drawing.Drawing2D; using System.Linq; using Core.Components.Gis.Data; using DotSpatial.Controls; using DotSpatial.Data; +using DotSpatial.Symbology; using DotSpatial.Topology; +using LineStyle = Core.Components.Gis.Style.LineStyle; namespace Core.Components.DotSpatial.Converter { @@ -62,10 +65,20 @@ Name = data.Name }; + CreateStyle(layer, data.Style); + return new List { layer }; } + + private void CreateStyle(MapLineLayer layer, LineStyle style) + { + if (style != null) + { + layer.Symbolizer = new LineSymbolizer(style.Color, style.Color, style.Width, style.Style, LineCap.Round); + } + } } } \ No newline at end of file Index: Core/Components/src/Core.Components.DotSpatial/Converter/MapPointDataConverter.cs =================================================================== diff -u -r2117ba3d745d5776cefdf94dc86ac8d5950aa31e -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad --- Core/Components/src/Core.Components.DotSpatial/Converter/MapPointDataConverter.cs (.../MapPointDataConverter.cs) (revision 2117ba3d745d5776cefdf94dc86ac8d5950aa31e) +++ Core/Components/src/Core.Components.DotSpatial/Converter/MapPointDataConverter.cs (.../MapPointDataConverter.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -22,8 +22,10 @@ using System.Collections.Generic; using System.Linq; using Core.Components.Gis.Data; +using Core.Components.Gis.Style; using DotSpatial.Controls; using DotSpatial.Data; +using DotSpatial.Symbology; using DotSpatial.Topology; namespace Core.Components.DotSpatial.Converter @@ -48,10 +50,20 @@ Name = data.Name }; + CreateStyle(layer, data.Style); + return new List { layer }; } + + private void CreateStyle(MapPointLayer layer, PointStyle style) + { + if (style != null) + { + layer.Symbolizer = new PointSymbolizer(style.Color, MapDataHelper.Convert(style.Symbol), style.Size); + } + } } } \ No newline at end of file Index: Core/Components/src/Core.Components.DotSpatial/Converter/MapPolygonDataConverter.cs =================================================================== diff -u -rd2d0c9d6f209b4f3a36da6f8692cd66d8ce767b6 -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad --- Core/Components/src/Core.Components.DotSpatial/Converter/MapPolygonDataConverter.cs (.../MapPolygonDataConverter.cs) (revision d2d0c9d6f209b4f3a36da6f8692cd66d8ce767b6) +++ Core/Components/src/Core.Components.DotSpatial/Converter/MapPolygonDataConverter.cs (.../MapPolygonDataConverter.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -20,11 +20,14 @@ // All rights reserved. using System.Collections.Generic; +using System.Drawing.Drawing2D; using System.Linq; using Core.Components.Gis.Data; +using Core.Components.Gis.Style; using DotSpatial.Controls; using DotSpatial.Data; +using DotSpatial.Symbology; using DotSpatial.Topology; namespace Core.Components.DotSpatial.Converter @@ -62,10 +65,20 @@ Name = data.Name }; + CreateStyle(layer, data.Style); + return new List { layer }; } + + private void CreateStyle(MapPolygonLayer layer, PolygonStyle style) + { + if (style != null) + { + layer.Symbolizer = new PolygonSymbolizer(style.FillColor, style.StrokeColor, style.Width); + } + } } } \ No newline at end of file Index: Core/Components/src/Core.Components.DotSpatial/Core.Components.DotSpatial.csproj =================================================================== diff -u -r884543108a6db82b36fca454624a7e9aacaf801d -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad --- Core/Components/src/Core.Components.DotSpatial/Core.Components.DotSpatial.csproj (.../Core.Components.DotSpatial.csproj) (revision 884543108a6db82b36fca454624a7e9aacaf801d) +++ Core/Components/src/Core.Components.DotSpatial/Core.Components.DotSpatial.csproj (.../Core.Components.DotSpatial.csproj) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -93,6 +93,7 @@ + Index: Core/Components/src/Core.Components.Gis/Core.Components.Gis.csproj =================================================================== diff -u -r87078a6e2cde2c9a94644739f0cf998c60c5da75 -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad --- Core/Components/src/Core.Components.Gis/Core.Components.Gis.csproj (.../Core.Components.Gis.csproj) (revision 87078a6e2cde2c9a94644739f0cf998c60c5da75) +++ Core/Components/src/Core.Components.Gis/Core.Components.Gis.csproj (.../Core.Components.Gis.csproj) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -34,6 +34,7 @@ + @@ -46,8 +47,12 @@ + + + + Index: Core/Components/src/Core.Components.Gis/Data/MapData.cs =================================================================== diff -u -recef7aa46cb8fb7d138a5cc00a35f9e7aa7676b6 -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad --- Core/Components/src/Core.Components.Gis/Data/MapData.cs (.../MapData.cs) (revision ecef7aa46cb8fb7d138a5cc00a35f9e7aa7676b6) +++ Core/Components/src/Core.Components.Gis/Data/MapData.cs (.../MapData.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -21,6 +21,7 @@ using System; using Core.Common.Base; +using Core.Components.Gis.Style; namespace Core.Components.Gis.Data { Index: Core/Components/src/Core.Components.Gis/Data/MapLineData.cs =================================================================== diff -u -r2117ba3d745d5776cefdf94dc86ac8d5950aa31e -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad --- Core/Components/src/Core.Components.Gis/Data/MapLineData.cs (.../MapLineData.cs) (revision 2117ba3d745d5776cefdf94dc86ac8d5950aa31e) +++ Core/Components/src/Core.Components.Gis/Data/MapLineData.cs (.../MapLineData.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -23,6 +23,7 @@ using System.Collections.Generic; using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; +using Core.Components.Gis.Style; namespace Core.Components.Gis.Data { @@ -43,5 +44,10 @@ /// /// public MapLineData(IEnumerable features, string name) : base(features, name) {} + + /// + /// The style of the line. + /// + public LineStyle Style { get; set; } } } \ No newline at end of file Index: Core/Components/src/Core.Components.Gis/Data/MapPointData.cs =================================================================== diff -u -r2117ba3d745d5776cefdf94dc86ac8d5950aa31e -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad --- Core/Components/src/Core.Components.Gis/Data/MapPointData.cs (.../MapPointData.cs) (revision 2117ba3d745d5776cefdf94dc86ac8d5950aa31e) +++ Core/Components/src/Core.Components.Gis/Data/MapPointData.cs (.../MapPointData.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -23,6 +23,7 @@ using System.Collections.Generic; using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; +using Core.Components.Gis.Style; namespace Core.Components.Gis.Data { @@ -43,5 +44,10 @@ /// /// public MapPointData(IEnumerable features, string name) : base(features, name) { } + + /// + /// The style of the points. + /// + public PointStyle Style { get; set; } } } \ No newline at end of file Index: Core/Components/src/Core.Components.Gis/Data/MapPolygonData.cs =================================================================== diff -u -r2117ba3d745d5776cefdf94dc86ac8d5950aa31e -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad --- Core/Components/src/Core.Components.Gis/Data/MapPolygonData.cs (.../MapPolygonData.cs) (revision 2117ba3d745d5776cefdf94dc86ac8d5950aa31e) +++ Core/Components/src/Core.Components.Gis/Data/MapPolygonData.cs (.../MapPolygonData.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -23,6 +23,7 @@ using System.Collections.Generic; using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; +using Core.Components.Gis.Style; namespace Core.Components.Gis.Data { @@ -43,5 +44,10 @@ /// /// public MapPolygonData(IEnumerable features, string name) : base(features, name) { } + + /// + /// The style of the polygon. + /// + public PolygonStyle Style { get; set; } } } \ No newline at end of file Index: Core/Components/src/Core.Components.Gis/Style/LineStyle.cs =================================================================== diff -u --- Core/Components/src/Core.Components.Gis/Style/LineStyle.cs (revision 0) +++ Core/Components/src/Core.Components.Gis/Style/LineStyle.cs (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -0,0 +1,19 @@ +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace Core.Components.Gis.Style +{ + public class LineStyle + { + public Color Color { get; private set; } + public int Width { get; private set; } + public DashStyle Style { get; private set; } + + public LineStyle(Color color, int width, DashStyle style) + { + Color = color; + Width = width; + Style = style; + } + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.Gis/Style/PointStyle.cs =================================================================== diff -u --- Core/Components/src/Core.Components.Gis/Style/PointStyle.cs (revision 0) +++ Core/Components/src/Core.Components.Gis/Style/PointStyle.cs (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -0,0 +1,18 @@ +using System.Drawing; + +namespace Core.Components.Gis.Style +{ + public class PointStyle { + + public Color Color { get; private set; } + public double Size { get; private set; } + public PointSymbol Symbol { get; private set; } + + public PointStyle(Color color, int size, PointSymbol symbol) + { + Color = color; + Size = size; + Symbol = symbol; + } + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.Gis/Style/PointSymbol.cs =================================================================== diff -u --- Core/Components/src/Core.Components.Gis/Style/PointSymbol.cs (revision 0) +++ Core/Components/src/Core.Components.Gis/Style/PointSymbol.cs (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -0,0 +1,7 @@ +namespace Core.Components.Gis.Style +{ + public enum PointSymbol + { + Circle, Square, Triangle + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.Gis/Style/PolygonStyle.cs =================================================================== diff -u --- Core/Components/src/Core.Components.Gis/Style/PolygonStyle.cs (revision 0) +++ Core/Components/src/Core.Components.Gis/Style/PolygonStyle.cs (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -0,0 +1,18 @@ +using System.Drawing; + +namespace Core.Components.Gis.Style +{ + public class PolygonStyle + { + public Color FillColor { get; private set; } + public Color StrokeColor { get; private set; } + public int Width { get; private set; } + + public PolygonStyle(Color fillColor, Color strokeColor, int width) + { + FillColor = fillColor; + StrokeColor = strokeColor; + Width = width; + } + } +} \ No newline at end of file Index: Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapDataHelperTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapDataHelperTest.cs (revision 0) +++ Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapDataHelperTest.cs (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -0,0 +1,41 @@ +using Core.Components.DotSpatial.Converter; +using Core.Components.Gis.Style; +using DotSpatial.Symbology; +using NUnit.Framework; + +namespace Core.Components.DotSpatial.Test.Converter +{ + [TestFixture] + public class MapDataHelperTest + { + [Test] + public void Convert_Circle_ReturnDefault() + { + // Call + var symbol = MapDataHelper.Convert(PointSymbol.Circle); + + // Assert + Assert.AreEqual(PointShape.Undefined, symbol); + } + + [Test] + public void Convert_Square_ReturnRectangle() + { + // Call + var symbol = MapDataHelper.Convert(PointSymbol.Square); + + // Assert + Assert.AreEqual(PointShape.Rectangle, symbol); + } + + [Test] + public void Convert_Triangle_ReturnTriangle() + { + // Call + var symbol = MapDataHelper.Convert(PointSymbol.Triangle); + + // Assert + Assert.AreEqual(PointShape.Triangle, symbol); + } + } +} \ No newline at end of file Index: Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapLineDataConverterTest.cs =================================================================== diff -u -r884543108a6db82b36fca454624a7e9aacaf801d -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad --- Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapLineDataConverterTest.cs (.../MapLineDataConverterTest.cs) (revision 884543108a6db82b36fca454624a7e9aacaf801d) +++ Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapLineDataConverterTest.cs (.../MapLineDataConverterTest.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Drawing; +using System.Drawing.Drawing2D; using System.Linq; using Core.Common.Base.Geometry; using Core.Common.TestUtil; @@ -10,7 +12,9 @@ using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; using DotSpatial.Controls; +using DotSpatial.Symbology; using NUnit.Framework; +using LineStyle = Core.Components.Gis.Style.LineStyle; namespace Core.Components.DotSpatial.Test.Converter { @@ -232,5 +236,89 @@ var layer = layers.First() as MapLineLayer; Assert.AreEqual(name, layer.Name); } + + [Test] + [TestCase(KnownColor.AliceBlue)] + [TestCase(KnownColor.Azure)] + [TestCase(KnownColor.Beige)] + public void Convert_WithDifferentColors_AppliesStyleToLayer(KnownColor color) + { + // Setup + var converter = new MapLineDataConverter(); + var expectedColor = Color.FromKnownColor(color); + var style = new LineStyle(expectedColor, 3, DashStyle.Solid); + var data = new MapLineData(Enumerable.Empty(), "test") + { + Style = style + }; + + // Call + var layers = converter.Convert(data); + + // Assert + var layer = (MapLineLayer) layers.First(); + AssertAreEqual(new LineSymbolizer(expectedColor, expectedColor, 3, DashStyle.Solid, LineCap.Round), layer.Symbolizer); + } + + [Test] + [TestCase(1)] + [TestCase(5)] + [TestCase(7)] + public void Convert_WithDifferentWidths_AppliesStyleToLayer(int width) + { + // Setup + var converter = new MapLineDataConverter(); + var style = new LineStyle(Color.AliceBlue, width, DashStyle.Solid); + var data = new MapLineData(Enumerable.Empty(), "test") + { + Style = style + }; + + // Call + var layers = converter.Convert(data); + + // Assert + var layer = (MapLineLayer) layers.First(); + AssertAreEqual(new LineSymbolizer(Color.AliceBlue, Color.AliceBlue, width, DashStyle.Solid, LineCap.Round), layer.Symbolizer); + } + + [Test] + [TestCase(DashStyle.Solid)] + [TestCase(DashStyle.Dash)] + [TestCase(DashStyle.Dot)] + public void Convert_WithDifferentLineStyles_AppliesStyleToLayer(DashStyle lineStyle) + { + // Setup + var converter = new MapLineDataConverter(); + var style = new LineStyle(Color.AliceBlue, 3, lineStyle); + var data = new MapLineData(Enumerable.Empty(), "test") + { + Style = style + }; + + // Call + var layers = converter.Convert(data); + + // Assert + var layer = (MapLineLayer) layers.First(); + AssertAreEqual(new LineSymbolizer(Color.AliceBlue, Color.AliceBlue, 3, lineStyle, LineCap.Round), layer.Symbolizer); + } + + private void AssertAreEqual(ILineSymbolizer firstSymbolizer, ILineSymbolizer secondSymbolizer) + { + var firstStrokes = firstSymbolizer.Strokes; + var secondStrokes = secondSymbolizer.Strokes; + Assert.AreEqual(firstStrokes.Count, secondStrokes.Count, "Unequal amount of strokes defined."); + for (var i = 0; i < firstStrokes.Count; i++) + { + var firstStroke = (CartographicStroke) firstStrokes[i]; + var secondStroke = (CartographicStroke) secondStrokes[i]; + + Assert.AreEqual(firstStroke.Color, secondStroke.Color); + Assert.AreEqual(firstStroke.EndCap, secondStroke.EndCap); + Assert.AreEqual(firstStroke.DashStyle, secondStroke.DashStyle); + Assert.AreEqual(firstStroke.Width, secondStroke.Width); + } + } } } \ No newline at end of file Index: Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPointDataConverterTest.cs =================================================================== diff -u -r884543108a6db82b36fca454624a7e9aacaf801d -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad --- Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPointDataConverterTest.cs (.../MapPointDataConverterTest.cs) (revision 884543108a6db82b36fca454624a7e9aacaf801d) +++ Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPointDataConverterTest.cs (.../MapPointDataConverterTest.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; using System.Linq; using Core.Common.Base.Geometry; using Core.Common.TestUtil; @@ -8,9 +10,12 @@ using Core.Components.Gis.Data; using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; +using Core.Components.Gis.Style; using DotSpatial.Controls; +using DotSpatial.Symbology; using DotSpatial.Topology; using NUnit.Framework; +using LineStyle = Core.Components.Gis.Style.LineStyle; namespace Core.Components.DotSpatial.Test.Converter { @@ -209,5 +214,89 @@ var layer = layers.First() as MapPointLayer; Assert.AreEqual(name, layer.Name); } + + [Test] + [TestCase(KnownColor.AliceBlue)] + [TestCase(KnownColor.Azure)] + [TestCase(KnownColor.Beige)] + public void Convert_WithDifferentColors_AppliesStyleToLayer(KnownColor color) + { + // Setup + var converter = new MapPointDataConverter(); + var expectedColor = Color.FromKnownColor(color); + var style = new PointStyle(expectedColor, 3, PointSymbol.Circle); + var data = new MapPointData(Enumerable.Empty(), "test") + { + Style = style + }; + + // Call + var layers = converter.Convert(data); + + // Assert + var layer = (MapPointLayer)layers.First(); + AssertAreEqual(new PointSymbolizer(expectedColor, PointShape.Undefined, 3), layer.Symbolizer); + } + + [Test] + [TestCase(1)] + [TestCase(5)] + [TestCase(7)] + public void Convert_WithDifferentWidths_AppliesStyleToLayer(int width) + { + // Setup + var converter = new MapPointDataConverter(); + var style = new PointStyle(Color.AliceBlue, width, PointSymbol.Circle); + var data = new MapPointData(Enumerable.Empty(), "test") + { + Style = style + }; + + // Call + var layers = converter.Convert(data); + + // Assert + var layer = (MapPointLayer)layers.First(); + AssertAreEqual(new PointSymbolizer(Color.AliceBlue, PointShape.Undefined, width), layer.Symbolizer); + } + + [Test] + [TestCase(PointSymbol.Circle)] + [TestCase(PointSymbol.Square)] + [TestCase(PointSymbol.Triangle)] + public void Convert_WithDifferentPointStyles_AppliesStyleToLayer(PointSymbol pointStyle) + { + // Setup + var converter = new MapPointDataConverter(); + var style = new PointStyle(Color.AliceBlue, 3, pointStyle); + var data = new MapPointData(Enumerable.Empty(), "test") + { + Style = style + }; + + // Call + var layers = converter.Convert(data); + + // Assert + var layer = (MapPointLayer)layers.First(); + PointShape expectedPointShape = pointStyle == PointSymbol.Circle ? PointShape.Undefined : pointStyle == PointSymbol.Square ? PointShape.Rectangle : PointShape.Triangle; + AssertAreEqual(new PointSymbolizer(Color.AliceBlue, expectedPointShape, 3), layer.Symbolizer); + } + + private void AssertAreEqual(IPointSymbolizer firstSymbolizer, IPointSymbolizer secondSymbolizer) + { + var firstSymbols = firstSymbolizer.Symbols; + var secondSymbols = secondSymbolizer.Symbols; + Assert.AreEqual(firstSymbols.Count, secondSymbols.Count, "Unequal amount of strokes defined."); + for (var i = 0; i < firstSymbols.Count; i++) + { + var firstStroke = (SimpleSymbol)firstSymbols[i]; + var secondStroke = (SimpleSymbol)secondSymbols[i]; + + Assert.AreEqual(firstStroke.Color, secondStroke.Color); + Assert.AreEqual(firstStroke.PointShape, secondStroke.PointShape); + Assert.AreEqual(firstStroke.Size, secondStroke.Size); + } + } } } \ No newline at end of file Index: Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPolygonDataConverterTest.cs =================================================================== diff -u -r884543108a6db82b36fca454624a7e9aacaf801d -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad --- Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPolygonDataConverterTest.cs (.../MapPolygonDataConverterTest.cs) (revision 884543108a6db82b36fca454624a7e9aacaf801d) +++ Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPolygonDataConverterTest.cs (.../MapPolygonDataConverterTest.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Drawing; using System.Linq; using Core.Common.Base.Geometry; using Core.Common.TestUtil; @@ -9,7 +10,9 @@ using Core.Components.Gis.Data; using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; +using Core.Components.Gis.Style; using DotSpatial.Controls; +using DotSpatial.Symbology; using DotSpatial.Topology; using NUnit.Framework; @@ -235,5 +238,89 @@ var layer = layers.First() as MapPolygonLayer; Assert.AreEqual(name, layer.Name); } + + [Test] + [TestCase(KnownColor.AliceBlue)] + [TestCase(KnownColor.Azure)] + [TestCase(KnownColor.Beige)] + public void Convert_WithDifferentFillColors_AppliesStyleToLayer(KnownColor color) + { + // Setup + var converter = new MapPolygonDataConverter(); + var expectedColor = Color.FromKnownColor(color); + var style = new PolygonStyle(expectedColor, Color.AliceBlue, 3); + var data = new MapPolygonData(Enumerable.Empty(), "test") + { + Style = style + }; + + // Call + var layers = converter.Convert(data); + + // Assert + var layer = (MapPolygonLayer)layers.First(); + AssertAreEqual(new PolygonSymbolizer(expectedColor, Color.AliceBlue, 3), layer.Symbolizer); + } + + [Test] + [TestCase(KnownColor.AliceBlue)] + [TestCase(KnownColor.Azure)] + [TestCase(KnownColor.Beige)] + public void Convert_WithDifferentStrokeColors_AppliesStyleToLayer(KnownColor color) + { + // Setup + var converter = new MapPolygonDataConverter(); + var expectedColor = Color.FromKnownColor(color); + var style = new PolygonStyle(Color.AliceBlue, expectedColor, 3); + var data = new MapPolygonData(Enumerable.Empty(), "test") + { + Style = style + }; + + // Call + var layers = converter.Convert(data); + + // Assert + var layer = (MapPolygonLayer)layers.First(); + AssertAreEqual(new PolygonSymbolizer(Color.AliceBlue, expectedColor, 3), layer.Symbolizer); + } + + [Test] + [TestCase(1)] + [TestCase(5)] + [TestCase(7)] + public void Convert_WithDifferentWidths_AppliesStyleToLayer(int width) + { + // Setup + var converter = new MapPolygonDataConverter(); + var style = new PolygonStyle(Color.AliceBlue, Color.AliceBlue, width); + var data = new MapPolygonData(Enumerable.Empty(), "test") + { + Style = style + }; + + // Call + var layers = converter.Convert(data); + + // Assert + var layer = (MapPolygonLayer)layers.First(); + AssertAreEqual(new PolygonSymbolizer(Color.AliceBlue, Color.AliceBlue, width), layer.Symbolizer); + } + + private void AssertAreEqual(IPolygonSymbolizer firstSymbolizer, IPolygonSymbolizer secondSymbolizer) + { + var firstSymbols = firstSymbolizer.Patterns; + var secondSymbols = secondSymbolizer.Patterns; + Assert.AreEqual(firstSymbols.Count, secondSymbols.Count, "Unequal amount of strokes defined."); + for (var i = 0; i < firstSymbols.Count; i++) + { + var firstStroke = (SimplePattern)firstSymbols[i]; + var secondStroke = (SimplePattern)secondSymbols[i]; + + Assert.AreEqual(firstStroke.FillColor, secondStroke.FillColor); + Assert.AreEqual(firstStroke.Outline.GetFillColor(), secondStroke.Outline.GetFillColor()); + Assert.AreEqual(firstStroke.Outline.GetWidth(), secondStroke.Outline.GetWidth()); + } + } } } \ No newline at end of file Index: Core/Components/test/Core.Components.DotSpatial.Test/Core.Components.DotSpatial.Test.csproj =================================================================== diff -u -r884543108a6db82b36fca454624a7e9aacaf801d -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad --- Core/Components/test/Core.Components.DotSpatial.Test/Core.Components.DotSpatial.Test.csproj (.../Core.Components.DotSpatial.Test.csproj) (revision 884543108a6db82b36fca454624a7e9aacaf801d) +++ Core/Components/test/Core.Components.DotSpatial.Test/Core.Components.DotSpatial.Test.csproj (.../Core.Components.DotSpatial.Test.csproj) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -102,6 +102,7 @@ + Index: Core/Components/test/Core.Components.Gis.Test/Core.Components.Gis.Test.csproj =================================================================== diff -u -re8ed2a7235a3d440d258ce5f76862196388c64bc -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad --- Core/Components/test/Core.Components.Gis.Test/Core.Components.Gis.Test.csproj (.../Core.Components.Gis.Test.csproj) (revision e8ed2a7235a3d440d258ce5f76862196388c64bc) +++ Core/Components/test/Core.Components.Gis.Test/Core.Components.Gis.Test.csproj (.../Core.Components.Gis.Test.csproj) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) @@ -39,6 +39,7 @@ + @@ -50,6 +51,9 @@ + + + @@ -68,6 +72,7 @@ Core.Components.Gis +