Ejemplo n.º 1
0
 private BackgroundImage InitBackgroundImageTiles(LatLng[] allLocations)
 {
     var zoom = MAX_ZOOM;
     var n = Math.Pow(2, zoom);
     var tiles = new Point
     {
         X = (int)Math.Ceiling(Math.Ceiling(GetXTile(allLocations.Max(l => l.lng), n)) - Math.Floor(GetXTile(allLocations.Min(l => l.lng), n))),
         Y = (int)Math.Ceiling(Math.Ceiling(GetYTile(allLocations.Min(l => l.lat), n)) - Math.Floor(GetYTile(allLocations.Max(l => l.lat), n)))
     };
     while (tiles.X > NUMBER_OF_TILES_FOR_IMAGE_X || tiles.Y > NUMBER_OF_TILES_FOR_IMAGE_Y)
     {
         zoom--;
         n = Math.Pow(2, zoom);
         tiles.X = (int)Math.Ceiling(Math.Ceiling(GetXTile(allLocations.Max(l => l.lng), n)) - Math.Floor(GetXTile(allLocations.Min(l => l.lng), n)));
         tiles.Y = (int)Math.Ceiling(Math.Ceiling(GetYTile(allLocations.Min(l => l.lat), n)) - Math.Floor(GetYTile(allLocations.Max(l => l.lat), n)));
     }
     return new BackgroundImage
     {
         Tiles = tiles,
         Zoom = zoom,
         N = n
     };
 }
Ejemplo n.º 2
0
 private async Task<BackgroundImage> GetBackGroundImage(string addressTemplate, LatLng[] allLocations)
 {
     var backgroundImage = InitBackgroundImageTiles(allLocations);
     var topLeft = new Point((int)GetXTile(allLocations.Min(l => l.lng), backgroundImage.N), (int)GetYTile(allLocations.Max(l => l.lat), backgroundImage.N));
     var bottomRight = new Point((int)GetXTile(allLocations.Max(l => l.lng), backgroundImage.N), (int)GetYTile(allLocations.Min(l => l.lat), backgroundImage.N));
     if (backgroundImage.Tiles.X == 2 && backgroundImage.Tiles.Y == 1)
     {
         // no need to do anything.
     }
     else if (backgroundImage.Tiles.X == 1 && backgroundImage.Tiles.Y == 1)
     {
         backgroundImage.Tiles = new Point(2, 1);
         bottomRight.X++;
     }
     else
     {
         backgroundImage.Tiles = new Point(NUMBER_OF_TILES_FOR_IMAGE_X, NUMBER_OF_TILES_FOR_IMAGE_Y);
         UpdateImageRectangle(ref topLeft, ref bottomRight);
     }
     backgroundImage.TopLeft = topLeft;
     backgroundImage.Image = await CreateSingleImageFromTiles(topLeft, bottomRight, backgroundImage.Zoom, addressTemplate);
     return backgroundImage;
 }