public void ReadMBRs_ReadUnifiedWithNullAtEnd_ShouldReturnCorrectValues()
        {
            // Arrange.
            MBRInfo[] infos = null;

            MBRInfo[] expectedInfos = new[]
            {
                new MBRInfo(new Envelope(-1.151515151515152, -0.353535353535354, -0.929292929292929, -0.419191919191919),
                            100,
                            0),
                new MBRInfo(new Envelope(-0.457070707070707, 0.421717171717172, 0.070707070707071, 0.578282828282829),
                            236,
                            1),
            };

            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("UnifiedChecksMaterialNullAtEnd"));

            // Act.
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            infos    = m_Reader.ReadMBRs().ToArray();

            // Assert.
            Assert.IsNotNull(infos);
            Assert.AreEqual(expectedInfos.Length, infos.Length);

            int currIndex = 0;

            foreach (MBRInfo expectedInfo in expectedInfos)
            {
                HelperMethods.AssertMBRInfoEqual(expectedInfo, infos[currIndex++]);
            }
        }
        public void ReadMBRs_ReadLine_ShouldReturnCorrectValues()
        {
            // Arrange.
            MBRInfo[] infos = null;

            MBRInfo[] expectedInfos = new[]
            {
                new MBRInfo(new Envelope(34.573027972716453, 34.628034609274806, 31.803273460424684, 31.895998933480186),
                            100,
                            0),
                new MBRInfo(new Envelope(34.396692412092257, 34.518021336158107, 31.778756216701534, 31.864880893370035),
                            236,
                            1),
            };

            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("line_wgs84_geo"));

            // Act.
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            infos    = m_Reader.ReadMBRs().ToArray();

            // Assert.
            Assert.IsNotNull(infos);
            Assert.AreEqual(2, infos.Length);

            int currIndex = 0;

            foreach (MBRInfo expectedInfo in expectedInfos)
            {
                HelperMethods.AssertMBRInfoEqual(expectedInfo, infos[currIndex++]);
            }
        }
        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_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 ReadMBRs_ReadPoint_ShouldReturnCorrectValues()
        {
            // Arrange.
            MBRInfo[] infos = null;

            MBRInfo[] expectedInfos = new[]
            {
                new MBRInfo(new Envelope(new Coordinate(34.282930701329349, 31.851167389309651)),
                            100,
                            0),
                new MBRInfo(new Envelope(new Coordinate(34.145260222088822, 31.864369159253059)),
                            128,
                            1),
                new MBRInfo(new Envelope(new Coordinate(34.181721116813314, 31.920632180204553)),
                            156,
                            2),
            };

            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("point_ed50_geo"));

            // Act.
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            infos    = m_Reader.ReadMBRs().ToArray();

            // Assert.
            Assert.IsNotNull(infos);
            Assert.AreEqual(3, infos.Length);

            int currIndex = 0;

            foreach (MBRInfo expectedInfo in expectedInfos)
            {
                HelperMethods.AssertMBRInfoEqual(expectedInfo, infos[currIndex++]);
            }
        }
        public void ReadShapeAtOffset_ReadPoint_shouldReturnCorrectValue()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();

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

            long[] shapeOffsets = { 100, 128, 156 };

            double[,] expectedCoordinates = { { 34.282930701329349, 31.851167389309651 },
                                              { 34.145260222088822, 31.864369159253059 },
                                              { 34.181721116813314, 31.920632180204553 } };

            // Act.
            for (int i = 0; i < shapeOffsets.Length; i++)
            {
                IGeometry geo = m_Reader.ReadShapeAtOffset(shapeOffsets[i], factory);

                // Assert.
                Assert.IsNotNull(geo);
                Assert.IsTrue(geo.IsValid);
                Assert.IsInstanceOf <IPoint>(geo);
                IPoint givenPoint = geo as IPoint;

                HelperMethods.AssertDoubleValuesEqual(givenPoint.X, expectedCoordinates[i, 0]);
                HelperMethods.AssertDoubleValuesEqual(givenPoint.Y, expectedCoordinates[i, 1]);
            }
        }
        public void ReadMBRs_ReadPolygon_ShouldReturnCorrectValues()
        {
            // Arrange.
            MBRInfo[] infos = null;

            MBRInfo[] expectedInfos = new[]
            {
                new MBRInfo(new Envelope(33.719047819505683, 33.78096814177016, 31.928805665809271, 32.025301664150398),
                            100,
                            0),
                new MBRInfo(new Envelope(33.819000337359398, 33.929011051318348, 31.97406740944362, 32.072449163771559),
                            252,
                            1),
            };

            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("polygon_ed50_geo"));

            // Act.
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            infos    = m_Reader.ReadMBRs().ToArray();

            // Assert.
            Assert.IsNotNull(infos);
            Assert.AreEqual(2, infos.Length);

            int currIndex = 0;

            foreach (MBRInfo expectedInfo in expectedInfos)
            {
                HelperMethods.AssertMBRInfoEqual(expectedInfo, infos[currIndex++]);
            }
        }
        public void ReadShapeAtIndex_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.ReadShapeAtIndex(0, null);
        }
        public void ReadEntry_SendOutOfBoundIndex_ShouldThrowException()
        {
            // Arrange
            m_TmpFile = new TempFileWriter("data.dbf", DbfFiles.Read("point_ed50_geo"));
            m_Reader = new DbaseReader(m_TmpFile.Path);

            // Act.
            m_Reader.ReadEntry(3);
        }
Example #10
0
        public void ReadEntry_SendOutOfBoundIndex_ShouldThrowException()
        {
            // Arrange
            m_TmpFile = new TempFileWriter("data.dbf", DbfFiles.Read("point_ed50_geo"));
            m_Reader  = new DbaseReader(m_TmpFile.Path);

            // Act.
            m_Reader.ReadEntry(3);
        }
        public void ReadShapeAtOffset_ReadPolygon_shouldReturnCorrectValue()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();

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

            long[] shapeOffsets = { 100, 252 };

            Coordinate[,] expectedLines = new Coordinate[, ]
            {
                {
                    new Coordinate(33.719047819505683, 31.989469320254013),
                    new Coordinate(33.730049025918099, 32.025301664150398),
                    new Coordinate(33.771538712027194, 32.008956957757299),
                    new Coordinate(33.78096814177016, 31.993555297099103),
                    new Coordinate(33.744507207486457, 31.928805665809271),
                    new Coordinate(33.719047819505683, 31.989469320254013)
                },
                {
                    new Coordinate(33.821829475819285, 32.051075573685317),
                    new Coordinate(33.860176141775888, 32.072449163771559),
                    new Coordinate(33.927125440097875, 32.054847113210094),
                    new Coordinate(33.929011051318348, 31.97878189417845),
                    new Coordinate(33.819000337359398, 31.97406740944362),
                    new Coordinate(33.821829475819285, 32.051075573685317)
                }
            };

            // Act.
            for (int i = 0; i < shapeOffsets.Length; i++)
            {
                IGeometry geo = m_Reader.ReadShapeAtOffset(shapeOffsets[i], factory);

                // Assert.
                Assert.IsNotNull(geo);
                Assert.IsTrue(geo.IsValid);
                Assert.IsInstanceOf <IPolygon>(geo);
                IPolygon givenPoly = geo as IPolygon;

                Assert.IsNotNull(givenPoly.ExteriorRing);
                Assert.AreSame(givenPoly.ExteriorRing, givenPoly.Shell);
                Assert.AreEqual(givenPoly.Shell.Coordinates.Length, expectedLines.GetLength(1));

                ILineString givenLine = givenPoly.Shell;

                for (int j = 0; j < givenLine.Coordinates.Length; j++)
                {
                    Coordinate currPoint = givenLine.Coordinates[j];

                    HelperMethods.AssertDoubleValuesEqual(currPoint.X, expectedLines[i, j].X);
                    HelperMethods.AssertDoubleValuesEqual(currPoint.Y, expectedLines[i, j].Y);
                }
            }
        }
        public void ReadShapeAtIndex_SendOutOfBoundIndex_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.ReadShapeAtIndex(2, factory);
        }
        public void ReadShapeAtOffset_ReadAllPolygonsFromUnifiedWithNullAtEnd_ShouldReturnCorrectValues()
        {
            // Arrange.
            GeometryFactory factory = new GeometryFactory();

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

            var expectedResult = new Coordinate[][]
            {
                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 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),
                }
            };

            long[] offsets = { 100, 236 };

            // Act.
            for (int i = 0; i < offsets.Length; i++)
            {
                var geo = m_Reader.ReadShapeAtOffset(offsets[i], factory);

                // Assert.
                Assert.IsNotNull(geo);
                Assert.IsTrue(geo.IsValid);
                Assert.IsInstanceOf <Polygon>(geo);
                var givenPoly = geo as Polygon;

                Assert.IsNotNull(givenPoly.ExteriorRing);
                Assert.AreSame(givenPoly.ExteriorRing, givenPoly.Shell);
                Assert.AreEqual(givenPoly.Shell.Coordinates.Length, expectedResult[i].Length);

                LineString givenLine = givenPoly.Shell;

                for (int j = 0; j < givenLine.Coordinates.Length; j++)
                {
                    var currPoint = givenLine.Coordinates[j];

                    HelperMethods.AssertDoubleValuesEqual(currPoint.X, expectedResult[i][j].X);
                    HelperMethods.AssertDoubleValuesEqual(currPoint.Y, expectedResult[i][j].Y);
                }
            }
        }
        public void ReadShapeAtOffset_TryReadAfterDisposed_shouldThrowException()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();

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

            m_Reader.Dispose();
            m_Reader.ReadShapeAtOffset(108, factory);
        }
Example #15
0
        public void ReadEntry_ReadNonExistantKeyFromEntry_ShoudReturnCorrectValues()
        {
            // Arrange
            m_TmpFile = new TempFileWriter("data.dbf", DbfFiles.Read("point_ed50_geo"));
            m_Reader  = new DbaseReader(m_TmpFile.Path);

            IAttributesTable results = m_Reader.ReadEntry(0);

            // Act.
            object a = results["a"];
        }
Example #16
0
        public void Ctor_SendValidParameters_ShouldReturnNotNull()
        {
            // Arrange
            m_TmpFile = new TempFileWriter("data.dbf", DbfFiles.Read("line_ed50_geo"));

            // Act.
            m_Reader = new DbaseReader(m_TmpFile.Path);

            // Assert.
            Assert.IsNotNull(m_Reader);
        }
Example #17
0
        public void ReadEntry_TryReadAfterDisposed_ShouldThrowException()
        {
            // Arrange
            m_TmpFile = new TempFileWriter("data.dbf", DbfFiles.Read("point_ed50_geo"));
            m_Reader  = new DbaseReader(m_TmpFile.Path);

            m_Reader.Dispose();

            // Act.
            m_Reader.ReadEntry(1);
        }
        public void Ctor_SendValidParameters_ShouldReturnNotNull()
        {
            // Arrange
            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("line_ed50_geo"));

            // Act.
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            // Assert.
            Assert.IsNotNull(m_Reader);
        }
        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 Ctor_SendValidParameters_ShouldReturnNotNull()
        {
            // Arrange
            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("line_ed50_geo"));

            // Act.
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            // Assert.
            Assert.IsNotNull(m_Reader);
        }
        public void Ctor_SendValidParameters_ShouldReturnNotNull()
        {
            // Arrange
            m_TmpFile = new TempFileWriter("data.dbf", DbfFiles.Read("line_ed50_geo"));

            // Act.
            m_Reader = new DbaseReader(m_TmpFile.Path);

            // Assert.
            Assert.IsNotNull(m_Reader);
        }
        public void ReadShapeAtOffset_SendOffsetAtEndOfFile_shouldThrowException()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();

            m_TmpFile = new TempFileWriter("polygon_intersecting_line.shp", ShpFiles.Read("polygon intersecting line"));
            m_Reader  = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            // Act.
            m_Reader.ReadShapeAtOffset(ShpFiles.Read("polygon intersecting line").Length, factory);
        }
        public void ReadEntry_SendOutOfBoundIndex_ShouldThrowException()
        {
            // Arrange
            m_TmpFile = new TempFileWriter(".dbf", DbfFiles.Read("point_ed50_geo"));
            m_Reader  = new DbaseReader(m_TmpFile.Path);

            // Act.
            Assert.Catch <ArgumentOutOfRangeException>(() =>
            {
                m_Reader.ReadEntry(3);
            });
        }
        public void ReadAllShapes_SendNullFactory_ShouldThrowException()
        {
            // Arrange.
            m_TmpFile = new TempFileWriter(".shp", ShpFiles.Read("UnifiedChecksMaterial"));
            m_Reader  = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            // Act.
            Assert.Catch <ArgumentNullException>(() =>
            {
                m_Reader.ReadAllShapes(null);
            });
        }
        public void ReadShapeAtIndex_SendNegativeIndex_ShouldThrowException()
        {
            // Arrange.
            m_TmpFile = new TempFileWriter(".shp", ShpFiles.Read("UnifiedChecksMaterial"));
            m_Reader  = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            GeometryFactory factory = new GeometryFactory();

            // Act.
            Assert.Catch <ArgumentOutOfRangeException>(() =>
            {
                m_Reader.ReadShapeAtIndex(-1, factory);
            });
        }
        public void ReadShapeAtIndex_TryReadAfterDisposed_ShouldThrowException()
        {
            // Arrange.
            m_TmpFile = new TempFileWriter(".shp", ShpFiles.Read("UnifiedChecksMaterial"));
            m_Reader  = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            GeometryFactory factory = new GeometryFactory();

            // Act.
            m_Reader.Dispose();
            Assert.Catch <InvalidOperationException>(() =>
            {
                m_Reader.ReadShapeAtIndex(0, factory);
            });
        }
        public void ReadShapeAtOffset_SendNegativeOffset_shouldThrowException()
        {
            // Arrange.
            GeometryFactory factory = new GeometryFactory();

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

            // Act.
            Assert.Catch <IndexOutOfRangeException>(() =>
            {
                m_Reader.ReadShapeAtOffset(-1, factory);
            });
        }
        public void ReadShapeAtOffset_TryReadAfterDisposed_shouldThrowException()
        {
            // Arrange.
            GeometryFactory factory = new GeometryFactory();

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

            m_Reader.Dispose();
            Assert.Catch <InvalidOperationException>(() =>
            {
                m_Reader.ReadShapeAtOffset(108, factory);
            });
        }
        public void ReadEntry_TryReadAfterDisposed_ShouldThrowException()
        {
            // Arrange
            m_TmpFile = new TempFileWriter(".dbf", DbfFiles.Read("point_ed50_geo"));
            m_Reader  = new DbaseReader(m_TmpFile.Path);

            m_Reader.Dispose();

            // Act.
            Assert.Catch <InvalidOperationException>(() =>
            {
                m_Reader.ReadEntry(1);
            });
        }
        public void TestCleanup()
        {
            if (m_Reader != null)
            {
                m_Reader.Dispose();
                m_Reader = null;
            }

            if (m_TmpFile != null)
            {
                m_TmpFile.Dispose();
                m_TmpFile = null;
            }
        }
        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 ReadEntry_ReadNonExistantKeyFromEntry_ShoudReturnCorrectValues()
        {
            // Arrange
            m_TmpFile = new TempFileWriter(".dbf", DbfFiles.Read("point_ed50_geo"));
            m_Reader  = new DbaseReader(m_TmpFile.Path);

            var results = m_Reader.ReadEntry(0);

            // Act.
            Assert.Catch <ArgumentException>(() =>
            {
                object a = results["a"];
            });
        }
        public void ReadShapeAtOffset_ReadLines_shouldReturnCorrectValue()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();

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

            long[] shapeOffsets = { 100, 236 };

            Coordinate[,] expectedLines = new Coordinate[, ]
            {
                {
                    new Coordinate(34.574599590903837, 31.884368958893564),
                    new Coordinate(34.57648553272869, 31.803273460424684),
                    new Coordinate(34.628034609274806, 31.875882220681703),
                    new Coordinate(34.573027972716453, 31.895998933480186),
                    new Coordinate(34.582143358203268, 31.886883547993374)
                },
                {
                    new Coordinate(34.448555812275849, 31.864880893370035),
                    new Coordinate(34.396692412092257, 31.778756216701534),
                    new Coordinate(34.468672525074325, 31.794158074937872),
                    new Coordinate(34.484703030585621, 31.844135533296601),
                    new Coordinate(34.518021336158107, 31.838163384184551)
                }
            };

            // Act.
            for (int i = 0; i < shapeOffsets.Length; i++)
            {
                IGeometry geo = m_Reader.ReadShapeAtOffset(shapeOffsets[i], factory);

                // Assert.
                Assert.IsNotNull(geo);
                Assert.IsTrue(geo.IsValid);
                Assert.IsInstanceOf <ILineString>(geo);
                ILineString givenLine = geo as ILineString;

                for (int j = 0; j < givenLine.Coordinates.Length; j++)
                {
                    Coordinate currPoint = givenLine.Coordinates[j];

                    HelperMethods.AssertDoubleValuesEqual(currPoint.X, expectedLines[i, j].X);
                    HelperMethods.AssertDoubleValuesEqual(currPoint.Y, expectedLines[i, j].Y);
                }
            }
        }
        public void FileHeader_ReadPoint_ShouldReturnCorrectValues()
        {
            // Arrange.
            Envelope expectedMBR = new Envelope(34.14526022208882, 34.28293070132935, 31.85116738930965, 31.92063218020455);

            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("point_ed50_geo"));

            // Act.
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            // Assert.
            Assert.IsNotNull(m_Reader);
            Assert.IsNotNull(m_Reader.ShapefileHeader);
            Assert.AreEqual(m_Reader.ShapefileHeader.ShapeType, ShapeGeometryType.Point);
            HelperMethods.AssertEnvelopesEqual(m_Reader.ShapefileHeader.Bounds, expectedMBR);
        }
        public void ReadShapeAtOffset_ReadPolygonWithIntersectingLine_shouldReturnInvalidGeo()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();
            m_TmpFile = new TempFileWriter("polygon_intersecting_line.shp", ShpFiles.Read("polygon intersecting line"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            long[] shapeOffsets = { 100, 236 };

            bool[] expectedValidityResults = new bool[] { false, true };

            // Act.
            for (int i = 0; i < shapeOffsets.Length; i++)
            {
                IGeometry geo = m_Reader.ReadShapeAtOffset(shapeOffsets[i], factory);

                // Assert.
                Assert.IsNotNull(geo);
                Assert.AreEqual(geo.IsValid, expectedValidityResults[i]);
            }
        }
        public void TestCleanup()
        {
            if (m_Reader != null)
            {
                m_Reader.Dispose();
                m_Reader = null;
            }

            if (m_TmpFile != null)
            {
                m_TmpFile.Dispose();
                m_TmpFile = null;
            }
        }
        public void ReadEntry_ReadNonExistantKeyFromEntry_ShoudReturnCorrectValues()
        {
            // Arrange
            m_TmpFile = new TempFileWriter("data.dbf", DbfFiles.Read("point_ed50_geo"));
            m_Reader = new DbaseReader(m_TmpFile.Path);

            IAttributesTable results = m_Reader.ReadEntry(0);

            // Act.
            object a = results["a"];
        }
        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 ReadMBRs_ReadLine_ShouldReturnCorrectValues()
        {
            // Arrange.
            MBRInfo[] infos = null;

            MBRInfo[] expectedInfos = new[]
				{
					new MBRInfo(new Envelope(34.573027972716453, 34.628034609274806, 31.803273460424684, 31.895998933480186),
							    100,
								0),
					new MBRInfo(new Envelope(34.396692412092257, 34.518021336158107, 31.778756216701534, 31.864880893370035),
							    236,
								1),
				};

            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("line_wgs84_geo"));

            // Act.
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            infos = m_Reader.ReadMBRs().ToArray();

            // Assert.
            Assert.IsNotNull(infos);
            Assert.AreEqual(2, infos.Length);

            int currIndex = 0;

            foreach (MBRInfo expectedInfo in expectedInfos)
            {
                HelperMethods.AssertMBRInfoEqual(expectedInfo, infos[currIndex++]);
            }
        }
        public void ReadShapeAtIndex_SendNegativeIndex_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.ReadShapeAtIndex(-1, factory);
        }
        public void ReadShapeAtOffset_TryReadAfterDisposed_shouldThrowException()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();
            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("line_wgs84_geo"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            m_Reader.Dispose();
            m_Reader.ReadShapeAtOffset(108, factory);
        }
        public void FileHeader_ReadPolygon_ShouldReturnCorrectValues()
        {
            // Arrange.
            Envelope expectedMBR = new Envelope(33.47383821246188, 33.75452922072821, 32.0295864794076, 32.1886342399706);

            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("polygon_wgs84_geo"));

            // Act.
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            // Assert.
            Assert.IsNotNull(m_Reader);
            Assert.IsNotNull(m_Reader.ShapefileHeader);
            Assert.AreEqual(m_Reader.ShapefileHeader.ShapeType, ShapeGeometryType.Polygon);
            HelperMethods.AssertEnvelopesEqual(m_Reader.ShapefileHeader.Bounds, expectedMBR);
        }
        public void ReadShapeAtIndex_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.ReadShapeAtIndex(0, 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 ReadShapeAtOffset_SendOffsetAtEndOfFile_shouldThrowException()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();
            m_TmpFile = new TempFileWriter("polygon_intersecting_line.shp", ShpFiles.Read("polygon intersecting line"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            // Act.
            m_Reader.ReadShapeAtOffset(ShpFiles.Read("polygon intersecting line").Length, factory);
        }
        public void ReadMBRs_ReadUnifiedWithNullAtEnd_ShouldReturnCorrectValues()
        {
            // Arrange.
            MBRInfo[] infos = null;

            MBRInfo[] expectedInfos = new[]
				{
					new MBRInfo(new Envelope(-1.151515151515152, -0.353535353535354, -0.929292929292929, -0.419191919191919),
							    100,
								0),
					new MBRInfo(new Envelope(-0.457070707070707, 0.421717171717172, 0.070707070707071, 0.578282828282829),
							    236,
								1),
				};

            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("UnifiedChecksMaterialNullAtEnd"));

            // Act.
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            infos = m_Reader.ReadMBRs().ToArray();

            // Assert.
            Assert.IsNotNull(infos);
            Assert.AreEqual(expectedInfos.Length, infos.Length);

            int currIndex = 0;

            foreach (MBRInfo expectedInfo in expectedInfos)
            {
                HelperMethods.AssertMBRInfoEqual(expectedInfo, infos[currIndex++]);
            }
        }
        public void ReadMBRs_ReadPolygon_ShouldReturnCorrectValues()
        {
            // Arrange.
            MBRInfo[] infos = null;

            MBRInfo[] expectedInfos = new[]
				{
					new MBRInfo(new Envelope(33.719047819505683, 33.78096814177016, 31.928805665809271, 32.025301664150398),
							    100,
								0),
					new MBRInfo(new Envelope(33.819000337359398, 33.929011051318348, 31.97406740944362, 32.072449163771559),
							    252,
								1),
				};

            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("polygon_ed50_geo"));

            // Act.
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            infos = m_Reader.ReadMBRs().ToArray();

            // Assert.
            Assert.IsNotNull(infos);
            Assert.AreEqual(2, infos.Length);

            int currIndex = 0;

            foreach (MBRInfo expectedInfo in expectedInfos)
            {
                HelperMethods.AssertMBRInfoEqual(expectedInfo, infos[currIndex++]);
            }
        }
        public void ReadShapeAtIndex_ReadUnifiedCheckMaterialWithNulLInMiddle_ShouldReturnBothShapesCorrectly()
        {
            // Arrange.
            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("UnifiedChecksMaterialNullInMiddle"));
            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.
            for (int i = 0; i < expectedResult.Length; i++)
            {
                IGeometry result = m_Reader.ReadShapeAtIndex(i, factory);

                Assert.IsNotNull(result);
                Assert.IsInstanceOf<IPolygon>(result);

                HelperMethods.AssertPolygonsEqual(expectedResult[i], result as IPolygon);
            }
        }
        public void ReadShapeAtOffset_ReadAllPolygonsFromUnifiedWithNullAtEnd_ShouldReturnCorrectValues()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();
            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("UnifiedChecksMaterialNullAtEnd"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            Coordinate[][] expectedResult = new Coordinate[][]
			{
                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 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),
				}
			};
            long[] offsets = { 100, 236 };

            // Act.
            for (int i = 0; i < offsets.Length; i++)
            {
                IGeometry geo = m_Reader.ReadShapeAtOffset(offsets[i], factory);

                // Assert.
                Assert.IsNotNull(geo);
                Assert.IsTrue(geo.IsValid);
                Assert.IsInstanceOf<IPolygon>(geo);
                IPolygon givenPoly = geo as IPolygon;

                Assert.IsNotNull(givenPoly.ExteriorRing);
                Assert.AreSame(givenPoly.ExteriorRing, givenPoly.Shell);
                Assert.AreEqual(givenPoly.Shell.Coordinates.Length, expectedResult[i].Length);

                ILineString givenLine = givenPoly.Shell;

                for (int j = 0; j < givenLine.Coordinates.Length; j++)
                {
                    Coordinate currPoint = givenLine.Coordinates[j];

                    HelperMethods.AssertDoubleValuesEqual(currPoint.X, expectedResult[i][j].X);
                    HelperMethods.AssertDoubleValuesEqual(currPoint.Y, expectedResult[i][j].Y);
                }
            }
        }
        public void FileHeader_ReadLine_ShouldReturnCorrectValues()
        {
            // Arrange.
            Envelope expectedMBR = new Envelope(639384.5630270261, 662946.9241196744, 3505730.839052265, 3515879.236960234);

            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("line_ed50_utm36"));

            // Act.
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            // Assert.
            Assert.IsNotNull(m_Reader);
            Assert.IsNotNull(m_Reader.ShapefileHeader);
            Assert.AreEqual(m_Reader.ShapefileHeader.ShapeType, ShapeGeometryType.LineString);
            HelperMethods.AssertEnvelopesEqual(m_Reader.ShapefileHeader.Bounds, expectedMBR);
        }
        public void ReadMBRs_ReadPoint_ShouldReturnCorrectValues()
        {
            // Arrange.
            MBRInfo[] infos = null;

            MBRInfo[] expectedInfos = new[]
				{
					new MBRInfo(new Envelope(new Coordinate(34.282930701329349, 31.851167389309651)),
							    100,
								0),
					new MBRInfo(new Envelope(new Coordinate(34.145260222088822, 31.864369159253059)),
							    128,
								1),
					new MBRInfo(new Envelope(new Coordinate(34.181721116813314, 31.920632180204553)),
							    156,
								2),
				};

            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("point_ed50_geo"));

            // Act.
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            infos = m_Reader.ReadMBRs().ToArray();

            // Assert.
            Assert.IsNotNull(infos);
            Assert.AreEqual(3, infos.Length);

            int currIndex = 0;

            foreach (MBRInfo expectedInfo in expectedInfos)
            {
                HelperMethods.AssertMBRInfoEqual(expectedInfo, infos[currIndex++]);
            }
        }
        public void ReadShapeAtOffset_ReadPolygon_shouldReturnCorrectValue()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();
            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("polygon_ed50_geo"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            long[] shapeOffsets = { 100, 252 };

            Coordinate[,] expectedLines = new Coordinate[,]
			{
				{
					new Coordinate(33.719047819505683, 31.989469320254013), 
					new Coordinate(33.730049025918099, 32.025301664150398),
					new Coordinate(33.771538712027194, 32.008956957757299),
					new Coordinate(33.78096814177016, 31.993555297099103),
					new Coordinate(33.744507207486457, 31.928805665809271),
					new Coordinate(33.719047819505683, 31.989469320254013)
				},
				{
					new Coordinate(33.821829475819285, 32.051075573685317), 
					new Coordinate(33.860176141775888, 32.072449163771559),
					new Coordinate(33.927125440097875, 32.054847113210094),
					new Coordinate(33.929011051318348, 31.97878189417845),
					new Coordinate(33.819000337359398, 31.97406740944362),
					new Coordinate(33.821829475819285, 32.051075573685317)
				}
			};

            // Act.
            for (int i = 0; i < shapeOffsets.Length; i++)
            {
                IGeometry geo = m_Reader.ReadShapeAtOffset(shapeOffsets[i], factory);

                // Assert.
                Assert.IsNotNull(geo);
                Assert.IsTrue(geo.IsValid);
                Assert.IsInstanceOf<IPolygon>(geo);
                IPolygon givenPoly = geo as IPolygon;

                Assert.IsNotNull(givenPoly.ExteriorRing);
                Assert.AreSame(givenPoly.ExteriorRing, givenPoly.Shell);
                Assert.AreEqual(givenPoly.Shell.Coordinates.Length, expectedLines.GetLength(1));

                ILineString givenLine = givenPoly.Shell;

                for (int j = 0; j < givenLine.Coordinates.Length; j++)
                {
                    Coordinate currPoint = givenLine.Coordinates[j];

                    HelperMethods.AssertDoubleValuesEqual(currPoint.X, expectedLines[i, j].X);
                    HelperMethods.AssertDoubleValuesEqual(currPoint.Y, expectedLines[i, j].Y);
                }
            }
        }
        public void ReadShapeAtIndex_ReadSecondUnifiedCheckMaterialShape_ShouldReturnTriangle()
        {
            // Arrange.
            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("UnifiedChecksMaterial"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);
            IGeometryFactory factory = new GeometryFactory();

            Polygon expectedPolygon = 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 polygon = m_Reader.ReadShapeAtIndex(1, factory);

            Assert.IsNotNull(polygon);
            Assert.IsInstanceOf<IPolygon>(polygon);
            HelperMethods.AssertPolygonsEqual(polygon as IPolygon, expectedPolygon);
        }
        public void ReadShapeAtOffset_ReadLines_shouldReturnCorrectValue()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();
            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("line_wgs84_geo"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            long[] shapeOffsets = { 100, 236 };

            Coordinate[,] expectedLines = new Coordinate[,]
			{
				{
					new Coordinate(34.574599590903837, 31.884368958893564), 
					new Coordinate(34.57648553272869, 31.803273460424684),
					new Coordinate(34.628034609274806, 31.875882220681703),
					new Coordinate(34.573027972716453, 31.895998933480186),
					new Coordinate(34.582143358203268, 31.886883547993374)
				},
				{
					new Coordinate(34.448555812275849, 31.864880893370035), 
					new Coordinate(34.396692412092257, 31.778756216701534),
					new Coordinate(34.468672525074325, 31.794158074937872),
					new Coordinate(34.484703030585621, 31.844135533296601),
					new Coordinate(34.518021336158107, 31.838163384184551)
				}
			};

            // Act.
            for (int i = 0; i < shapeOffsets.Length; i++)
            {
                IGeometry geo = m_Reader.ReadShapeAtOffset(shapeOffsets[i], factory);

                // Assert.
                Assert.IsNotNull(geo);
                Assert.IsTrue(geo.IsValid);
                Assert.IsInstanceOf<ILineString>(geo);
                ILineString givenLine = geo as ILineString;

                for (int j = 0; j < givenLine.Coordinates.Length; j++)
                {
                    Coordinate currPoint = givenLine.Coordinates[j];

                    HelperMethods.AssertDoubleValuesEqual(currPoint.X, expectedLines[i, j].X);
                    HelperMethods.AssertDoubleValuesEqual(currPoint.Y, expectedLines[i, j].Y);
                }
            }
        }
        public void ForEachIteration_ReadEntryValues_ShoudReturnCorrectValues()
        {
            // Arrange
            m_TmpFile = new TempFileWriter("data.dbf", DbfFiles.Read("point_ed50_geo"));
            m_Reader = new DbaseReader(m_TmpFile.Path);

            var expectedTable = new
            {
                Ids = new double[] 
				{ 
					3, 2, 1
				},
                Strings = new string[] 
				{ 
					"str3", "str2", "str1"
				},
                WholeNums = new double[] 
				{ 
					3, 2, 1
				},
                DecNums = new double[] 
				{
					3, 2, 1
				},
            };

            // Act.
            IAttributesTable[] results = m_Reader.ToArray();

            Assert.AreEqual(results.Length, 3);

            // Assert.
            int currResIndex = 0;
            foreach (IAttributesTable res in results)
            {
                object id = res["id"];
                object str = res["str"];
                object wholeNum = res["wholeNum"];
                object decNum = res["decNum"];
                object date = res["dt"];

                Assert.IsNotNull(id);
                Assert.IsNotNull(str);
                Assert.IsNotNull(wholeNum);
                Assert.IsNotNull(decNum);
                Assert.IsNotNull(date);

                Assert.IsInstanceOf<double>(id);
                Assert.IsInstanceOf<string>(str);
                Assert.IsInstanceOf<double>(wholeNum);
                Assert.IsInstanceOf<double>(decNum);
                Assert.IsInstanceOf<DateTime>(date);

                Assert.AreEqual(id, expectedTable.Ids[currResIndex]);
                Assert.AreEqual(str, expectedTable.Strings[currResIndex]);
                Assert.AreEqual(wholeNum, expectedTable.WholeNums[currResIndex]);
                Assert.AreEqual(decNum, expectedTable.DecNums[currResIndex]);
                Assert.AreEqual(date, DATE_SAVED_IN_DBF);

                currResIndex++;
            }
        }
        public void ReadShapeAtOffset_ReadPoint_shouldReturnCorrectValue()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();
            m_TmpFile = new TempFileWriter("shape.shp", ShpFiles.Read("point_ed50_geo"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(m_TmpFile.Path);

            long[] shapeOffsets = { 100, 128, 156 };

            double[,] expectedCoordinates = {{ 34.282930701329349, 31.851167389309651 },
											 { 34.145260222088822, 31.864369159253059 },
											 { 34.181721116813314, 31.920632180204553 }};

            // Act.
            for (int i = 0; i < shapeOffsets.Length; i++)
            {
                IGeometry geo = m_Reader.ReadShapeAtOffset(shapeOffsets[i], factory);

                // Assert.
                Assert.IsNotNull(geo);
                Assert.IsTrue(geo.IsValid);
                Assert.IsInstanceOf<IPoint>(geo);
                IPoint givenPoint = geo as IPoint;

                HelperMethods.AssertDoubleValuesEqual(givenPoint.X, expectedCoordinates[i, 0]);
                HelperMethods.AssertDoubleValuesEqual(givenPoint.Y, expectedCoordinates[i, 1]);
            }
        }
        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_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 ReadEntry_TryReadAfterDisposed_ShouldThrowException()
        {
            // Arrange
            m_TmpFile = new TempFileWriter("data.dbf", DbfFiles.Read("point_ed50_geo"));
            m_Reader = new DbaseReader(m_TmpFile.Path);

            m_Reader.Dispose();

            // Act.
            m_Reader.ReadEntry(1);
        }
        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);
            }
        }