Permalink
Browse files

Add --max-extent and --resolutions options for OpenLayers in tc-viewer

  • Loading branch information...
1 parent 9d50c23 commit 039e7db6b5391c3d7aee4cb3e8e36460b9514822 @twpayne twpayne committed Jun 7, 2012
Showing with 22 additions and 1 deletion.
  1. +11 −1 tc-viewer
  2. +11 −0 views/openlayers.tpl
View
@@ -18,6 +18,8 @@ option_parser.add_option('--root', metavar='Z/X/Y')
option_parser.add_option('--host', default='127.0.0.1', metavar='HOST')
option_parser.add_option('--port', default=8080, metavar='PORT', type=int)
option_parser.add_option('--quiet', action='store_true', default=False)
+option_parser.add_option('--max-extent', metavar='MAX-EXTENT', type=str)
+option_parser.add_option('--resolutions', metavar='RESOLUTIONS', type=str)
option_parser.add_option('--server', metavar='SERVER')
options, args = option_parser.parse_args(sys.argv[1:])
@@ -39,6 +41,14 @@ if options.server is None:
options.server = 'wsgiref'
cache = {} if options.cache else None
+if options.max_extent:
+ max_extent = map(int, re.split(r'\s*,\s*', options.max_extent))
+else:
+ max_extent = None
+if options.resolutions:
+ resolutions = map(int, re.split(r'\s*,\s*', options.resolutions))
+else:
+ resolutions = None
tilestores = [(os.path.basename(arg), TileStore.load(arg)) for arg in args]
content_type_adder = ContentTypeAdder()
@@ -100,7 +110,7 @@ def openwebglobe_layersettings(index):
@bottle.route('/openlayers')
@bottle.view('openlayers')
def openlayers():
- return dict(tilestores=tilestores)
+ return dict(max_extent=max_extent, resolutions=resolutions, tilestores=tilestores)
@bottle.route('/googlemaps')
View
@@ -19,6 +19,13 @@
<script type="text/javascript">
var map = new OpenLayers.Map({
div: "map",
+%if max_extent:
+ maxExtent: new OpenLayers.Bounds({{max_extent[0]}}, {{max_extent[1]}}, {{max_extent[2]}}, {{max_extent[3]}}),
+%end
+%if resolutions:
+ resolutions: {{resolutions}},
+ maxResolution: 'auto',
+%end
allOverlays: true
});
%for index, (name, tilestore) in enumerate(tilestores):
@@ -27,8 +34,12 @@
%if getattr(tilestore, 'attribution', None):
attribution: '{{!tilestore.attribution}}',
%end
+%if max_extent or resolutions:
+%pass
+%else:
numZoomLevels: 32,
sphericalMercator: true
+%end
}));
%end
%end

0 comments on commit 039e7db

Please sign in to comment.