Skip to content

Commit

Permalink
Added scale parameter throughout compile chain
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Migurski committed May 23, 2012
1 parent 9264158 commit 6f9d6eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 5 additions & 2 deletions cascadenik/__init__.py
Expand Up @@ -36,7 +36,7 @@


__all__ = ['load_map', 'compile', '_compile', 'style', 'stylesheet_declarations'] __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(). """ Apply a stylesheet source file to a given mapnik Map instance, like mapnik.load_map().
Parameters: Parameters:
Expand All @@ -53,6 +53,9 @@ def load_map(map, src_file, output_dir, cache_dir=None, datasources_cfg=None, ve
Keyword Parameters: Keyword Parameters:
scale:
Optional scale value for output map, 2 doubles the size for high-res displays.
cache_dir: cache_dir:
... ...
Expand All @@ -76,4 +79,4 @@ def load_map(map, src_file, output_dir, cache_dir=None, datasources_cfg=None, ve
chmod(cache_dir, 0755) chmod(cache_dir, 0755)


dirs = Directories(output_dir, realpath(cache_dir), dirname(src_file)) 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)
11 changes: 7 additions & 4 deletions cascadenik/compile.py
Expand Up @@ -609,7 +609,7 @@ def is_merc_projection(srs):


return True 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 """ Given a Map element and directories object, remove and return a complete
list of style declarations from any Stylesheet elements found within. list of style declarations from any Stylesheet elements found within.
""" """
Expand All @@ -625,7 +625,7 @@ def extract_declarations(map_el, dirs):


is_merc = is_merc_projection(map_el.get('srs','')) 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 # Change the value of each URI relative to the location
Expand Down Expand Up @@ -1426,7 +1426,7 @@ def localize_file_datasource(file_href, dirs):
else: else:
return dirs.output_path(path) 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. """ Compile a Cascadenik MML file, returning a cascadenik.output.Map object.
Parameters: Parameters:
Expand All @@ -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> (i.e. postgis_dbname) defined in the map's canonical <DataSourcesConfig>
entities. This is most useful in development, whereby one redefines entities. This is most useful in development, whereby one redefines
individual datasources, connection parameters, and/or local paths. individual datasources, connection parameters, and/or local paths.
scale:
Scale value for output map, 2 doubles the size for high-res displays.
""" """
global VERBOSE global VERBOSE


Expand Down Expand Up @@ -1480,7 +1483,7 @@ def compile(src, dirs, verbose=False, srs=None, datasources_cfg=None):
map_el = doc.getroot() map_el = doc.getroot()


expand_source_declarations(map_el, dirs, datasources_cfg) 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 # a list of layers and a sequential ID generator
layers, ids = [], (i for i in xrange(1, 999999)) layers, ids = [], (i for i in xrange(1, 999999))
Expand Down

0 comments on commit 6f9d6eb

Please sign in to comment.