Hey @Dennis,
Issue 1
These properties do not contain data when the events fire:
TheEventArgs.BitmapTile.Bitmap.PathName;
TheEventArgs.BitmapTile.Bitmap.FileName;
TheEventArgs.BitmapTile.Bitmap.PathFilename;
In certain instances, Bitmap may or may not have a filepath because it may have been stored in memory or elsewhere. Instead, you can get the filepath by casting the BitmapTile as a FileBitmapTile:
private void TileCacheOnGottenCacheImage(object sender, GottenCacheImageBitmapTileCacheEventArgs e)
{
Trace.WriteLine($"[Tile Cache - Retrieved] {((FileBitmapTile)e.BitmapTile).PathFilename}");
}
Issue 2
The reason I’m logging the TileCache events is so that I can corralate a request with either a SentWebRequest or TileCache events. This is for debugging purposes.
In order to do this I need the original requesting URL. It would be awfully nice to have the original in the EventArgs for TileCache events. Would you add this information?
The TileCache is oblivious to whatever the layers are requesting. It only knows the requested tile’s row, column, scale, and extent and tries to find an image that matches that description in the cache. I’ve added these properties to the EventArgs that might help you correlate the WebRequests in today’s nuget package update. Now my event handlers look like:
private void TileCacheOnGottenCacheImage(object sender, GottenCacheImageBitmapTileCacheEventArgs e)
{
Trace.WriteLine($"[Tile Cache - Retrieved] {((FileBitmapTile)e.BitmapTile).PathFilename}");
Trace.WriteLine($"[Tile Cache - Retrieved] {_tileCache.CacheDirectory}/{_tileCache.CacheId}/{e.Scale}/{e.Row}/{e.Column}.png");
Trace.WriteLine($"[Tile Cache - Retrieved] {e.Extent}");
}
private void TileCacheOnGettingCacheImage(object sender, GettingCacheImageBitmapTileCacheEventArgs e)
{
Trace.WriteLine($"[Tile Cache - Get] {_tileCache.CacheDirectory}/{_tileCache.CacheId}/{e.Scale}/{e.Row}/{e.Column}.png");
Trace.WriteLine($"[Tile Cache - Get] {e.Extent}");
}
Example Output:
[Tile Cache - Get] c:/temp/inmem/73957193.82/203/204.png
[Tile Cache - Get] 21910369.4956324,-13155182.3988256,26919734.0519836,-18164546.9551768
[Tile Cache - Retrieved] c:/temp\inmem\73957193.82\203\204.png
[Tile Cache - Retrieved] c:/temp/inmem/73957193.82/203/204.png
[Tile Cache - Retrieved] 21910369.4956324,-13155182.3988256,26919734.0519836,-18164546.9551768
[Tile Cache - Get] c:/temp/inmem/73957193.82/199/196.png
[Tile Cache - Get] -18164546.9551767,6882275.82657886,-13155182.3988256,1872911.27022772
[Tile Cache - Retrieved] c:/temp\inmem\73957193.82\199\196.png
[Tile Cache - Retrieved] c:/temp/inmem/73957193.82/199/196.png
[Tile Cache - Retrieved] -18164546.9551767,6882275.82657886,-13155182.3988256,1872911.27022772
[Tile Cache - Get] c:/temp/inmem/73957193.82/198/199.png
[Tile Cache - Get] -3136453.28612328,11891640.38293,1872911.27022786,6882275.8265789
[Tile Cache - Retrieved] c:/temp\inmem\73957193.82\198\199.png
[Tile Cache - Retrieved] c:/temp/inmem/73957193.82/198/199.png
[Tile Cache - Retrieved] -3136453.28612328,11891640.38293,1872911.27022786,6882275.8265789
Issue 3
My logging shows that GottenCacheImage is fired before GettingCacheImage.
This should be resolved in today’s Nuget package.
Issue 4
In my code I was setting the events in the following fashion and they were not being fired:
TheFileBitmapTileCache.GettingCacheImage += TheFileBitmapTileCache_GettingCacheImage;
TheFileBitmapTileCache.GottenCacheImage += TheFileBitmapTileCache_GottenCacheImage;
I’m not sure how or why that would happen. Those events are fairly standard. In my test cases, I’ve tried setting the events both directly on the TileCache and on MapConfiguration’s TileCache and both ways had their events fire. Either that event handler got removed somewhere down the line or MapConfiguration’s TileCache got replaced by a different TileCache.
Today I’ve noticed that even though tiles are not retrieved from cache the GottenCacheImage event is fired.
My logs show a series of GottenCacheImage/GettingCacheImage events followed by SendingWebResponse and SentWebResponse.
This usually means one of two things: either the tile didn’t perfectly line up to what the layer was expecting, or more likely, the tile was expired after 12 hours.
Thanks,
Kyle