PILcopy layer

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

PILcopy layer

Richard Duivenvoorde
Hi all,

I have this almost complete tilecache of my country in 14 zoomlevels.

Now somebody wanted to have this cache (sometimes) in black and white.

Thinking about PIL and ImageMagick, I managed to hack a (what I call)
'PILcopy'-Layer together, which generates black and white tiles on the
fly/demand based on an (almost full) excisting disk cache.

It has a 'parent'-layer parameter (the layer that it is supposed to use
the tiles from).
Upon a request, it just finds out the path/key, and reads the tile of
the parent from disk, convert it to b&w ( img.convert("L") ) and saves
it in a second cache and returns the b&w tile to client.

It's that simple.

Anybody interested in such functionality? Or maybe this is not the
preferred way? Or maybe it's already there :-)
PIL can also do other tricks probably (I'm hoping it can do the same as
ImageMagick, then you can also spit out dithered maps. sepia maps etc etc).

Only question I have:
- it would be nice to make this work on layers which are not fully
seeded too. So upon a negative test if the 'parent'-layer-tile is
available, the Layer should 'switch back' as parent-layer first,
generate the parent tiles. and then 'switch forward' to the copy-layer
again to do the b&w trick. In this way we can generate two 'dependent'
caches in one go.
I did not manage to do that in a Layer-impl: the MetaLayer constructor
is constructed with **kwargs, and I do not no how to store those for use
in 'renderTile'.

Somebody an idea for that?

Regards,

Richard Duivenvoorde

_______________________________________________
Tilecache mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/tilecache
Reply | Threaded
Open this post in threaded view
|

Re: PILcopy layer

Marco Nijdam
As quoted from Richard Duivenvoorde <[hidden email]>:

> Only question I have:
> - it would be nice to make this work on layers which are not fully
> seeded too. So upon a negative test if the 'parent'-layer-tile is
> available, the Layer should 'switch back' as parent-layer first,
> generate the parent tiles. and then 'switch forward' to the copy-layer
> again to do the b&w trick. In this way we can generate two 'dependent'
> caches in one go.
> I did not manage to do that in a Layer-impl: the MetaLayer constructor
> is constructed with **kwargs, and I do not no how to store those for use
> in 'renderTile'.
>
> Somebody an idea for that?

Why not make it "just another layer" in tilecache, with the "parent"
layer configured as WMS(C) server source. So Tilecache would call itself
for the parent layer image via WMS(C) URLs.

Then the only new feature in the child layer would be a "filter"
to make the image black-and-white.

Kind regards,
--
-- Marco Nijdam,         [hidden email]
-- West Consulting B.V., Delftechpark 5, 2628 XJ  Delft, The Netherlands
-- Tel: +3115 219 1600,  Fax: +3115 214 7889
_______________________________________________
Tilecache mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/tilecache