Exemplo n.º 1
0
        /// <summary>
        /// gets matrix size in tiles
        /// </summary>
        /// <param name="zoom"></param>
        /// <returns></returns>
        public virtual GSize GetTileMatrixSizeXY(int zoom)
        {
            GSize sMin = GetTileMatrixMinXY(zoom);
            GSize sMax = GetTileMatrixMaxXY(zoom);

            return(new GSize(sMax.Width - sMin.Width + 1, sMax.Height - sMin.Height + 1));
        }
Exemplo n.º 2
0
 public GRect(GPoint location, GSize size)
 {
     this.x      = location.X;
     this.y      = location.Y;
     this.width  = size.Width;
     this.height = size.Height;
 }
Exemplo n.º 3
0
        public override bool Equals(object obj)
        {
            if (!(obj is GSize))
            {
                return(false);
            }

            GSize comp = (GSize)obj;

            // Note value types can't have derived classes, so we don't need to
            //
            return((comp.width == this.width) &&
                   (comp.height == this.height));
        }
Exemplo n.º 4
0
        public override PointLatLng FromPixelToLatLng(long x, long y, int zoom)
        {
            PointLatLng ret = PointLatLng.Empty;

            GSize  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);
        }
Exemplo n.º 5
0
        public override GPoint FromLatLngToPixel(double lat, double lng, int zoom)
        {
            GPoint ret = GPoint.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);

            GSize s        = GetTileMatrixSizePixel(zoom);
            long  mapSizeX = s.Width;
            long  mapSizeY = s.Height;

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

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

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

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