Make data credit optional.

This commit is contained in:
Sergey Vartanov 2022-05-25 01:05:32 +03:00
parent 7373eadaa6
commit 9b5066fd44
3 changed files with 18 additions and 14 deletions

View file

@ -111,16 +111,17 @@ class Grid:
def get_boundary_box(self) -> BoundaryBox:
"""Compute resulting boundary box with margin of one grid step."""
return BoundaryBox(
-self.x_step,
-self.max_i - self.y_step,
self.max_j + self.x_step,
self.y_step,
-self.x_step * 1.5,
-self.max_i - self.y_step * 1.5,
self.max_j + self.x_step * 1.5,
self.y_step * 1.5,
)
def draw(self, output_path: Path, zoom: float = DEFAULT_ZOOM) -> None:
"""Draw grid."""
configuration: MapConfiguration = MapConfiguration(level="all")
configuration: MapConfiguration = MapConfiguration(
level="all", credit=None
)
flinger: Flinger = Flinger(
self.get_boundary_box(), zoom, self.osm_data.equator_length
)

View file

@ -57,6 +57,7 @@ class MapConfiguration:
draw_roofs: bool = True
use_building_colors: bool = False
show_overlapped: bool = False
credit: Optional[str] = "© OpenStreetMap contributors"
@classmethod
def from_options(

View file

@ -34,8 +34,6 @@ from map_machine.workspace import workspace
__author__ = "Sergey Vartanov"
__email__ = "me@enzet.ru"
OPENSTREETMAP_CREDIT: str = "© OpenStreetMap contributors"
class Map:
"""Map drawing."""
@ -207,13 +205,17 @@ class Map:
text_color: Color = Color("#888888")
outline_color: Color = Color("#FFFFFF")
for text, point in (
(
f"Data: {OPENSTREETMAP_CREDIT}",
credit_list: list[tuple[str, tuple[float, float]]] = [
(f"Rendering: {__project__}", (right_margin, bottom_margin))
]
if self.configuration.credit:
data_credit: tuple[str, tuple[float, float]] = (
f"Data: {self.configuration.credit}",
(right_margin, bottom_margin + font_size + vertical_spacing),
),
(f"Rendering: {__project__}", (right_margin, bottom_margin)),
):
)
credit_list.append(data_credit)
for text, point in credit_list:
for stroke_width, stroke, opacity in (
(3.0, outline_color, 0.7),
(1.0, None, 1.0),