Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/AssessmentSectionPersistorTest.cs =================================================================== diff -u -rf1bd17ba95b3fbae5928d4240523d50d8b83b64d -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/AssessmentSectionPersistorTest.cs (.../AssessmentSectionPersistorTest.cs) (revision f1bd17ba95b3fbae5928d4240523d50d8b83b64d) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/AssessmentSectionPersistorTest.cs (.../AssessmentSectionPersistorTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -743,7 +743,6 @@ { // Setup const string name = "test"; - const long storageId = 0L; // Newly inserted entities have Id = 0 untill they are saved const int norm = 30000; AssessmentSectionEntity entityToDelete = new AssessmentSectionEntity { Index: Core/Components/src/Core.Components.DotSpatial/Converter/MapLineDataConverter.cs =================================================================== diff -u -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/src/Core.Components.DotSpatial/Converter/MapLineDataConverter.cs (.../MapLineDataConverter.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) +++ Core/Components/src/Core.Components.DotSpatial/Converter/MapLineDataConverter.cs (.../MapLineDataConverter.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -48,7 +48,7 @@ foreach (var mapGeometry in mapFeature.MapGeometries) { - var coordinates = mapGeometry.Points.Select(p => new Coordinate(p.X, p.Y)); + var coordinates = mapGeometry.PointCollections.First().Select(p => new Coordinate(p.X, p.Y)); IBasicLineString lineString = new LineString(coordinates); geometryList.Add(lineString); } Index: Core/Components/src/Core.Components.DotSpatial/Converter/MapPointDataConverter.cs =================================================================== diff -u -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/src/Core.Components.DotSpatial/Converter/MapPointDataConverter.cs (.../MapPointDataConverter.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) +++ Core/Components/src/Core.Components.DotSpatial/Converter/MapPointDataConverter.cs (.../MapPointDataConverter.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -39,7 +39,7 @@ { var featureSet = new FeatureSet(FeatureType.Point); - foreach (var point in data.Features.SelectMany(features => features.MapGeometries.SelectMany(mapGeometry => mapGeometry.Points))) + foreach (var point in data.Features.SelectMany(features => features.MapGeometries.SelectMany(mapGeometry => mapGeometry.PointCollections.First()))) { featureSet.Features.Add(new Coordinate(point.X, point.Y)); } Index: Core/Components/src/Core.Components.DotSpatial/Converter/MapPolygonDataConverter.cs =================================================================== diff -u -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/src/Core.Components.DotSpatial/Converter/MapPolygonDataConverter.cs (.../MapPolygonDataConverter.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) +++ Core/Components/src/Core.Components.DotSpatial/Converter/MapPolygonDataConverter.cs (.../MapPolygonDataConverter.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -48,7 +48,7 @@ foreach (var mapGeometry in mapFeature.MapGeometries) { - var coordinates = mapGeometry.Points.Select(p => new Coordinate(p.X, p.Y)); + var coordinates = mapGeometry.PointCollections.First().Select(p => new Coordinate(p.X, p.Y)); IPolygon polygon = new Polygon(coordinates); geometryList.Add(polygon); } Index: Core/Components/src/Core.Components.Gis.IO/Readers/PointShapeFileReader.cs =================================================================== diff -u -r884543108a6db82b36fca454624a7e9aacaf801d -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/src/Core.Components.Gis.IO/Readers/PointShapeFileReader.cs (.../PointShapeFileReader.cs) (revision 884543108a6db82b36fca454624a7e9aacaf801d) +++ Core/Components/src/Core.Components.Gis.IO/Readers/PointShapeFileReader.cs (.../PointShapeFileReader.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -29,6 +29,8 @@ using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; using DotSpatial.Data; +using DotSpatial.Topology; + using CoreCommonUtilsResources = Core.Common.Utils.Properties.Resources; using GisIOResources = Core.Components.Gis.IO.Properties.Resources; @@ -74,7 +76,8 @@ featureList.Add(ReadFeatureLine()); } - return ConvertPointFeaturesToMapPointData(featureList, !string.IsNullOrWhiteSpace(name) ? name : GisIOResources.PointShapeFileReader_ReadLine_Points); + string mapFeatureName = !string.IsNullOrWhiteSpace(name) ? name : GisIOResources.PointShapeFileReader_ReadLine_Points; + return ConvertPointFeaturesToMapPointData(featureList, mapFeatureName); } public override FeatureBasedMapData ReadLine(string name = null) @@ -87,7 +90,8 @@ try { IFeature pointFeature = GetFeature(readIndex); - return ConvertPointFeatureToMapPointData(pointFeature, !string.IsNullOrWhiteSpace(name) ? name : GisIOResources.PointShapeFileReader_ReadLine_Points); + string mapFeatureName = !string.IsNullOrWhiteSpace(name) ? name : GisIOResources.PointShapeFileReader_ReadLine_Points; + return ConvertPointFeatureToMapPointData(pointFeature, mapFeatureName); } finally { @@ -97,8 +101,7 @@ public override IFeature GetFeature(int index) { - IFeature pointFeature = ShapeFile.Features[index]; - return pointFeature; + return ShapeFile.Features[index]; } private IFeature ReadFeatureLine() @@ -115,31 +118,35 @@ private FeatureBasedMapData ConvertPointFeatureToMapPointData(IFeature pointFeature, string name) { - var feature = new MapFeature(pointFeature.Coordinates.Select(c => new MapGeometry(new List + MapFeature feature = CreateMapFeatureForPointFeature(pointFeature); + IEnumerable mapFeatures = new List { - new Point2D(c.X, c.Y) - }))); - - return new MapPointData(new List - { feature - }, name); + }; + return new MapPointData(mapFeatures, name); } - private FeatureBasedMapData ConvertPointFeaturesToMapPointData(List featureList, string name) + private FeatureBasedMapData ConvertPointFeaturesToMapPointData(IEnumerable featureList, string name) { - var mapFeatureList = new List(); - foreach (var feature in featureList) + IEnumerable mapFeatures = featureList.Select(CreateMapFeatureForPointFeature); + return new MapPointData(mapFeatures, name); + } + + private static MapFeature CreateMapFeatureForPointFeature(IFeature pointFeature) + { + IEnumerable mapGeometries = pointFeature.Coordinates.Select(c => new MapGeometry(GetMapGeometryPointCollections(c))); + return new MapFeature(mapGeometries); + } + + private static IEnumerable> GetMapGeometryPointCollections(Coordinate c) + { + return new[] { - var f = new MapFeature(feature.Coordinates.Select(c => new MapGeometry(new List + new[] { new Point2D(c.X, c.Y) - }))); - - mapFeatureList.Add(f); - } - - return new MapPointData(mapFeatureList, name); + } + }; } } } \ No newline at end of file Index: Core/Components/src/Core.Components.Gis.IO/Readers/PolygonShapeFileReader.cs =================================================================== diff -u -r2117ba3d745d5776cefdf94dc86ac8d5950aa31e -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/src/Core.Components.Gis.IO/Readers/PolygonShapeFileReader.cs (.../PolygonShapeFileReader.cs) (revision 2117ba3d745d5776cefdf94dc86ac8d5950aa31e) +++ Core/Components/src/Core.Components.Gis.IO/Readers/PolygonShapeFileReader.cs (.../PolygonShapeFileReader.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -29,6 +29,8 @@ using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; using DotSpatial.Data; +using DotSpatial.Topology; + using CoreCommonUtilsResources = Core.Common.Utils.Properties.Resources; using GisIOResources = Core.Components.Gis.IO.Properties.Resources; @@ -97,8 +99,7 @@ public override IFeature GetFeature(int index) { - IFeature polygonFeature = ShapeFile.Features[index]; - return polygonFeature; + return ShapeFile.Features[index]; } private IFeature ReadFeatureLine() @@ -115,41 +116,38 @@ private FeatureBasedMapData ConvertPolygonFeatureToMapPolygonData(IFeature polygonFeature, string name) { + var mapFeature = CreateMapFeatureForPolygonFeature(polygonFeature); + IEnumerable mapFeatures = new [] { mapFeature }; + return new MapPolygonData(mapFeatures, name); + } + + private FeatureBasedMapData ConvertPolygonFeaturesToMapPointData(IEnumerable featureList, string name) + { + var mapFeatures = featureList.Select(CreateMapFeatureForPolygonFeature); + return new MapPolygonData(mapFeatures, name); + } + + private static MapFeature CreateMapFeatureForPolygonFeature(IFeature polygonFeature) + { var geometries = new List(); for (int i = 0; i < polygonFeature.BasicGeometry.NumGeometries; i++) { - var polygonFeatureGeometry = polygonFeature.BasicGeometry.GetBasicGeometryN(i); + IBasicGeometry polygonFeatureGeometry = polygonFeature.BasicGeometry.GetBasicGeometryN(i); - geometries.Add(new MapGeometry(polygonFeatureGeometry.Coordinates.Select(c => new Point2D(c.X, c.Y)))); + MapGeometry mapGeometry = new MapGeometry(GetMapGeometryPointCollections(polygonFeatureGeometry.Coordinates)); + geometries.Add(mapGeometry); } - return new MapPolygonData(new List - { - new MapFeature(geometries) - }, name); + return new MapFeature(geometries); } - private FeatureBasedMapData ConvertPolygonFeaturesToMapPointData(List featureList, string name) + private static IEnumerable> GetMapGeometryPointCollections(IEnumerable polygonCoordinates) { - var mapFeatureList = new List(); - foreach (var feature in featureList) + return new[] { - var featureGeometry = new List(); - - for (int i = 0; i < feature.BasicGeometry.NumGeometries; i++) - { - var polygonFeatureGeometry = feature.BasicGeometry.GetBasicGeometryN(i); - - featureGeometry.Add(new MapGeometry(polygonFeatureGeometry.Coordinates.Select(c => new Point2D(c.X, c.Y)))); - } - - var polygonFeature = new MapFeature(featureGeometry); - - mapFeatureList.Add(polygonFeature); - } - - return new MapPolygonData(mapFeatureList, name); + polygonCoordinates.Select(c => new Point2D(c.X, c.Y)) + }; } } } \ No newline at end of file Index: Core/Components/src/Core.Components.Gis.IO/Readers/PolylineShapeFileReader.cs =================================================================== diff -u -r2117ba3d745d5776cefdf94dc86ac8d5950aa31e -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/src/Core.Components.Gis.IO/Readers/PolylineShapeFileReader.cs (.../PolylineShapeFileReader.cs) (revision 2117ba3d745d5776cefdf94dc86ac8d5950aa31e) +++ Core/Components/src/Core.Components.Gis.IO/Readers/PolylineShapeFileReader.cs (.../PolylineShapeFileReader.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -30,6 +30,8 @@ using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; using DotSpatial.Data; +using DotSpatial.Topology; + using CoreCommonUtilsResources = Core.Common.Utils.Properties.Resources; using GisIOResources = Core.Components.Gis.IO.Properties.Resources; @@ -120,62 +122,65 @@ /// The feature that consists out of 1 whole polyline. public override IFeature GetFeature(int index) { - IFeature lineFeature = ShapeFile.Features[index]; - return lineFeature; + return ShapeFile.Features[index]; } private MapLineData ConvertSingleLineFeatureToMapLineData(IFeature lineFeature, string name) { - var geometries = new List(); - for (int i = 0; i < lineFeature.BasicGeometry.NumGeometries; i++) + MapFeature feature = CreateMapFeatureForLineFeature(lineFeature); + CopyMetaDataIntoFeature(feature, readIndex); + + IEnumerable mapFeatures = new[] { feature }; + return new MapLineData(mapFeatures, name); + } + + private MapLineData ConvertMultiLineFeatureToMapLineData(List lineFeatures, string name) + { + var mapFeatureList = new List(); + for (int featureIndex = 0; featureIndex < lineFeatures.Count; featureIndex++) { - var polygonFeatureGeometry = lineFeature.BasicGeometry.GetBasicGeometryN(i); + IFeature lineFeature = lineFeatures[featureIndex]; + MapFeature feature = CreateMapFeatureForLineFeature(lineFeature); + CopyMetaDataIntoFeature(feature, featureIndex); - geometries.Add(new MapGeometry(polygonFeatureGeometry.Coordinates.Select(c => new Point2D(c.X, c.Y)))); + mapFeatureList.Add(feature); } - var feature = new MapFeature(geometries); + return new MapLineData(mapFeatureList, name); + } - DataTable table = ShapeFile.GetAttributes(readIndex, 1); - DataRow dataRow = table.Rows[0]; - for (int i = 0; i < table.Columns.Count; i++) + private static MapFeature CreateMapFeatureForLineFeature(IFeature lineFeature) + { + var geometries = new List(); + + for (int i = 0; i < lineFeature.BasicGeometry.NumGeometries; i++) { - feature.MetaData[table.Columns[i].ColumnName] = dataRow[i]; + var polylineGeometry = lineFeature.BasicGeometry.GetBasicGeometryN(i); + + MapGeometry mapGeometry = new MapGeometry(GetMapGeometryPointCollections(polylineGeometry.Coordinates)); + geometries.Add(mapGeometry); } - return new MapLineData(new List - { - feature - }, name); + return new MapFeature(geometries); } - private MapLineData ConvertMultiLineFeatureToMapLineData(List lineFeatures, string name) + private static IEnumerable[] GetMapGeometryPointCollections(IEnumerable lineCoordinates) { - var mapFeatureList = new List(); - for (int featureIndex = 0; featureIndex < lineFeatures.Count; featureIndex++) + return new[] { - var lineFeature = lineFeatures[featureIndex]; - var geometries = new List(); - for (int i = 0; i < lineFeature.BasicGeometry.NumGeometries; i++) - { - var polygonFeatureGeometry = lineFeature.BasicGeometry.GetBasicGeometryN(i); + lineCoordinates.Select(c => new Point2D(c.X, c.Y)) + }; + } - geometries.Add(new MapGeometry(polygonFeatureGeometry.Coordinates.Select(c => new Point2D(c.X, c.Y)))); - } + private void CopyMetaDataIntoFeature(MapFeature targetFeature, int sourceFeatureIndex) + { + DataTable table = ShapeFile.GetAttributes(sourceFeatureIndex, 1); + DataRow dataRow = table.Rows[0]; - var feature = new MapFeature(geometries); - - DataTable table = ShapeFile.GetAttributes(featureIndex, 1); - DataRow dataRow = table.Rows[0]; - for (int i = 0; i < table.Columns.Count; i++) - { - feature.MetaData[table.Columns[i].ColumnName] = dataRow[i]; - } - - mapFeatureList.Add(feature); + for (int i = 0; i < table.Columns.Count; i++) + { + targetFeature.MetaData[table.Columns[i].ColumnName] = dataRow[i]; } - - return new MapLineData(mapFeatureList, name); } } } \ No newline at end of file Index: Core/Components/src/Core.Components.Gis/Data/FeatureBasedMapData.cs =================================================================== diff -u -r2117ba3d745d5776cefdf94dc86ac8d5950aa31e -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/src/Core.Components.Gis/Data/FeatureBasedMapData.cs (.../FeatureBasedMapData.cs) (revision 2117ba3d745d5776cefdf94dc86ac8d5950aa31e) +++ Core/Components/src/Core.Components.Gis/Data/FeatureBasedMapData.cs (.../FeatureBasedMapData.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -37,20 +37,29 @@ /// /// A of which describes a of . /// The name of the . - /// Thrown when - /// is null. - /// Thrown when is - /// null or only whitespace. + /// Thrown when + /// is not a valid instance to create an instance of with, + /// or when is null or only whitespace. protected FeatureBasedMapData(IEnumerable features, string name) : base(name) { + ValidateFeatures(features); + + Features = features.ToArray(); + IsVisible = true; + } + + /// + /// Validates the features. + /// + /// The features captured by this map data object. + /// When is invalid. + protected virtual void ValidateFeatures(IEnumerable features) + { if (features == null) { var message = String.Format("A feature collection is required when creating a subclass of {0}.", typeof(FeatureBasedMapData)); - throw new ArgumentNullException("features", message); + throw new ArgumentException(message, "features"); } - - Features = features.ToArray(); - IsVisible = true; } /// Index: Core/Components/src/Core.Components.Gis/Data/MapLineData.cs =================================================================== diff -u -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/src/Core.Components.Gis/Data/MapLineData.cs (.../MapLineData.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) +++ Core/Components/src/Core.Components.Gis/Data/MapLineData.cs (.../MapLineData.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -21,6 +21,8 @@ using System; using System.Collections.Generic; +using System.Linq; + using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; using Core.Components.Gis.Style; @@ -37,9 +39,9 @@ /// /// A of which describes a of . /// The name of the . - /// Thrown when + /// Thrown when /// - /// is null. + /// is invalid. /// is null or only whitespace. /// /// @@ -49,5 +51,27 @@ /// The style of the line. /// public LineStyle Style { get; set; } + + /// + /// Validates the features. + /// + /// The features. + /// When is null + /// or any feature contains multiple point-collections. + protected override void ValidateFeatures(IEnumerable features) + { + base.ValidateFeatures(features); + + if (HasFeatureWithMultiplePointCollections(features)) + { + throw new ArgumentException("MapLineData only accept MapFeature instances whose MapGeometries contain a single point-collection."); + } + } + + private static bool HasFeatureWithMultiplePointCollections(IEnumerable lineFeatures) + { + return lineFeatures.SelectMany(feature => feature.MapGeometries) + .Any(geometry => geometry.PointCollections.Count() != 1); + } } } \ No newline at end of file Index: Core/Components/src/Core.Components.Gis/Data/MapPointData.cs =================================================================== diff -u -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/src/Core.Components.Gis/Data/MapPointData.cs (.../MapPointData.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) +++ Core/Components/src/Core.Components.Gis/Data/MapPointData.cs (.../MapPointData.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -21,6 +21,8 @@ using System; using System.Collections.Generic; +using System.Linq; + using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; using Core.Components.Gis.Style; @@ -35,19 +37,42 @@ /// /// Create a new instance of . /// - /// A of which describes a of . + /// A of + /// which describes a of . /// The name of the . - /// Thrown when + /// Thrown when /// - /// is null. + /// is invalid. /// is null or only whitespace. /// /// - public MapPointData(IEnumerable features, string name) : base(features, name) { } + public MapPointData(IEnumerable features, string name) : base(features, name) {} /// /// The style of the points. /// public PointStyle Style { get; set; } + + /// + /// Validates the features. + /// + /// The features. + /// When is null + /// or any feature contains multiple point-collections. + protected override void ValidateFeatures(IEnumerable features) + { + base.ValidateFeatures(features); + + if (HasFeatureWithMultiplePointCollections(features)) + { + throw new ArgumentException("MapPointData only accept MapFeature instances whose MapGeometries contain a single point-collection."); + } + } + + private static bool HasFeatureWithMultiplePointCollections(IEnumerable pointFeatures) + { + return pointFeatures.SelectMany(feature => feature.MapGeometries) + .Any(geometry => geometry.PointCollections.Count() != 1); + } } } \ No newline at end of file Index: Core/Components/src/Core.Components.Gis/Data/MapPolygonData.cs =================================================================== diff -u -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/src/Core.Components.Gis/Data/MapPolygonData.cs (.../MapPolygonData.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) +++ Core/Components/src/Core.Components.Gis/Data/MapPolygonData.cs (.../MapPolygonData.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -21,6 +21,8 @@ using System; using System.Collections.Generic; +using System.Linq; + using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; using Core.Components.Gis.Style; @@ -37,9 +39,9 @@ /// /// A of which describes a of . /// The name of the . - /// Thrown when + /// Thrown when /// - /// is null. + /// is invalid. /// is null or only whitespace. /// /// @@ -49,5 +51,27 @@ /// The style of the polygon. /// public PolygonStyle Style { get; set; } + + /// + /// Validates the features. + /// + /// The features. + /// When is null + /// or any feature contains multiple point-collections. + protected override void ValidateFeatures(IEnumerable features) + { + base.ValidateFeatures(features); + + if (HasFeatureWithMultiplePointCollections(features)) + { + throw new ArgumentException("MapPolygonData only accept MapFeature instances whose MapGeometries contain a single point-collection."); + } + } + + private static bool HasFeatureWithMultiplePointCollections(IEnumerable lineFeatures) + { + return lineFeatures.SelectMany(feature => feature.MapGeometries) + .Any(geometry => geometry.PointCollections.Count() != 1); + } } } \ No newline at end of file Index: Core/Components/src/Core.Components.Gis/Geometries/MapGeometry.cs =================================================================== diff -u -r354027b2a36a779798852d3edadaaf339140295c -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/src/Core.Components.Gis/Geometries/MapGeometry.cs (.../MapGeometry.cs) (revision 354027b2a36a779798852d3edadaaf339140295c) +++ Core/Components/src/Core.Components.Gis/Geometries/MapGeometry.cs (.../MapGeometry.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -33,20 +33,20 @@ /// /// Creates a new instance of . /// - /// An of . - /// Thrown when is null. - public MapGeometry(IEnumerable points) + /// A sequence of -sequences. + /// Thrown when is null. + public MapGeometry(IEnumerable> pointCollections) { - if (points == null) + if (pointCollections == null) { - throw new ArgumentNullException("points", "MapGeometry cannot be created without points."); + throw new ArgumentNullException("pointCollections", "MapGeometry cannot be created without points."); } - Points = points; + PointCollections = pointCollections; } /// /// Gets the points associated with the . /// - public IEnumerable Points { get; private set; } + public IEnumerable> PointCollections { get; private set; } } } Index: Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs =================================================================== diff -u -r1d8207d879e9aca8d34bd5b62410c04229c7d0d5 -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs (.../MapControlTest.cs) (revision 1d8207d879e9aca8d34bd5b62410c04229c7d0d5) +++ Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs (.../MapControlTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -165,10 +165,13 @@ { new MapFeature(new Collection { - new MapGeometry(new Collection + new MapGeometry(new[] { - new Point2D(0.0, 0.0), - new Point2D(1.0, 1.0) + new[] + { + new Point2D(0.0, 0.0), + new Point2D(1.0, 1.0) + } }) }) }; @@ -228,7 +231,7 @@ [TestCase(5.0, 5.0)] [TestCase(5.0, 1.0)] [TestCase(1.0, 5.0)] - [TestCase(Double.MaxValue*0.96, Double.MaxValue*0.96)] + [TestCase(Double.MaxValue * 0.96, Double.MaxValue * 0.96)] [TestCase(Double.MaxValue, Double.MaxValue)] public void ZoomToAllVisibleLayers_LayersOfVariousDimensions_ZoomToVisibleLayersExtent(double xMax, double yMax) { @@ -241,10 +244,13 @@ { new MapFeature(new List { - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(0.0, 0.0), - new Point2D(xMax, yMax) + new[] + { + new Point2D(0.0, 0.0), + new Point2D(xMax, yMax) + } }) }) }, "test data") @@ -254,7 +260,7 @@ var expectedExtent = new Extent(0.0, 0.0, xMax, yMax); var smallest = expectedExtent.Height < expectedExtent.Width ? expectedExtent.Height : expectedExtent.Width; - expectedExtent.ExpandBy(smallest*padding); + expectedExtent.ExpandBy(smallest * padding); // Call map.ZoomToAllVisibleLayers(); @@ -687,41 +693,56 @@ { new MapFeature(new List { - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(1.5, 2) + new[] + { + new Point2D(1.5, 2) + } }), - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(1.1, 1) + new[] + { + new Point2D(1.1, 1) + } }), - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(0.8, 0.5) + new[] + { + new Point2D(0.8, 0.5) + } }) }) }, "test data"); var lines = new MapLineData(new Collection { new MapFeature(new List { - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(0.0, 1.1), - new Point2D(1.0, 2.1), - new Point2D(1.6, 1.6) + new[] + { + new Point2D(0.0, 1.1), + new Point2D(1.0, 2.1), + new Point2D(1.6, 1.6) + } }) }) }, "test data"); var polygons = new MapPolygonData(new Collection { new MapFeature(new List { - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(1.0, 1.3), - new Point2D(3.0, 2.6), - new Point2D(5.6, 1.6) + new[] + { + new Point2D(1.0, 1.3), + new Point2D(3.0, 2.6), + new Point2D(5.6, 1.6) + } }) }) }, "test data") Index: Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapDataCollectionConverterTest.cs =================================================================== diff -u -r884543108a6db82b36fca454624a7e9aacaf801d -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapDataCollectionConverterTest.cs (.../MapDataCollectionConverterTest.cs) (revision 884543108a6db82b36fca454624a7e9aacaf801d) +++ Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapDataCollectionConverterTest.cs (.../MapDataCollectionConverterTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -105,15 +105,21 @@ { new MapFeature(new List { - new MapGeometry(points) + new MapGeometry(new[] + { + points + }) }) }; var lineFeature = new List { new MapFeature(new List { - new MapGeometry(linePoints) + new MapGeometry(new[] + { + linePoints + }) }) }; Index: Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapDataFactoryTest.cs =================================================================== diff -u -r473efe5f1b2aff98ffc7ad1d826c3ef90f77a7a6 -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapDataFactoryTest.cs (.../MapDataFactoryTest.cs) (revision 473efe5f1b2aff98ffc7ad1d826c3ef90f77a7a6) +++ Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapDataFactoryTest.cs (.../MapDataFactoryTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -80,7 +80,7 @@ new MapPolygonData(testData, "test data") }, "test data"); - var points = testData.First().MapGeometries.First().Points.ToArray(); + var points = testData.First().MapGeometries.First().PointCollections.First().ToArray(); // Call IList layers = factory.Create(mapDataCollection); @@ -128,12 +128,12 @@ { new MapFeature(new List { - new MapGeometry(new List + new MapGeometry(new[]{new [] { new Point2D(1.2, 3.4), new Point2D(3.2, 3.4), new Point2D(0.2, 2.4) - }) + }}) }) }; } Index: Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapLineDataConverterTest.cs =================================================================== diff -u -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapLineDataConverterTest.cs (.../MapLineDataConverterTest.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) +++ Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapLineDataConverterTest.cs (.../MapLineDataConverterTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -39,7 +39,10 @@ { new MapFeature(new List { - new MapGeometry(Enumerable.Empty()) + new MapGeometry(new[] + { + Enumerable.Empty() + }) }) }; var converter = new MapLineDataConverter(); @@ -115,7 +118,10 @@ { new MapFeature(new List { - new MapGeometry(points) + new MapGeometry(new[] + { + points + }) }) }; @@ -163,25 +169,37 @@ { new MapFeature(new List { - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(1.0, 2.0), - new Point2D(2.0, 1.0), + new[] + { + new Point2D(1.0, 2.0), + new Point2D(2.0, 1.0), + } }), - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(2.0, 2.0), - new Point2D(3.0, 2.0), + new[] + { + new Point2D(2.0, 2.0), + new Point2D(3.0, 2.0), + } }), - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(1.0, 3.0), - new Point2D(1.0, 4.0), + new[] + { + new Point2D(1.0, 3.0), + new Point2D(1.0, 4.0), + } }), - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(3.0, 2.0), - new Point2D(4.0, 1.0), + new[] + { + new Point2D(3.0, 2.0), + new Point2D(4.0, 1.0), + } }) }) }; Index: Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPointDataConverterTest.cs =================================================================== diff -u -rc67c5e4d2dcf0e3a105aab6b2bb323e9a128ff22 -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPointDataConverterTest.cs (.../MapPointDataConverterTest.cs) (revision c67c5e4d2dcf0e3a105aab6b2bb323e9a128ff22) +++ Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPointDataConverterTest.cs (.../MapPointDataConverterTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -1,7 +1,6 @@ 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; @@ -39,7 +38,10 @@ { new MapFeature(new List { - new MapGeometry(Enumerable.Empty()) + new MapGeometry(new[] + { + Enumerable.Empty() + }) }) }; @@ -80,9 +82,12 @@ { features.Add(new MapFeature(new List { - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(random.NextDouble(), random.NextDouble()) + new[] + { + new Point2D(random.NextDouble(), random.NextDouble()) + } }) })); } @@ -99,7 +104,7 @@ Assert.AreEqual(pointData.Features.ToArray().Length, layer.DataSet.Features.Count); Assert.IsInstanceOf(layer); Assert.AreEqual(FeatureType.Point, layer.DataSet.FeatureType); - CollectionAssert.AreNotEqual(pointData.Features.First().MapGeometries.First().Points, layer.DataSet.Features[0].Coordinates); + CollectionAssert.AreNotEqual(pointData.Features.First().MapGeometries.First().PointCollections, layer.DataSet.Features[0].Coordinates); } [Test] @@ -111,23 +116,32 @@ { new MapFeature(new List { - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(1, 2) + new[] + { + new Point2D(1, 2) + } }) }), new MapFeature(new List { - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(2, 3) + new[] + { + new Point2D(2, 3) + } }) }), new MapFeature(new List { - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(4, 6) + new[] + { + new Point2D(4, 6) + } }) }) }; Index: Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPolygonDataConverterTest.cs =================================================================== diff -u -r4dc676d1823dfb3c1d52935ccc2f107883fa10ad -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPolygonDataConverterTest.cs (.../MapPolygonDataConverterTest.cs) (revision 4dc676d1823dfb3c1d52935ccc2f107883fa10ad) +++ Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPolygonDataConverterTest.cs (.../MapPolygonDataConverterTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -39,7 +39,10 @@ { new MapFeature(new List { - new MapGeometry(Enumerable.Empty()) + new MapGeometry(new[] + { + Enumerable.Empty() + }) }) }; @@ -85,7 +88,10 @@ { new MapFeature(new List { - new MapGeometry(polygonPoints) + new MapGeometry(new[] + { + polygonPoints + }) }) }; @@ -100,7 +106,7 @@ Assert.AreEqual(1, layer.DataSet.Features.Count); Assert.IsInstanceOf(layer); Assert.AreEqual(FeatureType.Polygon, layer.DataSet.FeatureType); - CollectionAssert.AreNotEqual(polygonData.Features.First().MapGeometries.First().Points, layer.DataSet.Features[0].Coordinates); + CollectionAssert.AreNotEqual(polygonData.Features.First().MapGeometries.First().PointCollections, layer.DataSet.Features[0].Coordinates); } [Test] @@ -135,25 +141,37 @@ { new MapFeature(new List { - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(1.0, 2.0), - new Point2D(2.0, 1.0), + new[] + { + new Point2D(1.0, 2.0), + new Point2D(2.0, 1.0), + } }), - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(2.0, 2.0), - new Point2D(3.0, 2.0), + new[] + { + new Point2D(2.0, 2.0), + new Point2D(3.0, 2.0), + } }), - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(1.0, 3.0), - new Point2D(1.0, 4.0), + new[] + { + new Point2D(1.0, 3.0), + new Point2D(1.0, 4.0), + } }), - new MapGeometry(new List + new MapGeometry(new[] { - new Point2D(3.0, 2.0), - new Point2D(4.0, 1.0), + new[] + { + new Point2D(3.0, 2.0), + new Point2D(4.0, 1.0), + } }) }) }; Index: Core/Components/test/Core.Components.Gis.IO.Test/Readers/PointShapeFileReaderTest.cs =================================================================== diff -u -r2117ba3d745d5776cefdf94dc86ac8d5950aa31e -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/test/Core.Components.Gis.IO.Test/Readers/PointShapeFileReaderTest.cs (.../PointShapeFileReaderTest.cs) (revision 2117ba3d745d5776cefdf94dc86ac8d5950aa31e) +++ Core/Components/test/Core.Components.Gis.IO.Test/Readers/PointShapeFileReaderTest.cs (.../PointShapeFileReaderTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -1,7 +1,12 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; + +using Core.Common.Base.Geometry; using Core.Common.IO.Exceptions; using Core.Common.TestUtil; using Core.Components.Gis.Data; +using Core.Components.Gis.Features; +using Core.Components.Gis.Geometries; using Core.Components.Gis.IO.Readers; using NUnit.Framework; @@ -107,7 +112,7 @@ using (var reader = new PointShapeFileReader(shapeWithOnePoint)) { // Call - MapPointData pointData = reader.ReadLine(name) as MapPointData; + MapPointData pointData = (MapPointData)reader.ReadLine(name); // Assert Assert.AreEqual(name, pointData.Name); @@ -126,7 +131,7 @@ using (var reader = new PointShapeFileReader(shapeWithOnePoint)) { // Call - MapPointData pointData = reader.ReadLine(name) as MapPointData; + MapPointData pointData = (MapPointData)reader.ReadLine(name); // Assert Assert.AreEqual("Punten", pointData.Name); @@ -147,9 +152,17 @@ // Assert Assert.IsNotNull(pointData); Assert.AreEqual(1, pointData.Features.Count()); - var points = pointData.Features.First().MapGeometries.First().Points.ToArray(); - Assert.AreEqual(1.705, points[0].X, 1e-1); - Assert.AreEqual(0.922, points[0].Y, 1e-1); + + MapGeometry[] mapGeometries = pointData.Features.First().MapGeometries.ToArray(); + Assert.AreEqual(1, mapGeometries.Length); + + IEnumerable[] pointCollections = mapGeometries[0].PointCollections.ToArray(); + Assert.AreEqual(1, pointCollections.Length); + + Point2D[] firstPointCollection = pointCollections[0].ToArray(); + Assert.AreEqual(1, firstPointCollection.Length); + Assert.AreEqual(1.705, firstPointCollection[0].X, 1e-1); + Assert.AreEqual(0.922, firstPointCollection[0].Y, 1e-1); } } @@ -158,19 +171,19 @@ { // Setup string shapeWithMultiplePoints = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, - "Multiple_Point_with_ID.shp"); + "Multiple_Point_with_ID.shp"); using (var reader = new PointShapeFileReader(shapeWithMultiplePoints)) { // Precondition Assert.AreEqual(6, reader.GetNumberOfLines()); // Call - MapPointData points1 = reader.ReadLine() as MapPointData; - MapPointData points2 = reader.ReadLine() as MapPointData; - MapPointData points3 = reader.ReadLine() as MapPointData; - MapPointData points4 = reader.ReadLine() as MapPointData; - MapPointData points5 = reader.ReadLine() as MapPointData; - MapPointData points6 = reader.ReadLine() as MapPointData; + MapPointData points1 = (MapPointData)reader.ReadLine(); + MapPointData points2 = (MapPointData)reader.ReadLine(); + MapPointData points3 = (MapPointData)reader.ReadLine(); + MapPointData points4 = (MapPointData)reader.ReadLine(); + MapPointData points5 = (MapPointData)reader.ReadLine(); + MapPointData points6 = (MapPointData)reader.ReadLine(); // Assert @@ -179,85 +192,111 @@ var features1 = points1.Features.ToArray(); Assert.AreEqual(1, features1.Length); - var point1 = features1[0]; - var point1Geometry = point1.MapGeometries.ToArray(); + MapFeature point1 = features1[0]; + MapGeometry[] point1Geometry = point1.MapGeometries.ToArray(); Assert.AreEqual(1, point1Geometry.Length); - var point1Points = point1Geometry[0].Points.ToArray(); - Assert.AreEqual(1, point1Points.Length); - Assert.AreEqual(-1.750, point1Points[0].X, 1e-1); - Assert.AreEqual(-0.488, point1Points[0].Y, 1e-1); + IEnumerable[] point1PointCollections = point1Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, point1PointCollections.Length); + + Point2D[] point1FirstPointCpllection = point1PointCollections[0].ToArray(); + Assert.AreEqual(1, point1FirstPointCpllection.Length); + Assert.AreEqual(-1.750, point1FirstPointCpllection[0].X, 1e-1); + Assert.AreEqual(-0.488, point1FirstPointCpllection[0].Y, 1e-1); + #endregion #region Assertion for 'point2' - var features2 = points2.Features.ToArray(); + MapFeature[] features2 = points2.Features.ToArray(); Assert.AreEqual(1, features2.Length); - var point2 = features2[0]; - var point2Geometry = point2.MapGeometries.ToArray(); + MapFeature point2 = features2[0]; + MapGeometry[] point2Geometry = point2.MapGeometries.ToArray(); Assert.AreEqual(1, point2Geometry.Length); - var point2Points = point2Geometry[0].Points.ToArray(); - Assert.AreEqual(1, point2Points.Length); - Assert.AreEqual(-0.790, point2Points[0].X, 1e-1); - Assert.AreEqual(-0.308, point2Points[0].Y, 1e-1); + IEnumerable[] point2PointCollections = point2Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, point2PointCollections.Length); + + Point2D[] point2FirstPointCollection = point2PointCollections[0].ToArray(); + Assert.AreEqual(1, point2FirstPointCollection.Length); + Assert.AreEqual(-0.790, point2FirstPointCollection[0].X, 1e-1); + Assert.AreEqual(-0.308, point2FirstPointCollection[0].Y, 1e-1); + #endregion #region Assertion for 'point3' - var features3 = points3.Features.ToArray(); + + MapFeature[] features3 = points3.Features.ToArray(); Assert.AreEqual(1, features3.Length); - var point3 = features3[0]; - var point3Geometry = point3.MapGeometries.ToArray(); + MapFeature point3 = features3[0]; + MapGeometry[] point3Geometry = point3.MapGeometries.ToArray(); Assert.AreEqual(1, point3Geometry.Length); - var point3Points = point3Geometry[0].Points.ToArray(); - Assert.AreEqual(1, point3Points.Length); - Assert.AreEqual(0.740, point3Points[0].X, 1e-1); - Assert.AreEqual(-0.577, point3Points[0].Y, 1e-1); + IEnumerable[] point3PointCollections = point3Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, point3PointCollections.Length); + + Point2D[] point3FirstPointCollection = point3PointCollections[0].ToArray(); + Assert.AreEqual(1, point3FirstPointCollection.Length); + Assert.AreEqual(0.740, point3FirstPointCollection[0].X, 1e-1); + Assert.AreEqual(-0.577, point3FirstPointCollection[0].Y, 1e-1); + #endregion #region Assertion for 'point4' - var features4 = points4.Features.ToArray(); + + MapFeature[] features4 = points4.Features.ToArray(); Assert.AreEqual(1, features4.Length); - var point4 = features4[0]; - var point4Geometry = point4.MapGeometries.ToArray(); + MapFeature point4 = features4[0]; + MapGeometry[] point4Geometry = point4.MapGeometries.ToArray(); Assert.AreEqual(1, point4Geometry.Length); - var point4Points = point4Geometry[0].Points.ToArray(); - Assert.AreEqual(1, point4Points.Length); - Assert.AreEqual(0.787, point4Points[0].X, 1e-1); - Assert.AreEqual(0.759, point4Points[0].Y, 1e-1); + IEnumerable[] point4PointCollections = point4Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, point4PointCollections.Length); + + Point2D[] point4FirstPointCollection = point4PointCollections[0].ToArray(); + Assert.AreEqual(1, point4FirstPointCollection.Length); + Assert.AreEqual(0.787, point4FirstPointCollection[0].X, 1e-1); + Assert.AreEqual(0.759, point4FirstPointCollection[0].Y, 1e-1); + #endregion #region Assertion for 'point5' - var features5 = points5.Features.ToArray(); + MapFeature[] features5 = points5.Features.ToArray(); Assert.AreEqual(1, features5.Length); - var point5 = features5[0]; + MapFeature point5 = features5[0]; var point5Geometry = point5.MapGeometries.ToArray(); Assert.AreEqual(1, point5Geometry.Length); - var point5Points = point5Geometry[0].Points.ToArray(); - Assert.AreEqual(1, point5Points.Length); - Assert.AreEqual(-0.544, point5Points[0].X, 1e-1); - Assert.AreEqual(0.283, point5Points[0].Y, 1e-1); + IEnumerable[] point5PointCollections = point5Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, point5PointCollections.Length); + + Point2D[] point5FirstPointCollection = point5PointCollections[0].ToArray(); + Assert.AreEqual(1, point5FirstPointCollection.Length); + Assert.AreEqual(-0.544, point5FirstPointCollection[0].X, 1e-1); + Assert.AreEqual(0.283, point5FirstPointCollection[0].Y, 1e-1); + #endregion #region Assertion for 'point6' - var features6 = points6.Features.ToArray(); + MapFeature[] features6 = points6.Features.ToArray(); Assert.AreEqual(1, features6.Length); - var point6 = features6[0]; - var point6Geometry = point6.MapGeometries.ToArray(); + MapFeature point6 = features6[0]; + MapGeometry[] point6Geometry = point6.MapGeometries.ToArray(); Assert.AreEqual(1, point6Geometry.Length); - var point6Points = point6Geometry[0].Points.ToArray(); - Assert.AreEqual(1, point6Points.Length); - Assert.AreEqual(-2.066, point6Points[0].X, 1e-1); - Assert.AreEqual(0.827, point6Points[0].Y, 1e-1); + IEnumerable[] point6PointCollections = point6Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, point6PointCollections.Length); + + Point2D[] point6FirstPointCollection = point6PointCollections[0].ToArray(); + Assert.AreEqual(1, point6FirstPointCollection.Length); + Assert.AreEqual(-2.066, point6FirstPointCollection[0].X, 1e-1); + Assert.AreEqual(0.827, point6FirstPointCollection[0].Y, 1e-1); + #endregion } } @@ -273,7 +312,7 @@ using (var reader = new PointShapeFileReader(shapeWithOnePoint)) { // Call - MapPointData pointData = reader.ReadShapeFile(name) as MapPointData; + MapPointData pointData = (MapPointData)reader.ReadShapeFile(name); // Assert Assert.AreEqual(name, pointData.Name); @@ -292,7 +331,7 @@ using (var reader = new PointShapeFileReader(shapeWithOnePoint)) { // Call - MapPointData pointData = reader.ReadShapeFile(name) as MapPointData; + MapPointData pointData = (MapPointData)reader.ReadShapeFile(name); // Assert Assert.AreEqual("Punten", pointData.Name); @@ -304,89 +343,113 @@ { // Setup string shapeWithMultiplePoints = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, - "Multiple_Point_with_ID.shp"); + "Multiple_Point_with_ID.shp"); using (var reader = new PointShapeFileReader(shapeWithMultiplePoints)) { // Precondition Assert.AreEqual(6, reader.GetNumberOfLines()); // Call - MapPointData points = reader.ReadShapeFile() as MapPointData; + MapPointData points = (MapPointData)reader.ReadShapeFile(); // Assert var features = points.Features.ToArray(); Assert.AreEqual(6, features.Length); #region Assertion for 'point1' - var point1 = features[0]; - var point1Geometry = point1.MapGeometries.ToArray(); + MapFeature point1 = features[0]; + MapGeometry[] point1Geometry = point1.MapGeometries.ToArray(); Assert.AreEqual(1, point1Geometry.Length); - var point1Points = point1Geometry[0].Points.ToArray(); - Assert.AreEqual(1, point1Points.Length); - Assert.AreEqual(-1.750, point1Points[0].X, 1e-1); - Assert.AreEqual(-0.488, point1Points[0].Y, 1e-1); + IEnumerable[] point1PointCollections = point1Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, point1PointCollections.Length); + + Point2D[] point1FirstPointCollection = point1PointCollections[0].ToArray(); + Assert.AreEqual(1, point1FirstPointCollection.Length); + Assert.AreEqual(-1.750, point1FirstPointCollection[0].X, 1e-1); + Assert.AreEqual(-0.488, point1FirstPointCollection[0].Y, 1e-1); + #endregion #region Assertion for 'point2' - var point2 = features[1]; - var point2Geometry = point2.MapGeometries.ToArray(); + MapFeature point2 = features[1]; + MapGeometry[] point2Geometry = point2.MapGeometries.ToArray(); Assert.AreEqual(1, point2Geometry.Length); - var point2Points = point2Geometry[0].Points.ToArray(); - Assert.AreEqual(1, point2Points.Length); - Assert.AreEqual(-0.790, point2Points[0].X, 1e-1); - Assert.AreEqual(-0.308, point2Points[0].Y, 1e-1); + IEnumerable[] point2PointCollections = point2Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, point2PointCollections.Length); + + Point2D[] point2FirstPointCollection = point2PointCollections[0].ToArray(); + Assert.AreEqual(1, point2FirstPointCollection.Length); + Assert.AreEqual(-0.790, point2FirstPointCollection[0].X, 1e-1); + Assert.AreEqual(-0.308, point2FirstPointCollection[0].Y, 1e-1); + #endregion #region Assertion for 'point3' - var point3 = features[2]; - var point3Geometry = point3.MapGeometries.ToArray(); + MapFeature point3 = features[2]; + MapGeometry[] point3Geometry = point3.MapGeometries.ToArray(); Assert.AreEqual(1, point3Geometry.Length); - var point3Points = point3Geometry[0].Points.ToArray(); - Assert.AreEqual(1, point3Points.Length); - Assert.AreEqual(0.740, point3Points[0].X, 1e-1); - Assert.AreEqual(-0.577, point3Points[0].Y, 1e-1); + IEnumerable[] point3PointCollections = point3Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, point3PointCollections.Length); + + Point2D[] point3FirstPointCollection = point3PointCollections[0].ToArray(); + Assert.AreEqual(1, point3FirstPointCollection.Length); + Assert.AreEqual(0.740, point3FirstPointCollection[0].X, 1e-1); + Assert.AreEqual(-0.577, point3FirstPointCollection[0].Y, 1e-1); + #endregion #region Assertion for 'point4' - var point4 = features[3]; - var point4Geometry = point4.MapGeometries.ToArray(); + MapFeature point4 = features[3]; + MapGeometry[] point4Geometry = point4.MapGeometries.ToArray(); Assert.AreEqual(1, point4Geometry.Length); - var point4Points = point4Geometry[0].Points.ToArray(); - Assert.AreEqual(1, point4Points.Length); - Assert.AreEqual(0.787, point4Points[0].X, 1e-1); - Assert.AreEqual(0.759, point4Points[0].Y, 1e-1); + IEnumerable[] point4PointCollections = point4Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, point4PointCollections.Length); + + Point2D[] point4FirstPointCollection = point4PointCollections[0].ToArray(); + Assert.AreEqual(1, point4FirstPointCollection.Length); + Assert.AreEqual(0.787, point4FirstPointCollection[0].X, 1e-1); + Assert.AreEqual(0.759, point4FirstPointCollection[0].Y, 1e-1); + #endregion #region Assertion for 'point5' - var point5 = features[4]; - var point5Geometry = point5.MapGeometries.ToArray(); + MapFeature point5 = features[4]; + MapGeometry[] point5Geometry = point5.MapGeometries.ToArray(); Assert.AreEqual(1, point5Geometry.Length); - var point5Points = point5Geometry[0].Points.ToArray(); - Assert.AreEqual(1, point5Points.Length); - Assert.AreEqual(-0.544, point5Points[0].X, 1e-1); - Assert.AreEqual(0.283, point5Points[0].Y, 1e-1); + IEnumerable[] point5PointCollections = point5Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, point5PointCollections.Length); + + Point2D[] point5FirstPointCollection = point5PointCollections[0].ToArray(); + Assert.AreEqual(1, point5FirstPointCollection.Length); + Assert.AreEqual(-0.544, point5FirstPointCollection[0].X, 1e-1); + Assert.AreEqual(0.283, point5FirstPointCollection[0].Y, 1e-1); + #endregion #region Assertion for 'point6' - var point6 = features[5]; - var point6Geometry = point6.MapGeometries.ToArray(); + MapFeature point6 = features[5]; + MapGeometry[] point6Geometry = point6.MapGeometries.ToArray(); Assert.AreEqual(1, point6Geometry.Length); - var point6Points = point6Geometry[0].Points.ToArray(); - Assert.AreEqual(1, point6Points.Length); - Assert.AreEqual(-2.066, point6Points[0].X, 1e-1); - Assert.AreEqual(0.827, point6Points[0].Y, 1e-1); + IEnumerable[] point6PointCollections = point6Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, point6PointCollections.Length); + + Point2D[] point6FirstPointCollection = point6PointCollections[0].ToArray(); + Assert.AreEqual(1, point6FirstPointCollection.Length); + Assert.AreEqual(-2.066, point6FirstPointCollection[0].X, 1e-1); + Assert.AreEqual(0.827, point6FirstPointCollection[0].Y, 1e-1); + #endregion } } Index: Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolygonShapeFileReaderTest.cs =================================================================== diff -u -r2117ba3d745d5776cefdf94dc86ac8d5950aa31e -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolygonShapeFileReaderTest.cs (.../PolygonShapeFileReaderTest.cs) (revision 2117ba3d745d5776cefdf94dc86ac8d5950aa31e) +++ Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolygonShapeFileReaderTest.cs (.../PolygonShapeFileReaderTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -1,7 +1,12 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; + +using Core.Common.Base.Geometry; using Core.Common.IO.Exceptions; using Core.Common.TestUtil; using Core.Components.Gis.Data; +using Core.Components.Gis.Features; +using Core.Components.Gis.Geometries; using Core.Components.Gis.IO.Readers; using NUnit.Framework; @@ -40,7 +45,7 @@ { // Setup string nonPolygonShapeFile = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, - shapeFileName); + shapeFileName); // Call TestDelegate call = () => new PolygonShapeFileReader(nonPolygonShapeFile); @@ -57,7 +62,7 @@ { // Setup string shapeWithOnePolygon = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, - "Empty_Polygon_with_ID.shp"); + "Empty_Polygon_with_ID.shp"); using (var reader = new PolygonShapeFileReader(shapeWithOnePolygon)) { // Call @@ -73,7 +78,7 @@ { // Setup string shapeWithOnePolygon = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, - "Single_Polygon_with_ID.shp"); + "Single_Polygon_with_ID.shp"); using (var reader = new PolygonShapeFileReader(shapeWithOnePolygon)) { // Call @@ -89,7 +94,7 @@ { // Setup string shapeWithMultiplePolygons = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, - "Multiple_Polygon_with_ID.shp"); + "Multiple_Polygon_with_ID.shp"); using (var reader = new PolygonShapeFileReader(shapeWithMultiplePolygons)) { @@ -108,11 +113,11 @@ { // Setup string shapeWithOnePolygon = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, - "Single_Polygon_with_ID.shp"); + "Single_Polygon_with_ID.shp"); using (var reader = new PolygonShapeFileReader(shapeWithOnePolygon)) { // Call - MapPolygonData polygon = reader.ReadLine(name) as MapPolygonData; + MapPolygonData polygon = (MapPolygonData)reader.ReadLine(name); // Assert Assert.AreEqual(name, polygon.Name); @@ -127,11 +132,11 @@ { // Setup string shapeWithOnePolygon = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, - "Single_Polygon_with_ID.shp"); + "Single_Polygon_with_ID.shp"); using (var reader = new PolygonShapeFileReader(shapeWithOnePolygon)) { // Call - MapPolygonData polygon = reader.ReadLine(name) as MapPolygonData; + MapPolygonData polygon = (MapPolygonData)reader.ReadLine(name); // Assert Assert.AreEqual("Polygoon", polygon.Name); @@ -143,46 +148,57 @@ { // Setup string shapeWithOnePolygon = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, - "Single_Polygon_with_ID.shp"); + "Single_Polygon_with_ID.shp"); using (var reader = new PolygonShapeFileReader(shapeWithOnePolygon)) { // Call - MapPolygonData polygon = reader.ReadLine() as MapPolygonData; + MapPolygonData polygon = (MapPolygonData)reader.ReadLine(); // Assert Assert.IsNotNull(polygon); - var polygonFeatures = polygon.Features.ToArray(); + MapFeature[] polygonFeatures = polygon.Features.ToArray(); Assert.AreEqual(1, polygonFeatures.Length); - var polygonGeometries = polygonFeatures[0].MapGeometries.ToArray(); + + MapGeometry[] polygonGeometries = polygonFeatures[0].MapGeometries.ToArray(); Assert.AreEqual(1, polygonGeometries.Length); - var polygonPoints = polygonGeometries[0].Points.ToArray(); - Assert.AreEqual(30, polygonPoints.Length); - Assert.AreEqual(-0.264, polygonPoints[25].X, 1e-1); - Assert.AreEqual(0.169, polygonPoints[25].Y, 1e-1); + + IEnumerable[] polygonPointCollections = polygonGeometries[0].PointCollections.ToArray(); + Assert.AreEqual(1, polygonPointCollections.Length); + + var firstPointCollection = polygonPointCollections[0].ToArray(); + Assert.AreEqual(30, firstPointCollection.Length); + Assert.AreEqual(-0.264, firstPointCollection[25].X, 1e-1); + Assert.AreEqual(0.169, firstPointCollection[25].Y, 1e-1); } } [Test] public void ReadLine_ShapeFileWithSingeFeatureMultiplePolygons_ReturnShapes() { // Setup - string shape = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, "Single_Multi-Polygon_with_ID.shp"); + string shape = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, + "Single_Multi-Polygon_with_ID.shp"); using (var reader = new PolygonShapeFileReader(shape)) { // Call - MapPolygonData polygon = reader.ReadLine() as MapPolygonData; + MapPolygonData polygon = (MapPolygonData)reader.ReadLine(); // Assert Assert.IsNotNull(polygon); - var polygonFeatures = polygon.Features.ToArray(); + MapFeature[] polygonFeatures = polygon.Features.ToArray(); Assert.AreEqual(1, polygonFeatures.Length); - var polygonGeometries = polygonFeatures[0].MapGeometries.ToArray(); + + MapGeometry[] polygonGeometries = polygonFeatures[0].MapGeometries.ToArray(); Assert.AreEqual(2, polygonGeometries.Length); - var polygonPoints = polygonGeometries[0].Points.ToArray(); - Assert.AreEqual(7, polygonPoints.Length); - Assert.AreEqual(-2.257, polygonPoints[4].X, 1e-1); - Assert.AreEqual(0.419, polygonPoints[4].Y, 1e-1); + + IEnumerable[] firstGeometryPointCollections = polygonGeometries[0].PointCollections.ToArray(); + Assert.AreEqual(1, firstGeometryPointCollections.Length); + + Point2D[] firstGeometryFirstPointCollection = firstGeometryPointCollections[0].ToArray(); + Assert.AreEqual(7, firstGeometryFirstPointCollection.Length); + Assert.AreEqual(-2.257, firstGeometryFirstPointCollection[4].X, 1e-1); + Assert.AreEqual(0.419, firstGeometryFirstPointCollection[4].Y, 1e-1); } } @@ -191,77 +207,93 @@ { // Setup string shapeWithMultiplePolygons = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, - "Multiple_Polygon_with_ID.shp"); + "Multiple_Polygon_with_ID.shp"); using (var reader = new PolygonShapeFileReader(shapeWithMultiplePolygons)) { // Precondition Assert.AreEqual(4, reader.GetNumberOfLines()); // Call - MapPolygonData polygons1 = reader.ReadLine() as MapPolygonData; - MapPolygonData polygons2 = reader.ReadLine() as MapPolygonData; - MapPolygonData polygons3 = reader.ReadLine() as MapPolygonData; - MapPolygonData polygons4 = reader.ReadLine() as MapPolygonData; + MapPolygonData polygons1 = (MapPolygonData)reader.ReadLine(); + MapPolygonData polygons2 = (MapPolygonData)reader.ReadLine(); + MapPolygonData polygons3 = (MapPolygonData)reader.ReadLine(); + MapPolygonData polygons4 = (MapPolygonData)reader.ReadLine(); // Assert #region Assertsions for 'polygon1' - var features1 = polygons1.Features.ToArray(); + MapFeature[] features1 = polygons1.Features.ToArray(); Assert.AreEqual(1, features1.Length); - var polygon1 = features1[0]; - var polygon1Geometry = polygon1.MapGeometries.ToArray(); + MapFeature polygon1 = features1[0]; + MapGeometry[] polygon1Geometry = polygon1.MapGeometries.ToArray(); Assert.AreEqual(1, polygon1Geometry.Length); - var polygon1Points = polygon1Geometry[0].Points.ToArray(); - Assert.AreEqual(6, polygon1Points.Length); - Assert.AreEqual(-1.070, polygon1Points[2].X, 1e-1); - Assert.AreEqual(0.066, polygon1Points[2].Y, 1e-1); + IEnumerable[] polygon1PointCollections = polygon1Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, polygon1PointCollections.Length); + + var polygon1PointCollection = polygon1PointCollections[0].ToArray(); + Assert.AreEqual(6, polygon1PointCollection.Length); + Assert.AreEqual(-1.070, polygon1PointCollection[2].X, 1e-1); + Assert.AreEqual(0.066, polygon1PointCollection[2].Y, 1e-1); + #endregion #region Assertsions for 'polygon2' - var features2 = polygons2.Features.ToArray(); + MapFeature[] features2 = polygons2.Features.ToArray(); Assert.AreEqual(1, features2.Length); - var polygon2 = features2[0]; - var polygon2Geometry = polygon2.MapGeometries.ToArray(); + MapFeature polygon2 = features2[0]; + MapGeometry[] polygon2Geometry = polygon2.MapGeometries.ToArray(); Assert.AreEqual(1, polygon2Geometry.Length); - var polygon2Points = polygon2Geometry[0].Points.ToArray(); - Assert.AreEqual(25, polygon2Points.Length); - Assert.AreEqual(-2.172, polygon2Points[23].X, 1e-1); - Assert.AreEqual(0.212, polygon2Points[23].Y, 1e-1); + IEnumerable[] polygon2PointCollections = polygon2Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, polygon2PointCollections.Length); + + Point2D[] polygon2PointCollection = polygon2PointCollections[0].ToArray(); + Assert.AreEqual(25, polygon2PointCollection.Length); + Assert.AreEqual(-2.172, polygon2PointCollection[23].X, 1e-1); + Assert.AreEqual(0.212, polygon2PointCollection[23].Y, 1e-1); + #endregion #region Assertsions for 'polygon3' - var features3 = polygons3.Features.ToArray(); + MapFeature[] features3 = polygons3.Features.ToArray(); Assert.AreEqual(1, features3.Length); - var polygon3 = features3[0]; - var polygon3Geometry = polygon3.MapGeometries.ToArray(); + MapFeature polygon3 = features3[0]; + MapGeometry[] polygon3Geometry = polygon3.MapGeometries.ToArray(); Assert.AreEqual(1, polygon3Geometry.Length); - var polygon3Points = polygon3Geometry[0].Points.ToArray(); - Assert.AreEqual(10, polygon3Points.Length); - Assert.AreEqual(-1.091, polygon3Points[0].X, 1e-1); - Assert.AreEqual(0.566, polygon3Points[0].Y, 1e-1); + IEnumerable[] polygon3PointCollections = polygon3Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, polygon3PointCollections.Length); + + Point2D[] polygon3PointCollection = polygon3PointCollections[0].ToArray(); + Assert.AreEqual(10, polygon3PointCollection.Length); + Assert.AreEqual(-1.091, polygon3PointCollection[0].X, 1e-1); + Assert.AreEqual(0.566, polygon3PointCollection[0].Y, 1e-1); + #endregion #region Assertsions for 'polygon4' - var features4 = polygons4.Features.ToArray(); + MapFeature[] features4 = polygons4.Features.ToArray(); Assert.AreEqual(1, features4.Length); - var polygon4 = features4[0]; - var polygon4Geometry = polygon4.MapGeometries.ToArray(); + MapFeature polygon4 = features4[0]; + MapGeometry[] polygon4Geometry = polygon4.MapGeometries.ToArray(); Assert.AreEqual(1, polygon4Geometry.Length); - var polygon4Points = polygon4Geometry[0].Points.ToArray(); - Assert.AreEqual(9, polygon4Points.Length); - Assert.AreEqual(-1.917, polygon4Points[8].X, 1e-1); - Assert.AreEqual(0.759, polygon4Points[8].Y, 1e-1); + IEnumerable[] polygon4PointCollections = polygon4Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, polygon4PointCollections.Length); + + var polygon4PointCollection = polygon4PointCollections[0].ToArray(); + Assert.AreEqual(9, polygon4PointCollection.Length); + Assert.AreEqual(-1.917, polygon4PointCollection[8].X, 1e-1); + Assert.AreEqual(0.759, polygon4PointCollection[8].Y, 1e-1); + #endregion } } @@ -271,46 +303,57 @@ { // Setup string shapeWithOnePolygon = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, - "Single_Polygon_with_ID.shp"); + "Single_Polygon_with_ID.shp"); using (var reader = new PolygonShapeFileReader(shapeWithOnePolygon)) { // Call - MapPolygonData polygon = reader.ReadShapeFile() as MapPolygonData; + MapPolygonData polygon = (MapPolygonData)reader.ReadShapeFile(); // Assert Assert.IsNotNull(polygon); - var polygonFeatures = polygon.Features.ToArray(); + MapFeature[] polygonFeatures = polygon.Features.ToArray(); Assert.AreEqual(1, polygonFeatures.Length); - var polygonGeometries = polygonFeatures[0].MapGeometries.ToArray(); + + MapGeometry[] polygonGeometries = polygonFeatures[0].MapGeometries.ToArray(); Assert.AreEqual(1, polygonGeometries.Length); - var polygonPoints = polygonGeometries[0].Points.ToArray(); - Assert.AreEqual(30, polygonPoints.Length); - Assert.AreEqual(-0.264, polygonPoints[25].X, 1e-1); - Assert.AreEqual(0.169, polygonPoints[25].Y, 1e-1); + + IEnumerable[] polygonPointCollections = polygonGeometries[0].PointCollections.ToArray(); + Assert.AreEqual(1, polygonPointCollections.Length); + + var polygonFirstPointCollection = polygonPointCollections[0].ToArray(); + Assert.AreEqual(30, polygonFirstPointCollection.Length); + Assert.AreEqual(-0.264, polygonFirstPointCollection[25].X, 1e-1); + Assert.AreEqual(0.169, polygonFirstPointCollection[25].Y, 1e-1); } } [Test] public void ReadShapeFile_ShapeFileWithSingeFeatureMultiplePolygons_ReturnShapes() { // Setup - string shape = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, "Single_Multi-Polygon_with_ID.shp"); + string shape = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, + "Single_Multi-Polygon_with_ID.shp"); using (var reader = new PolygonShapeFileReader(shape)) { // Call - MapPolygonData polygon = reader.ReadShapeFile() as MapPolygonData; + MapPolygonData polygon = (MapPolygonData)reader.ReadShapeFile(); // Assert Assert.IsNotNull(polygon); - var polygonFeatures = polygon.Features.ToArray(); + MapFeature[] polygonFeatures = polygon.Features.ToArray(); Assert.AreEqual(1, polygonFeatures.Length); - var polygonGeometries = polygonFeatures[0].MapGeometries.ToArray(); + + MapGeometry[] polygonGeometries = polygonFeatures[0].MapGeometries.ToArray(); Assert.AreEqual(2, polygonGeometries.Length); - var polygonPoints = polygonGeometries[0].Points.ToArray(); - Assert.AreEqual(7, polygonPoints.Length); - Assert.AreEqual(-2.257, polygonPoints[4].X, 1e-1); - Assert.AreEqual(0.419, polygonPoints[4].Y, 1e-1); + + IEnumerable[] polygonPointCollections = polygonGeometries[0].PointCollections.ToArray(); + Assert.AreEqual(1, polygonPointCollections.Length); + + var firstPointCollection = polygonPointCollections[0].ToArray(); + Assert.AreEqual(7, firstPointCollection.Length); + Assert.AreEqual(-2.257, firstPointCollection[4].X, 1e-1); + Assert.AreEqual(0.419, firstPointCollection[4].Y, 1e-1); } } @@ -321,11 +364,11 @@ { // Setup string shapeWithOnePolygon = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, - "Single_Polygon_with_ID.shp"); + "Single_Polygon_with_ID.shp"); using (var reader = new PolygonShapeFileReader(shapeWithOnePolygon)) { // Call - MapPolygonData polygon = reader.ReadShapeFile(name) as MapPolygonData; + MapPolygonData polygon = (MapPolygonData)reader.ReadShapeFile(name); // Assert Assert.AreEqual(name, polygon.Name); @@ -340,11 +383,11 @@ { // Setup string shapeWithOnePolygon = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, - "Single_Polygon_with_ID.shp"); + "Single_Polygon_with_ID.shp"); using (var reader = new PolygonShapeFileReader(shapeWithOnePolygon)) { // Call - MapPolygonData polygon = reader.ReadShapeFile(name) as MapPolygonData; + MapPolygonData polygon = (MapPolygonData)reader.ReadShapeFile(name); // Assert Assert.AreEqual("Polygoon", polygon.Name); @@ -356,65 +399,81 @@ { // Setup string shapeWithMultiplePolygons = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, - "Multiple_Polygon_with_ID.shp"); + "Multiple_Polygon_with_ID.shp"); using (var reader = new PolygonShapeFileReader(shapeWithMultiplePolygons)) { // Precondition Assert.AreEqual(4, reader.GetNumberOfLines()); // Call - MapPolygonData polygons = reader.ReadShapeFile() as MapPolygonData; + MapPolygonData polygons = (MapPolygonData)reader.ReadShapeFile(); // Assert - var features = polygons.Features.ToArray(); + MapFeature[] features = polygons.Features.ToArray(); Assert.AreEqual(4, features.Length); #region Assertsions for 'polygon1' - var polygon1 = features[0]; - var polygon1Geometry = polygon1.MapGeometries.ToArray(); + MapFeature polygon1 = features[0]; + MapGeometry[] polygon1Geometry = polygon1.MapGeometries.ToArray(); Assert.AreEqual(1, polygon1Geometry.Length); - var polygon1Points = polygon1Geometry[0].Points.ToArray(); - Assert.AreEqual(6, polygon1Points.Length); - Assert.AreEqual(-1.070, polygon1Points[2].X, 1e-1); - Assert.AreEqual(0.066, polygon1Points[2].Y, 1e-1); + IEnumerable[] polygon1PointCollections = polygon1Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, polygon1PointCollections.Length); + + Point2D[] polygon1FirstPointCollection = polygon1PointCollections[0].ToArray(); + Assert.AreEqual(6, polygon1FirstPointCollection.Length); + Assert.AreEqual(-1.070, polygon1FirstPointCollection[2].X, 1e-1); + Assert.AreEqual(0.066, polygon1FirstPointCollection[2].Y, 1e-1); + #endregion #region Assertsions for 'polygon2' - var polygon2 = features[1]; - var polygon2Geometry = polygon2.MapGeometries.ToArray(); + MapFeature polygon2 = features[1]; + MapGeometry[] polygon2Geometry = polygon2.MapGeometries.ToArray(); Assert.AreEqual(1, polygon2Geometry.Length); - var polygon2Points = polygon2Geometry[0].Points.ToArray(); - Assert.AreEqual(25, polygon2Points.Length); - Assert.AreEqual(-2.172, polygon2Points[23].X, 1e-1); - Assert.AreEqual(0.212, polygon2Points[23].Y, 1e-1); + IEnumerable[] polygon2PointCollections = polygon2Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, polygon2PointCollections.Length); + + Point2D[] polygon2FirstPointCollection = polygon2PointCollections[0].ToArray(); + Assert.AreEqual(25, polygon2FirstPointCollection.Length); + Assert.AreEqual(-2.172, polygon2FirstPointCollection[23].X, 1e-1); + Assert.AreEqual(0.212, polygon2FirstPointCollection[23].Y, 1e-1); + #endregion #region Assertsions for 'polygon3' - var polygon3 = features[2]; - var polygon3Geometry = polygon3.MapGeometries.ToArray(); + MapFeature polygon3 = features[2]; + MapGeometry[] polygon3Geometry = polygon3.MapGeometries.ToArray(); Assert.AreEqual(1, polygon3Geometry.Length); - var polygon3Points = polygon3Geometry[0].Points.ToArray(); - Assert.AreEqual(10, polygon3Points.Length); - Assert.AreEqual(-1.091, polygon3Points[0].X, 1e-1); - Assert.AreEqual(0.566, polygon3Points[0].Y, 1e-1); + IEnumerable[] polygon3PointCollections = polygon3Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, polygon3PointCollections.Length); + + Point2D[] polygon3FirstPointCollection = polygon3PointCollections[0].ToArray(); + Assert.AreEqual(10, polygon3FirstPointCollection.Length); + Assert.AreEqual(-1.091, polygon3FirstPointCollection[0].X, 1e-1); + Assert.AreEqual(0.566, polygon3FirstPointCollection[0].Y, 1e-1); + #endregion #region Assertsions for 'polygon4' - var polygon4 = features[3]; - var polygon4Geometry = polygon4.MapGeometries.ToArray(); + MapFeature polygon4 = features[3]; + MapGeometry[] polygon4Geometry = polygon4.MapGeometries.ToArray(); Assert.AreEqual(1, polygon4Geometry.Length); - var polygon4Points = polygon4Geometry[0].Points.ToArray(); - Assert.AreEqual(9, polygon4Points.Length); - Assert.AreEqual(-1.917, polygon4Points[8].X, 1e-1); - Assert.AreEqual(0.759, polygon4Points[8].Y, 1e-1); + IEnumerable[] polygon4PointCollections = polygon4Geometry[0].PointCollections.ToArray(); + Assert.AreEqual(1, polygon4PointCollections.Length); + + Point2D[] polygon4FirstPointCollection = polygon4PointCollections[0].ToArray(); + Assert.AreEqual(9, polygon4FirstPointCollection.Length); + Assert.AreEqual(-1.917, polygon4FirstPointCollection[8].X, 1e-1); + Assert.AreEqual(0.759, polygon4FirstPointCollection[8].Y, 1e-1); + #endregion } } Index: Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolylineShapeFileReaderTest.cs =================================================================== diff -u -r2117ba3d745d5776cefdf94dc86ac8d5950aa31e -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolylineShapeFileReaderTest.cs (.../PolylineShapeFileReaderTest.cs) (revision 2117ba3d745d5776cefdf94dc86ac8d5950aa31e) +++ Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolylineShapeFileReaderTest.cs (.../PolylineShapeFileReaderTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -1,9 +1,12 @@ -using System; -using System.IO; +using System.Collections.Generic; using System.Linq; + +using Core.Common.Base.Geometry; using Core.Common.IO.Exceptions; using Core.Common.TestUtil; using Core.Components.Gis.Data; +using Core.Components.Gis.Features; +using Core.Components.Gis.Geometries; using Core.Components.Gis.IO.Readers; using NUnit.Framework; @@ -108,7 +111,7 @@ using (var reader = new PolylineShapeFileReader(shapeWithOneLine)) { // Call - MapLineData line = reader.ReadLine(name) as MapLineData; + MapLineData line = (MapLineData)reader.ReadLine(name); // Assert Assert.AreEqual(name, line.Name); @@ -127,7 +130,7 @@ using (var reader = new PolylineShapeFileReader(shapeWithOneLine)) { // Call - MapLineData line = reader.ReadLine(name) as MapLineData; + MapLineData line = (MapLineData)reader.ReadLine(name); // Assert Assert.AreEqual("Lijn", line.Name); @@ -143,22 +146,25 @@ using (var reader = new PolylineShapeFileReader(shapeWithOneLine)) { // Call - MapLineData line = reader.ReadLine() as MapLineData; + MapLineData line = (MapLineData)reader.ReadLine(); // Assert Assert.IsNotNull(line); - var features = line.Features.ToArray(); + MapFeature[] features = line.Features.ToArray(); Assert.AreEqual(1, features.Length); - var geometries = features[0].MapGeometries.ToArray(); + MapGeometry[] geometries = features[0].MapGeometries.ToArray(); Assert.AreEqual(1, geometries.Length); - var points = geometries[0].Points.ToArray(); - Assert.AreEqual(1669, points.Length); - Assert.AreEqual(202714.219, points[457].X, 1e-6); - Assert.AreEqual(507775.781, points[457].Y, 1e-6); + IEnumerable[] pointCollections = geometries[0].PointCollections.ToArray(); + Assert.AreEqual(1, pointCollections.Length); + var firstPointCollection = pointCollections[0].ToArray(); + Assert.AreEqual(1669, firstPointCollection.Length); + Assert.AreEqual(202714.219, firstPointCollection[457].X, 1e-6); + Assert.AreEqual(507775.781, firstPointCollection[457].Y, 1e-6); + Assert.AreEqual(6, features[0].MetaData.Count); Assert.AreEqual("A", features[0].MetaData["CATEGORIE"]); Assert.AreEqual("10", features[0].MetaData["DIJKRING"]); @@ -174,87 +180,99 @@ { // Setup string shapeWithMultipleLines = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, - "Multiple_PolyLine_with_ID.shp"); + "Multiple_PolyLine_with_ID.shp"); using (var reader = new PolylineShapeFileReader(shapeWithMultipleLines)) { // Precondition Assert.AreEqual(4, reader.GetNumberOfLines()); // Call - MapLineData line1 = reader.ReadLine() as MapLineData; - MapLineData line2 = reader.ReadLine() as MapLineData; - MapLineData line3 = reader.ReadLine() as MapLineData; - MapLineData line4 = reader.ReadLine() as MapLineData; + MapLineData line1 = (MapLineData)reader.ReadLine(); + MapLineData line2 = (MapLineData)reader.ReadLine(); + MapLineData line3 = (MapLineData)reader.ReadLine(); + MapLineData line4 = (MapLineData)reader.ReadLine(); // Assert #region Assertions for 'line1' - var features1 = line1.Features.ToArray(); + MapFeature[] features1 = line1.Features.ToArray(); Assert.AreEqual(1, features1.Length); - var geometries1 = features1[0].MapGeometries.ToArray(); + MapGeometry[] geometries1 = features1[0].MapGeometries.ToArray(); Assert.AreEqual(1, geometries1.Length); - var line1Points = geometries1[0].Points.ToArray(); - Assert.AreEqual(15, line1Points.Length); - Assert.AreEqual(-1.514151, line1Points[2].X, 1e-6); - Assert.AreEqual(-0.879717, line1Points[2].Y, 1e-6); + IEnumerable[] line1PointCollections = geometries1[0].PointCollections.ToArray(); + Assert.AreEqual(1, line1PointCollections.Length); + Point2D[] line1FirstPointCollection = line1PointCollections[0].ToArray(); + Assert.AreEqual(15, line1FirstPointCollection.Length); + Assert.AreEqual(-1.514151, line1FirstPointCollection[2].X, 1e-6); + Assert.AreEqual(-0.879717, line1FirstPointCollection[2].Y, 1e-6); + Assert.AreEqual(1, features1[0].MetaData.Count); Assert.AreEqual(4, features1[0].MetaData["id"]); #endregion #region Assertions for 'line2' - var features2 = line2.Features.ToArray(); + MapFeature[] features2 = line2.Features.ToArray(); Assert.AreEqual(1, features2.Length); - var geometries2 = features2[0].MapGeometries.ToArray(); + MapGeometry[] geometries2 = features2[0].MapGeometries.ToArray(); Assert.AreEqual(1, geometries2.Length); - var line2Points = geometries2[0].Points.ToArray(); - Assert.AreEqual(6, line2Points.Length); - Assert.AreEqual(-2.028302, line2Points[3].X, 1e-6); - Assert.AreEqual(-0.382075, line2Points[3].Y, 1e-6); + IEnumerable[] line2PointCollections = geometries2[0].PointCollections.ToArray(); + Assert.AreEqual(1, line2PointCollections.Length); + Point2D[] line2FirstPointCollection = line2PointCollections[0].ToArray(); + Assert.AreEqual(6, line2FirstPointCollection.Length); + Assert.AreEqual(-2.028302, line2FirstPointCollection[3].X, 1e-6); + Assert.AreEqual(-0.382075, line2FirstPointCollection[3].Y, 1e-6); + Assert.AreEqual(1, features2[0].MetaData.Count); Assert.AreEqual(3, features2[0].MetaData["id"]); #endregion #region Assertions for 'line3' - var features3 = line3.Features.ToArray(); + MapFeature[] features3 = line3.Features.ToArray(); Assert.AreEqual(1, features3.Length); - var geometries3 = features3[0].MapGeometries.ToArray(); + MapGeometry[] geometries3 = features3[0].MapGeometries.ToArray(); Assert.AreEqual(1, geometries3.Length); - var line3Points = geometries3[0].Points.ToArray(); - Assert.AreEqual(13, line3Points.Length); - Assert.AreEqual(0.891509, line3Points[12].X, 1e-6); - Assert.AreEqual(-0.122641, line3Points[12].Y, 1e-6); + IEnumerable[] line3PointCollections = geometries3[0].PointCollections.ToArray(); + Assert.AreEqual(1, line3PointCollections.Length); + Point2D[] line3FirstPointCollection = line3PointCollections[0].ToArray(); + Assert.AreEqual(13, line3FirstPointCollection.Length); + Assert.AreEqual(0.891509, line3FirstPointCollection[12].X, 1e-6); + Assert.AreEqual(-0.122641, line3FirstPointCollection[12].Y, 1e-6); + Assert.AreEqual(1, features3[0].MetaData.Count); Assert.AreEqual(2, features3[0].MetaData["id"]); #endregion #region Assertions for 'line4' - var features4 = line4.Features.ToArray(); + MapFeature[] features4 = line4.Features.ToArray(); Assert.AreEqual(1, features4.Length); - var geometries4 = features4[0].MapGeometries.ToArray(); + MapGeometry[] geometries4 = features4[0].MapGeometries.ToArray(); Assert.AreEqual(1, geometries4.Length); - var line4Points = geometries4[0].Points.ToArray(); - Assert.AreEqual(6, line4Points.Length); - Assert.AreEqual(-2.070754, line4Points[0].X, 1e-6); - Assert.AreEqual(0.73584906, line4Points[0].Y, 1e-6); + IEnumerable[] line4PointCollections = geometries4[0].PointCollections.ToArray(); + Assert.AreEqual(1, line4PointCollections.Length); + Point2D[] line4FirstPointCollection = line4PointCollections[0].ToArray(); + Assert.AreEqual(6, line4FirstPointCollection.Length); + Assert.AreEqual(-2.070754, line4FirstPointCollection[0].X, 1e-6); + Assert.AreEqual(0.73584906, line4FirstPointCollection[0].Y, 1e-6); + Assert.AreEqual(1, features4[0].MetaData.Count); Assert.AreEqual(1, features4[0].MetaData["id"]); @@ -273,7 +291,7 @@ using (var reader = new PolylineShapeFileReader(shapeWithOneLine)) { // Call - MapLineData line = reader.ReadShapeFile(name) as MapLineData; + MapLineData line = (MapLineData)reader.ReadShapeFile(name); // Assert Assert.AreEqual(name, line.Name); @@ -292,7 +310,7 @@ using (var reader = new PolylineShapeFileReader(shapeWithOneLine)) { // Call - MapLineData line = reader.ReadShapeFile(name) as MapLineData; + MapLineData line = (MapLineData)reader.ReadShapeFile(name); // Assert Assert.AreEqual("Lijn", line.Name); @@ -308,22 +326,25 @@ using (var reader = new PolylineShapeFileReader(shapeWithOneLine)) { // Call - MapLineData line = reader.ReadShapeFile() as MapLineData; + MapLineData line = (MapLineData)reader.ReadShapeFile(); // Assert Assert.IsNotNull(line); - var features = line.Features.ToArray(); + MapFeature[] features = line.Features.ToArray(); Assert.AreEqual(1, features.Length); - var geometries = features[0].MapGeometries.ToArray(); + MapGeometry[] geometries = features[0].MapGeometries.ToArray(); Assert.AreEqual(1, geometries.Length); - var points = geometries[0].Points.ToArray(); - Assert.AreEqual(1669, points.Length); - Assert.AreEqual(202714.219, points[457].X, 1e-6); - Assert.AreEqual(507775.781, points[457].Y, 1e-6); + IEnumerable[] pointCollections = geometries[0].PointCollections.ToArray(); + Assert.AreEqual(1, pointCollections.Length); + var firstPointCollection = pointCollections[0].ToArray(); + Assert.AreEqual(1669, firstPointCollection.Length); + Assert.AreEqual(202714.219, firstPointCollection[457].X, 1e-6); + Assert.AreEqual(507775.781, firstPointCollection[457].Y, 1e-6); + Assert.AreEqual(6, features[0].MetaData.Count); Assert.AreEqual("A", features[0].MetaData["CATEGORIE"]); Assert.AreEqual("10", features[0].MetaData["DIJKRING"]); @@ -339,74 +360,86 @@ { // Setup string shapeWithMultipleLines = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, - "Multiple_PolyLine_with_ID.shp"); + "Multiple_PolyLine_with_ID.shp"); using (var reader = new PolylineShapeFileReader(shapeWithMultipleLines)) { // Precondition Assert.AreEqual(4, reader.GetNumberOfLines()); // Call - MapLineData lines = reader.ReadShapeFile() as MapLineData; + MapLineData lines = (MapLineData)reader.ReadShapeFile(); // Assert - var features = lines.Features.ToArray(); + MapFeature[] features = lines.Features.ToArray(); Assert.AreEqual(4, features.Length); #region Assertions for 'line1' - var geometries1 = features[0].MapGeometries.ToArray(); + MapGeometry[] geometries1 = features[0].MapGeometries.ToArray(); Assert.AreEqual(1, geometries1.Length); - var line1Points = geometries1[0].Points.ToArray(); - Assert.AreEqual(15, line1Points.Length); - Assert.AreEqual(-1.514151, line1Points[2].X, 1e-6); - Assert.AreEqual(-0.879717, line1Points[2].Y, 1e-6); + IEnumerable[] line1PointCollections = geometries1[0].PointCollections.ToArray(); + Assert.AreEqual(1, line1PointCollections.Length); + Point2D[] line1FirstPointCollection = line1PointCollections[0].ToArray(); + Assert.AreEqual(15, line1FirstPointCollection.Length); + Assert.AreEqual(-1.514151, line1FirstPointCollection[2].X, 1e-6); + Assert.AreEqual(-0.879717, line1FirstPointCollection[2].Y, 1e-6); + Assert.AreEqual(1, features[0].MetaData.Count); Assert.AreEqual(4, features[0].MetaData["id"]); #endregion #region Assertions for 'line2' - var geometries2 = features[1].MapGeometries.ToArray(); + MapGeometry[] geometries2 = features[1].MapGeometries.ToArray(); Assert.AreEqual(1, geometries2.Length); - var line2Points = geometries2[0].Points.ToArray(); - Assert.AreEqual(6, line2Points.Length); - Assert.AreEqual(-2.028302, line2Points[3].X, 1e-6); - Assert.AreEqual(-0.382075, line2Points[3].Y, 1e-6); + IEnumerable[] line2PointCollections = geometries2[0].PointCollections.ToArray(); + Assert.AreEqual(1, line2PointCollections.Length); + Point2D[] line2FirstPointCollection = line2PointCollections[0].ToArray(); + Assert.AreEqual(6, line2FirstPointCollection.Length); + Assert.AreEqual(-2.028302, line2FirstPointCollection[3].X, 1e-6); + Assert.AreEqual(-0.382075, line2FirstPointCollection[3].Y, 1e-6); + Assert.AreEqual(1, features[1].MetaData.Count); Assert.AreEqual(3, features[1].MetaData["id"]); #endregion #region Assertions for 'line3' - var geometries3 = features[2].MapGeometries.ToArray(); + MapGeometry[] geometries3 = features[2].MapGeometries.ToArray(); Assert.AreEqual(1, geometries3.Length); - var line3Points = geometries3[0].Points.ToArray(); - Assert.AreEqual(13, line3Points.Length); - Assert.AreEqual(0.891509, line3Points[12].X, 1e-6); - Assert.AreEqual(-0.122641, line3Points[12].Y, 1e-6); + IEnumerable[] line3PointCollections = geometries3[0].PointCollections.ToArray(); + Assert.AreEqual(1, line3PointCollections.Length); + Point2D[] line3FirstPointCollection = line3PointCollections[0].ToArray(); + Assert.AreEqual(13, line3FirstPointCollection.Length); + Assert.AreEqual(0.891509, line3FirstPointCollection[12].X, 1e-6); + Assert.AreEqual(-0.122641, line3FirstPointCollection[12].Y, 1e-6); + Assert.AreEqual(1, features[2].MetaData.Count); Assert.AreEqual(2, features[2].MetaData["id"]); #endregion #region Assertions for 'line4' - var geometries4 = features[3].MapGeometries.ToArray(); + MapGeometry[] geometries4 = features[3].MapGeometries.ToArray(); Assert.AreEqual(1, geometries4.Length); - var line4Points = geometries4[0].Points.ToArray(); - Assert.AreEqual(6, line4Points.Length); - Assert.AreEqual(-2.070754, line4Points[0].X, 1e-6); - Assert.AreEqual(0.73584906, line4Points[0].Y, 1e-6); + IEnumerable[] line4PointCollections = geometries4[0].PointCollections.ToArray(); + Assert.AreEqual(1, line4PointCollections.Length); + Point2D[] line4FirstPointCollection = line4PointCollections[0].ToArray(); + Assert.AreEqual(6, line4FirstPointCollection.Length); + Assert.AreEqual(-2.070754, line4FirstPointCollection[0].X, 1e-6); + Assert.AreEqual(0.73584906, line4FirstPointCollection[0].Y, 1e-6); + Assert.AreEqual(1, features[3].MetaData.Count); Assert.AreEqual(1, features[3].MetaData["id"]); Index: Core/Components/test/Core.Components.Gis.Test/Data/FeatureBasedMapDataTest.cs =================================================================== diff -u -r2117ba3d745d5776cefdf94dc86ac8d5950aa31e -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/test/Core.Components.Gis.Test/Data/FeatureBasedMapDataTest.cs (.../FeatureBasedMapDataTest.cs) (revision 2117ba3d745d5776cefdf94dc86ac8d5950aa31e) +++ Core/Components/test/Core.Components.Gis.Test/Data/FeatureBasedMapDataTest.cs (.../FeatureBasedMapDataTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -22,7 +22,7 @@ // Assert var expectedMessage = "A feature collection is required when creating a subclass of Core.Components.Gis.Data.FeatureBasedMapData."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); } [Test] @@ -32,11 +32,14 @@ public void Constructor_InvalidName_ThrowsArgumentExcpetion(string invalidName) { // Setup - var features = new Collection + var features = new Collection { new MapFeature(new Collection { - new MapGeometry(Enumerable.Empty()) + new MapGeometry(new[] + { + Enumerable.Empty() + }) }) }; @@ -51,17 +54,20 @@ public void Constructor_WithPoints_PropertiesSet() { // Setup - var points = new Collection + var points = new[] { new Point2D(0.0, 1.0), new Point2D(2.5, 1.1) }; - var features = new Collection + var features = new[] { - new MapFeature(new Collection + new MapFeature(new[] { - new MapGeometry(points) + new MapGeometry(new[] + { + points + }) }) }; @@ -70,19 +76,24 @@ // Assert Assert.AreNotSame(features, data.Features); - CollectionAssert.AreEqual(points, data.Features.First().MapGeometries.First().Points); + Assert.AreEqual(features.Length, data.Features.Count()); + Assert.AreEqual(features[0].MapGeometries.Count(), data.Features.First().MapGeometries.Count()); + CollectionAssert.AreEqual(points, data.Features.First().MapGeometries.First().PointCollections.First()); Assert.IsTrue(data.IsVisible); } [Test] public void Constructor_WithName_SetsName() { // Setup - var features = new Collection + var features = new Collection { new MapFeature(new Collection { - new MapGeometry(Enumerable.Empty()) + new MapGeometry(new[] + { + Enumerable.Empty() + }) }) }; var name = "Some name"; Index: Core/Components/test/Core.Components.Gis.Test/Data/MapLineDataTest.cs =================================================================== diff -u -r2117ba3d745d5776cefdf94dc86ac8d5950aa31e -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/test/Core.Components.Gis.Test/Data/MapLineDataTest.cs (.../MapLineDataTest.cs) (revision 2117ba3d745d5776cefdf94dc86ac8d5950aa31e) +++ Core/Components/test/Core.Components.Gis.Test/Data/MapLineDataTest.cs (.../MapLineDataTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using Core.Common.Base.Geometry; @@ -20,7 +21,7 @@ TestDelegate test = () => new MapLineData(null, "test data"); // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, string.Format("A feature collection is required when creating a subclass of {0}.", typeof(FeatureBasedMapData))); + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, string.Format("A feature collection is required when creating a subclass of {0}.", typeof(FeatureBasedMapData))); } [Test] @@ -37,14 +38,45 @@ } [Test] + [TestCase(0)] + [TestCase(2)] + [TestCase(5)] + public void Constructor_InvalidGeometryConfiguration_ThrowArgumentException(int numberOfPointCollections) + { + // Setup + var invalidPointsCollections = new IEnumerable[numberOfPointCollections]; + for (int i = 0; i < numberOfPointCollections; i++) + { + invalidPointsCollections[i] = CreateSingleLinePoints(); + } + var features = new[] + { + new MapFeature(new[] + { + new MapGeometry(invalidPointsCollections), + }) + }; + + // Call + TestDelegate call = () => new MapLineData(features, "Some invalid map data"); + + // Assert + string expectedMessage = "MapLineData only accept MapFeature instances whose MapGeometries contain a single point-collection."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] public void Constructor_WithEmptyMapGeometryPoints_CreatesNewMapLineData() { // Setup - var features = new Collection + var features = new[] { - new MapFeature(new Collection + new MapFeature(new[] { - new MapGeometry(Enumerable.Empty()) + new MapGeometry(new[] + { + Enumerable.Empty() + }) }) }; @@ -54,7 +86,7 @@ // Assert Assert.IsInstanceOf(data); Assert.AreNotSame(features, data.Features); - CollectionAssert.IsEmpty(data.Features.First().MapGeometries.First().Points); + CollectionAssert.IsEmpty(data.Features.First().MapGeometries.First().PointCollections.First()); } [Test] @@ -65,7 +97,7 @@ { new MapFeature(new Collection { - new MapGeometry(CreateTestPoints()) + new MapGeometry(CreateTestPointCollections()) }) }; @@ -75,19 +107,22 @@ // Assert Assert.IsInstanceOf(data); Assert.AreNotSame(features, data.Features); - CollectionAssert.AreEqual(CreateTestPoints(), data.Features.First().MapGeometries.First().Points); + CollectionAssert.AreEqual(CreateTestPointCollections(), data.Features.First().MapGeometries.First().PointCollections); CollectionAssert.IsEmpty(data.Features.First().MetaData); } [Test] public void Constructor_WithName_SetsName() { // Setup - var features = new Collection + var features = new Collection { new MapFeature(new Collection { - new MapGeometry(Enumerable.Empty()) + new MapGeometry(new[] + { + Enumerable.Empty() + }) }) }; var name = "Some name"; @@ -103,11 +138,14 @@ public void MetaData_SetNewValue_GetNewlySetValue() { // Setup - var features = new Collection + var features = new Collection { new MapFeature(new Collection { - new MapGeometry(Enumerable.Empty()) + new MapGeometry(new[] + { + Enumerable.Empty() + }) }) }; @@ -123,10 +161,18 @@ Assert.AreEqual(newValue, data.Features.First().MetaData[key]); } - private static Collection CreateTestPoints() + private static IEnumerable> CreateTestPointCollections() { - return new Collection + return new[] { + CreateSingleLinePoints() + }; + } + + private static Point2D[] CreateSingleLinePoints() + { + return new [] + { new Point2D(0.0, 1.1), new Point2D(1.0, 2.1), new Point2D(1.6, 1.6) Index: Core/Components/test/Core.Components.Gis.Test/Data/MapPointDataTest.cs =================================================================== diff -u -r2117ba3d745d5776cefdf94dc86ac8d5950aa31e -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/test/Core.Components.Gis.Test/Data/MapPointDataTest.cs (.../MapPointDataTest.cs) (revision 2117ba3d745d5776cefdf94dc86ac8d5950aa31e) +++ Core/Components/test/Core.Components.Gis.Test/Data/MapPointDataTest.cs (.../MapPointDataTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using Core.Common.Base.Geometry; @@ -20,7 +21,7 @@ TestDelegate test = () => new MapPointData(null, "test data"); // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, string.Format("A feature collection is required when creating a subclass of {0}.", typeof(FeatureBasedMapData))); + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, string.Format("A feature collection is required when creating a subclass of {0}.", typeof(FeatureBasedMapData))); } [Test] @@ -34,7 +35,10 @@ { new MapFeature(new Collection { - new MapGeometry(Enumerable.Empty()) + new MapGeometry(new[] + { + Enumerable.Empty() + }) }) }; @@ -46,14 +50,45 @@ } [Test] + [TestCase(0)] + [TestCase(2)] + [TestCase(7)] + public void Constructor_InvalidGeometryConfiguration_ThrowArgumentException(int numberOfPointCollections) + { + // Setup + var invalidPointsCollections = new IEnumerable[numberOfPointCollections]; + for (int i = 0; i < numberOfPointCollections; i++) + { + invalidPointsCollections[i] = CreateTestPoints(); + } + var features = new[] + { + new MapFeature(new[] + { + new MapGeometry(invalidPointsCollections), + }) + }; + + // Call + TestDelegate call = () => new MapPointData(features, "Some invalid map data"); + + // Assert + string expectedMessage = "MapPointData only accept MapFeature instances whose MapGeometries contain a single point-collection."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] public void Constructor_WithEmptyPoints_CreatesNewMapPointData() { // Setup - var features = new Collection + var features = new Collection { new MapFeature(new Collection { - new MapGeometry(Enumerable.Empty()) + new MapGeometry(new[] + { + Enumerable.Empty() + }) }) }; @@ -69,11 +104,14 @@ public void Constructor_WithPoints_CreatesNewMapPointData() { // Setup - var features = new Collection + var features = new[] { - new MapFeature(new Collection + new MapFeature(new[] { - new MapGeometry(CreateTestPoints()) + new MapGeometry(new[] + { + CreateTestPoints() + }) }) }; @@ -83,7 +121,7 @@ // Assert Assert.IsInstanceOf(data); Assert.AreNotSame(features, data.Features); - CollectionAssert.AreEqual(CreateTestPoints(), data.Features.First().MapGeometries.First().Points); + CollectionAssert.AreEqual(CreateTestPoints(), data.Features.First().MapGeometries.First().PointCollections.First()); } private Collection CreateTestPoints() Index: Core/Components/test/Core.Components.Gis.Test/Data/MapPolygonDataTest.cs =================================================================== diff -u -r2117ba3d745d5776cefdf94dc86ac8d5950aa31e -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/test/Core.Components.Gis.Test/Data/MapPolygonDataTest.cs (.../MapPolygonDataTest.cs) (revision 2117ba3d745d5776cefdf94dc86ac8d5950aa31e) +++ Core/Components/test/Core.Components.Gis.Test/Data/MapPolygonDataTest.cs (.../MapPolygonDataTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using Core.Common.Base.Geometry; @@ -20,7 +21,7 @@ TestDelegate test = () => new MapPolygonData(null, "test data"); // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, string.Format("A feature collection is required when creating a subclass of {0}.", typeof(FeatureBasedMapData))); + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, string.Format("A feature collection is required when creating a subclass of {0}.", typeof(FeatureBasedMapData))); } [Test] @@ -30,11 +31,14 @@ public void Constructor_InvalidName_ThrowsArgumentException(string invalidName) { // Setup - var features = new Collection + var features = new Collection { new MapFeature(new Collection { - new MapGeometry(Enumerable.Empty()) + new MapGeometry(new[] + { + Enumerable.Empty() + }) }) }; @@ -46,14 +50,45 @@ } [Test] + [TestCase(0)] + [TestCase(2)] + [TestCase(5)] + public void Constructor_InvalidGeometryConfiguration_ThrowArgumentException(int numberOfPointCollections) + { + // Setup + var invalidPointsCollections = new IEnumerable[numberOfPointCollections]; + for (int i = 0; i < numberOfPointCollections; i++) + { + invalidPointsCollections[i] = CreateOuterRingPoint2Ds(); + } + var features = new[] + { + new MapFeature(new[] + { + new MapGeometry(invalidPointsCollections), + }) + }; + + // Call + TestDelegate call = () => new MapPolygonData(features, "Some invalid map data"); + + // Assert + string expectedMessage = "MapPolygonData only accept MapFeature instances whose MapGeometries contain a single point-collection."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] public void Constructor_WithEmptyPoints_CreatesNewMapPolygonData() { // Setup - var features = new Collection + var features = new Collection { new MapFeature(new Collection { - new MapGeometry(Enumerable.Empty()) + new MapGeometry(new[] + { + Enumerable.Empty() + }) }) }; @@ -73,7 +108,7 @@ { new MapFeature(new Collection { - new MapGeometry(CreateTestPoints()) + new MapGeometry(CreateTestPointsCollections()) }) }; @@ -83,18 +118,21 @@ // Assert Assert.IsInstanceOf(data); Assert.AreNotSame(features, data.Features); - CollectionAssert.AreEqual(CreateTestPoints(), data.Features.First().MapGeometries.First().Points); + CollectionAssert.AreEqual(CreateTestPointsCollections(), data.Features.First().MapGeometries.First().PointCollections); } [Test] public void Constructor_WithName_SetsName() { // Setup - var features = new Collection + var features = new Collection { new MapFeature(new Collection { - new MapGeometry(Enumerable.Empty()) + new MapGeometry(new[] + { + Enumerable.Empty() + }) }) }; var name = "Some name"; @@ -106,10 +144,18 @@ Assert.AreEqual(name, data.Name); } - private static Collection CreateTestPoints() + private static IEnumerable> CreateTestPointsCollections() { - return new Collection + return new[] { + CreateOuterRingPoint2Ds() + }; + } + + private static Point2D[] CreateOuterRingPoint2Ds() + { + return new [] + { new Point2D(0.0, 1.1), new Point2D(1.0, 2.1), new Point2D(1.6, 1.6) Index: Core/Components/test/Core.Components.Gis.Test/Features/MapFeatureTest.cs =================================================================== diff -u -r354027b2a36a779798852d3edadaaf339140295c -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/test/Core.Components.Gis.Test/Features/MapFeatureTest.cs (.../MapFeatureTest.cs) (revision 354027b2a36a779798852d3edadaaf339140295c) +++ Core/Components/test/Core.Components.Gis.Test/Features/MapFeatureTest.cs (.../MapFeatureTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -18,7 +18,10 @@ // Setup var mapGeometries = new List { - new MapGeometry(Enumerable.Empty()) + new MapGeometry(new[] + { + Enumerable.Empty() + }) }; // Call Index: Core/Components/test/Core.Components.Gis.Test/Geometries/MapGeometryTest.cs =================================================================== diff -u -r354027b2a36a779798852d3edadaaf339140295c -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Components/test/Core.Components.Gis.Test/Geometries/MapGeometryTest.cs (.../MapGeometryTest.cs) (revision 354027b2a36a779798852d3edadaaf339140295c) +++ Core/Components/test/Core.Components.Gis.Test/Geometries/MapGeometryTest.cs (.../MapGeometryTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -14,18 +14,39 @@ public void ParameteredConstructor_WithPoints_PointsSet() { // Setup - var points = new List + var list1 = new List { - new Point2D(0.1, 1.3), - new Point2D(2.1, 5.3), - new Point2D(3.8, 1.1) + new Point2D(1.1, 2.2), + new Point2D(3.3, 4.4), + new Point2D(5.5, 6.6) }; + var list2 = new List + { + new Point2D(7.7, 8.8), + new Point2D(9.9, 10.1), + new Point2D(11.11, 12.12) + }; + + var list3 = new List + { + new Point2D(13.13, 14.14), + new Point2D(15.15, 16.16), + new Point2D(17.17, 18.18) + }; + + var geometriesList = new List> + { + list1, + list2, + list3 + }; + // Call - var mapGeometry = new MapGeometry(points); + var mapGeometry = new MapGeometry(geometriesList); // Assert - CollectionAssert.AreEqual(points, mapGeometry.Points); + CollectionAssert.AreEqual(geometriesList, mapGeometry.PointCollections); } [Test] Index: Core/Plugins/test/Core.Plugins.DotSpatial.Test/Forms/MapDataViewTest.cs =================================================================== diff -u -recef7aa46cb8fb7d138a5cc00a35f9e7aa7676b6 -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Plugins/test/Core.Plugins.DotSpatial.Test/Forms/MapDataViewTest.cs (.../MapDataViewTest.cs) (revision ecef7aa46cb8fb7d138a5cc00a35f9e7aa7676b6) +++ Core/Plugins/test/Core.Plugins.DotSpatial.Test/Forms/MapDataViewTest.cs (.../MapDataViewTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -82,11 +82,14 @@ public void Data_SetToMapCollectionData_MapDataSet() { // Setup - var features = new Collection + var features = new Collection { new MapFeature(new Collection { - new MapGeometry(Enumerable.Empty()) + new MapGeometry(new[] + { + Enumerable.Empty() + }) }) }; Index: Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapLegendViewTest.cs =================================================================== diff -u -r354027b2a36a779798852d3edadaaf339140295c -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapLegendViewTest.cs (.../MapLegendViewTest.cs) (revision 354027b2a36a779798852d3edadaaf339140295c) +++ Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapLegendViewTest.cs (.../MapLegendViewTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -167,11 +167,14 @@ private Collection CreateFeature() { - return new Collection + return new Collection { new MapFeature(new Collection { - new MapGeometry(Enumerable.Empty()) + new MapGeometry(new[] + { + Enumerable.Empty() + }) }) }; } Index: Demo/Ringtoets/src/Demo.Ringtoets/Commands/OpenMapViewCommand.cs =================================================================== diff -u -r2117ba3d745d5776cefdf94dc86ac8d5950aa31e -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Demo/Ringtoets/src/Demo.Ringtoets/Commands/OpenMapViewCommand.cs (.../OpenMapViewCommand.cs) (revision 2117ba3d745d5776cefdf94dc86ac8d5950aa31e) +++ Demo/Ringtoets/src/Demo.Ringtoets/Commands/OpenMapViewCommand.cs (.../OpenMapViewCommand.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -166,11 +166,14 @@ private IEnumerable GetFeatureWithPoints(Collection points) { - return new Collection + return new Collection { new MapFeature(new Collection { - new MapGeometry(points) + new MapGeometry(new[] + { + points + }) }) }; } Index: Ringtoets/Common/src/Ringtoets.Common.IO/FailureMechanismSectionReader.cs =================================================================== diff -u -ra9aafffab97152303562110b1d789bacb465ce24 -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Ringtoets/Common/src/Ringtoets.Common.IO/FailureMechanismSectionReader.cs (.../FailureMechanismSectionReader.cs) (revision a9aafffab97152303562110b1d789bacb465ce24) +++ Ringtoets/Common/src/Ringtoets.Common.IO/FailureMechanismSectionReader.cs (.../FailureMechanismSectionReader.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -146,7 +146,7 @@ throw new CriticalFileReadException(RingtoetsCommonIOResources.FailureMechanismSectionReader_File_has_unsupported_multiPolyline); } - var feature = features.First(); + var feature = features[0]; string name = GetSectionName(feature); IEnumerable geometryPoints = GetSectionGeometry(feature); @@ -166,7 +166,7 @@ throw new CriticalFileReadException(RingtoetsCommonIOResources.FailureMechanismSectionReader_File_has_unsupported_multiPolyline); } - return mapGeometries.First().Points.Select(p => new Point2D(p.X, p.Y)); + return mapGeometries[0].PointCollections.First().Select(p => new Point2D(p.X, p.Y)); } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineReader.cs =================================================================== diff -u -ra9aafffab97152303562110b1d789bacb465ce24 -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineReader.cs (.../ReferenceLineReader.cs) (revision a9aafffab97152303562110b1d789bacb465ce24) +++ Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineReader.cs (.../ReferenceLineReader.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -28,6 +28,7 @@ using Core.Common.Utils; using Core.Common.Utils.Builders; using Core.Components.Gis.Data; +using Core.Components.Gis.Geometries; using Core.Components.Gis.IO; using Core.Components.Gis.IO.Readers; using Ringtoets.Common.Data; @@ -149,8 +150,8 @@ throw new CriticalFileReadException(message); } - var referenceGeometry = referenceGeometries.First(); - referenceLine.SetGeometry(referenceGeometry.Points.Select(t => new Point2D(t.X, t.Y))); + MapGeometry referenceGeometry = referenceGeometries[0]; + referenceLine.SetGeometry(referenceGeometry.PointCollections.First().Select(t => new Point2D(t.X, t.Y))); return referenceLine; } } Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/MapDataFactory.cs =================================================================== diff -u -ra9aafffab97152303562110b1d789bacb465ce24 -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/MapDataFactory.cs (.../MapDataFactory.cs) (revision a9aafffab97152303562110b1d789bacb465ce24) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/MapDataFactory.cs (.../MapDataFactory.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -107,14 +107,16 @@ private static IEnumerable GetMapFeature(IEnumerable points) { - var features = new List + return new[] { - new MapFeature(new List + new MapFeature(new[] { - new MapGeometry(points) + new MapGeometry(new[] + { + points + }) }) }; - return features; } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/MapDataFactoryTest.cs =================================================================== diff -u -ra9aafffab97152303562110b1d789bacb465ce24 -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/MapDataFactoryTest.cs (.../MapDataFactoryTest.cs) (revision a9aafffab97152303562110b1d789bacb465ce24) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/MapDataFactoryTest.cs (.../MapDataFactoryTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -29,7 +29,6 @@ using Core.Components.Gis.Geometries; using Core.Components.Gis.Style; using NUnit.Framework; -using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.HydraRing.Data; @@ -158,7 +157,7 @@ private void AssertEqualPointCollections(IEnumerable points, MapGeometry geometry) { - CollectionAssert.AreEqual(points.Select(p => new Point2D(p.X, p.Y)), geometry.Points); + CollectionAssert.AreEqual(points.Select(p => new Point2D(p.X, p.Y)), geometry.PointCollections.First()); } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs =================================================================== diff -u -rfa424689d48793c024e73bfcee1c202559eea3e0 -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision fa424689d48793c024e73bfcee1c202559eea3e0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -150,7 +150,6 @@ new FailureMechanismPlaceholder("A") }; var contribution = new FailureMechanismContribution(failureMechanisms, 10.0, 2); - var comments = "some comment"; var assessmentSection = mocks.Stub(); assessmentSection.Stub(section => section.FailureMechanismContribution).Return(contribution); Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssessmentSectionViewTest.cs =================================================================== diff -u -rf1bd17ba95b3fbae5928d4240523d50d8b83b64d -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssessmentSectionViewTest.cs (.../AssessmentSectionViewTest.cs) (revision f1bd17ba95b3fbae5928d4240523d50d8b83b64d) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssessmentSectionViewTest.cs (.../AssessmentSectionViewTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -130,12 +130,12 @@ Assert.IsNotNull(mapData); var hrLocationsMapData = (MapPointData) mapData.List[0]; - CollectionAssert.AreEqual(hydraulicBoundaryDatabase.Locations.Select(l => l.Location), hrLocationsMapData.Features.First().MapGeometries.First().Points); + CollectionAssert.AreEqual(hydraulicBoundaryDatabase.Locations.Select(l => l.Location), hrLocationsMapData.Features.First().MapGeometries.First().PointCollections.First()); Assert.AreEqual("Hydraulische randvoorwaarden", hrLocationsMapData.Name); Assert.IsTrue(hrLocationsMapData.IsVisible); var referenceLineMapData = (MapLineData) mapData.List[1]; - CollectionAssert.AreEqual(referenceLine.Points, referenceLineMapData.Features.First().MapGeometries.First().Points); + CollectionAssert.AreEqual(referenceLine.Points, referenceLineMapData.Features.First().MapGeometries.First().PointCollections.First()); Assert.AreEqual("Referentielijn", referenceLineMapData.Name); Assert.IsTrue(referenceLineMapData.IsVisible); } @@ -156,11 +156,11 @@ view.Data = assessmentSection; var mapData = map.Data; - var mapDataElementBeforeUpdate = mapData.List.First() as MapPointData; - var geometryBeforeUpdate = mapDataElementBeforeUpdate.Features.First().MapGeometries.First().Points.First(); + var mapDataElementBeforeUpdate = (MapPointData)mapData.List.First(); + var geometryBeforeUpdate = mapDataElementBeforeUpdate.Features.First().MapGeometries.First().PointCollections.First(); // Precondition - Assert.AreEqual(geometryBeforeUpdate, new Point2D(1.0, 2.0)); + Assert.AreEqual(new Point2D(1.0, 2.0), geometryBeforeUpdate.First()); assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); assessmentSection.HydraulicBoundaryDatabase.Locations.Add(new HydraulicBoundaryLocation(2, "test2", 2.0, 3.0)); @@ -173,10 +173,10 @@ Assert.AreEqual(mapData, map.Data); CollectionAssert.AreEquivalent(mapData.List, map.Data.List); - var mapDataElementAfterUpdate = map.Data.List.First() as MapPointData; - var geometryAfterUpdate = mapDataElementAfterUpdate.Features.First().MapGeometries.First().Points.First(); + var mapDataElementAfterUpdate = (MapPointData)map.Data.List.First(); + var geometryAfterUpdate = mapDataElementAfterUpdate.Features.First().MapGeometries.First().PointCollections.First(); - Assert.AreEqual(geometryAfterUpdate, new Point2D(2.0, 3.0)); + Assert.AreEqual(new Point2D(2.0, 3.0), geometryAfterUpdate.First()); } [Test] @@ -207,8 +207,8 @@ view.Data = assessmentSection; var mapData = map.Data; - var mapDataElementBeforeUpdate = mapData.List.ElementAt(1) as MapLineData; - var geometryBeforeUpdate = mapDataElementBeforeUpdate.Features.First().MapGeometries.First().Points; + var mapDataElementBeforeUpdate = (MapLineData)mapData.List.ElementAt(1); + var geometryBeforeUpdate = mapDataElementBeforeUpdate.Features.First().MapGeometries.First().PointCollections.First(); // Precondition CollectionAssert.AreEquivalent(geometryBeforeUpdate, points); @@ -224,8 +224,8 @@ Assert.AreEqual(mapData, map.Data); CollectionAssert.AreEquivalent(mapData.List, map.Data.List); - var mapDataElementAfterUpdate = map.Data.List.ElementAt(1) as MapLineData; - var geometryAfterUpdate = mapDataElementAfterUpdate.Features.First().MapGeometries.First().Points; + var mapDataElementAfterUpdate = (MapLineData)map.Data.List.ElementAt(1); + var geometryAfterUpdate = mapDataElementAfterUpdate.Features.First().MapGeometries.First().PointCollections.First(); CollectionAssert.AreEquivalent(geometryAfterUpdate, pointsUpdate); } Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingMapDataFactory.cs =================================================================== diff -u -r9b82ed0cf3ec503d05ac1e21243e9c1e1177b9b2 -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingMapDataFactory.cs (.../PipingMapDataFactory.cs) (revision 9b82ed0cf3ec503d05ac1e21243e9c1e1177b9b2) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingMapDataFactory.cs (.../PipingMapDataFactory.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -58,7 +58,10 @@ var mapFeatures = new List { - new MapFeature(surfaceLines.Select(surfaceLine => new MapGeometry(surfaceLine.Points.Select(p => new Point2D(p.X, p.Y))))) + new MapFeature(surfaceLines.Select(surfaceLine => new MapGeometry(new[] + { + surfaceLine.Points.Select(p => new Point2D(p.X, p.Y)) + }))) }; return new MapLineData(mapFeatures, Resources.PipingSurfaceLinesCollection_DisplayName) @@ -82,7 +85,10 @@ var mapFeatures = new List { - new MapFeature(stochasticSoilModels.Select(stochasticSoilModel => new MapGeometry(stochasticSoilModel.Geometry.Select(p => new Point2D(p.X, p.Y))))) + new MapFeature(stochasticSoilModels.Select(stochasticSoilModel => new MapGeometry(new[] + { + stochasticSoilModel.Geometry.Select(p => new Point2D(p.X, p.Y)) + }))) }; return new MapLineData(mapFeatures, Resources.StochasticSoilModelCollection_DisplayName) @@ -106,7 +112,10 @@ var mapFeatures = new List { - new MapFeature(sections.Select(section => new MapGeometry(section.Points.Select(p => new Point2D(p.X, p.Y))))) + new MapFeature(sections.Select(section => new MapGeometry(new[] + { + section.Points.Select(p => new Point2D(p.X, p.Y)) + }))) }; return new MapLineData(mapFeatures, Common.Forms.Properties.Resources.FailureMechanism_Sections_DisplayName) @@ -227,14 +236,16 @@ private static IEnumerable GetMapFeature(IEnumerable points) { - var features = new List + return new[] { - new MapFeature(new List + new MapFeature(new[] { - new MapGeometry(points) + new MapGeometry(new[] + { + points + }) }) }; - return features; } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismViewTest.cs =================================================================== diff -u -r9b82ed0cf3ec503d05ac1e21243e9c1e1177b9b2 -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismViewTest.cs (.../PipingFailureMechanismViewTest.cs) (revision 9b82ed0cf3ec503d05ac1e21243e9c1e1177b9b2) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismViewTest.cs (.../PipingFailureMechanismViewTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -224,11 +224,11 @@ view.Data = pipingContext; var mapData = map.Data; - var mapDataElementBeforeUpdate = mapData.List.ElementAt(hydraulicLocationsLayerIndex) as MapPointData; - var geometryBeforeUpdate = mapDataElementBeforeUpdate.Features.First().MapGeometries.First().Points.First(); + var mapDataElementBeforeUpdate = (MapPointData)mapData.List.ElementAt(hydraulicLocationsLayerIndex); + var geometryBeforeUpdate = mapDataElementBeforeUpdate.Features.First().MapGeometries.First().PointCollections.First(); // Precondition - Assert.AreEqual(geometryBeforeUpdate, new Point2D(1.0, 2.0)); + Assert.AreEqual(new Point2D(1.0, 2.0), geometryBeforeUpdate.First()); var hydraulicBoundaryDatabase2 = new HydraulicBoundaryDatabase(); hydraulicBoundaryDatabase2.Locations.Add(new HydraulicBoundaryLocation(2, "test2", 2.0, 3.0)); @@ -243,10 +243,10 @@ Assert.AreEqual(mapData, map.Data); CollectionAssert.AreEquivalent(mapData.List, map.Data.List); - var mapDataElementAfterUpdate = map.Data.List.ElementAt(hydraulicLocationsLayerIndex) as MapPointData; - var geometryAfterUpdate = mapDataElementAfterUpdate.Features.First().MapGeometries.First().Points.First(); + var mapDataElementAfterUpdate = (MapPointData)map.Data.List.ElementAt(hydraulicLocationsLayerIndex); + var geometryAfterUpdate = mapDataElementAfterUpdate.Features.First().MapGeometries.First().PointCollections.First(); - Assert.AreEqual(geometryAfterUpdate, new Point2D(2.0, 3.0)); + Assert.AreEqual(new Point2D(2.0, 3.0), geometryAfterUpdate.First()); } [Test] @@ -280,11 +280,11 @@ view.Data = pipingContext; var mapData = map.Data; - var mapDataElementBeforeUpdate = mapData.List.ElementAt(referenceLineLayerIndex) as MapLineData; - var geometryBeforeUpdate = mapDataElementBeforeUpdate.Features.First().MapGeometries.First().Points; + var mapDataElementBeforeUpdate = (MapLineData)mapData.List.ElementAt(referenceLineLayerIndex); + var geometryBeforeUpdate = mapDataElementBeforeUpdate.Features.First().MapGeometries.First().PointCollections.First(); // Precondition - CollectionAssert.AreEquivalent(geometryBeforeUpdate, points); + CollectionAssert.AreEquivalent(points, geometryBeforeUpdate); assessmentSection.ReferenceLine.SetGeometry(pointsUpdate); @@ -296,10 +296,10 @@ Assert.AreEqual(mapData, map.Data); CollectionAssert.AreEquivalent(mapData.List, map.Data.List); - var mapDataElementAfterUpdate = map.Data.List.ElementAt(referenceLineLayerIndex) as MapLineData; - var geometryAfterUpdate = mapDataElementAfterUpdate.Features.First().MapGeometries.First().Points; + var mapDataElementAfterUpdate = (MapLineData)map.Data.List.ElementAt(referenceLineLayerIndex); + var geometryAfterUpdate = mapDataElementAfterUpdate.Features.First().MapGeometries.First().PointCollections.First(); - CollectionAssert.AreEquivalent(geometryAfterUpdate, pointsUpdate); + CollectionAssert.AreEquivalent(pointsUpdate, geometryAfterUpdate); } [Test] @@ -569,11 +569,11 @@ var referenceLineData = (MapLineData) mapData; if (referenceLine == null) { - CollectionAssert.IsEmpty(referenceLineData.Features.First().MapGeometries.First().Points); + CollectionAssert.IsEmpty(referenceLineData.Features.First().MapGeometries.First().PointCollections.First()); } else { - CollectionAssert.AreEqual(referenceLine.Points, referenceLineData.Features.First().MapGeometries.First().Points); + CollectionAssert.AreEqual(referenceLine.Points, referenceLineData.Features.First().MapGeometries.First().PointCollections.First()); } Assert.AreEqual("Referentielijn", mapData.Name); } @@ -584,11 +584,11 @@ var hydraulicLocationsMapData = (MapPointData) mapData; if (database == null) { - CollectionAssert.IsEmpty(hydraulicLocationsMapData.Features.First().MapGeometries.First().Points); + CollectionAssert.IsEmpty(hydraulicLocationsMapData.Features.First().MapGeometries.First().PointCollections.First()); } else { - CollectionAssert.AreEqual(database.Locations.Select(hrp => hrp.Location), hydraulicLocationsMapData.Features.First().MapGeometries.First().Points); + CollectionAssert.AreEqual(database.Locations.Select(hrp => hrp.Location), hydraulicLocationsMapData.Features.First().MapGeometries.First().PointCollections.First()); } Assert.AreEqual("Hydraulische randvoorwaarden", mapData.Name); } @@ -607,7 +607,7 @@ for (int index = 0; index < sectionsArray.Length; index++) { var failureMechanismSection = sectionsArray[index]; - CollectionAssert.AreEquivalent(geometries[index].Points, failureMechanismSection.Points); + CollectionAssert.AreEquivalent(failureMechanismSection.Points, geometries[index].PointCollections.First()); } Assert.AreEqual("Vakindeling", mapData.Name); } @@ -616,15 +616,15 @@ { Assert.IsInstanceOf(mapData); var sectionsStartPointData = (MapPointData) mapData; - CollectionAssert.AreEqual(sections.Select(s => s.GetStart()), sectionsStartPointData.Features.First().MapGeometries.First().Points); + CollectionAssert.AreEqual(sections.Select(s => s.GetStart()), sectionsStartPointData.Features.First().MapGeometries.First().PointCollections.First()); Assert.AreEqual("Vakindeling (startpunten)", mapData.Name); } private void AssertFailureMechanismSectionsEndPointMapData(IEnumerable sections, MapData mapData) { Assert.IsInstanceOf(mapData); var sectionsStartPointData = (MapPointData) mapData; - CollectionAssert.AreEqual(sections.Select(s => s.GetLast()), sectionsStartPointData.Features.First().MapGeometries.First().Points); + CollectionAssert.AreEqual(sections.Select(s => s.GetLast()), sectionsStartPointData.Features.First().MapGeometries.First().PointCollections.First()); Assert.AreEqual("Vakindeling (eindpunten)", mapData.Name); } @@ -642,7 +642,7 @@ for (int index = 0; index < surfaceLinesArray.Length; index++) { var surfaceLine = surfaceLinesArray[index]; - CollectionAssert.AreEquivalent(geometries[index].Points, surfaceLine.Points.Select(p => new Point2D(p.X, p.Y))); + CollectionAssert.AreEquivalent(surfaceLine.Points.Select(p => new Point2D(p.X, p.Y)), geometries[index].PointCollections.First()); } Assert.AreEqual("Profielschematisaties", mapData.Name); } @@ -661,7 +661,7 @@ for (int index = 0; index < stochasticSoilModelsArray.Length; index++) { var stochasticSoilModel = stochasticSoilModelsArray[index]; - CollectionAssert.AreEquivalent(geometries[index].Points, stochasticSoilModel.Geometry.Select(p => new Point2D(p.X, p.Y))); + CollectionAssert.AreEquivalent(stochasticSoilModel.Geometry.Select(p => new Point2D(p.X, p.Y)), geometries[index].PointCollections.First()); } Assert.AreEqual("Stochastisch ondergrondmodellen", mapData.Name); } Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingMapDataFactoryTest.cs =================================================================== diff -u -r9b82ed0cf3ec503d05ac1e21243e9c1e1177b9b2 -r04b631b486b742c5339deb1d5504bb13ab5e248d --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingMapDataFactoryTest.cs (.../PipingMapDataFactoryTest.cs) (revision 9b82ed0cf3ec503d05ac1e21243e9c1e1177b9b2) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingMapDataFactoryTest.cs (.../PipingMapDataFactoryTest.cs) (revision 04b631b486b742c5339deb1d5504bb13ab5e248d) @@ -418,7 +418,7 @@ private void AssertEqualPointCollections(IEnumerable points, MapGeometry geometry) { - CollectionAssert.AreEqual(points.Select(p => new Point2D(p.X, p.Y)), geometry.Points); + CollectionAssert.AreEqual(points.Select(p => new Point2D(p.X, p.Y)), geometry.PointCollections.First()); } } } \ No newline at end of file