mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-30 17:36:27 +02:00
Issue #140: put scheme inside map configuration.
Refactoring of `Scheme` and `MapConfiguration` classes.
This commit is contained in:
parent
596910fe01
commit
c76e1f0301
12 changed files with 114 additions and 70 deletions
|
@ -2,10 +2,13 @@
|
|||
import argparse
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
from typing import Optional, Any
|
||||
|
||||
from colour import Color
|
||||
|
||||
from map_machine.pictogram.icon import ShapeExtractor, IconSet
|
||||
from map_machine.scheme import Scheme
|
||||
|
||||
__author__ = "Sergey Vartanov"
|
||||
__email__ = "me@enzet.ru"
|
||||
|
||||
|
@ -42,6 +45,7 @@ class BuildingMode(Enum):
|
|||
class MapConfiguration:
|
||||
"""Map drawing configuration."""
|
||||
|
||||
scheme: Scheme
|
||||
drawing_mode: DrawingMode = DrawingMode.NORMAL
|
||||
building_mode: BuildingMode = BuildingMode.FLAT
|
||||
label_mode: LabelMode = LabelMode.MAIN
|
||||
|
@ -59,10 +63,11 @@ class MapConfiguration:
|
|||
|
||||
@classmethod
|
||||
def from_options(
|
||||
cls, options: argparse.Namespace, zoom_level: float
|
||||
cls, scheme: Scheme, options: argparse.Namespace, zoom_level: float
|
||||
) -> "MapConfiguration":
|
||||
"""Initialize from command-line options."""
|
||||
return cls(
|
||||
scheme,
|
||||
DrawingMode(options.mode),
|
||||
BuildingMode(options.buildings),
|
||||
LabelMode(options.label_mode),
|
||||
|
@ -87,3 +92,19 @@ class MapConfiguration:
|
|||
if self.drawing_mode not in (DrawingMode.NORMAL, DrawingMode.BLACK):
|
||||
return Color("#111111")
|
||||
return None
|
||||
|
||||
def get_icon(
|
||||
self,
|
||||
extractor: ShapeExtractor,
|
||||
tags: dict[str, Any],
|
||||
processed: set[str],
|
||||
) -> tuple[Optional[IconSet], int]:
|
||||
return self.scheme.get_icon(
|
||||
extractor,
|
||||
tags,
|
||||
processed,
|
||||
self.country,
|
||||
self.zoom_level,
|
||||
self.ignore_level_matching,
|
||||
self.show_overlapped,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue