Exemple #1
0
        public int GetMaxZoomToFitRect(RectLatLng rect)
        {
            int zoom = minZoom;

            for (int i = zoom; i <= maxZoom; i++)
            {
                MapPoint p1 = Projection.FromLatLngToPixel(rect.LocationTopLeft, i);
                MapPoint p2 = Projection.FromLatLngToPixel(rect.LocationRightBottom, i);

                if (((p2.X - p1.X) <= Width + 10) && (p2.Y - p1.Y) <= Height + 10)
                {
                    zoom = i;
                }
                else
                {
                    break;
                }
            }

            return(zoom);
        }
        /// <summary>
        /// gets all tiles in rect at specific zoom
        /// </summary>
        public List <MapPoint> GetAreaTileList(RectLatLng rect, int zoom, int padding)
        {
            List <MapPoint> ret = new List <MapPoint>();

            MapPoint topLeft     = FromPixelToTileXY(FromLatLngToPixel(rect.LocationTopLeft, zoom));
            MapPoint rightBottom = FromPixelToTileXY(FromLatLngToPixel(rect.LocationRightBottom, zoom));

            for (int x = (topLeft.X - padding); x <= (rightBottom.X + padding); x++)
            {
                for (int y = (topLeft.Y - padding); y <= (rightBottom.Y + padding); y++)
                {
                    MapPoint p = new MapPoint(x, y);
                    if (!ret.Contains(p) && p.X >= 0 && p.Y >= 0)
                    {
                        ret.Add(p);
                    }
                }
            }
            ret.TrimExcess();

            return(ret);
        }
Exemple #3
0
        public bool SetZoomToFitRect(RectLatLng rect)
        {
            int mmaxZoom = GetMaxZoomToFitRect(rect);

            if (mmaxZoom > 0)
            {
                PointLatLng center = new PointLatLng(rect.Lat - (rect.HeightLat / 2), rect.Lng + (rect.WidthLng / 2));
                CurrentPosition = center;

                if (mmaxZoom > maxZoom)
                {
                    mmaxZoom = maxZoom;
                }

                if ((int)Zoom != mmaxZoom)
                {
                    Zoom = mmaxZoom;
                }

                return(true);
            }
            return(false);
        }
Exemple #4
0
 static RectLatLng()
 {
     Empty = new RectLatLng();
 }
Exemple #5
0
 // ok ???
 public bool IntersectsWith(RectLatLng rect)
 {
     return((((rect.Lng < (this.Lng + this.WidthLng)) && (this.Lng < (rect.Lng + rect.WidthLng))) && (rect.Lat < (this.Lat + this.HeightLat))) && (this.Lat < (rect.Lat + rect.HeightLat)));
 }
Exemple #6
0
 public bool Contains(RectLatLng rect)
 {
     return((((this.Lng <= rect.Lng) && ((rect.Lng + rect.WidthLng) <= (this.Lng + this.WidthLng))) && (this.Lat >= rect.Lat)) && ((rect.Lat - rect.HeightLat) >= (this.Lat - this.HeightLat)));
 }