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 Ctor_SendNullSpatialIndex_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)), null);
        }
        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 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 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 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 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_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());
        }