public override PointLatLng FromPixelToLatLng(int x, int y, int zoom)
        {
            PointLatLng ret = PointLatLng.Zero;

            MapSize s        = GetTileMatrixSizePixel(zoom);
            double  mapSizeX = s.Width;
            double  mapSizeY = s.Height;

            double xx = (Clip(x, 0, mapSizeX - 1) / mapSizeX) - 0.5;
            double yy = 0.5 - (Clip(y, 0, mapSizeY - 1) / mapSizeY);

            ret.Lat = 90 - 360 * Math.Atan(Math.Exp(-yy * 2 * Math.PI)) / Math.PI;
            ret.Lng = 360 * xx;

            return(ret);
        }
        public override MapPoint FromLatLngToPixel(double lat, double lng, int zoom)
        {
            MapPoint ret = MapPoint.Empty;

            lat = Clip(lat, MinLatitude, MaxLatitude);
            lng = Clip(lng, MinLongitude, MaxLongitude);

            double x           = (lng + 180) / 360;
            double sinLatitude = Math.Sin(lat * Math.PI / 180);
            double y           = 0.5 - Math.Log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI);

            MapSize s        = GetTileMatrixSizePixel(zoom);
            int     mapSizeX = s.Width;
            int     mapSizeY = s.Height;

            ret.X = (int)Clip(x * mapSizeX + 0.5, 0, mapSizeX - 1);
            ret.Y = (int)Clip(y * mapSizeY + 0.5, 0, mapSizeY - 1);

            return(ret);
        }
Ejemplo n.º 3
0
 public static MapSize Subtract(MapSize sz1, MapSize sz2)
 {
     return(new MapSize(sz1.Width - sz2.Width, sz1.Height - sz2.Height));
 }
Ejemplo n.º 4
0
 public static MapSize Add(MapSize sz1, MapSize sz2)
 {
     return(new MapSize(sz1.Width + sz2.Width, sz1.Height + sz2.Height));
 }
Ejemplo n.º 5
0
 public void Inflate(MapSize size)
 {
     Inflate(size.Width, size.Height);
 }
Ejemplo n.º 6
0
 public static MapPoint Subtract(MapPoint pt, MapSize sz)
 {
     return(new MapPoint(pt.X - sz.Width, pt.Y - sz.Height));
 }
Ejemplo n.º 7
0
 public static MapPoint Add(MapPoint pt, MapSize sz)
 {
     return(new MapPoint(pt.X + sz.Width, pt.Y + sz.Height));
 }
Ejemplo n.º 8
0
 public MapPoint(MapSize sz)
 {
     this.x = sz.Width;
     this.y = sz.Height;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// gets matrix size in pixels
        /// </summary>
        /// <param name="zoom"></param>
        /// <returns></returns>
        public virtual MapSize GetTileMatrixSizePixel(int zoom)
        {
            MapSize s = GetTileMatrixSizeXY(zoom);

            return(new MapSize(s.Width * TileSize.Width, s.Height * TileSize.Height));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// tile matrix size in pixels at custom zoom level
        /// </summary>
        /// <param name="zoom"></param>
        /// <returns></returns>
        public int GetTileMatrixItemCount(int zoom)
        {
            MapSize s = GetTileMatrixSizeXY(zoom);

            return(s.Width * s.Height);
        }