[Tilecache] Patch to KML Service to limit zooms to resolutions

Christopher Schmidt crschmidt at metacarta.com
Sat Nov 15 04:19:25 EST 2008


On Wed, Nov 12, 2008 at 05:07:20PM +0000, Graham Carlyle wrote:
> Hi Christopher
> 
> Your request for any oustanding patches reminded me of a patch I've 
> applied to the KML service to stop it generating NetworkLink elements 
> for zooms beyond the maximum resolution available. Patch is attached.

Applied, thanks.

> I've also got another change which might be of interest, it makes 
> TileCache return an X-SendFile header rather than returning the tile 
> data if the tile is cached so that apache serves the file. I think I'd 
> have to clean it up a bit as its currently not optional and assumes you 
> have a proxying webserver that understands this header. I guess it would 
> need to be enabled via a config option. But maybe this functionality is 
> a bit too specialised?

I'm concerned about it polluting the 'core' in a way that makes other
developments more difficult. However, I'd be willing to look at the
patch and see what yo'uve got in order to make that determination -- the
idea behind it certainly makes sense.

-- Chris

> 
> cheers,
> Graham

> Index: TileCache/Services/KML.py
> ===================================================================
> --- TileCache/Services/KML.py	(revision 360)
> +++ TileCache/Services/KML.py	(working copy)
> @@ -21,6 +21,8 @@
>          network_links = []
>          
>          for single_tile in tiles:
> +            if single_tile.z >= len(tile.layer.resolutions):
> +                continue
>              b = single_tile.bounds()
>              network_links.append("""<NetworkLink>
>        <name>tile</name>
> @@ -44,11 +46,15 @@
>          if include_wrapper: 
>              kml.append( """<?xml version="1.0" encoding="UTF-8"?>
>  <kml xmlns="http://earth.google.com/kml/2.1">""")
> +        if tile.z == len(tile.layer.resolutions) - 1:
> +            max_lod_pixels = -1
> +        else:
> +            max_lod_pixels = 512
>          kml.append("""
>    <Document>
>      <Region>
>        <Lod>
> -        <minLodPixels>256</minLodPixels><maxLodPixels>512</maxLodPixels>
> +        <minLodPixels>256</minLodPixels><maxLodPixels>%d</maxLodPixels>
>        </Lod>
>        <LatLonAltBox>
>          <north>%s</north><south>%s</south>
> @@ -66,7 +72,7 @@
>        </LatLonBox>
>      </GroundOverlay>
>      %s
> -    """ % (b[3], b[1], b[2], b[0], tile.z, base_path, tile.layer.name, tile.z, tile.x, tile.y, b[3], b[1], b[2], b[0], "\n".join(network_links)))
> +    """ % (max_lod_pixels, b[3], b[1], b[2], b[0], tile.z, base_path, tile.layer.name, tile.z, tile.x, tile.y, b[3], b[1], b[2], b[0], "\n".join(network_links)))
>          if include_wrapper:
>              kml.append("""</Document></kml>""" )
>          kml = "\n".join(kml)       

> _______________________________________________
> Tilecache mailing list
> Tilecache at openlayers.org
> http://openlayers.org/mailman/listinfo/tilecache


-- 
Christopher Schmidt
MetaCarta



More information about the Tilecache mailing list