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