Beispiel #1
0
        private Uri GetLatLonBoundingBoxUri(int x, int y, int zoomLevel)
        {
            var tileSize = 360d / (1 << zoomLevel); // tile width in degrees
            var west     = x * tileSize - 180d;
            var east     = (x + 1) * tileSize - 180d;
            var south    = MercatorTransform.YToLatitude(180d - (y + 1) * tileSize);
            var north    = MercatorTransform.YToLatitude(180d - y * tileSize);

            return(new Uri(uriFormat
                           .Replace("{w}", west.ToString(CultureInfo.InvariantCulture))
                           .Replace("{s}", south.ToString(CultureInfo.InvariantCulture))
                           .Replace("{e}", east.ToString(CultureInfo.InvariantCulture))
                           .Replace("{n}", north.ToString(CultureInfo.InvariantCulture))
                           .Replace("{X}", TileSize.ToString())
                           .Replace("{Y}", TileSize.ToString())));
        }
Beispiel #2
0
        private Uri GetLatLonBoundingBoxUri(int x, int y, int zoomLevel)
        {
            var t  = new MercatorTransform();
            var n  = (double)(1 << zoomLevel);
            var x1 = (double)x * 360d / n - 180d;
            var x2 = (double)(x + 1) * 360d / n - 180d;
            var y1 = 180d - (double)(y + 1) * 360d / n;
            var y2 = 180d - (double)y * 360d / n;
            var p1 = t.Transform(new Point(x1, y1));
            var p2 = t.Transform(new Point(x2, y2));

            return(new Uri(UriFormat.
                           Replace("{w}", p1.Longitude.ToString(CultureInfo.InvariantCulture)).
                           Replace("{s}", p1.Latitude.ToString(CultureInfo.InvariantCulture)).
                           Replace("{e}", p2.Longitude.ToString(CultureInfo.InvariantCulture)).
                           Replace("{n}", p2.Latitude.ToString(CultureInfo.InvariantCulture))));
        }
Beispiel #3
0
        private Uri GetLatLonBoundingBoxUri(int x, int y, int zoomLevel)
        {
            var t = new MercatorTransform();
            var n = (double)(1 << zoomLevel);
            var x1 = (double)x * 360d / n - 180d;
            var x2 = (double)(x + 1) * 360d / n - 180d;
            var y1 = 180d - (double)(y + 1) * 360d / n;
            var y2 = 180d - (double)y * 360d / n;
            var p1 = t.Transform(new Point(x1, y1));
            var p2 = t.Transform(new Point(x2, y2));

            return new Uri(uriFormat.
                Replace("{w}", p1.Longitude.ToString(CultureInfo.InvariantCulture)).
                Replace("{s}", p1.Latitude.ToString(CultureInfo.InvariantCulture)).
                Replace("{e}", p2.Longitude.ToString(CultureInfo.InvariantCulture)).
                Replace("{n}", p2.Latitude.ToString(CultureInfo.InvariantCulture)));
        }