@@ -571,14 +571,21 @@ def get_thumbnail(self, cfg_item, service_name, capabilities, assets_dir):
571571 thumbnail_directory , thumbnail_filename )
572572
573573 if os .path .exists (thumbnail_path ):
574- self .logger .info ("Found existing thumbnail %s for theme %s" % (
574+ self .logger .info ("Using manually provided thumbnail %s for theme %s" % (
575575 thumbnail_filename , service_name ))
576576 return os .path .join ('img/mapthumbs' , thumbnail_filename )
577577
578578 if self .use_default_map_thumbnail :
579579 self .logger .info ("Using default map thumbnail for " + service_name )
580580 return os .path .join ('img/mapthumbs' , 'default.jpg' )
581581
582+ basename = cfg_item ["url" ].rsplit ("/" )[- 1 ].rstrip ("?" ) + ".png"
583+ thumbnail = os .path .join (assets_dir , "img/genmapthumbs" , basename )
584+ if self .use_cached_project_metadata :
585+ if os .path .isfile (thumbnail ):
586+ self .logger .info ("Using pre-existing autogenerated thumbnail for " + service_name )
587+ return 'img/genmapthumbs/' + basename
588+
582589 self .logger .info ("Using WMS GetMap to generate thumbnail for " + service_name )
583590
584591 root_layer = capabilities .get ('root_layer' , {})
@@ -643,13 +650,11 @@ def get_thumbnail(self, cfg_item, service_name, capabilities, assets_dir):
643650
644651 document = response .content
645652
646- basename = cfg_item ["url" ].rsplit ("/" )[- 1 ].rstrip ("?" ) + ".png"
647653 try :
648654 os .makedirs (os .path .join (assets_dir , "img/genmapthumbs/" ))
649655 except Exception as e :
650656 if not isinstance (e , FileExistsError ):
651657 self .logger .warn ("The directory for auto generated thumbnails could not be created\n %s" % (str (e )))
652- thumbnail = os .path .join (assets_dir , "img/genmapthumbs" , basename )
653658 with open (thumbnail , "wb" ) as fh :
654659 fh .write (document )
655660 return 'img/genmapthumbs/' + basename
0 commit comments