Ejemplo n.º 1
0
        private coord Ll(coord px, int zoom)
        {
            //if (isFloat(zoom))
            //{
            var size = this.size * Math.Pow(2, zoom);
            var bc   = (size / 360);
            var cc   = (size / (2 * Math.PI));
            var zc   = size / 2;
            var g    = (px.y - zc) / -cc;
            var _lon = (px.x - zc) / bc;
            var _lat = R2D * (2 * Math.Atan(Math.Exp(g)) - 0.5 * Math.PI);

            return(new coord()
            {
                x = _lat, y = _lon
            });
            //}
            //else
            //{
            //    var g = (px[1] - this.zc[zoom]) / (-this.Cc[zoom]);
            //    var lon = (px[0] - this.zc[zoom]) / this.Bc[zoom];
            //    var lat = R2D * (2 * Math.atan(Math.exp(g)) - 0.5 * Math.PI);
            //    return [lon, lat];
            //}
        }
Ejemplo n.º 2
0
        public bbox bbox(double x, double y, int zoom, bool tms_style, string srs)
        {
            // Convert xyz into bbox with srs WGS84
            if (tms_style)
            {
                y = (Math.Pow(2, zoom) - 1) - y;
            }
            // Use +y to make sure it's a number to avoid inadvertent concatenation.
            var ll = new coord()
            {
                x = x * this.size, y = (+y + 1) * this.size
            };                                                                    // lower left
            // Use +x to make sure it's a number to avoid inadvertent concatenation.
            var ur = new coord()
            {
                x = (+x + 1) * this.size, y = y * this.size
            };                                                                    // upper right
            var bbox = new bbox()
            {
                ll = this.Ll(ll, zoom), ur = (this.Ll(ur, zoom))
            };

            // If web mercator requested reproject to 900913.
            //if (srs == "900913")
            //{
            //    return this.convert(bbox, "900913");
            //}
            //else
            //{
            //    return bbox;
            //}
            return(bbox);
        }
Ejemplo n.º 3
0
        private coord px(coord ll, int zoom)
        {
            //if (isFloat(zoom))
            //{
            var size = this.size * Math.Pow(2, zoom);
            var d    = size / 2;
            var bc   = (size / 360);
            var cc   = (size / (2 * Math.PI));
            var ac   = size;
            var f    = Math.Min(Math.Max(Math.Sin(D2R * ll.y), -0.9999), 0.9999);
            var x    = d + ll.x * bc;
            var y    = d + 0.5 * Math.Log((1 + f) / (1 - f)) * -cc;

            if (x > ac)
            {
                x = ac;
            }
            if (y > ac)
            {
                y = ac;
            }
            //(x < 0) && (x = 0);
            //(y < 0) && (y = 0);
            return(new coord()
            {
                x = x, y = y
            });
            //}
            //else
            //{
            //    var d = this.zc[zoom];
            //    var f = Math.min(Math.max(Math.sin(D2R * ll[1]), -0.9999), 0.9999);
            //    var x = Math.round(d + ll[0] * this.Bc[zoom]);
            //    var y = Math.round(d + 0.5 * Math.log((1 + f) / (1 - f)) * (-this.Cc[zoom]));
            //    (x > this.Ac[zoom]) && (x = this.Ac[zoom]);
            //    (y > this.Ac[zoom]) && (y = this.Ac[zoom]);
            //    //(x < 0) && (x = 0);
            //    //(y < 0) && (y = 0);
            //    return [x, y];
            //}
        }