[Tilecache] Customize TileCache get image routine
Linda Rawson
linda.rawson at gmail.com
Mon Oct 15 18:51:06 EDT 2007
Thanks for the information.
*>>>>1. Check if the image already exists in the cache.
>>>>>I believe this is handled by TileCache at the 'Service' level,
depending
>>>>>on what you mean by 'cache'.
*
Basically from the class MyDGLayer(Layer):
I only want to "question" the service if I don't have the image cached on my
disk already. What method would I call to check that? They don't have one
call to question and retrieve. Basically you call one url to ask if they
have an image then I will call the WMS service if they do. Their WMS
service returns an image, right or wrong, always. So I could eliminate two
hits on their server if I knew I had the image on disk already.
Thanks in advance,
Linda
On 10/15/07, Christopher Schmidt <crschmidt at metacarta.com> wrote:
>
> On Mon, Oct 15, 2007 at 09:49:19AM -0600, Linda Rawson wrote:
> > Basically I need to do the following:
> >
> > 1. Check if the image already exists in the cache.
>
> I believe this is handled by TileCache at the 'Service' level, depending
> on what you mean by 'cache'.
>
> > 2. If not then check for the image with the provider by utilizing a url
> > that returns a value.
> > 3. Check the value and If still no image then try another WMS service
> > provider.
> > 4. If still no image then return a noimage tile.
>
> Right. You'll need to add something like:
>
> class MyDGLayer(Layer):
> def renderTile(self: tile):
> bbox = tile.bbox()
> u = urllib.urlopen('http://digitalglobe.com/tile?bbox=%s' % bbox)
> tile.data = u.read()
> if not tile.data:
> u = urllib.urlopen('http://wms.example.com/tile?bbox=%s' %
> bbox)
> tile.data = u.read()
> if not tile.data:
> tile.data = open("/my/local/no_image.png").read()
> return tile.data
>
> > Can you direct me to the best python resource for these things?
>
> You'll probably just want to look at basic Python documentation for
> 'loading data from remote servers' or 'loading data over http' or
> something like that. I never looked at any resources other than Google
> for learning Python, so I can't help specifically.
>
> Sticking that at the end of the Layer.py file, and then creating a:
>
> [digitalglobe]
> type=MyDGLayer
>
> Should get you started.
>
> Regards,
> --
> Christopher Schmidt
> MetaCarta
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/tilecache/attachments/20071015/31c62adc/attachment.html
More information about the Tilecache
mailing list