From 803e26510bafbcc42bb563be5b83689bc8359d2d Mon Sep 17 00:00:00 2001 From: XANTRONIX Industrial Date: Thu, 3 Apr 2025 21:53:54 -0400 Subject: [PATCH] Locate map assets from config file --- bin/xmet-spc-render-file | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/bin/xmet-spc-render-file b/bin/xmet-spc-render-file index 388c2f3..03be208 100755 --- a/bin/xmet-spc-render-file +++ b/bin/xmet-spc-render-file @@ -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'])