ThinkGeo.com    |     Documentation    |     Premium Support

ThinkGeoCloudRasterMapsOverlay does not obey explicitly set FileRasterTileCache

When trying to set tile cache for ThinkGeoCloudRasterMapsOverlay something will always override it’s cache id. This causes some frustration as I’m trying to create uniform naming for all overlays we are using.

Please see following:

private void Window_Loaded(object sender, RoutedEventArgs e)
{
    mapView.MapUnit = GeographyUnit.Meter;

    var overlay = new ThinkGeoCloudRasterMapsOverlay(@"clientId", @"clientSecret");
    overlay.MapType = ThinkGeoCloudRasterMapsMapType.Light;
    Console.WriteLine(overlay.TileCache);
    // Prints C:\Users\viita\AppData\Local\Temp\ ThinkGeoCloudMaps_Light_3857

    var tileCache = new FileRasterTileCache(@"C:\Temp", @"Cache");
    Console.WriteLine(tileCache);
    // Prints C:\Temp Cache

    overlay.TileCache = tileCache;
    Console.WriteLine(overlay.TileCache);
    // Prints C:\Temp Cache_Light_3857

    mapView.Overlays.Add(overlay);
    mapView.Refresh();
}

So path to cache root is kept intact but cache id can’t be changed.

ThinkGeoCloudVectorMapsOverlay and it’s FileVectorTileCache does not have this issue.

Thanks Mikko,
I looked into this one. This because for the ThinkGeoCloudRasterMapsOverlay we have the different type. We can not put all cache in one folder. so we adjusted the cache id base on the type. We may need put a sub-folder to the cache folder. Something like C:\Temp[CacheId]\Cache files.

For your case. The work around
var tileCache = new FileRasterTileCache(@“C:\Temp\Cache”, @“Raster”);
This will put all files to C:\Temp\Cache and create a subfolder such as Raster_Light_3857

Meanwhile we will adjust the ThinkGeoCloudRasterMapsOverlay cache structure.

Thanks

Frank

1 Like

Thanks Mikko,
We did some changes for this one.
When you using
var tileCache = new FileRasterTileCache(@“C:\Temp”, @“Cache”);
you will get cache folder created C:\Temp\Cache…
The overlay.TileCache = tileCache; will adjust the cache id base on the current map type. But the main cache folder still will be C:\Temp\Cache\ So don’t worry about the overwrite thing.

The daily build process will push the changes to the NuGet beta release.

Thanks

Frank

1 Like

Thanks, I changed the cache handling on our software and it’s all good now.

But there’s still one more problem I have.

TileCache has ClearCache() method but due to requirements I need to fetch the current cache size. This still requires some “extra” work on my part since FileRasterTileCache has no property to actual cache path. Outputting ToString() on cache shows this path, though, and FileVectorTileCache has CachePath property that is not available on FileRasterTileCache.

Thanks Mikko,
Yes. Here is the code we get the main cache folder name. You can use this one to remove the suffix.

private string GetCacheIdWithoutSuffix(string cacheIdWithSuffix)
{
string cacheIdWithoutSuffix = cacheIdWithSuffix;
// Trim proj flag
if (cacheIdWithoutSuffix.EndsWith($"_3857"))
{
cacheIdWithoutSuffix = cacheIdWithoutSuffix.Remove(cacheIdWithoutSuffix.LastIndexOf($"_3857"));
}

        // Trim suffix from cache id
        foreach (string mapTypeStr in Enum.GetNames(typeof(ThinkGeoCloudRasterMapsMapType)))
        {
            if (cacheIdWithoutSuffix.EndsWith($@"\{mapTypeStr}"))
            {
                cacheIdWithoutSuffix = cacheIdWithoutSuffix.Remove(cacheIdWithoutSuffix.LastIndexOf($@"\{mapTypeStr}"));
            }
        }

        return cacheIdWithoutSuffix;
    }

Thanks

Frank

Thanks for the example code. I have worked around the issue but was actually hoping for CachePath property to be implemented on RasterCache at some point, similar to VectorCache.

Thanks Mikko,
RasterCache changes may effect some other layers such as WMS, WMTS layer. It required more test. We will put this to our backlog.

Thanks

Frank