Remove progress bar.

This commit is contained in:
Sergey Vartanov 2021-09-30 23:45:24 +03:00
parent 6ffa91344a
commit 96514ddf95
4 changed files with 22 additions and 47 deletions

View file

@ -9,7 +9,6 @@ from typing import Any, Iterator, Optional, Union
import numpy as np
from colour import Color
from map_machine import ui
from map_machine.color import get_gradient_color
from map_machine.figure import (
Building,
@ -18,7 +17,6 @@ from map_machine.figure import (
StyledFigure,
Tree,
)
from map_machine.road import Road, Roads
from map_machine.flinger import Flinger
from map_machine.icon import (
DEFAULT_SMALL_SHAPE_ID,
@ -37,6 +35,7 @@ from map_machine.osm_reader import (
parse_levels,
)
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.text import Label
from map_machine.ui import BuildingMode
@ -206,18 +205,11 @@ class Constructor:
def construct_ways(self) -> None:
"""Construct Map Machine ways."""
for index, way_id in enumerate(self.osm_data.ways):
ui.progress_bar(
index,
len(self.osm_data.ways),
step=10,
text="Constructing ways",
)
logging.info("Constructing ways...")
for way_id in self.osm_data.ways:
way: OSMWay = self.osm_data.ways[way_id]
self.construct_line(way, [], [way.nodes])
ui.progress_bar(-1, len(self.osm_data.ways), text="Constructing ways")
def construct_line(
self,
line: Union[OSMWay, OSMRelation],
@ -400,17 +392,14 @@ class Constructor:
def construct_nodes(self) -> None:
"""Draw nodes."""
logging.info("Constructing nodes...")
sorted_node_ids: Iterator[int] = sorted(
self.osm_data.nodes.keys(),
key=lambda x: -self.osm_data.nodes[x].coordinates[0],
)
for index, node_id in enumerate(sorted_node_ids):
ui.progress_bar(
index, len(self.osm_data.nodes), text="Constructing nodes"
)
for node_id in sorted_node_ids:
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:
"""Draw one node."""

View file

@ -46,9 +46,9 @@ class MapConfiguration:
Map drawing configuration.
"""
drawing_mode: DrawingMode = DrawingMode.NORMAL
building_mode: BuildingMode = BuildingMode.FLAT
label_mode: LabelMode = LabelMode.MAIN
drawing_mode: str = DrawingMode.NORMAL
building_mode: str = BuildingMode.FLAT
label_mode: str = LabelMode.MAIN
zoom_level: float = 18.0
overlap: int = 12
level: str = "overground"

View file

@ -24,7 +24,7 @@ from map_machine.osm_reader import OSMData, OSMNode
from map_machine.point import Occupied, Point
from map_machine.road import Intersection, Road, RoadPart
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
__author__ = "Sergey Vartanov"
@ -60,15 +60,14 @@ class Map:
ways: list[StyledFigure] = sorted(
constructor.figures, key=lambda x: x.line_style.priority
)
ways_length: int = len(ways)
for index, way in enumerate(ways):
progress_bar(index, ways_length, step=10, text="Drawing ways")
logging.info("Drawing ways...")
for way in ways:
path_commands: str = way.get_path(self.flinger)
if path_commands:
path: SVGPath = SVGPath(d=path_commands)
path.update(way.line_style.style)
self.svg.add(path)
progress_bar(-1, 0, text="Drawing ways")
constructor.roads.draw(self.svg, self.flinger)
@ -97,22 +96,16 @@ class Map:
nodes: list[Point] = sorted(
constructor.points, key=lambda x: -x.priority
)
steps: int = len(nodes)
for index, node in enumerate(nodes):
progress_bar(index, steps * 3, step=10, text="Drawing main icons")
logging.info("Drawing main icons...")
for node in nodes:
node.draw_main_shapes(self.svg, occupied)
for index, point in enumerate(nodes):
progress_bar(
steps + index, steps * 3, step=10, text="Drawing extra icons"
)
logging.info("Drawing extra icons...")
for point in nodes:
point.draw_extra_shapes(self.svg, occupied)
for index, point in enumerate(nodes):
progress_bar(
steps * 2 + index, steps * 3, step=10, text="Drawing texts"
)
logging.info("Drawing texts...")
for point in nodes:
if (
not self.configuration.is_wireframe()
and self.configuration.label_mode != LabelMode.NO
@ -121,8 +114,6 @@ class Map:
self.svg, occupied, self.configuration.label_mode
)
progress_bar(-1, len(nodes), step=10, text="Drawing nodes")
def draw_buildings(self, constructor: Constructor) -> None:
"""Draw buildings: shade, walls, and roof."""
if self.configuration.building_mode == BuildingMode.NO:
@ -132,6 +123,8 @@ class Map:
building.draw(self.svg, self.flinger)
return
logging.info("Drawing buildings...")
scale: float = self.flinger.get_scale() / 3.0
building_shade: Group = Group(opacity=0.1)
for building in constructor.buildings:
@ -139,9 +132,7 @@ class Map:
self.svg.add(building_shade)
previous_height: float = 0
count: int = len(constructor.heights)
for index, height in enumerate(sorted(constructor.heights)):
progress_bar(index, count, step=1, text="Drawing buildings")
for height in sorted(constructor.heights):
fill: Color()
for building in constructor.buildings:
if building.height < height or building.min_height > height:
@ -155,8 +146,6 @@ class Map:
previous_height = height
progress_bar(-1, count, step=1, text="Drawing buildings")
def draw_roads(self, roads: Iterator[Road]) -> None:
"""Draw road as simple SVG path."""
nodes: dict[OSMNode, set[RoadPart]] = {}

View file

@ -310,9 +310,6 @@ def progress_bar(
subsequently)
:param text: short description
"""
if number == 0:
sys.stdout.write(text + "...\n")
return
if number == -1:
sys.stdout.write(f"100 % {length * ''}{text}\n")
elif number % step == 0: