Пример #1
0
        //Converts a latitude and longitude to quadtree at the specified zoom level
        public static string LatLonToQuadTree(LatLon latLon, int zoom)
        {
            GeoPoint    m = LatLonToMeters(latLon);
            TileAddress t = MetersToTile(m, zoom);

            return(t.ToQuadTree());
        }
Пример #2
0
        //Returns bounds of the given tile in EPSG:900913 coordinates
        public static GeoExtent TileBounds(TileAddress t)
        {
            var min = PixelsToMeters(new Point(t.X * TileSize, t.Y * TileSize), t.Zoom);
            var max = PixelsToMeters(new Point((t.X + 1) * TileSize, (t.Y + 1) * TileSize), t.Zoom);

            return(new GeoExtent(min, max));
        }
Пример #3
0
        //Returns bounds of the given tile in latitude/longitude using WGS84 datum
        public static GeoExtent TileLatLonBounds(TileAddress t)
        {
            var bound = TileBounds(t);
            var min   = MetersToLatLon(new GeoPoint(bound.Left, bound.Top));
            var max   = MetersToLatLon(new GeoPoint(bound.Right, bound.Bottom));

            return(new GeoExtent(min, max));
        }
Пример #4
0
        //Returns a list of all of the quadtree locations at a given zoom level within a latitude/longitude box
        public static List <string> GetQuadTreeList(int zoom, LatLon latLonMin, LatLon latLonMax)
        {
            if (latLonMax.Latitude < latLonMin.Latitude || latLonMax.Longitude < latLonMin.Longitude)
            {
                return(null);
            }

            GeoPoint    mMin = LatLonToMeters(latLonMin);
            TileAddress tmin = MetersToTile(mMin, zoom);
            GeoPoint    mMax = LatLonToMeters(latLonMax);
            TileAddress tmax = MetersToTile(mMax, zoom);

            var arr = new List <string>();

            for (var ty = tmin.Y; ty <= tmax.Y; ty++)
            {
                for (var tx = tmin.X; tx <= tmax.X; tx++)
                {
                    arr.Add(new TileAddress(tx, ty, zoom).ToQuadTree());
                }
            }
            return(arr);
        }
Пример #5
0
        //Converts a Quadtree location into a latitude/longitude bounding rectangle
        public static GeoExtent QuadTreeToLatLon(string quadtree)
        {
            TileAddress t = QuadTreeToTile(quadtree, quadtree.Length);

            return(TileLatLonBounds(t));
        }
Пример #6
0
 // Switch to TMS Tile representation from Google
 public static TileAddress ToTmsTile(TileAddress t)
 {
     return(new TileAddress(t.X, ((int)Math.Pow(2, t.Zoom) - 1) - t.Y, t.Zoom));
 }