コード例 #1
0
        public TileAddress GoogleTile(int tx, int ty, int zoom)
        {
            TileAddress retval = new TileAddress();

            try
            {
                retval.X = tx;
                retval.Y = Convert.ToInt32((Math.Pow(2, zoom) - 1) - ty);
                return(retval);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        public TileAddress MetersToTile(double mx, double my, int zoom)
        {
            TileAddress retval = new TileAddress();

            try
            {
                var p = this.MetersToPixels(mx, my, zoom);
                retval = this.PixelsToTile(p.X, p.Y);
                return(retval);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public TileAddress LatLonToTile(double lat, double lon, int zoom)
        {
            TileAddress retval = new TileAddress();

            try
            {
                var m = this.LatLonToMeters(lat, lon);
                retval = this.MetersToTile(m.X, m.Y, zoom);
                return(retval);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
        public TileAddress PixelsToTile(double px, double py)
        {
            TileAddress retval = new TileAddress();

            try
            {
                retval.X = (int)(Math.Ceiling(Convert.ToDouble(px / this.tileSize)) - 1);
                retval.Y = (int)(Math.Ceiling(Convert.ToDouble(py / this.tileSize)) - 1);
                return(retval);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #5
0
        public TileAddress QuadTreeToTile(string quadtree, int zoom)
        {
            TileAddress retval = new TileAddress();

            try
            {
                var tx = 0;
                var ty = 0;

                for (var i = zoom; i >= 1; i--)
                {
                    var ch   = quadtree[zoom - i];
                    var mask = 1 << (i - 1);

                    var digit = ch - '0';

                    if (Convert.ToBoolean(digit & 1))
                    {
                        tx += mask;
                    }

                    if (Convert.ToBoolean(digit & 2))
                    {
                        ty += mask;
                    }
                }

                ty       = ((1 << zoom) - 1) - ty;
                retval.X = tx;
                retval.Y = ty;
                return(retval);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }