mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-10 14:51:49 +02:00
Merge main.
This commit is contained in:
commit
124ba3e171
14 changed files with 45 additions and 17 deletions
23
.github/workflows/test.yml
vendored
23
.github/workflows/test.yml
vendored
|
@ -30,3 +30,26 @@ jobs:
|
|||
- name: Test with pytest
|
||||
run: |
|
||||
pytest -v
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python 3.9
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.9
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install black flake8 pytest
|
||||
pip install -r requirements.txt
|
||||
pip install .
|
||||
- name: Check code style with Black
|
||||
run: |
|
||||
black -l 80 --check map_machine tests
|
||||
- name: Lint with Flake8
|
||||
run: |
|
||||
flake8 --max-line-length=80 --ignore=E203,W503
|
||||
- name: Test render
|
||||
run: |
|
||||
map-machine render -b 10.000,20.000,10.001,20.001 --cache tests/data
|
||||
|
|
|
@ -140,7 +140,7 @@ class SVGDrawing(Drawing):
|
|||
|
||||
def write(self) -> None:
|
||||
"""Write image to the SVG file."""
|
||||
with self.file_path.open("w+") as output_file:
|
||||
with self.file_path.open("w+", encoding="utf-8") as output_file:
|
||||
self.image.write(output_file)
|
||||
|
||||
|
||||
|
|
|
@ -70,6 +70,6 @@ def draw_element(options: argparse.Namespace) -> None:
|
|||
point.draw_main_shapes(svg)
|
||||
point.draw_extra_shapes(svg)
|
||||
point.draw_texts(svg)
|
||||
with output_file_path.open("w+") as output_file:
|
||||
with output_file_path.open("w+", encoding="utf-8") as output_file:
|
||||
svg.write(output_file)
|
||||
logging.info(f"Element is written to {output_file_path}.")
|
||||
|
|
|
@ -196,7 +196,7 @@ class IconCollection:
|
|||
point += np.array((0, step))
|
||||
height += step
|
||||
|
||||
with file_name.open("w") as output_file:
|
||||
with file_name.open("w", encoding="utf-8") as output_file:
|
||||
svg.write(output_file)
|
||||
|
||||
def __len__(self) -> int:
|
||||
|
|
|
@ -404,7 +404,7 @@ class Icon:
|
|||
shape_specification.color = color
|
||||
shape_specification.draw(svg, np.array((8, 8)))
|
||||
|
||||
with file_name.open("w") as output_file:
|
||||
with file_name.open("w", encoding="utf-8") as output_file:
|
||||
svg.write(output_file)
|
||||
|
||||
def is_default(self) -> bool:
|
||||
|
|
|
@ -199,7 +199,9 @@ def ui(options: argparse.Namespace) -> None:
|
|||
options.ways,
|
||||
options.lifecycle,
|
||||
)
|
||||
with workspace.get_mapcss_file_path().open("w+") as output_file:
|
||||
with workspace.get_mapcss_file_path().open(
|
||||
"w+", encoding="utf-8"
|
||||
) as output_file:
|
||||
mapcss_writer.write(output_file)
|
||||
|
||||
logging.info(f"MapCSS 0.2 scheme is written to {directory}.")
|
||||
|
|
|
@ -280,5 +280,5 @@ def ui(arguments: argparse.Namespace) -> None:
|
|||
painter.draw(constructor)
|
||||
|
||||
logging.info(f"Writing output SVG to {arguments.output_file_name}...")
|
||||
with open(arguments.output_file_name, "w") as output_file:
|
||||
with open(arguments.output_file_name, "w", encoding="utf-8") as output_file:
|
||||
svg.write(output_file)
|
||||
|
|
|
@ -307,8 +307,8 @@ class MapMachineMarkdown(MapMachineMoire, DefaultMarkdown):
|
|||
|
||||
def convert(input_path: Path, output_path: Path) -> None:
|
||||
"""Convert Moire file to Markdown."""
|
||||
with input_path.open() as input_file:
|
||||
with output_path.open("w+") as output_file:
|
||||
with input_path.open(encoding="utf-8") as input_file:
|
||||
with output_path.open("w+", encoding="utf-8") as output_file:
|
||||
output_file.write(MapMachineMarkdown().convert(input_file.read()))
|
||||
|
||||
|
||||
|
|
|
@ -361,7 +361,7 @@ class OSMData:
|
|||
|
||||
See https://wiki.openstreetmap.org/wiki/Overpass_API
|
||||
"""
|
||||
with file_name.open() as input_file:
|
||||
with file_name.open(encoding="utf-8") as input_file:
|
||||
structure = json.load(input_file)
|
||||
|
||||
node_map: Dict[int, OSMNode] = {}
|
||||
|
|
|
@ -306,7 +306,7 @@ class Scheme:
|
|||
:param file_name: name of the scheme file with tags, colors, and tag key
|
||||
specification
|
||||
"""
|
||||
with file_name.open() as input_file:
|
||||
with file_name.open(encoding="utf-8") as input_file:
|
||||
content: Dict[str, Any] = yaml.load(
|
||||
input_file.read(), Loader=yaml.FullLoader
|
||||
)
|
||||
|
|
|
@ -51,7 +51,7 @@ class _Handler(SimpleHTTPRequestHandler):
|
|||
if not png_path.exists():
|
||||
if not svg_path.exists():
|
||||
tile.draw(tile_path, self.cache, self.options)
|
||||
with svg_path.open() as input_file:
|
||||
with svg_path.open(encoding="utf-8") as input_file:
|
||||
cairosvg.svg2png(
|
||||
file_obj=input_file, write_to=str(png_path)
|
||||
)
|
||||
|
|
|
@ -74,7 +74,7 @@ class TaginfoProjectFile:
|
|||
|
||||
def write(self) -> None:
|
||||
"""Write Taginfo JSON file."""
|
||||
with self.path.open("w+") as output_file:
|
||||
with self.path.open("w+", encoding="utf-8") as output_file:
|
||||
json.dump(self.structure, output_file, indent=4, sort_keys=True)
|
||||
|
||||
|
||||
|
|
|
@ -182,12 +182,12 @@ class Tile:
|
|||
)
|
||||
painter.draw(constructor)
|
||||
|
||||
with output_file_name.open("w") as output_file:
|
||||
with output_file_name.open("w", encoding="utf-8") as output_file:
|
||||
svg.write(output_file)
|
||||
logging.info(f"Tile is drawn to {output_file_name}.")
|
||||
|
||||
output_path: Path = output_file_name.with_suffix(".png")
|
||||
with output_file_name.open() as input_file:
|
||||
with output_file_name.open(encoding="utf-8") as input_file:
|
||||
cairosvg.svg2png(file_obj=input_file, write_to=str(output_path))
|
||||
logging.info(f"SVG file is rasterized to {output_path}.")
|
||||
|
||||
|
@ -287,7 +287,7 @@ class Tiles:
|
|||
|
||||
output_path: Path = file_path.with_suffix(".png")
|
||||
if not output_path.exists():
|
||||
with file_path.open() as input_file:
|
||||
with file_path.open(encoding="utf-8") as input_file:
|
||||
cairosvg.svg2png(
|
||||
file_obj=input_file, write_to=str(output_path)
|
||||
)
|
||||
|
@ -398,14 +398,14 @@ class Tiles:
|
|||
map_.draw(constructor)
|
||||
|
||||
logging.info(f"Writing output SVG {output_path}...")
|
||||
with output_path.open("w+") as output_file:
|
||||
with output_path.open("w+", encoding="utf-8") as output_file:
|
||||
svg.write(output_file)
|
||||
else:
|
||||
logging.debug(f"File {output_path} already exists.")
|
||||
|
||||
png_path: Path = self.get_file_path(cache_path).with_suffix(".png")
|
||||
if not png_path.exists():
|
||||
with output_path.open() as input_file:
|
||||
with output_path.open(encoding="utf-8") as input_file:
|
||||
cairosvg.svg2png(file_obj=input_file, write_to=str(png_path))
|
||||
logging.info(f"SVG file is rasterized to {png_path}.")
|
||||
else:
|
||||
|
|
|
@ -338,6 +338,9 @@ 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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue