public void ReadAllShapes_ReadPointZMWithMissingMValues_ShouldReturnCorrectValues()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();

            m_TmpFile = new TempFileWriter("shape_PointZMWithMissingMValue.shp", ShpFiles.Read("shape_pointZM_MissingM values"));
            m_Reader  = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            double errorMargin = Math.Pow(10, -6);

            double[,] expectedValues = { { -11348202.6085706,  4503476.68482375 },
                                         { -601708.888562033,  3537065.37906758 },
                                         { -7366588.02885523, -637831.461799072 } };

            // Act.
            IEnumerable <IGeometry> shapes = m_Reader.ReadAllShapes(factory);

            // Assert.
            Assert.IsNotNull(shapes);
            IGeometry[] shapesArr = shapes.ToArray();
            Assert.AreEqual(shapesArr.Length, 3);

            for (int i = 0; i < shapesArr.Length; i++)
            {
                Assert.IsInstanceOf <IPoint>(shapesArr[i]);
                IPoint currPoint = shapesArr[i] as IPoint;
                HelperMethods.AssertDoubleValuesEqual(currPoint.X, expectedValues[i, 0], errorMargin);
                HelperMethods.AssertDoubleValuesEqual(currPoint.Y, expectedValues[i, 1], errorMargin);
                HelperMethods.AssertDoubleValuesEqual(currPoint.Z, 0);
                HelperMethods.AssertDoubleValuesEqual(currPoint.M, Double.NaN);
            }
        }
        public void ReadAllShapes_ReadPointM_ShouldReturnCorrectValues()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();

            m_TmpFile = new TempFileWriter("shape_pointM.shp", ShpFiles.Read("shape_pointM"));
            m_Reader  = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            double[,] expectedValues = { { -133.606621226874, 66.8997078870497 },
                                         { -68.0564751703992, 56.4888023369036 },
                                         { -143.246348588121, 40.6796494644596 },
                                         { -82.3232716650438, -21.014605647517 } };

            // Act.
            IEnumerable <IGeometry> shapes = m_Reader.ReadAllShapes(factory);

            // Assert.
            Assert.IsNotNull(shapes);
            IGeometry[] shapesArr = shapes.ToArray();
            Assert.AreEqual(shapesArr.Length, 4);

            for (int i = 0; i < shapesArr.Length; i++)
            {
                Assert.IsInstanceOf <IPoint>(shapesArr[i]);
                IPoint currPoint = shapesArr[i] as IPoint;
                HelperMethods.AssertDoubleValuesEqual(currPoint.X, expectedValues[i, 0]);
                HelperMethods.AssertDoubleValuesEqual(currPoint.Y, expectedValues[i, 1]);
                HelperMethods.AssertDoubleValuesEqual(currPoint.Z, Double.NaN);
                HelperMethods.AssertDoubleValuesEqual(currPoint.M, Double.NaN);
            }
        }
        public void ReadAllShapes_SendNullFactory_ShouldThrowException()
        {
            // Arrange.
            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("UnifiedChecksMaterial"));
            m_Reader  = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            // Act.
            m_Reader.ReadAllShapes(null);
        }
        public void ReadAllShapes_TryReadAfterDisposed_ShouldThrowException()
        {
            // Arrange.
            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("UnifiedChecksMaterial"));
            m_Reader  = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            IGeometryFactory factory = new GeometryFactory();

            // Act.
            m_Reader.Dispose();
            m_Reader.ReadAllShapes(factory);
        }
        public void ReadAllShapes_ReadEmptyShapeFile_ShouldReturnEmptyEnumerable()
        {
            // Arrange.
            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("EmptyShapeFile"));
            m_Reader  = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            IGeometryFactory factory = new GeometryFactory();

            // Act.
            IEnumerable <IGeometry> geos = m_Reader.ReadAllShapes(factory);

            // Assert.
            Assert.IsNotNull(geos);
            Assert.IsFalse(geos.Any());
        }
        public void ReadAllShapes_ReadAllPolygonsFromUnifiedWithNullAtEnd_ShouldReturnCorrectValues()
        {
            // Arrange.
            m_TmpFile = new TempFileWriter("UnifiedChecksMaterial.shp", ShpFiles.Read("UnifiedChecksMaterialNullAtEnd"));
            m_Reader  = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            IGeometryFactory factory = new GeometryFactory();

            IPolygon[] expectedResult = new Polygon[]
            {
                new Polygon(new LinearRing(new Coordinate[]
                {
                    new Coordinate(-0.815656565656566, -0.439393939393939),
                    new Coordinate(-0.353535353535354, -0.795454545454545),
                    new Coordinate(-0.888888888888889, -0.929292929292929),
                    new Coordinate(-1.151515151515152, -0.419191919191919),
                    new Coordinate(-0.815656565656566, -0.439393939393939),
                })),
                new Polygon(new LinearRing(new Coordinate[]
                {
                    new Coordinate(0.068181818181818, 0.578282828282829),
                    new Coordinate(0.421717171717172, 0.070707070707071),
                    new Coordinate(-0.457070707070707, 0.080808080808081),
                    new Coordinate(0.068181818181818, 0.578282828282829),
                }))
            };

            // Act.
            IGeometry[] shapes = m_Reader.ReadAllShapes(factory).ToArray();

            Assert.IsNotNull(shapes);
            Assert.AreEqual(shapes.Length, 2);

            for (int i = 0; i < shapes.Length; i++)
            {
                Assert.IsInstanceOf <IPolygon>(shapes[i]);
                HelperMethods.AssertPolygonsEqual(shapes[i] as IPolygon, expectedResult[i]);
            }
        }
        public void ReadAllShapes_ReadAllPolygonsFromUnifiedWithNullAtEnd_ShouldReturnCorrectValues()
        {
            // Arrange.
            m_TmpFile = new TempFileWriter("UnifiedChecksMaterial.shp", ShpFiles.Read("UnifiedChecksMaterialNullAtEnd"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            IGeometryFactory factory = new GeometryFactory();

            IPolygon[] expectedResult = new Polygon[]
			{
				new Polygon(new LinearRing(new Coordinate[]
					{
						new Coordinate(-0.815656565656566, -0.439393939393939),
						new Coordinate(-0.353535353535354, -0.795454545454545),
						new Coordinate(-0.888888888888889,-0.929292929292929),
						new Coordinate(-1.151515151515152, -0.419191919191919),
						new Coordinate(-0.815656565656566,-0.439393939393939),
					})),
				new Polygon(new LinearRing(new Coordinate[]
					{
						new Coordinate(0.068181818181818,0.578282828282829),
						new Coordinate(0.421717171717172,0.070707070707071),
						new Coordinate(-0.457070707070707,0.080808080808081),
						new Coordinate(0.068181818181818,0.578282828282829),
					}))
			};

            // Act.
            IGeometry[] shapes = m_Reader.ReadAllShapes(factory).ToArray();

            Assert.IsNotNull(shapes);
            Assert.AreEqual(shapes.Length, 2);

            for (int i = 0; i < shapes.Length; i++)
            {
                Assert.IsInstanceOf<IPolygon>(shapes[i]);
                HelperMethods.AssertPolygonsEqual(shapes[i] as IPolygon, expectedResult[i]);
            }
        }
        public void ReadAllShapes_TryReadAfterDisposed_ShouldThrowException()
        {
            // Arrange.
            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("UnifiedChecksMaterial"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            IGeometryFactory factory = new GeometryFactory();

            // Act.
            m_Reader.Dispose();
            m_Reader.ReadAllShapes(factory);
        }
        public void ReadAllShapes_ReadPointZMWithMissingMValues_ShouldReturnCorrectValues()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();
            m_TmpFile = new TempFileWriter("shape_PointZMWithMissingMValue.shp", ShpFiles.Read("shape_pointZM_MissingM values"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            double errorMargin = Math.Pow(10, -6);

            double[,] expectedValues = {{-11348202.6085706, 4503476.68482375},
									    {-601708.888562033, 3537065.37906758},
										{-7366588.02885523, -637831.461799072}};

            // Act.
            IEnumerable<IGeometry> shapes = m_Reader.ReadAllShapes(factory);

            // Assert.
            Assert.IsNotNull(shapes);
            IGeometry[] shapesArr = shapes.ToArray();
            Assert.AreEqual(shapesArr.Length, 3);

            for (int i = 0; i < shapesArr.Length; i++)
            {
                Assert.IsInstanceOf<IPoint>(shapesArr[i]);
                IPoint currPoint = shapesArr[i] as IPoint;
                HelperMethods.AssertDoubleValuesEqual(currPoint.X, expectedValues[i, 0], errorMargin);
                HelperMethods.AssertDoubleValuesEqual(currPoint.Y, expectedValues[i, 1], errorMargin);
                HelperMethods.AssertDoubleValuesEqual(currPoint.Z, 0);
                HelperMethods.AssertDoubleValuesEqual(currPoint.M, Double.NaN);
            }
        }
        public void ReadAllShapes_ReadPointM_ShouldReturnCorrectValues()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();
            m_TmpFile = new TempFileWriter("shape_pointM.shp", ShpFiles.Read("shape_pointM"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            double[,] expectedValues = {{-133.606621226874, 66.8997078870497},
									    {-68.0564751703992, 56.4888023369036},
										{-143.246348588121, 40.6796494644596},
										{-82.3232716650438, -21.014605647517}};

            // Act.
            IEnumerable<IGeometry> shapes = m_Reader.ReadAllShapes(factory);

            // Assert.
            Assert.IsNotNull(shapes);
            IGeometry[] shapesArr = shapes.ToArray();
            Assert.AreEqual(shapesArr.Length, 4);

            for (int i = 0; i < shapesArr.Length; i++)
            {
                Assert.IsInstanceOf<IPoint>(shapesArr[i]);
                IPoint currPoint = shapesArr[i] as IPoint;
                HelperMethods.AssertDoubleValuesEqual(currPoint.X, expectedValues[i, 0]);
                HelperMethods.AssertDoubleValuesEqual(currPoint.Y, expectedValues[i, 1]);
                HelperMethods.AssertDoubleValuesEqual(currPoint.Z, Double.NaN);
                HelperMethods.AssertDoubleValuesEqual(currPoint.M, Double.NaN);
            }
        }
        public void ReadAllShapes_ReadEmptyShapeFile_ShouldReturnEmptyEnumerable()
        {
            // Arrange.
            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("EmptyShapeFile"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            IGeometryFactory factory = new GeometryFactory();

            // Act.
            IEnumerable<IGeometry> geos = m_Reader.ReadAllShapes(factory);

            // Assert.
            Assert.IsNotNull(geos);
            Assert.IsFalse(geos.Any());
        }
        public void ReadAllShapes_SendNullFactory_ShouldThrowException()
        {
            // Arrange.
            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("UnifiedChecksMaterial"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            // Act.
            m_Reader.ReadAllShapes(null);
        }
        public void ReadAllShapes_TryReadAfterDisposed_ShouldThrowException()
        {
            // Arrange.
            m_TmpFile = new TempFileCloudUploader("shape.shp", ShpFiles.Read("UnifiedChecksMaterial"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(new ShapefileStreamProviderRegistry(GetProvider(m_TmpFile.Path), null, true, false));
            IGeometryFactory factory = new GeometryFactory();

            // Act.
            m_Reader.Dispose();
            m_Reader.ReadAllShapes(factory);
        }
        public void ReadAllShapes_ReadEmptyShapeFile_ShouldReturnEmptyEnumerable()
        {
            // Arrange.
            m_TmpFile = new TempFileCloudUploader("shape.shp", ShpFiles.Read("EmptyShapeFile"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(new ShapefileStreamProviderRegistry(GetProvider(m_TmpFile.Path), null, true, false));
            IGeometryFactory factory = new GeometryFactory();

            // Act.
            IEnumerable<IGeometry> geos = m_Reader.ReadAllShapes(factory);

            // Assert.
            Assert.IsNotNull(geos);
            Assert.IsFalse(geos.Any());
        }
        public void ReadAllShapes_SendNullFactory_ShouldThrowException()
        {
            // Arrange.
            m_TmpFile = new TempFileCloudUploader("shape.shp", ShpFiles.Read("UnifiedChecksMaterial"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(new ShapefileStreamProviderRegistry(GetProvider(m_TmpFile.Path), null, true, false));

            // Act.
            m_Reader.ReadAllShapes(null);
        }