mirror of
https://github.com/enzet/map-machine.git
synced 2025-07-13 06:37:49 +02:00
Remove progress bar.
This commit is contained in:
parent
6ffa91344a
commit
96514ddf95
4 changed files with 22 additions and 47 deletions
|
@ -9,7 +9,6 @@ from typing import Any, Iterator, Optional, Union
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from colour import Color
|
from colour import Color
|
||||||
|
|
||||||
from map_machine import ui
|
|
||||||
from map_machine.color import get_gradient_color
|
from map_machine.color import get_gradient_color
|
||||||
from map_machine.figure import (
|
from map_machine.figure import (
|
||||||
Building,
|
Building,
|
||||||
|
@ -18,7 +17,6 @@ from map_machine.figure import (
|
||||||
StyledFigure,
|
StyledFigure,
|
||||||
Tree,
|
Tree,
|
||||||
)
|
)
|
||||||
from map_machine.road import Road, Roads
|
|
||||||
from map_machine.flinger import Flinger
|
from map_machine.flinger import Flinger
|
||||||
from map_machine.icon import (
|
from map_machine.icon import (
|
||||||
DEFAULT_SMALL_SHAPE_ID,
|
DEFAULT_SMALL_SHAPE_ID,
|
||||||
|
@ -37,6 +35,7 @@ from map_machine.osm_reader import (
|
||||||
parse_levels,
|
parse_levels,
|
||||||
)
|
)
|
||||||
from map_machine.point import Point
|
from map_machine.point import Point
|
||||||
|
from map_machine.road import Road, Roads
|
||||||
from map_machine.scheme import DEFAULT_COLOR, LineStyle, RoadMatcher, Scheme
|
from map_machine.scheme import DEFAULT_COLOR, LineStyle, RoadMatcher, Scheme
|
||||||
from map_machine.text import Label
|
from map_machine.text import Label
|
||||||
from map_machine.ui import BuildingMode
|
from map_machine.ui import BuildingMode
|
||||||
|
@ -206,18 +205,11 @@ class Constructor:
|
||||||
|
|
||||||
def construct_ways(self) -> None:
|
def construct_ways(self) -> None:
|
||||||
"""Construct Map Machine ways."""
|
"""Construct Map Machine ways."""
|
||||||
for index, way_id in enumerate(self.osm_data.ways):
|
logging.info("Constructing ways...")
|
||||||
ui.progress_bar(
|
for way_id in self.osm_data.ways:
|
||||||
index,
|
|
||||||
len(self.osm_data.ways),
|
|
||||||
step=10,
|
|
||||||
text="Constructing ways",
|
|
||||||
)
|
|
||||||
way: OSMWay = self.osm_data.ways[way_id]
|
way: OSMWay = self.osm_data.ways[way_id]
|
||||||
self.construct_line(way, [], [way.nodes])
|
self.construct_line(way, [], [way.nodes])
|
||||||
|
|
||||||
ui.progress_bar(-1, len(self.osm_data.ways), text="Constructing ways")
|
|
||||||
|
|
||||||
def construct_line(
|
def construct_line(
|
||||||
self,
|
self,
|
||||||
line: Union[OSMWay, OSMRelation],
|
line: Union[OSMWay, OSMRelation],
|
||||||
|
@ -400,17 +392,14 @@ class Constructor:
|
||||||
|
|
||||||
def construct_nodes(self) -> None:
|
def construct_nodes(self) -> None:
|
||||||
"""Draw nodes."""
|
"""Draw nodes."""
|
||||||
|
logging.info("Constructing nodes...")
|
||||||
|
|
||||||
sorted_node_ids: Iterator[int] = sorted(
|
sorted_node_ids: Iterator[int] = sorted(
|
||||||
self.osm_data.nodes.keys(),
|
self.osm_data.nodes.keys(),
|
||||||
key=lambda x: -self.osm_data.nodes[x].coordinates[0],
|
key=lambda x: -self.osm_data.nodes[x].coordinates[0],
|
||||||
)
|
)
|
||||||
|
for node_id in sorted_node_ids:
|
||||||
for index, node_id in enumerate(sorted_node_ids):
|
|
||||||
ui.progress_bar(
|
|
||||||
index, len(self.osm_data.nodes), text="Constructing nodes"
|
|
||||||
)
|
|
||||||
self.construct_node(self.osm_data.nodes[node_id])
|
self.construct_node(self.osm_data.nodes[node_id])
|
||||||
ui.progress_bar(-1, len(self.osm_data.nodes), text="Constructing nodes")
|
|
||||||
|
|
||||||
def construct_node(self, node: OSMNode) -> None:
|
def construct_node(self, node: OSMNode) -> None:
|
||||||
"""Draw one node."""
|
"""Draw one node."""
|
||||||
|
|
|
@ -46,9 +46,9 @@ class MapConfiguration:
|
||||||
Map drawing configuration.
|
Map drawing configuration.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
drawing_mode: DrawingMode = DrawingMode.NORMAL
|
drawing_mode: str = DrawingMode.NORMAL
|
||||||
building_mode: BuildingMode = BuildingMode.FLAT
|
building_mode: str = BuildingMode.FLAT
|
||||||
label_mode: LabelMode = LabelMode.MAIN
|
label_mode: str = LabelMode.MAIN
|
||||||
zoom_level: float = 18.0
|
zoom_level: float = 18.0
|
||||||
overlap: int = 12
|
overlap: int = 12
|
||||||
level: str = "overground"
|
level: str = "overground"
|
||||||
|
|
|
@ -24,7 +24,7 @@ from map_machine.osm_reader import OSMData, OSMNode
|
||||||
from map_machine.point import Occupied, Point
|
from map_machine.point import Occupied, Point
|
||||||
from map_machine.road import Intersection, Road, RoadPart
|
from map_machine.road import Intersection, Road, RoadPart
|
||||||
from map_machine.scheme import Scheme
|
from map_machine.scheme import Scheme
|
||||||
from map_machine.ui import BuildingMode, progress_bar
|
from map_machine.ui import BuildingMode
|
||||||
from map_machine.workspace import workspace
|
from map_machine.workspace import workspace
|
||||||
|
|
||||||
__author__ = "Sergey Vartanov"
|
__author__ = "Sergey Vartanov"
|
||||||
|
@ -60,15 +60,14 @@ class Map:
|
||||||
ways: list[StyledFigure] = sorted(
|
ways: list[StyledFigure] = sorted(
|
||||||
constructor.figures, key=lambda x: x.line_style.priority
|
constructor.figures, key=lambda x: x.line_style.priority
|
||||||
)
|
)
|
||||||
ways_length: int = len(ways)
|
logging.info("Drawing ways...")
|
||||||
for index, way in enumerate(ways):
|
|
||||||
progress_bar(index, ways_length, step=10, text="Drawing ways")
|
for way in ways:
|
||||||
path_commands: str = way.get_path(self.flinger)
|
path_commands: str = way.get_path(self.flinger)
|
||||||
if path_commands:
|
if path_commands:
|
||||||
path: SVGPath = SVGPath(d=path_commands)
|
path: SVGPath = SVGPath(d=path_commands)
|
||||||
path.update(way.line_style.style)
|
path.update(way.line_style.style)
|
||||||
self.svg.add(path)
|
self.svg.add(path)
|
||||||
progress_bar(-1, 0, text="Drawing ways")
|
|
||||||
|
|
||||||
constructor.roads.draw(self.svg, self.flinger)
|
constructor.roads.draw(self.svg, self.flinger)
|
||||||
|
|
||||||
|
@ -97,22 +96,16 @@ class Map:
|
||||||
nodes: list[Point] = sorted(
|
nodes: list[Point] = sorted(
|
||||||
constructor.points, key=lambda x: -x.priority
|
constructor.points, key=lambda x: -x.priority
|
||||||
)
|
)
|
||||||
steps: int = len(nodes)
|
logging.info("Drawing main icons...")
|
||||||
|
for node in nodes:
|
||||||
for index, node in enumerate(nodes):
|
|
||||||
progress_bar(index, steps * 3, step=10, text="Drawing main icons")
|
|
||||||
node.draw_main_shapes(self.svg, occupied)
|
node.draw_main_shapes(self.svg, occupied)
|
||||||
|
|
||||||
for index, point in enumerate(nodes):
|
logging.info("Drawing extra icons...")
|
||||||
progress_bar(
|
for point in nodes:
|
||||||
steps + index, steps * 3, step=10, text="Drawing extra icons"
|
|
||||||
)
|
|
||||||
point.draw_extra_shapes(self.svg, occupied)
|
point.draw_extra_shapes(self.svg, occupied)
|
||||||
|
|
||||||
for index, point in enumerate(nodes):
|
logging.info("Drawing texts...")
|
||||||
progress_bar(
|
for point in nodes:
|
||||||
steps * 2 + index, steps * 3, step=10, text="Drawing texts"
|
|
||||||
)
|
|
||||||
if (
|
if (
|
||||||
not self.configuration.is_wireframe()
|
not self.configuration.is_wireframe()
|
||||||
and self.configuration.label_mode != LabelMode.NO
|
and self.configuration.label_mode != LabelMode.NO
|
||||||
|
@ -121,8 +114,6 @@ class Map:
|
||||||
self.svg, occupied, self.configuration.label_mode
|
self.svg, occupied, self.configuration.label_mode
|
||||||
)
|
)
|
||||||
|
|
||||||
progress_bar(-1, len(nodes), step=10, text="Drawing nodes")
|
|
||||||
|
|
||||||
def draw_buildings(self, constructor: Constructor) -> None:
|
def draw_buildings(self, constructor: Constructor) -> None:
|
||||||
"""Draw buildings: shade, walls, and roof."""
|
"""Draw buildings: shade, walls, and roof."""
|
||||||
if self.configuration.building_mode == BuildingMode.NO:
|
if self.configuration.building_mode == BuildingMode.NO:
|
||||||
|
@ -132,6 +123,8 @@ class Map:
|
||||||
building.draw(self.svg, self.flinger)
|
building.draw(self.svg, self.flinger)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
logging.info("Drawing buildings...")
|
||||||
|
|
||||||
scale: float = self.flinger.get_scale() / 3.0
|
scale: float = self.flinger.get_scale() / 3.0
|
||||||
building_shade: Group = Group(opacity=0.1)
|
building_shade: Group = Group(opacity=0.1)
|
||||||
for building in constructor.buildings:
|
for building in constructor.buildings:
|
||||||
|
@ -139,9 +132,7 @@ class Map:
|
||||||
self.svg.add(building_shade)
|
self.svg.add(building_shade)
|
||||||
|
|
||||||
previous_height: float = 0
|
previous_height: float = 0
|
||||||
count: int = len(constructor.heights)
|
for height in sorted(constructor.heights):
|
||||||
for index, height in enumerate(sorted(constructor.heights)):
|
|
||||||
progress_bar(index, count, step=1, text="Drawing buildings")
|
|
||||||
fill: Color()
|
fill: Color()
|
||||||
for building in constructor.buildings:
|
for building in constructor.buildings:
|
||||||
if building.height < height or building.min_height > height:
|
if building.height < height or building.min_height > height:
|
||||||
|
@ -155,8 +146,6 @@ class Map:
|
||||||
|
|
||||||
previous_height = height
|
previous_height = height
|
||||||
|
|
||||||
progress_bar(-1, count, step=1, text="Drawing buildings")
|
|
||||||
|
|
||||||
def draw_roads(self, roads: Iterator[Road]) -> None:
|
def draw_roads(self, roads: Iterator[Road]) -> None:
|
||||||
"""Draw road as simple SVG path."""
|
"""Draw road as simple SVG path."""
|
||||||
nodes: dict[OSMNode, set[RoadPart]] = {}
|
nodes: dict[OSMNode, set[RoadPart]] = {}
|
||||||
|
|
|
@ -310,9 +310,6 @@ def progress_bar(
|
||||||
subsequently)
|
subsequently)
|
||||||
:param text: short description
|
:param text: short description
|
||||||
"""
|
"""
|
||||||
if number == 0:
|
|
||||||
sys.stdout.write(text + "...\n")
|
|
||||||
return
|
|
||||||
if number == -1:
|
if number == -1:
|
||||||
sys.stdout.write(f"100 % {length * '█'}▏{text}\n")
|
sys.stdout.write(f"100 % {length * '█'}▏{text}\n")
|
||||||
elif number % step == 0:
|
elif number % step == 0:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue