[ka-Map-users] can 2 map files share a cache for a specific data
group
Steve Walker
walker at mfgis.com
Sat Jan 27 15:44:50 EST 2007
In response to the original poster's question I have the following idea:
Original Question Was:
=== SNIP ===
is it possible to have two map file choices in ka-map, each with different
groups of layers, where one group is in common to both map files and the
kacache for that group is shared by both maps?
=== SNIP ===
It is pointed out below that the parent cache directory for each map is
set using the $szMapCacheDir variable. It turns out that $szMapCacheDir
is itself set in config.php using the map name ($szMap) variable:
$szMapCacheDir = $szBaseCacheDir.$szMap;
Changing this line of code, to something like
$szMapCacheDir = $szBaseCacheDir.'foo'
would alter the cache path from
/var/tmp/kacache/gmap to
/var/tmp/kacache/foo
But if you wanted to be more elegant about it you could add an element
called 'cacheName' to the $aszMapFiles array like this:
$aszGMap = array (
'title' => 'GMap 75',
'path' => '../../gmap/htdocs/gmap75.map',
'scales' => array( 40000000, 25000000, 12000000, 7500000),
'format' =>'PNG',
'cacheName' =>'gmap')
$aszMyOtherMap = array (
'title' => 'My Other Map'
'path' => '/some/path/to/MyOtherMap.map'
'scales' => array (40000000, 25000000, 12000000, 7500000),
'format' => 'PNG',
'cacheName' => 'gmap')
Now that both maps share the same value (gmap) for the cacheName variable,
the code in config.php can be modified to use cacheName instead of $szMap
for building the $szMapCacheDir variable:
// include around line 168
// READ THE CACHE DIR FROM THE LOADED MAP FILE IF ITS VARIABLE WAS SET
// IN THE $aszMapFiles ARRAY
// (USEFUL IF WE WISH MULTIPLE MAPS TO SHARE ONE CACHE
if (isset($aszMapfiles[$szMap]['cacheName'])) {
$szMapCacheDir = $szBaseCacheDir.$aszMapFiles[$szMap]['cacheName'];
}
else { // OTHERWISE do things the standard way
$szMapCacheDir = $szBaseCacheDir.$szMap; // original line 168
}
I've just tried this out on my install and it seems to be working: I
duplicated an existing map which has a very large months-old cache, and to
the copy added a new layer/group not present in the original. The map
responds quickly while browsing, indicating that my existing cache is
being accessed, and when I look in the cache folder I see the new
layer/group shows up within the existing cache, that its tiles are being
populated, and that there is indeed *not* a complete new cache being
created for my new map, as desired.
While the above doesn't exactly answer the original poster's question
about working with individual groups, perhaps the above combined with
Lorenzo's code below the SNIP would.
As he alludes, you must be careful not to mix apples and oranges in the
sense that GROUP names which are present in both maps should be
represented *identically* in each map file.
-Steve
==== SNIP ====
//(from Lorenzo)
if I remember right, in tile.php you have:
$szCacheDir = $szMapCacheDir."/".$scale."/".$szGroupDir."/".
$szLayerDir."/".$szMetaTileId;
just force $szMapCacheDir as a string of the same value, es:
$szCacheDir = "MyCommonMapDir/".$scale."/".$szGroupDir."/".
$szLayerDir."/".$szMetaTileId;
naturally all other params have to coincide.
This is pretty useful to reduce the total amount of cached layers, more
then ever with raster layers.
=== SNIP ===
Steve Walker
Middle Fork Geographic Information Services
More information about the ka-Map-users
mailing list