-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #140: put scheme inside map configuration.
Refactoring of `Scheme` and `MapConfiguration` classes.
- Loading branch information
Showing
12 changed files
with
114 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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__ = "[email protected]" | ||
|
||
|
@@ -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 @@ def background_color(self) -> Optional[Color]: | |
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.