Exemplo n.º 1
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;
            }
        }
Exemplo n.º 2
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;
     }
 }
Exemplo n.º 3
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;
     }
 }
Exemplo n.º 4
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;
     }
 }
Exemplo n.º 5
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;
     }
 }
Exemplo n.º 6
0
 protected void saveImage(Graphics g,Bitmap bmp,TileAddress tile,int level)
 {
     g.Flush();
     string filename=Path.Combine(tileDir,string.Format("{0}\\{1}\\{2}.png",level,tile.X,tile.Y));
     Directory.CreateDirectory(Path.GetDirectoryName(filename));
     bmp.Save(filename);
 }