示例#1
0
        public void GetNumberOfLines_ShapeFileWithMultiplePointFeatures_ReturnThatNumberOfFeatures()
        {
            // Setup
            string shapeWithMultiplePoints = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
                                                                        "Multiple_Point_with_ID.shp");

            using (var reader = new PointShapeFileReader(shapeWithMultiplePoints))
            {
                // Call
                int count = reader.GetNumberOfFeatures();

                // Assert
                Assert.AreEqual(6, count);
            }
        }
示例#2
0
        public void GetNumberOfLines_EmptyPointShapeFile_ReturnZero()
        {
            // Setup
            string shapeWithOneLine = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
                                                                 "Empty_Point_with_ID.shp");

            using (var reader = new PointShapeFileReader(shapeWithOneLine))
            {
                // Call
                int count = reader.GetNumberOfFeatures();

                // Assert
                Assert.AreEqual(0, count);
            }
        }
示例#3
0
        public void ReadLine_WhenAtEndOfShapeFile_ReturnNull(string fileName)
        {
            // Setup
            string filePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
                                                         fileName);

            using (var reader = new PointShapeFileReader(filePath))
            {
                for (var i = 0; i < reader.GetNumberOfFeatures(); i++)
                {
                    reader.ReadFeature();
                }

                // Call
                var feature = reader.ReadFeature() as MapPointData;

                // Assert
                Assert.IsNull(feature);
            }
        }
示例#4
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
            }
        }
示例#5
0
        public void ReadLine_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 points1 = (MapPointData)reader.ReadFeature();
                var points2 = (MapPointData)reader.ReadFeature();
                var points3 = (MapPointData)reader.ReadFeature();
                var points4 = (MapPointData)reader.ReadFeature();
                var points5 = (MapPointData)reader.ReadFeature();
                var points6 = (MapPointData)reader.ReadFeature();

                // Assert

                #region Assertion for 'point1'

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

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

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

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

                MapFeature    point2         = features2[0];
                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);

                #endregion

                #region Assertion for 'point3'

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

                MapFeature    point3         = features3[0];
                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);

                #endregion

                #region Assertion for 'point4'

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

                MapFeature    point4         = features4[0];
                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);

                #endregion

                #region Assertion for 'point5'

                MapFeature[] features5 = points5.Features.ToArray();
                Assert.AreEqual(1, features5.Length);

                MapFeature    point5         = features5[0];
                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);

                #endregion

                #region Assertion for 'point6'

                MapFeature[] features6 = points6.Features.ToArray();
                Assert.AreEqual(1, features6.Length);

                MapFeature    point6         = features6[0];
                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);

                #endregion
            }
        }