예제 #1
0
 private async Task <byte[]> GetBitmapImpl(Geometry.MapTile tile)
 {
     try
     {
         string         url       = string.Format(_urlTemplate, tile.Zoom, tile.XNumber, tile.YNumber);
         HttpWebRequest request   = (HttpWebRequest)HttpWebRequest.Create(url);
         byte[]         buffer    = new byte[1024];
         List <byte>    outResult = new List <byte>();
         using (HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync())
             using (Stream responseStream = response.GetResponseStream())
             {
                 int bytesRead = 0;
                 do
                 {
                     bytesRead = responseStream.Read(buffer, 0, buffer.Length);
                     outResult.AddRange(buffer.Take(bytesRead));
                 }while (bytesRead > 0);
             }
         return(outResult.ToArray());
     }
     catch (WebException)
     {
         return(null);
     }
 }
예제 #2
0
 public async System.Threading.Tasks.Task <TBitmap> GetTileBitmap(Geometry.MapTile tile)
 {
     return(await _cache.GetItem(tile)); //System.Threading.Tasks.Task.Run(() => _cache[tile]);
 }
예제 #3
0
 public override Task <byte[]> GetBitmap(Geometry.MapTile tile)
 {
     return(GetBitmapImpl(tile));
 }
예제 #4
0
 public abstract Task <TBitmap> GetBitmap(Geometry.MapTile tile);