Cacheing Tiles for WMS

Steve Wormley steve at WORMLEY.COM
Tue Dec 20 14:02:39 EST 2005


I've spent about 2 hours working on something similar to this, I hope to
have it done today.
Here is the general outline:

Perl CGI accepts map request.
It computes a series of tiles based on hard coded tile sizes. This way a
future query will get the same tiles for the same zoom level.
It then creates new WMS queries for each tile and fires them off using
multiple threads so that multiple WMS server processes will handle the
drawing(I run the back end WMS servers so I can do this without annoying
anyone.)
Once the results come back the CGI stitches them together using Gd and
presents them back to the client and saves them into a directory using the
full query string as the key, these will be matched and returned for future
queries.

In addition to that one, which almost works right now I'm going to be adding
two more.

1. Which does the same as above but on layers, this requires knowledge of
the layers being requested and knowing the remote WMS servers will return
transparent backgrounds when needed.

2. One which has the back end WMS generate the 'tiles'.
We have some data which will be colored based on metrics within an arbitrary
region, such as a county. A strict tile based query will likely reprocess
the same county multiple times. So, this will have the perl CGI put a hint
in the Query String indicating which of the requests it is. The DATA
statement in the WMS will then look like this:
        DATA "wkb_geometry from (select ogc_fid as oid,wkb_geometry from
data_table where ( ogc_fid % %q_qty% ) = %q_num%  ) as
 foo USING SRID=4326"

Then, for instance, each call has q_qty set to 2 and one query has q_num set
to 0 and one has it set to 1. The WMS mapfile is set to return a transparent
background and I know these shapes don't overlap so I can composite them in
Gd.

Hope this helps, I'll see if management will let me release the code once
it's all working.

-Steve Wormley







On 2005-12-20 9:21, "David Bitner" <osgis.lists at GMAIL.COM> wrote:

> I use a number of WMS services for displaying imagery both for local
> client applications and for inclusion in Mapserver.  A lot of times
> these services are slow or require an additional step of projecting
> that slows them down a lot.
> 
> The idea I have is to create an application that sits in front of
> Mapserver (working as a WMS) and takes a request for a map and
> automatically splits the request into tiles that fit a shapefile with
> tiles for different scale ranges.  Once the tiles are there, it would
> then call mapserver on the shapefile index to generate the image to go
> back to the client.  It would basically act much in the same way as
> Ka-Map only completely on the server side.
> 
> Has anyone ever done anything like this?  Does what I am proposing
> make any sense?
> 
> Any ideas on different ways to implement something like this?



More information about the mapserver-users mailing list