mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-05 04:12:08 +02:00
Issue #89: fix encoding.
This commit is contained in:
parent
067b815100
commit
c0b4d35573
11 changed files with 18 additions and 16 deletions
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -69,6 +69,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}.")
|
||||
|
|
|
@ -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)
|
||||
)
|
||||
|
|
|
@ -73,7 +73,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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue