Locate map assets from config file
This commit is contained in:
parent
8b45d696a1
commit
803e26510b
1 changed files with 10 additions and 16 deletions
|
@ -11,30 +11,21 @@ from xmet.spc import SPCOutlookParser, \
|
|||
SPCOutlookMap, \
|
||||
SPCOutlookType
|
||||
|
||||
ASSETS = {
|
||||
'light': {
|
||||
'map': 'doc/conus.svg',
|
||||
'logo': 'doc/logo-paths.svg'
|
||||
},
|
||||
|
||||
'dark': {
|
||||
'map': 'doc/conus-dark.svg',
|
||||
'logo': 'doc/logo-paths-dark.svg'
|
||||
}
|
||||
}
|
||||
|
||||
def render_categorical(conus: SPCOutlookMap,
|
||||
outlook: SPCOutlook,
|
||||
args):
|
||||
config = Config.load()
|
||||
db = Database.from_config(config)
|
||||
|
||||
assets = ASSETS['dark'] if args.dark else ASSETS['light']
|
||||
assets = {
|
||||
'conus': config['map']['conus_dark' if args.dark else 'conus'],
|
||||
'logo': config['map']['logo_dark' if args.dark else 'logo']
|
||||
}
|
||||
|
||||
with cairo.SVGSurface(args.categorical, conus.width, conus.height) as surface:
|
||||
cr = cairo.Context(surface)
|
||||
|
||||
conus.draw_base_map_from_file(cr, assets['map'])
|
||||
conus.draw_base_map_from_file(cr, assets['conus'])
|
||||
conus.draw_categories(cr, outlook)
|
||||
conus.draw_cities(cr, db)
|
||||
conus.draw_logo(cr, assets['logo'])
|
||||
|
@ -53,12 +44,15 @@ def render_probabilistic(conus: SPCOutlookMap,
|
|||
config = Config.load()
|
||||
db = Database.from_config(config)
|
||||
|
||||
assets = ASSETS['dark'] if args.dark else ASSETS['light']
|
||||
assets = {
|
||||
'conus': config['map']['conus_dark' if args.dark else 'conus'],
|
||||
'logo': config['map']['logo_dark' if args.dark else 'logo']
|
||||
}
|
||||
|
||||
with cairo.SVGSurface(path, conus.width, conus.height) as surface:
|
||||
cr = cairo.Context(surface)
|
||||
|
||||
conus.draw_base_map_from_file(cr, assets['map'])
|
||||
conus.draw_base_map_from_file(cr, assets['conus'])
|
||||
conus.draw_probabilities(cr, outlook, hazard.upper())
|
||||
conus.draw_cities(cr, db)
|
||||
conus.draw_logo(cr, assets['logo'])
|
||||
|
|
Loading…
Add table
Reference in a new issue