mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-10 23:01:53 +02:00
Merge main.
This commit is contained in:
commit
db1c69fb42
18 changed files with 276 additions and 188 deletions
|
@ -19,6 +19,7 @@ from map_machine.constructor import Constructor
|
|||
from map_machine.drawing import draw_text
|
||||
from map_machine.feature.building import Building, draw_walls, BUILDING_SCALE
|
||||
from map_machine.feature.road import Intersection, Road, RoadPart
|
||||
from map_machine.figure import StyledFigure
|
||||
from map_machine.geometry.boundary_box import BoundaryBox
|
||||
from map_machine.geometry.flinger import Flinger
|
||||
from map_machine.geometry.vector import Segment
|
||||
|
@ -34,7 +35,7 @@ from map_machine.workspace import workspace
|
|||
__author__ = "Sergey Vartanov"
|
||||
__email__ = "me@enzet.ru"
|
||||
|
||||
OPENSTREETMAP_CREDIT: str = "© OpenStreetMap contributors"
|
||||
ROAD_PRIORITY: float = 40.0
|
||||
|
||||
|
||||
class Map:
|
||||
|
@ -63,7 +64,16 @@ class Map:
|
|||
)
|
||||
logging.info("Drawing ways...")
|
||||
|
||||
for figure in constructor.get_sorted_figures():
|
||||
figures: list[StyledFigure] = constructor.get_sorted_figures()
|
||||
|
||||
top_figures: list[StyledFigure] = [
|
||||
x for x in figures if x.line_style.priority >= ROAD_PRIORITY
|
||||
]
|
||||
bottom_figures: list[StyledFigure] = [
|
||||
x for x in figures if x.line_style.priority < ROAD_PRIORITY
|
||||
]
|
||||
|
||||
for figure in bottom_figures:
|
||||
path_commands: str = figure.get_path(self.flinger)
|
||||
if path_commands:
|
||||
path: SVGPath = SVGPath(d=path_commands)
|
||||
|
@ -72,6 +82,13 @@ class Map:
|
|||
|
||||
constructor.roads.draw(self.svg, self.flinger)
|
||||
|
||||
for figure in top_figures:
|
||||
path_commands: str = figure.get_path(self.flinger)
|
||||
if path_commands:
|
||||
path: SVGPath = SVGPath(d=path_commands)
|
||||
path.update(figure.line_style.style)
|
||||
self.svg.add(path)
|
||||
|
||||
for tree in constructor.trees:
|
||||
tree.draw(self.svg, self.flinger, self.scheme)
|
||||
for crater in constructor.craters:
|
||||
|
@ -207,13 +224,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),
|
||||
|
@ -255,12 +276,19 @@ def render_map(arguments: argparse.Namespace) -> None:
|
|||
|
||||
if arguments.boundary_box:
|
||||
boundary_box = BoundaryBox.from_text(arguments.boundary_box)
|
||||
|
||||
elif arguments.coordinates and arguments.size:
|
||||
coordinates: np.ndarray = np.array(
|
||||
list(map(float, arguments.coordinates.split(",")))
|
||||
)
|
||||
if len(coordinates) != 2:
|
||||
fatal("Wrong number of coordinates.")
|
||||
coordinates: Optional[np.ndarray] = None
|
||||
|
||||
for delimiter in ",", "/":
|
||||
if delimiter in arguments.coordinates:
|
||||
coordinates = np.array(
|
||||
list(map(float, arguments.coordinates.split(delimiter)))
|
||||
)
|
||||
|
||||
if coordinates is None or len(coordinates) != 2:
|
||||
fatal("Wrong coordinates format.")
|
||||
|
||||
width, height = np.array(list(map(float, arguments.size.split(","))))
|
||||
boundary_box = BoundaryBox.from_coordinates(
|
||||
coordinates, configuration.zoom_level, width, height
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue