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 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 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_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 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 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 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_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 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]);
            }
        }
Ejemplo n.º 10
0
        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 ReadShapeAtOffset_SendOffsetAtEndOfFile_shouldThrowException()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();
            m_TmpFile = new TempFileCloudUploader("polygon_intersecting_line.shp", ShpFiles.Read("polygon intersecting line"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(new ShapefileStreamProviderRegistry(GetProvider(m_TmpFile.Path), null, true, false));

            // Act.
            m_Reader.ReadShapeAtOffset(ShpFiles.Read("polygon intersecting line").Length, factory);
        }
        public void ReadShapeAtOffset_TryReadAfterDisposed_shouldThrowException()
        {
            // Arrange.
            IGeometryFactory factory = new GeometryFactory();
            m_TmpFile = new TempFileCloudUploader("shape.shp", ShpFiles.Read("line_wgs84_geo"));
            m_Reader = new IO.ShapeFile.Extended.ShapeReader(new ShapefileStreamProviderRegistry(GetProvider(m_TmpFile.Path), null, true, false));

            m_Reader.Dispose();
            m_Reader.ReadShapeAtOffset(108, factory);
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
        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);
                }
            }
        }
Ejemplo n.º 16
0
        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]);
            }
        }
Ejemplo n.º 17
0
        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);
                }
            }
        }
Ejemplo n.º 18
0
        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]);
            }
        }