mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-10 23:01:53 +02:00
Make data credit optional.
This commit is contained in:
parent
7373eadaa6
commit
9b5066fd44
3 changed files with 18 additions and 14 deletions
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue