Skip to content

Commit

Permalink
Add a primitive SuperOverlay generator. Will only work with factor
Browse files Browse the repository at this point in the history
of 2 resolution changes, and doesn't really seem to work as completely 
as I would like, but it's an interesting step forward.
  • Loading branch information
crschmidt committed Dec 5, 2007
1 parent 9b7d4a2 commit baef276
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pre-2.0/TileCache/Service.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,18 @@ def expireTile (self, tile):
self.cache.delete(coverage)

def dispatchRequest (self, params, path_info="/", req_method="GET", host="http://example.com/"):
if path_info.split(".")[-1] == "kml":
from TileCache.Services.KML import KML
return KML(self).parse(params, path_info, host)
raise TileCacheException("What, you think we do KML?")

if params.has_key("service") or params.has_key("SERVICE") or \
params.has_key("REQUEST") and params['REQUEST'] == "GetMap" or \
params.has_key("request") and params['request'] == "GetMap":
from TileCache.Services.WMS import WMS
tile = WMS(self).parse(params, path_info, host)
elif params.has_key("L") or params.has_key("l"):
elif params.has_key("L") or params.has_key("l") or \
params.has_key("request") and params['request'] == "metadata":
from TileCache.Services.WorldWind import WorldWind
tile = WorldWind(self).parse(params, path_info, host)
elif params.has_key("interface"):
Expand Down
64 changes: 64 additions & 0 deletions pre-2.0/TileCache/Services/KML.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from TileCache.Service import Request, Capabilities
from TileCache.Services.TMS import TMS
import TileCache.Layer as Layer

class KML(TMS):
def parse (self, fields, path, host):
tile = TMS.parse(self,fields, path, host)
tiles = [
Layer.Tile(tile.layer, tile.x << 1, tile.y << 1, tile.z + 1),
Layer.Tile(tile.layer, (tile.x << 1) + 1, tile.y << 1, tile.z + 1),
Layer.Tile(tile.layer, (tile.x << 1) + 1, (tile.y << 1) + 1, tile.z + 1),
Layer.Tile(tile.layer, tile.x << 1 , (tile.y << 1) + 1, tile.z + 1)
]

network_links = []

for single_tile in tiles:
b = single_tile.bounds()
network_links.append("""<NetworkLink>
<name>tile</name>
<Region>
<Lod>
<minLodPixels>128</minLodPixels><maxLodPixels>-1</maxLodPixels>
</Lod>
<LatLonAltBox>
<north>%s</north><south>%s</south>
<east>%s</east><west>%s</west>
</LatLonAltBox>
</Region>
<Link>
<href>%s/1.0.0/%s/%s/%s/%s.kml</href>
<viewRefreshMode>onRegion</viewRefreshMode>
</Link>
</NetworkLink>""" % (b[3], b[1], b[2], b[0], host, single_tile.layer.name, single_tile.z, single_tile.x, single_tile.y))

b = tile.bounds()

kml = """<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<Region>
<Lod>
<minLodPixels>128</minLodPixels><maxLodPixels>-1</maxLodPixels>
</Lod>
<LatLonAltBox>
<north>%s</north><south>%s</south>
<east>%s</east><west>%s</west>
</LatLonAltBox>
</Region>
<GroundOverlay>
<drawOrder>5</drawOrder>
<Icon>
<href>%s/1.0.0/%s/%s/%s/%s</href>
</Icon>
<LatLonBox>
<north>%s</north><south>%s</south>
<east>%s</east><west>%s</west>
</LatLonBox>
</GroundOverlay>
%s
</Document>
</kml>""" % (b[3], b[1], b[2], b[0], host, tile.layer, tile.z, tile.x, tile.y, b[3], b[1], b[2], b[0], "\n".join(network_links))

return ("text/plain", kml)

0 comments on commit baef276

Please sign in to comment.