Permalink
Browse files

Added scale parameter throughout compile chain

  • Loading branch information...
1 parent 9264158 commit 6f9d6eb18c5002caec8786a92c13faf920ac1e0c Michal Migurski committed May 23, 2012
Showing with 12 additions and 6 deletions.
  1. +5 −2 cascadenik/__init__.py
  2. +7 −4 cascadenik/compile.py
View
@@ -36,7 +36,7 @@
__all__ = ['load_map', 'compile', '_compile', 'style', 'stylesheet_declarations']
-def load_map(map, src_file, output_dir, cache_dir=None, datasources_cfg=None, verbose=False):
+def load_map(map, src_file, output_dir, scale=1, cache_dir=None, datasources_cfg=None, verbose=False):
""" Apply a stylesheet source file to a given mapnik Map instance, like mapnik.load_map().
Parameters:
@@ -53,6 +53,9 @@ def load_map(map, src_file, output_dir, cache_dir=None, datasources_cfg=None, ve
Keyword Parameters:
+ scale:
+ Optional scale value for output map, 2 doubles the size for high-res displays.
+
cache_dir:
...
@@ -76,4 +79,4 @@ def load_map(map, src_file, output_dir, cache_dir=None, datasources_cfg=None, ve
chmod(cache_dir, 0755)
dirs = Directories(output_dir, realpath(cache_dir), dirname(src_file))
- compile(src_file, dirs, verbose, datasources_cfg=datasources_cfg).to_mapnik(map, dirs)
+ compile(src_file, dirs, verbose, datasources_cfg=datasources_cfg, scale=scale).to_mapnik(map, dirs)
View
@@ -609,7 +609,7 @@ def is_merc_projection(srs):
return True
-def extract_declarations(map_el, dirs):
+def extract_declarations(map_el, dirs, scale=1):
""" Given a Map element and directories object, remove and return a complete
list of style declarations from any Stylesheet elements found within.
"""
@@ -625,7 +625,7 @@ def extract_declarations(map_el, dirs):
is_merc = is_merc_projection(map_el.get('srs',''))
- for declaration in stylesheet_declarations(styles, is_merc):
+ for declaration in stylesheet_declarations(styles, is_merc, scale):
#
# Change the value of each URI relative to the location
@@ -1426,7 +1426,7 @@ def localize_file_datasource(file_href, dirs):
else:
return dirs.output_path(path)
-def compile(src, dirs, verbose=False, srs=None, datasources_cfg=None):
+def compile(src, dirs, verbose=False, srs=None, datasources_cfg=None, scale=1):
""" Compile a Cascadenik MML file, returning a cascadenik.output.Map object.
Parameters:
@@ -1453,6 +1453,9 @@ def compile(src, dirs, verbose=False, srs=None, datasources_cfg=None):
(i.e. postgis_dbname) defined in the map's canonical <DataSourcesConfig>
entities. This is most useful in development, whereby one redefines
individual datasources, connection parameters, and/or local paths.
+
+ scale:
+ Scale value for output map, 2 doubles the size for high-res displays.
"""
global VERBOSE
@@ -1480,7 +1483,7 @@ def compile(src, dirs, verbose=False, srs=None, datasources_cfg=None):
map_el = doc.getroot()
expand_source_declarations(map_el, dirs, datasources_cfg)
- declarations = extract_declarations(map_el, dirs)
+ declarations = extract_declarations(map_el, dirs, scale)
# a list of layers and a sequential ID generator
layers, ids = [], (i for i in xrange(1, 999999))

0 comments on commit 6f9d6eb

Please sign in to comment.