Patch for a ka-Map cached layer

5 messages Options Options
Embed this Post
Permalink
Pedro Simonetti

Patch for a ka-Map cached layer

Reply Threaded MoreMore options
Print post
Permalink
Hi all,

As I stated in an earlier thread [1], I've changed some part of the OL's code to
handle ka-Map pre-cached layers, similar to the TileCache class. With a cached
layer, the ka-Map tiles will be loaded considerably faster.

[1] http://www.nabble.com/Fix-for-issue--327%3A-ka-Map-overlays-tc16620073.html

A long time ago [2], Jochen Grefe has posted here about a similar aproach:

[2] http://www.nabble.com/Using-kamaps-direct-cache-access-tc11581326.html#a11581326

The solution provided by him works, but it has some small problems I'll decribe
here. First, I thought it was more natural to make a separate KaMapCache class,
similar to TileCache class. One problem is that when the layer's group name (the
"g" parameter in KaMap class) has white spaces, it doesn't get the proper url.
Another problem is related to the directory structure described above. I've also
changed the string concatenation to the Array.splice method, as used in "
TileCache" class.

So, I wrote a new KaMapCache class, that overextends a KaMap class. This class
overrides the "getURL" to generate the full URL of each tile, without calling
the server.

To create a a new KaMapCache layer, you must indicate also the "i" parameter (
that will be used to calculate the file extension), and another special
parameter, object names "metaTileSize", with "h" (height) and "w" properties, as
suggested by Jochen.

Here's a simple example. Is the same example of my earlier thread [1], but using
a KaMapCache layer.

  // Create a new kaMapCache layer. You must allways inform the "i" parameter
  // for a KaMapCache layer.
  var kamap_base = new OpenLayers.Layer.KaMapCache(
      "Satellite",
      "http://www.example.org/web/acessible/cache",
      {g: "satellite", map: "world", i: 'png24', metaTileSize: {w: 5, h: 5} }
    );

  // Create an kaMapCache overlay layer (using "isBaseLayer: false"). Forces
  // the output to be a "gif", using the "i" parameter.
  var kamap_overlay = new OpenLayers.Layer.KaMapCache(
      "Streets",
      "http://www.example.org/web/acessible/cache",
      {g: "streets", map: "world", i: "gif", metaTileSize: {w: 5, h: 5} },
      {isBaseLayer: false}
    );

I don't have privileges to open a new ticket so I'll put the files as an
atachment of this message. As it was stated in my earlier thread, I've splitted
the "tile.php" in two files: "tile.php", and "config.php", so this configuration
file can be used also with a "precache.php" file.

Like the TileCache layers, you must pre-generate all tiles before using it. This
is done with the "precache.php" file. This file is basically the "precache2.php"
file that comes with ka-Map distribution, with almost none changes.

Was removed a piece of code that was trying to remotely create the cache
directory. This was a useless step, once "precache.php" is a command line tool
that will generate that folder locally.

The other change was related to the directory structure of the cache. There was
a slighly difference between the directory generated by "precache2.php", and the
one generated by "tile.php", the code already in use at OL.

precache2.php:
var/cache/World/50000/Group_Name/def/t-440320/l20480

tile.php:
var/cache/World/50000/Group_Name/def/t-440320l20480

I don't know why this was changed, and I would like to hear some opinions.
What's the best structure? Or both has the same performance? I mean, I suppose
the second one would generate more folders inside the "def" folder for smaller
scales like the street level scale. But since I'm not a hardware guru, I'm
asking here in the list. This can somehow affect the hard disk performance or
something related?

The files used are:
  * "precache.php", renamed as "precache.php.txt"
  * "config.php", the same used in the my earlier's post. I'll not upload this
     again to avoid duplicities in the tracker.
  * "KaMapCache.js", the new class.  


I hope this patch helps.

my best regards,

Pedro Simonetti.
KaMapCache.js
precache.php.txt
Paul Spencer-2

Re: Patch for a ka-Map cached layer

Reply Threaded MoreMore options
Print post
Permalink
Hi Pedro,

sounds like you are making good progress :)  You should be able to log  
in at http://trac.openlayers.org/ by following the instructions in the  
grey box at the top left of that page and then you can create tickets.


On 10-Apr-08, at 9:24 PM, Pedro Simonetti wrote:

<snip>

> The other change was related to the directory structure of the  
> cache. There
> was
> a slighly difference between the directory generated by  
> "precache2.php", and
> the
> one generated by "tile.php", the code already in use at OL.
>
> precache2.php:
> var/cache/World/50000/Group_Name/def/t-440320/l20480
>
> tile.php:
> var/cache/World/50000/Group_Name/def/t-440320l20480
>
> I don't know why this was changed, and I would like to hear some  
> opinions.
> What's the best structure? Or both has the same performance? I mean, I
> suppose
> the second one would generate more folders inside the "def" folder for
> smaller
> scales like the street level scale. But since I'm not a hardware  
> guru, I'm
> asking here in the list. This can somehow affect the hard disk  
> performance
> or
> something related?

You are exactly right, this was changed at one point to add an extra  
level of directory structure depth in an attempt to avoid file system  
limitations on the number of entries in a single directory.

Thank you for your hard work in figuring all this out.  I am sure that  
lots of people will finding both interesting and useful.

Cheers

Paul

__________________________________________

    Paul Spencer
    Chief Technology Officer
    DM Solutions Group Inc
    http://www.dmsolutions.ca/

_______________________________________________
Dev mailing list
Dev@...
http://openlayers.org/mailman/listinfo/dev
Pedro Simonetti

Re: Patch for a ka-Map cached layer

Reply Threaded MoreMore options
Print post
Permalink

pagameba wrote:
Hi Pedro,

sounds like you are making good progress :)  You should be able to log  
in at http://trac.openlayers.org/ by following the instructions in the  
grey box at the top left of that page and then you can create tickets.


On 10-Apr-08, at 9:24 PM, Pedro Simonetti wrote:

<snip>

> The other change was related to the directory structure of the  
> cache. There
> was
> a slighly difference between the directory generated by  
> "precache2.php", and
> the
> one generated by "tile.php", the code already in use at OL.
>
> precache2.php:
> var/cache/World/50000/Group_Name/def/t-440320/l20480
>
> tile.php:
> var/cache/World/50000/Group_Name/def/t-440320l20480
>
> I don't know why this was changed, and I would like to hear some  
> opinions.
> What's the best structure? Or both has the same performance? I mean, I
> suppose
> the second one would generate more folders inside the "def" folder for
> smaller
> scales like the street level scale. But since I'm not a hardware  
> guru, I'm
> asking here in the list. This can somehow affect the hard disk  
> performance
> or
> something related?

You are exactly right, this was changed at one point to add an extra  
level of directory structure depth in an attempt to avoid file system  
limitations on the number of entries in a single directory.
Hey Paul,

Thanks for your response.

Just to make it clear, so the structure [1] is the best one (one more directory level)?

[1] var/cache/World/50000/Group_Name/def/t-440320/l20480
[2] var/cache/World/50000/Group_Name/def/t-440320l20480

If so, I'll have to make this little modifications in the patches/files I've sended here, and in the earlier post. But this is easy, just confirm if the first one is the best.

regards,

Pedro.
Paul Spencer-2

Re: Patch for a ka-Map cached layer

Reply Threaded MoreMore options
Print post
Permalink

On 10-Apr-08, at 10:05 PM, Pedro Simonetti wrote:

> Hey Paul,
>
> Thanks for your response.
>
> Just to make it clear, so the structure [1] is the best one (one more
> directory level)?
>
> [1] var/cache/World/50000/Group_Name/def/t-440320/l20480
> [2] var/cache/World/50000/Group_Name/def/t-440320l20480
>
> If so, I'll have to make this little modifications in the patches/
> files I've
> sended here, and in the earlier post. But this is easy, just confirm  
> if the
> first one is the best.


The first one is better than the second one for sure.  I wouldn't go  
so far as to say it is the best ;)

Cheers

Paul

__________________________________________

    Paul Spencer
    Chief Technology Officer
    DM Solutions Group Inc
    http://www.dmsolutions.ca/

_______________________________________________
Dev mailing list
Dev@...
http://openlayers.org/mailman/listinfo/dev
Pedro Simonetti

Re: Patch for a ka-Map cached layer

Reply Threaded MoreMore options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Paul,

As you suggested, I've updated the file structure. Here comes the updated patch. As I stated in the earlier post, I'm using the same configuration file "config.php" for the "tile.php" and "precache.php". The "config.php" file is in the tracker of the issue #327.

[1] http://trac.openlayers.org/ticket/327

Sould I add this file to the new ticket I'm opening? I'm not doing this to avoid duplicities in the tracker.

The ticket for this patch is:

http://trac.openlayers.org/ticket/1518

My best regards,

Pedro Simonetti.

2008/4/11, Paul Spencer <pspencer@...>:

On 10-Apr-08, at 10:05 PM, Pedro Simonetti wrote:
Hey Paul,

Thanks for your response.

Just to make it clear, so the structure [1] is the best one (one more
directory level)?

[1] var/cache/World/50000/Group_Name/def/t-440320/l20480
[2] var/cache/World/50000/Group_Name/def/t-440320l20480

If so, I'll have to make this little modifications in the patches/files I've
sended here, and in the earlier post. But this is easy, just confirm if the
first one is the best.


The first one is better than the second one for sure.  I wouldn't go so far as to say it is the best ;)


Cheers

Paul

__________________________________________

  Paul Spencer
  Chief Technology Officer
  DM Solutions Group Inc
  http://www.dmsolutions.ca/



_______________________________________________
Dev mailing list
Dev@...
http://openlayers.org/mailman/listinfo/dev