public void Ctor_SendShpWithNoDbf_ShouldThrowException()
        {
            // Arrange.
            m_TempFiles = new TempFileWriter[]
			{
				new TempFileWriter("test.shp", ShpFiles.Read("UnifiedChecksMaterial")),
			};

            // Act.
            m_shapeDataReader = new ShapeDataReader(m_TempFiles[0].Path);
        }
        public void Ctor_SendNullSpatialIndex_ShouldThrowException()
        {
            // Arrange.
            m_TempFiles = new TempFileWriter[]
			{
				new TempFileWriter("test.shp", ShpFiles.Read("UnifiedChecksMaterial")),
				new TempFileWriter("test.dbf", DbfFiles.Read("UnifiedChecksMaterial")),
			};

            // Act.
            m_shapeDataReader = new ShapeDataReader(m_TempFiles[0].Path, null);
        }
        public void ReadByGeoFilter_ReadWithWholeTriangleInBounds_ShouldReturnTriangle()
        {
            Envelope boundsWithWholeTriangle = new Envelope(-0.62331, 0.63774, -0.02304, 0.76942);

            // Arrange.
            m_TempFiles = new TempFileCloudUploader[]
            {
                new TempFileCloudUploader("test.shp", ShpFiles.Read("UnifiedChecksMaterial")),
                new TempFileCloudUploader("test.dbf", DbfFiles.Read("UnifiedChecksMaterial")),
            };

            Polygon expectedTriangle = 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),
                    }));

            string expectedShapeMetadata = "Triangle";

            m_shapeDataReader = new ShapeDataReader(new ShapefileStreamProviderRegistry(GetProvider(m_TempFiles[0].Path), GetProvider(m_TempFiles[1].Path)));

            // Act.
            IEnumerable<IShapefileFeature> results = m_shapeDataReader.ReadByMBRFilter(boundsWithWholeTriangle);

            // Assert.
            Assert.IsNotNull(results);

            IShapefileFeature result = results.Single();

            Assert.IsNotNull(result);
            Assert.IsInstanceOf<ShapefileFeature>(result);
            Assert.AreEqual(((ShapefileFeature)result).FeatureId, 1);
            Assert.IsNotNull(result.Attributes);

            HelperMethods.AssertPolygonsEqual(result.Geometry as IPolygon, expectedTriangle);

            object shapeNameData = result.Attributes["ShapeName"];
            Assert.IsInstanceOf<string>(shapeNameData);

            Assert.AreEqual((string)shapeNameData, expectedShapeMetadata);
        }
        public void ReadByGeoFilter_ReadAllInBounds_ShouldReturnAllShapesAndCorrectDbfData()
        {
            // Arrange.
            m_TempFiles = new TempFileCloudUploader[]
            {
                new TempFileCloudUploader("test.shp", ShpFiles.Read("UnifiedChecksMaterial")),
                new TempFileCloudUploader("test.dbf", DbfFiles.Read("UnifiedChecksMaterial")),
            };

            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),
                    }))
            };

            string[] expectedShapeMetadata = new string[] { "Rectangle", "Triangle" };

            m_shapeDataReader = new ShapeDataReader(new ShapefileStreamProviderRegistry(GetProvider(m_TempFiles[0].Path), GetProvider(m_TempFiles[1].Path)));

            // Act.
            IEnumerable<IShapefileFeature> results = m_shapeDataReader.ReadByMBRFilter(m_shapeDataReader.ShapefileBounds);

            // Assert.
            Assert.IsNotNull(results);

            int currIndex = 0;
            foreach (IShapefileFeature result in results)
            {
                Assert.IsNotNull(result);
                Assert.IsInstanceOf<ShapefileFeature>(result);
                ShapefileFeature sf = (ShapefileFeature)result;
                Assert.AreEqual(sf.FeatureId, currIndex);
                Assert.IsNotNull(result.Attributes);

                HelperMethods.AssertPolygonsEqual(result.Geometry as IPolygon, expectedResult[currIndex]);

                object shapeNameData = result.Attributes["ShapeName"];
                Assert.IsInstanceOf<string>(shapeNameData);

                Assert.AreEqual((string)shapeNameData, expectedShapeMetadata[currIndex++]);
            }
        }
        public void ShapeFileBounds_ReadPointED50Geo_ShouldReturnCorrectEnvelope()
        {
            // Arrange.
            Envelope expectedMBR = new Envelope(34.14526022208882, 34.28293070132935, 31.85116738930965, 31.92063218020455);

            m_TempFiles = new TempFileCloudUploader[]
            {
                new TempFileCloudUploader("test.shp", ShpFiles.Read("point_ed50_geo")),
                new TempFileCloudUploader("test.dbf", DbfFiles.Read("point_ed50_geo")),
            };

            // Act.
            m_shapeDataReader = new ShapeDataReader(new ShapefileStreamProviderRegistry(GetProvider(m_TempFiles[0].Path), GetProvider(m_TempFiles[1].Path)));

            // Assert.
            HelperMethods.AssertEnvelopesEqual(expectedMBR, m_shapeDataReader.ShapefileBounds);
        }
 public void Ctor_SendNullPath_ShouldThrowException()
 {
     // Act.
     m_shapeDataReader = new ShapeDataReader((string)null);
 }
        public void TestCleanup()
        {
            if (m_shapeDataReader != null)
            {
                m_shapeDataReader.Dispose();
                m_shapeDataReader = null;
            }

            if (m_TempFiles != null)
            {
                foreach (TempFileCloudUploader tempFile in m_TempFiles)
                {
                    tempFile.Dispose();
                }

                m_TempFiles = null;
            }
        }
 public void Ctor_SendNonExistantFilePath_ShouldThrowException()
 {
     // Act.
     m_shapeDataReader = new ShapeDataReader(new ShapefileStreamProviderRegistry(GetProvider(@"/this/is/sheker/path/should/never/exist/on/ur/pc"),null));
 }
 public void Ctor_SendWhitespacePath_ShouldThrowException()
 {
     // Act.
     m_shapeDataReader = new ShapeDataReader(new ShapefileStreamProviderRegistry(GetProvider("   \t   "), null));
 }
        public void ReadByGeoFilter_ReadWithRectangleMBRPartiallyInBoundsAndFlagSetToTrue_ShouldReturnNoGeometries()
        {
            Envelope boundsWithWholeTriangle = new Envelope(-1.17459, -1.00231, -1.09803, -0.80861);

            // Arrange.
            m_TempFiles = new TempFileWriter[]
			{
				new TempFileWriter("test.shp", ShpFiles.Read("UnifiedChecksMaterial")),
				new TempFileWriter("test.dbf", DbfFiles.Read("UnifiedChecksMaterial")),
			};

            m_shapeDataReader = new ShapeDataReader(m_TempFiles[0].Path);

            // Act.
            IEnumerable<IShapefileFeature> results = m_shapeDataReader.ReadByMBRFilter(boundsWithWholeTriangle, true);

            // Assert.
            Assert.IsNotNull(results);
            Assert.IsFalse(results.Any());
        }
 public void Ctor_SendNonExistantFilePath_ShouldThrowException()
 {
     // Act.
     m_shapeDataReader = new ShapeDataReader(@"C:\this\is\sheker\path\should\never\exist\on\ur\pc");
 }
 public void Ctor_SendWhitespacePath_ShouldThrowException()
 {
     // Act.
     m_shapeDataReader = new ShapeDataReader("   \t   ");
 }
        public void ReadByGeoFilter_ReadWithWholeRectangleInBoundsAndFlagSetToTrue_ShouldReturnRectangle()
        {
            Envelope boundsWithWholeTriangle = new Envelope(-1.39510, -0.12716, -1.13938, -0.22977);

            // Arrange.
            m_TempFiles = new TempFileWriter[]
			{
				new TempFileWriter("test.shp", ShpFiles.Read("UnifiedChecksMaterial")),
				new TempFileWriter("test.dbf", DbfFiles.Read("UnifiedChecksMaterial")),
			};

            Polygon expectedTriangle = 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),
					}));

            string expectedShapeMetadata = "Rectangle";

            m_shapeDataReader = new ShapeDataReader(m_TempFiles[0].Path);

            // Act.
            IEnumerable<IShapefileFeature> results = m_shapeDataReader.ReadByMBRFilter(boundsWithWholeTriangle, true);

            // Assert.
            Assert.IsNotNull(results);

            IShapefileFeature result = results.Single();

            Assert.IsNotNull(result);
            Assert.IsInstanceOf<ShapefileFeature>(result);
            Assert.AreEqual(((ShapefileFeature)result).FeatureId, 0);
            Assert.IsNotNull(result.Attributes);

            HelperMethods.AssertPolygonsEqual(result.Geometry as IPolygon, expectedTriangle);

            object shapeNameData = result.Attributes["ShapeName"];
            Assert.IsInstanceOf<string>(shapeNameData);

            Assert.AreEqual((string)shapeNameData, expectedShapeMetadata);
        }
 public void Ctor_SendEmptyPath_ShouldThrowException()
 {
     // Act.
     m_shapeDataReader = new ShapeDataReader(string.Empty);
 }
 public void Ctor_SendEmptyPath_ShouldThrowException()
 {
     // Act.
     m_shapeDataReader = new ShapeDataReader(new ShapefileStreamProviderRegistry(GetProvider(string.Empty), null));
 }
        public void Ctor_SendNullGeometryFactory_ShouldThrowException()
        {
            // Arrange.
            m_TempFiles = new TempFileWriter[]
			{
				new TempFileWriter("test.shp", ShpFiles.Read("UnifiedChecksMaterial")),
				new TempFileWriter("test.dbf", DbfFiles.Read("UnifiedChecksMaterial")),
			};

            // Act.
            m_shapeDataReader = new ShapeDataReader(m_TempFiles[0].Path, new STRtree<ShapeLocationInFileInfo>(), null);
        }
        public void ReadByGeoFilter_ReadWithRectangleMBRPartiallyInBounds_ShouldReturnRectangle()
        {
            Envelope boundsWithWholeTriangle = new Envelope(-1.17459, -1.00231, -1.09803, -0.80861);

            // Arrange.
            m_TempFiles = new TempFileCloudUploader[]
            {
                new TempFileCloudUploader("test.shp", ShpFiles.Read("UnifiedChecksMaterial")),
                new TempFileCloudUploader("test.dbf", DbfFiles.Read("UnifiedChecksMaterial")),
            };

            Polygon expectedTriangle = 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),
                    }));

            string expectedShapeMetadata = "Rectangle";

            m_shapeDataReader = new ShapeDataReader(new ShapefileStreamProviderRegistry(GetProvider(m_TempFiles[0].Path), GetProvider(m_TempFiles[1].Path)));

            // Act.
            IEnumerable<IShapefileFeature> results = m_shapeDataReader.ReadByMBRFilter(boundsWithWholeTriangle);

            // Assert.
            Assert.IsNotNull(results);

            IShapefileFeature result = results.Single();

            Assert.IsNotNull(result);
            Assert.IsInstanceOf<ShapefileFeature>(result);
            Assert.AreEqual(((ShapefileFeature)result).FeatureId, 0);
            Assert.IsNotNull(result.Attributes);

            HelperMethods.AssertPolygonsEqual(result.Geometry as IPolygon, expectedTriangle);

            object shapeNameData = result.Attributes["ShapeName"];
            Assert.IsInstanceOf<string>(shapeNameData);

            Assert.AreEqual((string)shapeNameData, expectedShapeMetadata);
        }
        public void Ctor_SendShpWithNoPrj_ShouldReturnNotNull()
        {
            // Arrange.
            m_TempFiles = new TempFileWriter[]
			{
				new TempFileWriter("test.shp", ShpFiles.Read("UnifiedChecksMaterial")),
				new TempFileWriter("test.dbf", DbfFiles.Read("UnifiedChecksMaterial")),
			};

            // Act.
            m_shapeDataReader = new ShapeDataReader(m_TempFiles[0].Path);
            Assert.IsNotNull(m_shapeDataReader);
        }
        public void ReadByGeoFilter_ReadWithNoShapeInBoundsAndFlagSetToTrue_ShouldReturnEmptyEnumerable()
        {
            Envelope boundsWithWholeTriangle = new Envelope(-1.17459, -1.00231, -1.09803, -1.5);

            // Arrange.
            m_TempFiles = new TempFileCloudUploader[]
            {
                new TempFileCloudUploader("test.shp", ShpFiles.Read("UnifiedChecksMaterial")),
                new TempFileCloudUploader("test.dbf", DbfFiles.Read("UnifiedChecksMaterial")),
            };

            m_shapeDataReader = new ShapeDataReader(new ShapefileStreamProviderRegistry(GetProvider(m_TempFiles[0].Path), GetProvider(m_TempFiles[1].Path)));

            // Act.
            IEnumerable<IShapefileFeature> results = m_shapeDataReader.ReadByMBRFilter(boundsWithWholeTriangle, true);

            // Assert.
            Assert.IsNotNull(results);
            Assert.IsFalse(results.Any());
        }
        public void Ctor_SendShpWithNoPrj_ShouldReturnNotNull()
        {
            // Arrange.
            m_TempFiles = new TempFileCloudUploader[]
            {
                new TempFileCloudUploader("test.shp", ShpFiles.Read("UnifiedChecksMaterial")),
                new TempFileCloudUploader("test.dbf", DbfFiles.Read("UnifiedChecksMaterial")),
            };

            // Act.
            m_shapeDataReader = new ShapeDataReader(new ShapefileStreamProviderRegistry(GetProvider(m_TempFiles[0].Path), GetProvider(m_TempFiles[1].Path)));
            Assert.IsNotNull(m_shapeDataReader);
        }
        public void ReadByGeoFilter_ReadShapeDataAfterReaderObjectDisposed_ShouldThrowException()
        {
            Envelope boundsWithWholeTriangle = new Envelope(-1.17459, -1.00231, -1.09803, -0.80861);

            // Arrange.
            m_TempFiles = new TempFileCloudUploader[]
            {
                new TempFileCloudUploader("test.shp", ShpFiles.Read("UnifiedChecksMaterial")),
                new TempFileCloudUploader("test.dbf", DbfFiles.Read("UnifiedChecksMaterial")),
            };

            m_shapeDataReader = new ShapeDataReader(new ShapefileStreamProviderRegistry(GetProvider(m_TempFiles[0].Path), GetProvider(m_TempFiles[1].Path)));

            // Act.
            IEnumerable<IShapefileFeature> results = m_shapeDataReader.ReadByMBRFilter(boundsWithWholeTriangle);

            // Assert.
            Assert.IsNotNull(results);
            IShapefileFeature result = results.Single();

            // Dispose of the reader object.
            m_shapeDataReader.Dispose();

            // Try reading dbf data.
            IGeometry table = result.Geometry;
        }
        public void Ctor_SetAsyncIndexToFalse_ShouldReturnNotNull()
        {
            // Arrange.
            m_TempFiles = new TempFileCloudUploader[]
            {
                new TempFileCloudUploader("test.shp", ShpFiles.Read("UnifiedChecksMaterial")),
                new TempFileCloudUploader("test.dbf", DbfFiles.Read("UnifiedChecksMaterial")),
            };

            // Act.
            m_shapeDataReader = new ShapeDataReader(new ShapefileStreamProviderRegistry(GetProvider(m_TempFiles[0].Path), GetProvider(m_TempFiles[1].Path)), new STRtree<ShapeLocationInFileInfo>(), new GeometryFactory(), false);

            // Assert.
            Assert.IsNotNull(m_shapeDataReader);
        }
        public void Ctor_SendNullGeometryFactory_ShouldThrowException()
        {
            // Arrange.
            m_TempFiles = new TempFileCloudUploader[]
            {
                new TempFileCloudUploader("test.shp", ShpFiles.Read("UnifiedChecksMaterial")),
                new TempFileCloudUploader("test.dbf", DbfFiles.Read("UnifiedChecksMaterial")),
            };

            // Act.
            m_shapeDataReader = new ShapeDataReader(new ShapefileStreamProviderRegistry(GetProvider(m_TempFiles[0].Path), GetProvider(m_TempFiles[1].Path)), new STRtree<ShapeLocationInFileInfo>(), null);
        }
        public void Ctor_SetAsyncIndexToTrue_ShouldReturnNotNull()
        {
            // Arrange.
            m_TempFiles = new TempFileWriter[]
			{
				new TempFileWriter("test.shp", ShpFiles.Read("UnifiedChecksMaterial")),
				new TempFileWriter("test.dbf", DbfFiles.Read("UnifiedChecksMaterial"))
			};

            // Act.
            m_shapeDataReader = new ShapeDataReader(m_TempFiles[0].Path, new STRtree<ShapeLocationInFileInfo>(), new GeometryFactory(), true);

            // Assert.
            Assert.IsNotNull(m_shapeDataReader);
        }