コード例 #1
0
        public static SqlCommand CreateCommand(MapFeature mapFeature, bool geographyMode, int srid, string tableName, 
            string placemarkColumnName, SqlConnection connection)
        {
            StringBuilder sbColumns = new StringBuilder();
            StringBuilder sbValues = new StringBuilder();
            foreach (KeyValuePair<string, string> simpleData in mapFeature.Data)
            {
                sbColumns.Append(simpleData.Key + ",");
                sbValues.Append("@" + simpleData.Key + ",");
            }
            StringBuilder sb = new StringBuilder();
            sb.Append(ParseCoordinates(srid, mapFeature, geographyMode));
            sb.Append(string.Format("INSERT INTO {0}(Id,{1}{2}) VALUES(@Id,{3}@placemark)", tableName, sbColumns, placemarkColumnName, sbValues));
            string sqlCommandText = sb.ToString();
            SqlCommand sqlCommand = new SqlCommand(sqlCommandText, connection);
            sqlCommand.Parameters.AddWithValue("@Id", mapFeature.Id);
            foreach (KeyValuePair<string, string> simpleData in mapFeature.Data)
            {
                sqlCommand.Parameters.AddWithValue("@" + simpleData.Key, simpleData.Value);
            }
            //string UdtType;
            //if (geographyMode)
            //    UdtType = "Geography";
            //else
            //    UdtType = "Geometry";

            //sqlCommand.Parameters.Add(new SqlParameter("@placemark", parseCoordinates(srid, mapFeature, geographyMode)) { UdtTypeName = UdtType });
            return sqlCommand;
        }
コード例 #2
0
 private static string ParseCoordinatesGeography(int srid, MapFeature mapFeature)
 {
     StringBuilder commandString = new StringBuilder();
     commandString.Append(ParseCoordinatesGeometry(srid, mapFeature));
     commandString.Append("DECLARE @validGeo geography;");
     commandString.Append("SET @validGeo = geography::STGeomFromText(@validGeom.STAsText(), " + srid + @");");
     return commandString.ToString();
 }
コード例 #3
0
 private static string ParseCoordinatesGeometry(int srid, MapFeature mapFeature)
 {
     StringBuilder commandString = new StringBuilder();
     switch (mapFeature.GeometryType)
     {
         case OpenGisGeometryType.Polygon:
             {
                 commandString.Append(@"DECLARE @geom geometry;
                                 SET @geom = geometry::STPolyFromText('POLYGON((");
                 foreach (Vector coordinate in mapFeature.Coordinates)
                 {
                     commandString.Append(coordinate.Longitude + " " + coordinate.Latitude + ", ");
                 }
                 commandString.Remove(commandString.Length - 2, 2).ToString();
                 commandString.Append(@"))', " + srid + @");");
                 commandString.Append("DECLARE @validGeom geometry;");
                 commandString.Append("SET @validGeom = @geom.MakeValid().STUnion(@geom.STStartPoint());");
             }
             break;
         case OpenGisGeometryType.LineString:
             {
                 commandString.Append(@"DECLARE @validGeom geometry;
                             SET @validGeom = geometry::STLineFromText('LINESTRING (");
                 foreach (Vector coordinate in mapFeature.Coordinates)
                 {
                     commandString.Append(coordinate.Longitude + " " + coordinate.Latitude + ", ");
                 }
                 commandString.Remove(commandString.Length - 2, 2).ToString();
                 commandString.Append(@")', " + srid + @");");
                 //commandString.Append("DECLARE @validGeom geometry;");
                 //commandString.Append("SET @validGeom = @geom.MakeValid().STUnion(@geom.STStartPoint());");
             }
             break;
         case OpenGisGeometryType.Point:
             {
                 commandString.Append(@"DECLARE @validGeom geometry;");
                 commandString.Append("SET @validGeom = geometry::STPointFromText('POINT (");
                 commandString.Append(mapFeature.Coordinates[0].Longitude + " " + mapFeature.Coordinates[0].Latitude);
                 commandString.Append(@")', " + srid + @");");
             }
             break;
         default:
         {
             //Do nothing. It's probably polygon point we don't support.
         }
             break;
     }
     return commandString.ToString();
 }
コード例 #4
0
 private static string ParseCoordinates(int srid, MapFeature mapFeature, bool geographyMode)
 {
     StringBuilder commandString = new StringBuilder();
     if (geographyMode)
     {
         commandString.Append(ParseCoordinatesGeography(srid, mapFeature));
         commandString.Append("DECLARE @placemark geography;");
         commandString.Append("SET @placemark = @validGeo;");
     }
     else
     {
         commandString.Append(ParseCoordinatesGeometry(srid, mapFeature));
         commandString.Append("DECLARE @placemark geometry;");
         commandString.Append("SET @placemark = @validGeom;");
     }
     return commandString.ToString();
 }
コード例 #5
0
        public void CopyToFeature_FeatureContainsNoGeometries_ThrowsArgumentException()
        {
            // Setup
            var feature = new MapFeature(new MapGeometry[0]);

            var mapData = new MapPointData("test")
            {
                Features = new[]
                {
                    feature
                }
            };

            using (var writer = new PointShapeFileWriter())
            {
                // Call
                TestDelegate call = () => writer.CopyToFeature(mapData);

                // Assert
                TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(call, "Een feature mag maar één geometrie bevatten.");
            }
        }
コード例 #6
0
        /// <summary>
        /// Create reference line features based on the provided <paramref name="referenceLine"/>.
        /// </summary>
        /// <param name="referenceLine">The <see cref="ReferenceLine"/> to create the reference
        /// line features for.</param>
        /// <param name="id">The id of the <see cref="IAssessmentSection"/>.</param>
        /// <param name="name">The name of the <see cref="IAssessmentSection"/>.</param>
        /// <returns>A collection of features or an empty collection when <paramref name="referenceLine"/>
        /// has no geometry.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="referenceLine"/>
        /// is <c>null</c>.</exception>
        public static IEnumerable <MapFeature> CreateReferenceLineFeatures(ReferenceLine referenceLine, string id, string name)
        {
            if (referenceLine == null)
            {
                throw new ArgumentNullException(nameof(referenceLine));
            }

            if (referenceLine.Points.Any())
            {
                MapFeature feature = CreateSingleLineMapFeature(referenceLine.Points);
                feature.MetaData[RiskeerCommonUtilResources.MetaData_ID]   = id;
                feature.MetaData[RiskeerCommonUtilResources.MetaData_Name] = name;
                feature.MetaData[Resources.MetaData_Length_Rounded]        = new RoundedDouble(2, referenceLine.Length);

                return(new[]
                {
                    feature
                });
            }

            return(new MapFeature[0]);
        }
コード例 #7
0
        /// <summary>
        /// Create features for the geometry of the <paramref name="structures"/>.
        /// </summary>
        /// <param name="structures">The profiles to create features for.</param>
        /// <returns>A collection of features or an empty collection when <paramref name="structures"/> is
        /// <c>null</c> or empty.</returns>
        public static IEnumerable <MapFeature> CreateStructuresFeatures(IEnumerable <StructureBase> structures)
        {
            if (structures != null)
            {
                int nrOfElements = structures.Count();
                var mapFeatures  = new MapFeature[nrOfElements];

                var i = 0;
                foreach (StructureBase structure in structures)
                {
                    MapFeature feature = RiskeerMapDataFeaturesFactoryHelper.CreateSinglePointMapFeature(structure.Location);
                    feature.MetaData[RiskeerCommonUtilResources.MetaData_Name] = structure.Name;

                    mapFeatures[i] = feature;
                    i++;
                }

                return(mapFeatures);
            }

            return(new MapFeature[0]);
        }
コード例 #8
0
        /// <summary>
        /// Create features for the geometry of the <paramref name="dikeProfiles"/>.
        /// </summary>
        /// <param name="dikeProfiles">The profiles to create features for.</param>
        /// <returns>A collection of features or an empty collection when <paramref name="dikeProfiles"/> is
        /// <c>null</c> or empty.</returns>
        public static IEnumerable <MapFeature> CreateDikeProfilesFeatures(IEnumerable <DikeProfile> dikeProfiles)
        {
            if (dikeProfiles != null)
            {
                int nrOfElements = dikeProfiles.Count();
                var mapFeatures  = new MapFeature[nrOfElements];

                var i = 0;
                foreach (DikeProfile dikeProfile in dikeProfiles)
                {
                    MapFeature feature = CreateSingleLineMapFeature(GetWorldPoints(dikeProfile));
                    feature.MetaData[RiskeerCommonUtilResources.MetaData_Name] = dikeProfile.Name;

                    mapFeatures[i] = feature;
                    i++;
                }

                return(mapFeatures);
            }

            return(new MapFeature[0]);
        }
コード例 #9
0
        public void ConvertLayerFeatures_MapPolygonDataWithMultipleGeometryFeature_ConvertsFeatureToMapPolygonLayerAsMultiPolygonData()
        {
            // Setup
            var converter       = new MapPolygonDataConverter();
            var mapPolygonLayer = new MapPolygonLayer();
            var mapFeature      = new MapFeature(new[]
            {
                new MapGeometry(new[]
                {
                    CreateRectangularRing(2.0, 4.0)
                }),
                new MapGeometry(new[]
                {
                    CreateRectangularRing(6.0, 8.0)
                })
            });

            var mapPolygonData = new MapPolygonData("test data")
            {
                Features = new[]
                {
                    mapFeature
                }
            };

            // Call
            converter.ConvertLayerFeatures(mapPolygonData, mapPolygonLayer);

            // Assert
            IFeature feature = mapPolygonLayer.DataSet.Features[0];

            Assert.AreEqual(mapPolygonData.Features.Count(), mapPolygonLayer.DataSet.Features.Count);
            Assert.IsInstanceOf <MultiPolygon>(feature.Geometry);

            IEnumerable <Coordinate> expectedCoordinates = mapFeature.MapGeometries.SelectMany(mg => mg.PointCollections.ElementAt(0).Select(p => new Coordinate(p.X, p.Y)));

            CollectionAssert.AreEqual(expectedCoordinates, feature.Geometry.Coordinates);
        }
コード例 #10
0
        /// <summary>
        /// Create a new instance of <see cref="MapLineData"/> from a reference line and a traject id.
        /// </summary>
        /// <param name="referenceLine">The <see cref="ReferenceLine"/> supplying the geometry information
        /// for the new <see cref="MapLineData"/> object.</param>
        /// <param name="id">The id of the assessment section to which the reference line is associated.</param>
        /// <returns>A new instance of <see cref="MapLineData"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="referenceLine"/> or <paramref name="id"/>
        /// is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="id"/> is empty or consists only of whitespace.</exception>
        private static MapLineData CreateMapLineData(ReferenceLine referenceLine, string id)
        {
            if (referenceLine == null)
            {
                throw new ArgumentNullException(nameof(referenceLine));
            }

            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentException(Resources.ReferenceLineWriter_CreateMapLineData_Traject_cannot_be_empty, nameof(id));
            }

            var referenceLineGeometry = new MapGeometry(
                new List <IEnumerable <Point2D> >
            {
                referenceLine.Points
            });

            var mapFeature = new MapFeature(new[]
            {
                referenceLineGeometry
            });

            mapFeature.MetaData.Add(Resources.ReferenceLineWriter_CreateMapLineData_Traject_id, id);

            return(new MapLineData(RiskeerCommonDataResources.ReferenceLine_DisplayName)
            {
                Features = new[]
                {
                    mapFeature
                }
            });
        }
        public void CreateHydraulicBoundaryLocationCalculationFeature_WithData_ReturnFeature(bool calculationHasOutput)
        {
            // Setup
            const string metaDataHeader = "header";
            var          calculation    = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation("location 1"));

            if (calculationHasOutput)
            {
                calculation.Output = new TestHydraulicBoundaryLocationCalculationOutput();
            }

            // Call
            MapFeature feature = HydraulicBoundaryLocationMapDataFeaturesFactory.CreateHydraulicBoundaryLocationCalculationFeature(
                calculation, metaDataHeader);

            // Assert
            RoundedDouble expectedMetaDataValue = calculationHasOutput
                                                      ? calculation.Output.Result
                                                      : RoundedDouble.NaN;

            MapFeaturesMetaDataTestHelper.AssertMetaData(expectedMetaDataValue.ToString(),
                                                         feature, metaDataHeader);
        }
コード例 #12
0
        private static MapFeature CreateMapFeatureWithMetaData(string metadataAttributeName)
        {
            var random     = new Random(21);
            var point1     = new Point2D(random.NextDouble(), random.NextDouble());
            var point2     = new Point2D(random.NextDouble(), random.NextDouble());
            var mapFeature = new MapFeature(new[]
            {
                new MapGeometry(new[]
                {
                    new[]
                    {
                        point1,
                        point2,
                        point2,
                        point1
                    }
                })
            });

            mapFeature.MetaData[metadataAttributeName] = new object();

            return(mapFeature);
        }
        public void AddTargetProbabilityMetaData_WithAllData_AddsMetaDataItems()
        {
            // Setup
            const string displayNameFormat = "Test - {0}";

            var random              = new Random(21);
            var feature             = new MapFeature(Enumerable.Empty <MapGeometry>());
            var targetProbabilities = new[]
            {
                new Tuple <double, RoundedDouble>(0.01, random.NextRoundedDouble()),
                new Tuple <double, RoundedDouble>(0.01, RoundedDouble.NaN),
                new Tuple <double, RoundedDouble>(0.0001, random.NextRoundedDouble())
            };

            // Call
            HydraulicBoundaryLocationMapDataFeaturesFactory.AddTargetProbabilityMetaData(feature, targetProbabilities, displayNameFormat);

            // Assert
            Assert.AreEqual(3, feature.MetaData.Count);
            MapFeaturesMetaDataTestHelper.AssertMetaData(targetProbabilities[0].Item2.ToString(), feature, string.Format(displayNameFormat, "1/100"));
            MapFeaturesMetaDataTestHelper.AssertMetaData(targetProbabilities[1].Item2.ToString(), feature, string.Format(displayNameFormat, "1/100 (1)"));
            MapFeaturesMetaDataTestHelper.AssertMetaData(targetProbabilities[2].Item2.ToString(), feature, string.Format(displayNameFormat, "1/10.000"));
        }
コード例 #14
0
        public void DynamicReadOnlyValidator_AnyOtherProperty_ReturnsFalse()
        {
            // Setup
            var feature = new MapFeature(Enumerable.Empty <MapGeometry>());

            feature.MetaData["Key"] = "value";

            var mapData = new TestFeatureBasedMapData
            {
                Features = new[]
                {
                    feature
                }
            };

            var properties = new TestFeatureBasedMapDataProperties(mapData, Enumerable.Empty <MapDataCollection>());

            // Call
            bool isOtherPropertyReadOnly = properties.DynamicReadonlyValidator(string.Empty);

            // Assert
            Assert.IsFalse(isOtherPropertyReadOnly);
        }
コード例 #15
0
        /// <summary>
        /// Create features for the geometry of the <paramref name="foreshoreProfiles"/>.
        /// </summary>
        /// <param name="foreshoreProfiles">The profiles to create features for.</param>
        /// <returns>A collection of features or an empty collection when <paramref name="foreshoreProfiles"/>
        /// is <c>null</c> or empty.</returns>
        public static IEnumerable <MapFeature> CreateForeshoreProfilesFeatures(IEnumerable <ForeshoreProfile> foreshoreProfiles)
        {
            if (foreshoreProfiles != null)
            {
                ForeshoreProfile[] foreShoreProfilesWithGeometry = foreshoreProfiles.Where(fp => fp.Geometry != null && fp.Geometry.Any()).ToArray();

                int nrOfElements = foreShoreProfilesWithGeometry.Length;
                var mapFeatures  = new MapFeature[nrOfElements];

                for (var i = 0; i < nrOfElements; i++)
                {
                    ForeshoreProfile foreshoreProfile = foreShoreProfilesWithGeometry[i];
                    MapFeature       feature          = CreateSingleLineMapFeature(GetWorldPoints(foreshoreProfile));
                    feature.MetaData[RiskeerCommonUtilResources.MetaData_Name] = foreshoreProfile.Name;

                    mapFeatures[i] = feature;
                }

                return(mapFeatures);
            }

            return(new MapFeature[0]);
        }
コード例 #16
0
        public void ConvertLayerFeatures_MapPointDataWithFeature_ConvertsFeatureToMapPointLayerAsPointData()
        {
            // Setup
            var converter     = new MapPointDataConverter();
            var mapPointLayer = new MapPointLayer();
            var mapFeature    = new MapFeature(new[]
            {
                new MapGeometry(new[]
                {
                    new[]
                    {
                        new Point2D(1, 2)
                    }
                })
            });

            var mapPointData = new MapPointData("test")
            {
                Features = new[]
                {
                    mapFeature
                }
            };

            // Call
            converter.ConvertLayerFeatures(mapPointData, mapPointLayer);

            // Assert
            IFeature feature = mapPointLayer.DataSet.Features[0];

            Assert.AreEqual(mapPointData.Features.Count(), mapPointLayer.DataSet.Features.Count);
            Assert.IsInstanceOf <Point>(feature.Geometry);

            IEnumerable <Coordinate> expectedCoordinates = mapFeature.MapGeometries.ElementAt(0).PointCollections.ElementAt(0).Select(p => new Coordinate(p.X, p.Y));

            CollectionAssert.AreEqual(expectedCoordinates, feature.Geometry.Coordinates);
        }
コード例 #17
0
        private FeatureBasedMapData ConvertPolygonFeaturesToMapPointData(IEnumerable <IFeature> features, string name)
        {
            int featureCount = features.Count();
            var mapFeatures  = new MapFeature[featureCount];

            for (var i = 0; i < featureCount; i++)
            {
                IFeature   feature    = features.ElementAt(i);
                MapFeature mapFeature = CreateMapFeatureForPolygonFeature(feature);

                CopyMetaDataIntoFeature(mapFeature, i);

                mapFeatures[i] = mapFeature;
            }

            var mapPolygonData = new MapPolygonData(name)
            {
                Features = mapFeatures
            };

            mapPolygonData.SelectedMetaDataAttribute = mapPolygonData.MetaData.FirstOrDefault();

            return(mapPolygonData);
        }
コード例 #18
0
        protected override IEnumerable <IFeature> CreateFeatures(MapFeature mapFeature)
        {
            var geometryList = new List <IPolygon>();

            foreach (MapGeometry mapGeometry in mapFeature.MapGeometries)
            {
                IEnumerable <Point2D>[] pointCollections = mapGeometry.PointCollections.Select(CreateClosedRingIfNecessary).ToArray();

                Coordinate[] outerRingCoordinates = ConvertPoint2DElementsToCoordinates(pointCollections[0]);
                ILinearRing  outerRing            = new LinearRing(outerRingCoordinates);

                var innerRings = new ILinearRing[pointCollections.Length - 1];
                for (var i = 1; i < pointCollections.Length; i++)
                {
                    Coordinate[] innerRingCoordinates = ConvertPoint2DElementsToCoordinates(pointCollections[i]);
                    innerRings[i - 1] = new LinearRing(innerRingCoordinates);
                }

                IPolygon polygon = new Polygon(outerRing, innerRings);
                geometryList.Add(polygon);
            }

            yield return(new Feature(GetGeometry(geometryList)));
        }
コード例 #19
0
        /// <summary>
        /// Asserts whether <paramref name="features"/> contains the data that is representative for the data of
        /// hydraulic boundary locations and calculations in <paramref name="assessmentSection"/>.
        /// </summary>
        /// <param name="assessmentSection">The assessment section that contains the original data.</param>
        /// <param name="features">The features that need to be asserted.</param>
        /// <exception cref="AssertionException">Thrown when:
        /// <list type="bullet">
        /// <item>the number of hydraulic boundary locations and features are not the same;</item>
        /// <item>the general properties (such as id, name and location) of hydraulic boundary locations and features
        /// are not the same;</item>
        /// <item>the wave height or the design water level calculation results of a hydraulic boundary location and the
        /// respective outputs of a corresponding feature are not the same.</item>
        /// </list>
        /// </exception>
        public static void AssertHydraulicBoundaryFeaturesData(IAssessmentSection assessmentSection, IEnumerable <MapFeature> features)
        {
            HydraulicBoundaryLocation[] hydraulicBoundaryLocationsArray = assessmentSection.HydraulicBoundaryDatabase.Locations.ToArray();
            int expectedNrOfFeatures = hydraulicBoundaryLocationsArray.Length;

            Assert.AreEqual(expectedNrOfFeatures, features.Count());

            for (var i = 0; i < expectedNrOfFeatures; i++)
            {
                HydraulicBoundaryLocation hydraulicBoundaryLocation = hydraulicBoundaryLocationsArray[i];
                MapFeature mapFeature = features.ElementAt(i);

                Assert.AreEqual(hydraulicBoundaryLocation.Location, mapFeature.MapGeometries.First().PointCollections.First().First());

                MapFeaturesMetaDataTestHelper.AssertMetaData(hydraulicBoundaryLocation.Id, mapFeature, "ID");
                MapFeaturesMetaDataTestHelper.AssertMetaData(hydraulicBoundaryLocation.Name, mapFeature, "Naam");

                var presentedMetaDataItems = new List <string>();
                AssertMetaData(assessmentSection.WaterLevelCalculationsForMaximumAllowableFloodingProbability, hydraulicBoundaryLocation, mapFeature,
                               assessmentSection.FailureMechanismContribution.MaximumAllowableFloodingProbability, "h - {0}", presentedMetaDataItems);
                AssertMetaData(assessmentSection.WaterLevelCalculationsForSignalFloodingProbability, hydraulicBoundaryLocation, mapFeature,
                               assessmentSection.FailureMechanismContribution.SignalFloodingProbability, "h - {0}", presentedMetaDataItems);

                foreach (HydraulicBoundaryLocationCalculationsForTargetProbability calculationsForTargetProbability in assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities)
                {
                    AssertMetaData(calculationsForTargetProbability.HydraulicBoundaryLocationCalculations, hydraulicBoundaryLocation, mapFeature,
                                   calculationsForTargetProbability.TargetProbability, "h - {0}", presentedMetaDataItems);
                }

                foreach (HydraulicBoundaryLocationCalculationsForTargetProbability calculationsForTargetProbability in assessmentSection.WaveHeightCalculationsForUserDefinedTargetProbabilities)
                {
                    AssertMetaData(calculationsForTargetProbability.HydraulicBoundaryLocationCalculations, hydraulicBoundaryLocation, mapFeature,
                                   calculationsForTargetProbability.TargetProbability, "Hs - {0}", presentedMetaDataItems);
                }
            }
        }
コード例 #20
0
        private MapLineData ConvertMultiLineFeatureToMapLineData(IEnumerable <IFeature> lineFeatures, string name)
        {
            int lineFeaturesCount = lineFeatures.Count();
            var mapFeatures       = new MapFeature[lineFeaturesCount];

            for (var featureIndex = 0; featureIndex < lineFeaturesCount; featureIndex++)
            {
                IFeature   lineFeature = lineFeatures.ElementAt(featureIndex);
                MapFeature feature     = CreateMapFeatureForLineFeature(lineFeature);

                CopyMetaDataIntoFeature(feature, featureIndex);

                mapFeatures[featureIndex] = feature;
            }

            var mapLineData = new MapLineData(name)
            {
                Features = mapFeatures
            };

            mapLineData.SelectedMetaDataAttribute = mapLineData.MetaData.FirstOrDefault();

            return(mapLineData);
        }
コード例 #21
0
        /// <summary>
        /// Asserts whether <paramref name="features"/> contains the data that is representative for the data of
        /// dune locations and calculations in <paramref name="failureMechanism"/>.
        /// </summary>
        /// <param name="failureMechanism">The failure mechanism that contains the first part of the original data.</param>
        /// <param name="features">The collection of <see cref="MapFeature"/> to assert.</param>
        /// <exception cref="AssertionException">Thrown when:
        /// <list type="bullet">
        /// <item>the number of dune locations and features are not the same;</item>
        /// <item>the general properties (such as id, name and location) of dune locations and features
        /// are not the same;</item>
        /// <item>the water level, wave height or wave period calculation results of a dune location and the
        /// respective outputs of a corresponding feature are not the same.</item>
        /// <item>the number of meta data items does not match with the expected number of items.</item>
        /// </list>
        /// </exception>
        public static void AssertDuneLocationFeaturesData(DuneErosionFailureMechanism failureMechanism,
                                                          IEnumerable <MapFeature> features)
        {
            IEnumerable <DuneLocation> expectedDuneLocations = failureMechanism.DuneLocations;

            Assert.AreEqual(expectedDuneLocations.Count(), features.Count());
            for (var i = 0; i < expectedDuneLocations.Count(); i++)
            {
                DuneLocation expectedDuneLocation = expectedDuneLocations.ElementAt(i);
                MapFeature   mapFeature           = features.ElementAt(i);

                MapFeaturesMetaDataTestHelper.AssertMetaData(expectedDuneLocation.Id, mapFeature, "ID");
                MapFeaturesMetaDataTestHelper.AssertMetaData(expectedDuneLocation.Name, mapFeature, "Naam");
                MapFeaturesMetaDataTestHelper.AssertMetaData(expectedDuneLocation.CoastalAreaId, mapFeature, "Kustvaknummer");
                MapFeaturesMetaDataTestHelper.AssertMetaData(expectedDuneLocation.Offset.ToString("0.#", CultureInfo.CurrentCulture), mapFeature, "Metrering");
                MapFeaturesMetaDataTestHelper.AssertMetaData(expectedDuneLocation.D50.ToString(), mapFeature, "Rekenwaarde d50");

                Assert.AreEqual(expectedDuneLocation.Location, mapFeature.MapGeometries.First().PointCollections.First().Single());

                var presentedMetaDataItems = new List <string>();
                foreach (DuneLocationCalculationsForTargetProbability calculationsForTargetProbability in failureMechanism.DuneLocationCalculationsForUserDefinedTargetProbabilities)
                {
                    AssertMetaData(calculationsForTargetProbability.DuneLocationCalculations, expectedDuneLocation, GetExpectedWaterLevel,
                                   mapFeature, calculationsForTargetProbability.TargetProbability, "Rekenwaarde h - {0}", presentedMetaDataItems);

                    AssertMetaData(calculationsForTargetProbability.DuneLocationCalculations, expectedDuneLocation, GetExpectedWaveHeight,
                                   mapFeature, calculationsForTargetProbability.TargetProbability, "Rekenwaarde Hs - {0}", presentedMetaDataItems);

                    AssertMetaData(calculationsForTargetProbability.DuneLocationCalculations, expectedDuneLocation, GetExpectedWavePeriod,
                                   mapFeature, calculationsForTargetProbability.TargetProbability, "Rekenwaarde Tp - {0}", presentedMetaDataItems);
                }

                int expectedMetaDataCount = 5 + (3 * failureMechanism.DuneLocationCalculationsForUserDefinedTargetProbabilities.Count);
                Assert.AreEqual(expectedMetaDataCount, mapFeature.MetaData.Keys.Count);
            }
        }
コード例 #22
0
        public void ReadLine_ShapeFileWithMultiplePolygonFeatures_ReturnShapes()
        {
            // Setup
            string shapeWithMultiplePolygons = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
                                                                          "Multiple_Polygon_with_ID.shp");

            using (var reader = new PolygonShapeFileReader(shapeWithMultiplePolygons))
            {
                // Precondition
                Assert.AreEqual(4, reader.GetNumberOfFeatures());

                // Call
                var polygons1 = (MapPolygonData)reader.ReadFeature();
                var polygons2 = (MapPolygonData)reader.ReadFeature();
                var polygons3 = (MapPolygonData)reader.ReadFeature();
                var polygons4 = (MapPolygonData)reader.ReadFeature();

                // Assert

                #region Assertsions for 'polygon1'

                MapFeature[] features1 = polygons1.Features.ToArray();
                Assert.AreEqual(1, features1.Length);

                MapFeature    polygon1         = features1[0];
                MapGeometry[] polygon1Geometry = polygon1.MapGeometries.ToArray();
                Assert.AreEqual(1, polygon1Geometry.Length);

                IEnumerable <Point2D>[] polygon1PointCollections = polygon1Geometry[0].PointCollections.ToArray();
                Assert.AreEqual(1, polygon1PointCollections.Length);

                Point2D[] 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'

                MapFeature[] features2 = polygons2.Features.ToArray();
                Assert.AreEqual(1, features2.Length);

                MapFeature    polygon2         = features2[0];
                MapGeometry[] polygon2Geometry = polygon2.MapGeometries.ToArray();
                Assert.AreEqual(1, polygon2Geometry.Length);

                IEnumerable <Point2D>[] 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'

                MapFeature[] features3 = polygons3.Features.ToArray();
                Assert.AreEqual(1, features3.Length);

                MapFeature    polygon3         = features3[0];
                MapGeometry[] polygon3Geometry = polygon3.MapGeometries.ToArray();
                Assert.AreEqual(1, polygon3Geometry.Length);

                IEnumerable <Point2D>[] 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'

                MapFeature[] features4 = polygons4.Features.ToArray();
                Assert.AreEqual(1, features4.Length);

                MapFeature    polygon4         = features4[0];
                MapGeometry[] polygon4Geometry = polygon4.MapGeometries.ToArray();
                Assert.AreEqual(1, polygon4Geometry.Length);

                IEnumerable <Point2D>[] polygon4PointCollections = polygon4Geometry[0].PointCollections.ToArray();
                Assert.AreEqual(1, polygon4PointCollections.Length);

                Point2D[] 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
            }
        }
コード例 #23
0
        private static void AssertAssemblyGroupMapFeature(FailureMechanismSection section, MapFeature mapFeature, FailureMechanismSectionAssemblyResult expectedAssemblyResult)
        {
            IEnumerable <MapGeometry> mapGeometries = mapFeature.MapGeometries;

            Assert.AreEqual(1, mapGeometries.Count());
            CollectionAssert.AreEqual(section.Points, mapGeometries.Single().PointCollections.First());
            Assert.AreEqual(2, mapFeature.MetaData.Keys.Count);
            Assert.AreEqual(EnumDisplayNameHelper.GetDisplayName(expectedAssemblyResult.FailureMechanismSectionAssemblyGroup),
                            mapFeature.MetaData["Duidingsklasse"]);
            Assert.AreEqual(expectedAssemblyResult.SectionProbability, mapFeature.MetaData["Rekenwaarde faalkans per vak"]);
        }
コード例 #24
0
        static void Main(string[] args)
        {
            //Parse input
            int mapWidth  = File.ReadAllLines("./input.txt")[0].Length;
            int mapHeight = 0;

            foreach (string line in File.ReadAllLines("./input.txt"))
            {
                mapHeight++;
            }

            Console.WriteLine($"Map Width: {mapWidth}, Map Height: {mapHeight}");
            MapFeature[,] MapArray = new MapFeature[mapWidth, mapHeight];
            int y = 0;

            foreach (string line in File.ReadAllLines("./input.txt"))
            {
                int x = 0;
                foreach (char c in line)
                {
                    MapFeature currentFeature = MapFeature.Open;
                    if (c == '#')
                    {
                        currentFeature = MapFeature.Tree;
                    }
                    MapArray[x, y] = currentFeature;
                    x++;
                }
                y++;
            }

            List <int>          TreeCountList = new List <int>();
            List <SledSettings> settings      = new List <SledSettings>
            {
                new SledSettings {
                    x = 1, y = 1
                },
                new SledSettings {
                    x = 3, y = 1
                },
                new SledSettings {
                    x = 5, y = 1
                },
                new SledSettings {
                    x = 7, y = 1
                },
                new SledSettings {
                    x = 1, y = 2
                }
            };

            foreach (SledSettings setting in settings)
            {
                //Find route
                int currentX = 0;
                int currentY = 0;

                int MoveX = setting.x;
                int moveY = setting.y;

                int treeCount = 0;
                while (currentY < mapHeight)
                {
                    //Console.WriteLine($"X: {currentX}, Y: {currentY} - {MapArray[currentX, currentY]}");
                    if (MapArray[currentX, currentY] == MapFeature.Tree)
                    {
                        treeCount++;
                    }
                    currentX += MoveX;
                    if (currentX >= mapWidth)
                    {
                        currentX -= mapWidth;
                    }
                    currentY += moveY;
                }
                TreeCountList.Add(treeCount);
                Console.WriteLine($"You hit {treeCount} trees with the settings X{MoveX}Y{moveY}");
            }

            double multipliedTreeCount = 1;

            foreach (int TreeCount in TreeCountList)
            {
                multipliedTreeCount *= TreeCount;
            }
            Console.WriteLine($"The multiplied answer is {multipliedTreeCount}");
        }
コード例 #25
0
ファイル: MapUploader.cs プロジェクト: karun10/KML2SQL
 private static IEnumerable<MapFeature> GetPlacemarks(Kml kml)
 {
     int id = 1;
     foreach (var placemark in kml.Flatten().OfType<Placemark>())
     {
         MapFeature mapFeature = new MapFeature(placemark, id);
         id++;
         yield return mapFeature;
     }
 }
コード例 #26
0
        public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            var feature = new MapFeature(Enumerable.Empty <MapGeometry>());

            feature.MetaData["key"] = "value";

            var mapData = new TestFeatureBasedMapData
            {
                Features = new[]
                {
                    feature
                },
                ShowLabels = true
            };

            // Call
            var properties = new TestFeatureBasedMapDataProperties(mapData, Enumerable.Empty <MapDataCollection>());

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(6, dynamicProperties.Count);

            const string layerCategory = "Kaartlaag";
            const string labelCategory = "Labels";
            const string styleCategory = "Stijl";

            PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty,
                                                                            layerCategory,
                                                                            "Naam",
                                                                            "De naam van deze kaartlaag.",
                                                                            true);

            PropertyDescriptor typeProperty = dynamicProperties[typePropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(typeProperty,
                                                                            layerCategory,
                                                                            "Type",
                                                                            "Het type van de data die wordt weergegeven op deze kaartlaag.",
                                                                            true);

            PropertyDescriptor isVisibleProperty = dynamicProperties[isVisiblePropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isVisibleProperty,
                                                                            layerCategory,
                                                                            "Weergeven",
                                                                            "Geeft aan of deze kaartlaag wordt weergegeven.");

            PropertyDescriptor showlabelsProperty = dynamicProperties[showLabelsPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(showlabelsProperty,
                                                                            labelCategory,
                                                                            "Weergeven",
                                                                            "Geeft aan of labels worden weergegeven op deze kaartlaag.");

            PropertyDescriptor selectedMetaDataAttributeProperty = dynamicProperties[selectedMetaDataAttributePropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(selectedMetaDataAttributeProperty,
                                                                            labelCategory,
                                                                            "Op basis van",
                                                                            "Toont de eigenschap op basis waarvan labels worden weergegeven op deze kaartlaag.");

            PropertyDescriptor styleTypeProperty = dynamicProperties[stylePropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(styleTypeProperty,
                                                                            styleCategory,
                                                                            "Type",
                                                                            "Het type van de stijl die wordt toegepast voor het weergeven van deze kaartlaag.",
                                                                            true);
        }
コード例 #27
0
 /// <summary>
 /// Asserts whether the meta data for <paramref name="key"/> in <paramref name="feature"/>
 /// contains the correct value.
 /// </summary>
 /// <param name="expectedValue">The value to assert against.</param>
 /// <param name="feature">The <see cref="MapFeature"/> to be asserted.</param>
 /// <param name="key">The name of the meta data element to retrieve the value from.</param>
 /// <exception cref="KeyNotFoundException">Thrown when the meta data of <paramref name="feature"/> does not
 /// contain a <see cref="KeyValuePair{TKey,TValue}"/> with <paramref name="key"/> as key.</exception>
 /// <exception cref="AssertionException">Thrown when the value and the respective meta data value associated
 /// with <paramref name="key"/> are not equal.
 /// </exception>
 public static void AssertMetaData(object expectedValue,
                                   MapFeature feature,
                                   string key)
 {
     Assert.AreEqual(expectedValue, feature.MetaData[key]);
 }
コード例 #28
0
ファイル: MapCell.cs プロジェクト: benc-uk/dungeon-game
 public void addFeature(MapFeature f)
 {
     this.feature = f;
 }
コード例 #29
0
        private static void AddFeatureToLayer(TMapFeatureLayer layer, IFeature feature, MapFeature mapFeature, Dictionary <string, int> attributeMapping)
        {
            layer.DataSet.Features.Add(feature);

            AddMetaDataToFeature(feature, mapFeature, attributeMapping);
        }
コード例 #30
0
 /// <summary>
 /// Creates an <see cref="IEnumerable{T}"/> of <see cref="IFeature"/> based on
 /// <paramref name="mapFeature"/> that have been defined in the coordinate system
 /// given by <see cref="MapDataConstants.FeatureBasedMapDataCoordinateSystem"/>.
 /// </summary>
 /// <param name="mapFeature">The <see cref="MapFeature"/> to create features for.</param>
 /// <returns>An <see cref="IEnumerable{T}"/> of <see cref="IFeature"/>.</returns>
 protected abstract IEnumerable <IFeature> CreateFeatures(MapFeature mapFeature);
コード例 #31
0
 protected override IEnumerable <IFeature> CreateFeatures(MapFeature mapFeature)
 {
     yield return(new Feature(new Coordinate(1.1, 2.2)));
 }
コード例 #32
0
        public void ReadShapeFile_ShapeFileWithMultiplePointFeatures_ReturnShapes()
        {
            // Setup
            string shapeWithMultiplePoints = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
                                                                        "Multiple_Point_with_ID.shp");

            using (var reader = new PointShapeFileReader(shapeWithMultiplePoints))
            {
                // Precondition
                Assert.AreEqual(6, reader.GetNumberOfFeatures());

                // Call
                var points = (MapPointData)reader.ReadShapeFile();

                // Assert
                MapFeature[] features = points.Features.ToArray();
                Assert.AreEqual(6, features.Length);
                Assert.AreEqual("id", points.SelectedMetaDataAttribute);

                #region Assertion for 'point1'

                MapFeature    point1         = features[0];
                MapGeometry[] point1Geometry = point1.MapGeometries.ToArray();
                Assert.AreEqual(1, point1Geometry.Length);

                IEnumerable <Point2D>[] 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);

                Assert.AreEqual(1, point1.MetaData.Count);
                Assert.AreEqual(6, point1.MetaData["id"]);

                #endregion

                #region Assertion for 'point2'

                MapFeature    point2         = features[1];
                MapGeometry[] point2Geometry = point2.MapGeometries.ToArray();
                Assert.AreEqual(1, point2Geometry.Length);

                IEnumerable <Point2D>[] 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);

                Assert.AreEqual(1, point2.MetaData.Count);
                Assert.AreEqual(5, point2.MetaData["id"]);

                #endregion

                #region Assertion for 'point3'

                MapFeature    point3         = features[2];
                MapGeometry[] point3Geometry = point3.MapGeometries.ToArray();
                Assert.AreEqual(1, point3Geometry.Length);

                IEnumerable <Point2D>[] 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);

                Assert.AreEqual(1, point3.MetaData.Count);
                Assert.AreEqual(4, point3.MetaData["id"]);

                #endregion

                #region Assertion for 'point4'

                MapFeature    point4         = features[3];
                MapGeometry[] point4Geometry = point4.MapGeometries.ToArray();
                Assert.AreEqual(1, point4Geometry.Length);

                IEnumerable <Point2D>[] 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);

                Assert.AreEqual(1, point4.MetaData.Count);
                Assert.AreEqual(3, point4.MetaData["id"]);

                #endregion

                #region Assertion for 'point5'

                MapFeature    point5         = features[4];
                MapGeometry[] point5Geometry = point5.MapGeometries.ToArray();
                Assert.AreEqual(1, point5Geometry.Length);

                IEnumerable <Point2D>[] 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);

                Assert.AreEqual(1, point5.MetaData.Count);
                Assert.AreEqual(2, point5.MetaData["id"]);

                #endregion

                #region Assertion for 'point6'

                MapFeature    point6         = features[5];
                MapGeometry[] point6Geometry = point6.MapGeometries.ToArray();
                Assert.AreEqual(1, point6Geometry.Length);

                IEnumerable <Point2D>[] 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);

                Assert.AreEqual(1, point6.MetaData.Count);
                Assert.AreEqual(1, point6.MetaData["id"]);

                #endregion
            }
        }
コード例 #33
0
 public void PublicCopyMetaDataIntoFeature(MapFeature targetFeature, int sourceFeatureIndex)
 {
     CopyMetaDataIntoFeature(targetFeature, sourceFeatureIndex);
 }
コード例 #34
0
        /// <summary>
        /// Reads GML data
        /// </summary>
        /// <param name="rootElement">Root document element of the GML file</param>
        private void parseGMLDocument(string rootElementName, XmlElement rootElement)
        {
            try
            {
                #region READ FEATURES BOUNDS

                XmlNode bounds = rootElement.SelectSingleNode("/ogr:FeatureCollection/gml:boundedBy/gml:Envelope", GMLNamespaces);

                string lowerLeftCoordinates  = bounds.SelectSingleNode("gml:lowerCorner", GMLNamespaces).ChildNodes[0].Value;
                string upperRightCoordinates = bounds.SelectSingleNode("gml:upperCorner", GMLNamespaces).ChildNodes[0].Value;

                this.Bounds = new MapBounds(new Vertex(lowerLeftCoordinates), new Vertex(upperRightCoordinates));

                #endregion

                #region READ FEATURES

                this.Features = new List <MapFeature>();

                XmlNodeList featureNodes = rootElement.SelectNodes("/ogr:FeatureCollection/ogr:featureMember/ogr:" + rootElementName, GMLNamespaces);

                foreach (XmlNode featureNode in featureNodes)
                {
                    string fid = featureNode.SelectSingleNode("ogr:osm_id", GMLNamespaces).ChildNodes[0].Value;

                    int    dimension = this.GetAttribute <int>("srsDimension", featureNode.SelectSingleNode("ogr:geometryProperty/gml:Polygon/gml:exterior/gml:LinearRing/gml:posList", GMLNamespaces).Attributes);
                    string geometry  = featureNode.SelectSingleNode("ogr:geometryProperty/gml:Polygon/gml:exterior/gml:LinearRing/gml:posList", GMLNamespaces).ChildNodes[0].Value;

                    List <Vertex> verticesList = new List <Vertex>();
                    string[]      vertices     = geometry.Split(new char[] { ' ' });

                    switch (dimension)
                    {
                    // X Y Z
                    case 3:
                    {
                        for (int i = 0; i < vertices.Length - 3; i = i + 3)
                        {
                            verticesList.Add(new Vertex(String.Format("{0} {1} {2}", vertices[i], vertices[i + 1], vertices[i + 2])));
                        }

                        break;
                    }

                    // X Y
                    case 2:
                    {
                        for (int i = 0; i < vertices.Length - 2; i = i + 2)
                        {
                            verticesList.Add(new Vertex(String.Format("{0} {1}", vertices[i], vertices[i + 1])));
                        }

                        break;
                    }

                    default: break;
                    }

                    MapFeature feature = new MapFeature(fid);
                    feature.SetGeometry(EnumGeometryType.Polygon, verticesList);

                    this.Features.Add(feature);
                }

                #endregion
            }
            catch
            {
            }
        }
コード例 #35
0
        public void ReadShapeFile_ShapeFileWithMultiplePolygonFeatures_ReturnShapes()
        {
            // Setup
            string shapeWithMultiplePolygons = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
                                                                          "Multiple_Polygon_with_ID.shp");

            using (var reader = new PolygonShapeFileReader(shapeWithMultiplePolygons))
            {
                // Precondition
                Assert.AreEqual(4, reader.GetNumberOfFeatures());

                // Call
                var polygons = (MapPolygonData)reader.ReadShapeFile();

                // Assert
                MapFeature[] features = polygons.Features.ToArray();
                Assert.AreEqual(4, features.Length);
                Assert.AreEqual(1, polygons.MetaData.Count());
                Assert.AreEqual("id", polygons.SelectedMetaDataAttribute);

                #region Assertsions for 'polygon1'

                MapFeature    polygon1         = features[0];
                MapGeometry[] polygon1Geometry = polygon1.MapGeometries.ToArray();
                Assert.AreEqual(1, polygon1Geometry.Length);

                IEnumerable <Point2D>[] 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);

                Assert.AreEqual(1, polygon1.MetaData.Count);
                Assert.AreEqual(4, polygon1.MetaData["id"]);

                #endregion

                #region Assertsions for 'polygon2'

                MapFeature    polygon2         = features[1];
                MapGeometry[] polygon2Geometry = polygon2.MapGeometries.ToArray();
                Assert.AreEqual(1, polygon2Geometry.Length);

                IEnumerable <Point2D>[] 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);

                Assert.AreEqual(1, polygon2.MetaData.Count);
                Assert.AreEqual(3, polygon2.MetaData["id"]);

                #endregion

                #region Assertsions for 'polygon3'

                MapFeature    polygon3         = features[2];
                MapGeometry[] polygon3Geometry = polygon3.MapGeometries.ToArray();
                Assert.AreEqual(1, polygon3Geometry.Length);

                IEnumerable <Point2D>[] 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);

                Assert.AreEqual(1, polygon3.MetaData.Count);
                Assert.AreEqual(2, polygon3.MetaData["id"]);

                #endregion

                #region Assertsions for 'polygon4'

                MapFeature    polygon4         = features[3];
                MapGeometry[] polygon4Geometry = polygon4.MapGeometries.ToArray();
                Assert.AreEqual(1, polygon4Geometry.Length);

                IEnumerable <Point2D>[] 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);

                Assert.AreEqual(1, polygon4.MetaData.Count);
                Assert.AreEqual(1, polygon4.MetaData["id"]);

                #endregion
            }
        }