ThinkGeo.com    |     Documentation    |     Premium Support

Tilecache for raster is slow

Hello
I have a question about tilecache.
Currently for the layer base raster, our user have raster jp2.
Each customer has different rasters depending on their territory.

So that the rasters are not loaded in memory, we use the tilecache. (fileBitmapTileCache)
During the first opening of the application, there is a cache of rasters and this process is long.

Is there any good practice or hints for faster raster caching ? (like google map)

Our code is the following :
var overlay = new LayerOverlay();
if (rasterBaseMap)
{
overlay.TileCache =
new FileBitmapTileCache(OutilsRepertoire.PathCacheRaster, “ManualCache1”)
{
TileAccessMode = TileAccessMode.ReadAdd
};
}

   overlay.IsBase = rasterBaseMap;
        overlay.DrawingQuality = DrawingQuality.HighSpeed;
        overlay.TransitionEffect= TransitionEffect.None;
        overlay.TileType = TileType.MultipleTile;

Thanks.

Regards.

Steph.

Hi Steph,

I think you means when you open the cache, the first time you open the map it still be slow.

Please visit this sample: https://github.com/ThinkGeo/CacheGeneratorSample-ForWinForms

Which tells how to pre-build cache and it will increase the speed the first time.

Wish that’s helpful.

Regards,

Ethan

Hi Ethan,

Thanks for your answer.
I looked at the example of tilecachegenerator and there is a point that I failed to specify in my previous mail .
The layer I want pre tiled is a layer of type MultiGeoRasterLayer.

Our application works as follows :
Each client has his own rasters on his computer (more than 500 rasters).
In order not to load all the rasters in memory, a layer of the multigeoraster type is used for displaying these rasters.

So the different steps when the user opens the application and if the rasters are not cached :

  1. Loading rasters in memory that are within the limits of the map display.
  2. Only visible rasters on the screen are loaded into memory. (thanks to the class MultigeorasterLayer)
  3. Caching rasters.

With the example, TileCacheGenerator, is it possible to pre-tile with our configuration ?

Thanks regards.

Steph.

Hi Steph,

Thanks for your description, but I think for your scenario, the cache shouldn’t works.

Because you mentioned, the class MultigeorasterLayer can load different rasters, that means the data source is dynamic with the same extent, so if you open cache, it will save the tile images the first time you loaded, the next time if you modify the loaded raster file in the same area, it still will load the first time data.

Please notice the cache is based on cache folder & cacheID & bouding box but not the data source.

If I misunderstand anything please let me know.

BTW, I don’t know how you implement the class MultigeorasterLayer, but if it’s inherited from class Layer it should can be used.

You can view the class LayerProvider and try to build small group tiles to see whether it works.

Regards,

Ethan

Hi Ethan,

Thanks for your help.
You talk about LayerProvider, but I do not really know how to use this class in my case.
Currently, there is dynamic caching with our system (MultiGeoRasterLayer).

The user pan a first time to a place and the cache of the rasters is created at that time. Thus, if later it comes back to this place, it will be the cache that will be used and the display speed is much faster.
This mode of operation is correct for Tif type rasters. Dynamic caching is fast, at least it’s tolerable for the user.

But for JP2 raters, this dynamic caching system is very slow.
Is there a reason for this slowness ?

As the cache is created dynamically, at each pan on a new zone, there is slowness (because creation of the cache).
So I thought to create all caches at once during the first use of the module.
Disadvantage: the first opening of the module will be long with the creation of all these caches.
Advantage: navigation will be more fluid for the user.
In fact, the goal is to have the same feeling of navigation as on google, (I think that they are caches that are displayed and thus the navigation is fluid).

Is it possible to get this result with thinkgeo WPF ?
Thanks.

Regards.

Steph.

Hi Steph,

As below is our understanding about cache. For WPF, the cache is a group of images, if we have cache for an area, the source data don’t need to be read again and render in memory, which will takes so many system source. When the cache existing the map will directly read the images and render the images on map, that’s very fast.

And in fact the Google maps or any other maps is using the same logic, they have a static library, which contains all the images. Which means when you pan to any area, the speed is the same because you just need load the same number tile images, but not need to wait render different shapes from data.

And for raster layer, if you open cache, it will use the same logic, which means the tile image will be saved in disk and load when user access it. But if you want to load the raster layer dynamic, the speed cannot be guaranteed, because raster layer have many different types, most of them depend on c++ library to read and load, some of them cannot create index so each time the whole raster image need be load to memory, you can think about this process and know how many system source need be taken.

If you want to provide user better experience, you need avoid directly load the raster layer, you can pre-build some tile images for target area and target zoomlevel, which means you need to build a group of tile images, then when user try to access the area, map can quickly get pre-build images and show them on map.

You can try the utility, just make sure render the target raster layer in which area and zoomlevel, then put the same render logic into the LayerProvider class, and it will simulator user pan to all the target area and build the cache for you.

If this utility cannot works for your scenario, I think we don’t have better choice for improve the speed to load raster layer dynamic.

Wish that’s helpful.

Regards,

Ethan