[OpenLayers-Users] Using kamaps direct cache access
Jochen Grefe
jochen.grefe at ingenieurteam2.com
Fri Jul 13 11:03:53 EDT 2007
Hello,
I have changed the kamap Layer to work on precached http available
caches.
Usage:
new OpenLayers.Layer.KaMap('map','/kacachemap',
{g: 'test',map: 'testmap',i: 'png', cache:
true, metaTileSize: {w: 3, h: 3}},
{minScale: 100,maxScale: 500})
Everything like the normal kamap layer only cache: true to enable the
direct cache access.
And metaTileSize: {w: 3, h: 3} to give the number of tiles per metatile.
I'm not sure if the using of the params hashmap is appropriate.
Lib/layer/kamap.js:
84,88c84,113
< return this.getFullRequestString(
< { t: pY,
< l: pX,
< s: scale
< });
---
>
> if (this.params.cache){
> var metaX = Math.floor(pX / this.tileSize.w /
this.params.metaTileSize.w) * this.tileSize.w *
this.params.metaTileSize.w;
> var metaY = Math.floor(pY / this.tileSize.h /
this.params.metaTileSize.h) * this.tileSize.h *
this.params.metaTileSize.h;
> var paramsString = "/" + this.params["map"]
> + "/" + scale
> + "/" + this.params["g"]
> + "/" + "def"
> + "/t" + metaY
> + "/l" + metaX
> + "/t" + pY + "l" + pX + "." +
this.params.i;
>
> // if url is not a string, it should be an array of
strings,
> // in which case we will deterministically select one of
them in
> // order to evenly distribute requests to different urls.
> //
> var url = this.url;
> if (url instanceof Array) {
> url = this.selectUrl(paramsString, url);
> }
>
> return url + paramsString;
> }
> else {
> return this.getFullRequestString(
> { t: pY,
> l: pX,
> s: scale
> });
> }
More information about the Users
mailing list