Esempio n. 1
0
        public void PointInShapefile()
        {
            // It goes too fast for DotMemory:
            Thread.Sleep(2000);

            const string folder = @"D:\dev\GIS-Data\Issues\Point in Polygon";

            Assert.IsTrue(Directory.Exists(folder), "Input folder doesn't exists");
            var sfPolygons = new Shapefile {
                GlobalCallback = this
            };
            var sfPoints = new Shapefile {
                GlobalCallback = this
            };
            var found     = 0;
            var stopWatch = new Stopwatch();

            stopWatch.Start();

            try
            {
                var retVal = sfPolygons.Open(Path.Combine(folder, "CatchmentBuilderShapefile.shp"));
                Assert.IsTrue(retVal, "Can't open polygon shapefile");

                retVal = sfPoints.Open(Path.Combine(folder, "Sbk_FGrPt_n.shp"));
                Assert.IsTrue(retVal, "Can't open point shapefile");

                // Caches the coordinates of shapefile points for faster point in shape test:
                retVal = sfPolygons.BeginPointInShapefile();
                Assert.IsTrue(retVal, "Can't cache points");

                var numPoints = sfPoints.NumShapes;
                Assert.IsTrue(numPoints > 0, "No point shapes in shapefile");

                for (var i = 0; i < numPoints; i++)
                {
                    var pointShape = sfPoints.Shape[i];
                    Assert.IsNotNull(pointShape, "pointShape == null");

                    double x = 0d, y = 0d;
                    retVal = pointShape.XY[0, ref x, ref y];