Index: Core/Components/src/Core.Components.DotSpatial/Converter/MapPolygonDataConverter.cs =================================================================== diff -u -refe5cc540b802c2307b33eadaa7912e38b9d68a3 -r876d55bc25a5f8e583bbe02e55e916df8a8e4a20 --- Core/Components/src/Core.Components.DotSpatial/Converter/MapPolygonDataConverter.cs (.../MapPolygonDataConverter.cs) (revision efe5cc540b802c2307b33eadaa7912e38b9d68a3) +++ Core/Components/src/Core.Components.DotSpatial/Converter/MapPolygonDataConverter.cs (.../MapPolygonDataConverter.cs) (revision 876d55bc25a5f8e583bbe02e55e916df8a8e4a20) @@ -20,6 +20,7 @@ // All rights reserved. using System.Collections.Generic; +using System.Drawing; using System.Linq; using Core.Common.Base.Geometry; using Core.Components.Gis.Data; @@ -64,7 +65,12 @@ protected override IFeatureSymbolizer CreateSymbolizer(MapPolygonData mapData) { - return new PolygonSymbolizer(mapData.Style.FillColor, mapData.Style.StrokeColor, mapData.Style.StrokeThickness); + Color strokeColor = mapData.Style.StrokeColor; + if (mapData.Style.StrokeThickness == 0) + { + strokeColor = Color.Transparent; + } + return new PolygonSymbolizer(mapData.Style.FillColor, strokeColor, mapData.Style.StrokeThickness); } private static IBasicGeometry GetGeometry(List geometryList) Index: Core/Components/src/Core.Components.Gis/Properties/Resources.Designer.cs =================================================================== diff -u -r380ff7e39d59dc26bf7d03596a807acf3d2eeb24 -r876d55bc25a5f8e583bbe02e55e916df8a8e4a20 --- Core/Components/src/Core.Components.Gis/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 380ff7e39d59dc26bf7d03596a807acf3d2eeb24) +++ Core/Components/src/Core.Components.Gis/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 876d55bc25a5f8e583bbe02e55e916df8a8e4a20) @@ -163,6 +163,15 @@ } /// + /// Looks up a localized string similar to De waarde voor grootte moet in het bereik {0} liggen.. + /// + internal static string Size_Value_should_be_in_Range_0_ { + get { + return ResourceManager.GetString("Size_Value_should_be_in_Range_0_", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Vierkant. /// internal static string Square_DisplayName { @@ -181,6 +190,15 @@ } /// + /// Looks up a localized string similar to De waarde voor lijndikte moet in het bereik {0} liggen.. + /// + internal static string StrokeThickness_Value_should_be_in_Range_0_ { + get { + return ResourceManager.GetString("StrokeThickness_Value_should_be_in_Range_0_", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Driehoek. /// internal static string Triangle_DisplayName { @@ -190,6 +208,15 @@ } /// + /// Looks up a localized string similar to De waarde voor lijndikte moet in het bereik {0} liggen.. + /// + internal static string Width_Value_should_be_in_Range_0_ { + get { + return ResourceManager.GetString("Width_Value_should_be_in_Range_0_", resourceCulture); + } + } + + /// /// Looks up a localized string similar to <niet bepaald>. /// internal static string WmtsMapData_Unconfigured_name { Index: Core/Components/src/Core.Components.Gis/Properties/Resources.resx =================================================================== diff -u -r380ff7e39d59dc26bf7d03596a807acf3d2eeb24 -r876d55bc25a5f8e583bbe02e55e916df8a8e4a20 --- Core/Components/src/Core.Components.Gis/Properties/Resources.resx (.../Resources.resx) (revision 380ff7e39d59dc26bf7d03596a807acf3d2eeb24) +++ Core/Components/src/Core.Components.Gis/Properties/Resources.resx (.../Resources.resx) (revision 876d55bc25a5f8e583bbe02e55e916df8a8e4a20) @@ -156,4 +156,13 @@ Ster + + De waarde voor lijndikte moet in het bereik {0} liggen. + + + De waarde voor lijndikte moet in het bereik {0} liggen. + + + De waarde voor grootte moet in het bereik {0} liggen. + \ No newline at end of file Index: Core/Components/src/Core.Components.Gis/Style/LineStyle.cs =================================================================== diff -u -r081badaad87a6e2a6d5c861de9ee95fa1ca6dea3 -r876d55bc25a5f8e583bbe02e55e916df8a8e4a20 --- Core/Components/src/Core.Components.Gis/Style/LineStyle.cs (.../LineStyle.cs) (revision 081badaad87a6e2a6d5c861de9ee95fa1ca6dea3) +++ Core/Components/src/Core.Components.Gis/Style/LineStyle.cs (.../LineStyle.cs) (revision 876d55bc25a5f8e583bbe02e55e916df8a8e4a20) @@ -19,8 +19,11 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Drawing; using System.Drawing.Drawing2D; +using Core.Common.Base.Data; +using Core.Components.Gis.Properties; namespace Core.Components.Gis.Style { @@ -29,6 +32,9 @@ /// public class LineStyle { + private readonly Range widthValidityRange = new Range(0, 48); + private int width; + /// /// Gets or sets the line color. /// @@ -37,7 +43,25 @@ /// /// Gets or sets the line width. /// - public int Width { get; set; } + public int Width + { + get + { + return width; + } + set + { + if (widthValidityRange.InRange(value)) + { + width = value; + } + else + { + string message = string.Format(Resources.Width_Value_should_be_in_Range_0_, widthValidityRange); + throw new ArgumentOutOfRangeException(nameof(value), message); + } + } + } /// /// Gets or sets the line style. Index: Core/Components/src/Core.Components.Gis/Style/PointStyle.cs =================================================================== diff -u -r081badaad87a6e2a6d5c861de9ee95fa1ca6dea3 -r876d55bc25a5f8e583bbe02e55e916df8a8e4a20 --- Core/Components/src/Core.Components.Gis/Style/PointStyle.cs (.../PointStyle.cs) (revision 081badaad87a6e2a6d5c861de9ee95fa1ca6dea3) +++ Core/Components/src/Core.Components.Gis/Style/PointStyle.cs (.../PointStyle.cs) (revision 876d55bc25a5f8e583bbe02e55e916df8a8e4a20) @@ -19,7 +19,10 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Drawing; +using Core.Common.Base.Data; +using Core.Components.Gis.Properties; namespace Core.Components.Gis.Style { @@ -28,6 +31,11 @@ /// public class PointStyle { + private readonly Range strokeThicknessValidityRange = new Range(0, 48); + private readonly Range sizeValidityRange = new Range(0, 48); + private int strokeThickness; + private int size; + /// /// Gets or sets the point color. /// @@ -36,7 +44,25 @@ /// /// Gets or sets the point size. /// - public int Size { get; set; } + public int Size + { + get + { + return size; + } + set + { + if (sizeValidityRange.InRange(value)) + { + size = value; + } + else + { + string message = string.Format(Resources.Size_Value_should_be_in_Range_0_, sizeValidityRange); + throw new ArgumentOutOfRangeException(nameof(value), message); + } + } + } /// /// Gets or sets the point symbol. @@ -51,6 +77,24 @@ /// /// Gets or sets the stroke thickness. /// - public int StrokeThickness { get; set; } + public int StrokeThickness + { + get + { + return strokeThickness; + } + set + { + if (strokeThicknessValidityRange.InRange(value)) + { + strokeThickness = value; + } + else + { + string message = string.Format(Resources.StrokeThickness_Value_should_be_in_Range_0_, strokeThicknessValidityRange); + throw new ArgumentOutOfRangeException(nameof(value), message); + } + } + } } } \ No newline at end of file Index: Core/Components/src/Core.Components.Gis/Style/PolygonStyle.cs =================================================================== diff -u -r081badaad87a6e2a6d5c861de9ee95fa1ca6dea3 -r876d55bc25a5f8e583bbe02e55e916df8a8e4a20 --- Core/Components/src/Core.Components.Gis/Style/PolygonStyle.cs (.../PolygonStyle.cs) (revision 081badaad87a6e2a6d5c861de9ee95fa1ca6dea3) +++ Core/Components/src/Core.Components.Gis/Style/PolygonStyle.cs (.../PolygonStyle.cs) (revision 876d55bc25a5f8e583bbe02e55e916df8a8e4a20) @@ -19,7 +19,10 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Drawing; +using Core.Common.Base.Data; +using Core.Components.Gis.Properties; namespace Core.Components.Gis.Style { @@ -28,6 +31,9 @@ /// public class PolygonStyle { + private readonly Range strokeThicknessValidityRange = new Range(0, 48); + private int strokeThickness; + /// /// Gets or sets the polygon fill color. /// @@ -41,6 +47,24 @@ /// /// Gets or sets the polygon border stroke thickness. /// - public int StrokeThickness { get; set; } + public int StrokeThickness + { + get + { + return strokeThickness; + } + set + { + if (strokeThicknessValidityRange.InRange(value)) + { + strokeThickness = value; + } + else + { + string message = string.Format(Resources.StrokeThickness_Value_should_be_in_Range_0_, strokeThicknessValidityRange); + throw new ArgumentOutOfRangeException(nameof(value), message); + } + } + } } } \ No newline at end of file Index: Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPolygonDataConverterTest.cs =================================================================== diff -u -r081badaad87a6e2a6d5c861de9ee95fa1ca6dea3 -r876d55bc25a5f8e583bbe02e55e916df8a8e4a20 --- Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPolygonDataConverterTest.cs (.../MapPolygonDataConverterTest.cs) (revision 081badaad87a6e2a6d5c861de9ee95fa1ca6dea3) +++ Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPolygonDataConverterTest.cs (.../MapPolygonDataConverterTest.cs) (revision 876d55bc25a5f8e583bbe02e55e916df8a8e4a20) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using System.Drawing; using System.Linq; @@ -246,6 +247,28 @@ AssertAreEqual(new PolygonSymbolizer(expectedFillColor, expectedOutlineFillColor, width), mapPolygonLayer.Symbolizer); } + [Test] + [Combinatorial] + public void ConvertLayerProperties_MapPolygonDataWithStrokeThicknessZero_MapPolygonLayerOutlineColorTransparent() + { + // Setup + var converter = new MapPolygonDataConverter(); + var mapPolygonLayer = new MapPolygonLayer(); + Color expectedFillColor = Color.FromKnownColor(new Random(21).NextEnum()); + var mapPolygonData = new MapPolygonData("test", new PolygonStyle + { + FillColor = expectedFillColor, + StrokeColor = Color.ForestGreen, + StrokeThickness = 0 + }); + + // Call + converter.ConvertLayerProperties(mapPolygonData, mapPolygonLayer); + + // Assert + AssertAreEqual(new PolygonSymbolizer(expectedFillColor, Color.Transparent, 0), mapPolygonLayer.Symbolizer); + } + private static Point2D[] CreateRectangularRing(double xy1, double xy2) { return new[] Index: Core/Components/test/Core.Components.Gis.Test/Style/LineStyleTest.cs =================================================================== diff -u -r46225f06d83701220caca2c9904695fd1ca54bec -r876d55bc25a5f8e583bbe02e55e916df8a8e4a20 --- Core/Components/test/Core.Components.Gis.Test/Style/LineStyleTest.cs (.../LineStyleTest.cs) (revision 46225f06d83701220caca2c9904695fd1ca54bec) +++ Core/Components/test/Core.Components.Gis.Test/Style/LineStyleTest.cs (.../LineStyleTest.cs) (revision 876d55bc25a5f8e583bbe02e55e916df8a8e4a20) @@ -19,8 +19,10 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Drawing; using System.Drawing.Drawing2D; +using Core.Common.TestUtil; using Core.Components.Gis.Style; using NUnit.Framework; @@ -50,5 +52,41 @@ Assert.AreEqual(width, lineStyle.Width); Assert.AreEqual(style, lineStyle.DashStyle); } + + [Test] + [TestCase(-1)] + [TestCase(-10)] + [TestCase(49)] + [TestCase(501)] + [TestCase(int.MaxValue)] + [TestCase(int.MinValue)] + public void Width_SetInvalidValue_ThrowsArgumentOutOfRangeException(int invalidValue) + { + // Setup + var lineStyle = new LineStyle(); + + // Call + TestDelegate test = () => lineStyle.Width = invalidValue; + + // Assert + const string message = "De waarde voor lijndikte moet in het bereik [0, 48] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, message); + } + + [Test] + [TestCase(0)] + [TestCase(10)] + [TestCase(48)] + public void Width_SetValidValue_ValueSet(int validValue) + { + // Setup + var lineStyle = new LineStyle(); + + // Call + lineStyle.Width = validValue; + + // Assert + Assert.AreEqual(validValue, lineStyle.Width); + } } } \ No newline at end of file Index: Core/Components/test/Core.Components.Gis.Test/Style/PointStyleTest.cs =================================================================== diff -u -r46225f06d83701220caca2c9904695fd1ca54bec -r876d55bc25a5f8e583bbe02e55e916df8a8e4a20 --- Core/Components/test/Core.Components.Gis.Test/Style/PointStyleTest.cs (.../PointStyleTest.cs) (revision 46225f06d83701220caca2c9904695fd1ca54bec) +++ Core/Components/test/Core.Components.Gis.Test/Style/PointStyleTest.cs (.../PointStyleTest.cs) (revision 876d55bc25a5f8e583bbe02e55e916df8a8e4a20) @@ -19,7 +19,9 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Drawing; +using Core.Common.TestUtil; using Core.Components.Gis.Style; using NUnit.Framework; @@ -53,5 +55,77 @@ Assert.AreEqual(color, pointStyle.StrokeColor); Assert.AreEqual(1, pointStyle.StrokeThickness); } + + [Test] + [TestCase(-1)] + [TestCase(-10)] + [TestCase(49)] + [TestCase(501)] + [TestCase(int.MaxValue)] + [TestCase(int.MinValue)] + public void Size_SetInvalidValue_ThrowsArgumentOutOfRangeException(int invalidValue) + { + // Setup + var pointStyle = new PointStyle(); + + // Call + TestDelegate test = () => pointStyle.Size = invalidValue; + + // Assert + const string message = "De waarde voor grootte moet in het bereik [0, 48] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, message); + } + + [Test] + [TestCase(0)] + [TestCase(10)] + [TestCase(48)] + public void Size_SetValidValue_ValueSet(int validValue) + { + // Setup + var pointStyle = new PointStyle(); + + // Call + pointStyle.Size = validValue; + + // Assert + Assert.AreEqual(validValue, pointStyle.Size); + } + + [Test] + [TestCase(-1)] + [TestCase(-10)] + [TestCase(49)] + [TestCase(501)] + [TestCase(int.MaxValue)] + [TestCase(int.MinValue)] + public void StrokeThickness_SetInvalidValue_ThrowsArgumentOutOfRangeException(int invalidValue) + { + // Setup + var pointStyle = new PointStyle(); + + // Call + TestDelegate test = () => pointStyle.StrokeThickness = invalidValue; + + // Assert + const string message = "De waarde voor lijndikte moet in het bereik [0, 48] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, message); + } + + [Test] + [TestCase(0)] + [TestCase(10)] + [TestCase(48)] + public void StrokeThickness_SetValidValue_ValueSet(int validValue) + { + // Setup + var pointStyle = new PointStyle(); + + // Call + pointStyle.StrokeThickness = validValue; + + // Assert + Assert.AreEqual(validValue, pointStyle.StrokeThickness); + } } } \ No newline at end of file Index: Core/Components/test/Core.Components.Gis.Test/Style/PolygonStyleTest.cs =================================================================== diff -u -r46225f06d83701220caca2c9904695fd1ca54bec -r876d55bc25a5f8e583bbe02e55e916df8a8e4a20 --- Core/Components/test/Core.Components.Gis.Test/Style/PolygonStyleTest.cs (.../PolygonStyleTest.cs) (revision 46225f06d83701220caca2c9904695fd1ca54bec) +++ Core/Components/test/Core.Components.Gis.Test/Style/PolygonStyleTest.cs (.../PolygonStyleTest.cs) (revision 876d55bc25a5f8e583bbe02e55e916df8a8e4a20) @@ -19,7 +19,9 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Drawing; +using Core.Common.TestUtil; using Core.Components.Gis.Style; using NUnit.Framework; @@ -49,5 +51,41 @@ Assert.AreEqual(strokeColor, polygonStyle.StrokeColor); Assert.AreEqual(width, polygonStyle.StrokeThickness); } + + [Test] + [TestCase(-1)] + [TestCase(-10)] + [TestCase(49)] + [TestCase(501)] + [TestCase(int.MaxValue)] + [TestCase(int.MinValue)] + public void StrokeThickness_SetInvalidValue_ThrowsArgumentOutOfRangeException(int invalidValue) + { + // Setup + var polygonStyle = new PolygonStyle(); + + // Call + TestDelegate test = () => polygonStyle.StrokeThickness = invalidValue; + + // Assert + const string message = "De waarde voor lijndikte moet in het bereik [0, 48] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, message); + } + + [Test] + [TestCase(0)] + [TestCase(10)] + [TestCase(48)] + public void StrokeThickness_SetValidValue_ValueSet(int validValue) + { + // Setup + var polygonStyle = new PolygonStyle(); + + // Call + polygonStyle.StrokeThickness = validValue; + + // Assert + Assert.AreEqual(validValue, polygonStyle.StrokeThickness); + } } } \ No newline at end of file