[ka-Map-users] "Cache" mode to serve maps - tile.php & Pre-rendering

Javier Pascual Herranz javier.pascual at radmas.com
Thu Jan 10 12:58:32 EST 2008


Hi everyone.

I have a problem with "tile.php" and the pre-rendering. 

The objective of this configuration is to avoid the use of the file
"tile.php" for creating the fields and instead in cache mode use the ones we
have already rendered. 
This would highly accelerate the server response time, but in my case it
does not work.

I will try to explain you in detail the problem. I hope that someone can
help me with this:

1. In the file "mapas.map" I establish the mode in which the fields will
serve for each one of the layers.

LAYER
..

METADATA
..

"tile_source"	"cache"
END    #METADATA

...
END   #LAYER


2. Pre-rendering all the fields from each map layer for the 15000 scale
(inicial scale)

C:\ms4w\apps\ka-map-1.0\htdocs>C:\ms4w\Apache\cgi-bin\php.exe precache2.php
-m "gmap" -s 15000

Salida:
Output:
Map: gmap
  Scale: 15000
    Meta tiles: 3 x 2 = 6
    Tiles: 3 x 2 x 6 x 6 = 216
    Group: Callejero
    Group: Metro

.

With this we have created all the fields of all layers for the 15000 scale.


3.   File "config.php":
Creating the variable $szBaseWebCache

$szBaseWebCache = "/ms4w/tmp/ms_tmp/kacache/";


4.	The Apache file "httpd.conf" I permit web access to the pre-rendered
fields:

<Directory "/ms4w/tmp/">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

5. File "kamap.js"
The file "tile.php" is called by the function:

 _layer.prototype.setTile = function(img)

	of the file "kamap.js"
	



When we use the cache mode for each layer, the following part of the
function code _layer.prototype.setTile = function(img) is executed:

if(this.tileSource == 'cache') { 
var metaLeft = Math.floor(l/(this._map.kaMap.tileWidth *
this._map.kaMap.metaWidth)) * this._map.kaMap.tileWidth *
this._map.kaMap.metaWidth;
var metaTop = Math.floor(t/(this._map.kaMap.tileHeight *
this._map.kaMap.metaHeight)) * this._map.kaMap.tileHeight *
this._map.kaMap.metaHeight;
        var metaTileId = 't' + metaTop + '/l' + metaLeft;
        var groupsDir = (this.name != '') ? this.name.replace(/\W/g, '_') :
'def';
 var cacheDir = this._map.kaMap.webCache + this._map.name + '/' +
this._map.aScales[this._map.currentScale] + '/' + groupsDir + '/def/' +
metaTileId;
        var tileId = "t" + t + "l" + l;
        // the following conversion of image format to image extension
        // works for JPEG, GIF, PNG, PNG24 - others may need different
treatment
        var imageExtension =
this.imageformat.toLowerCase().replace(/[\de]/g, '');
        src = cacheDir + "/" + tileId + "." + imageExtension;
        //alert("Con cache... Nombre: " + this.name + " " + src);
    } else {
   ...

The variable "src" contains the entire route to the file of the previously
rendered field. This file exists, but does not finish to load it. So the
application never finishes loading.

Does anybody have an idea how to solve this?

Cheers, Javier






More information about the ka-Map-users mailing list