Beispiel #1
0
        private static List <Geometry <Point> > GetIndexLines(BoundingBox geographicIntersectRegion, double utmWidth, double utmHeight, int utmZone)
        {
            ////this approach start the grid at upper Y of the actual region
            //var utmBound = geographicIntersectRegion.Transform(p => MapProjects.GeodeticToUTM(p, Ellipsoids.WGS84, 39, true));

            //utmBound = new BoundingBox(
            //    xMin: Math.Max(utmBound.XMin, _2kUtmXmin),
            //    yMin: Math.Max(utmBound.YMin, _2kUtmYmin),
            //    xMax: Math.Min(utmBound.XMax, _2kUtmXmax),
            //    yMax: Math.Min(utmBound.YMax, _2kUtmYmax));

            //var utmBound = new BoundingBox(_2kUtmXmin, _2kUtmYmin, _2kUtmXmax, _2kUtmYmax)
            //                    .Transform(p => MapProjects.UTMToGeodetic(p, utmZone))
            //                    .Intersect(geographicIntersectRegion)
            //                    .Transform(p => MapProjects.GeodeticToUTM(p, Ellipsoids.WGS84, utmZone));

            List <Geometry <Point> > result = new List <Geometry <Point> >();

            var geoBound = BoundingBoxHelper.UtmMbbToGeodeticWgs84Mbb(_2kUtmBoudingBox, utmZone)
                           .Intersect(geographicIntersectRegion);

            if (geoBound.IsNaN())
            {
                return(result);
            }

            var utmBound = BoundingBoxHelper.GeodeticWgs84MbbToUtmMbb(geoBound, utmZone)
                           .Intersect(_2kUtmBoudingBox);

            if (utmBound.IsNaN())
            {
                return(result);
            }

            var startX = _2kUtmXmin + Math.Floor((utmBound.XMin - _2kUtmXmin) / utmWidth) * utmWidth;

            var endX = _2kUtmXmin + Math.Ceiling((utmBound.XMax - _2kUtmXmin) / utmWidth) * utmWidth;

            var middleX = (startX + endX) / 2.0;

            var startY = _2kUtmYmin + Math.Floor((utmBound.YMin - _2kUtmYmin) / utmHeight) * utmHeight;

            var endY = _2kUtmYmin + Math.Ceiling((utmBound.YMax - _2kUtmYmin) / utmHeight) * utmHeight;

            for (double i = startX; i <= endX; i += utmWidth)
            {
                var p1 = new Point(i, startY);

                var p2 = new Point(i, endY);

                result.Add(new Geometry <Point>(new List <Point>()
                {
                    p1, p2
                }, GeometryType.LineString, 0));
            }

            for (double j = startY; j <= endY; j += utmHeight)
            {
                var p1 = new Point(startX, j);

                var p2 = new Point(middleX, j);

                var p3 = new Point(endX, j);

                result.Add(new Geometry <Point>(new List <Point>()
                {
                    p1, p2, p3
                }, GeometryType.LineString, 0));
            }

            return(result.Select(g => g.Transform(p => MapProjects.UTMToGeodetic(p, utmZone), SridHelper.GeodeticWGS84)).ToList());
        }