Add background option to enable/disable background.

This commit is contained in:
Natanael Arndt 2024-07-22 23:33:34 +02:00
parent 825eb34191
commit e5b65b59c0
3 changed files with 16 additions and 3 deletions

View file

@ -63,6 +63,7 @@ class MapConfiguration:
show_overlapped: bool = False
credit: Optional[str] = "© OpenStreetMap contributors"
show_credit: bool = True
draw_background: bool = True
@classmethod
def from_options(
@ -85,6 +86,7 @@ class MapConfiguration:
options.building_colors,
options.show_overlapped,
show_credit=not options.hide_credit,
draw_background=options.background,
)
def is_wireframe(self) -> bool:

View file

@ -57,9 +57,14 @@ class Map:
def draw(self, constructor: Constructor) -> None:
"""Draw map."""
self.svg.add(
Rect((0.0, 0.0), self.flinger.size, fill=self.background_color)
)
if self.configuration.draw_background:
logging.info("Drawing background...")
self.svg.add(
Rect((0.0, 0.0), self.flinger.size, fill=self.background_color)
)
else:
logging.info("Drawing no background")
logging.info("Drawing ways...")
figures: list[StyledFigure] = constructor.get_sorted_figures()

View file

@ -214,6 +214,12 @@ def add_map_arguments(parser: argparse.ArgumentParser) -> None:
action=argparse.BooleanOptionalAction,
default=False,
)
parser.add_argument(
"--background",
help="enable or disable the background e.g. to use it as layer",
action=argparse.BooleanOptionalAction,
default=True,
)
def add_tile_arguments(parser: argparse.ArgumentParser) -> None: