mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-04 03:41:50 +02:00
Fix rasterization.
This commit is contained in:
parent
c20baa1554
commit
970046aa86
2 changed files with 12 additions and 5 deletions
|
@ -2,7 +2,7 @@
|
||||||
Röntgen tile server for sloppy maps.
|
Röntgen tile server for sloppy maps.
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
from http.server import SimpleHTTPRequestHandler, HTTPServer
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ __author__ = "Sergey Vartanov"
|
||||||
__email__ = "me@enzet.ru"
|
__email__ = "me@enzet.ru"
|
||||||
|
|
||||||
|
|
||||||
class Handler(BaseHTTPRequestHandler):
|
class Handler(SimpleHTTPRequestHandler):
|
||||||
"""
|
"""
|
||||||
HTTP request handler that process sloppy map tile requests.
|
HTTP request handler that process sloppy map tile requests.
|
||||||
"""
|
"""
|
||||||
|
@ -43,7 +43,10 @@ class Handler(BaseHTTPRequestHandler):
|
||||||
if not svg_path.exists():
|
if not svg_path.exists():
|
||||||
tile = Tile(x, y, zoom)
|
tile = Tile(x, y, zoom)
|
||||||
tile.draw(tile_path, self.cache)
|
tile.draw(tile_path, self.cache)
|
||||||
cairosvg.svg2png(file_obj=svg_path, write_to=str(png_path))
|
with svg_path.open() as input_file:
|
||||||
|
cairosvg.svg2png(
|
||||||
|
file_obj=input_file, write_to=str(png_path)
|
||||||
|
)
|
||||||
logging.info(f"SVG file is rasterized to {png_path}.")
|
logging.info(f"SVG file is rasterized to {png_path}.")
|
||||||
if zoom != 18:
|
if zoom != 18:
|
||||||
return
|
return
|
||||||
|
|
|
@ -84,7 +84,10 @@ class Tiles:
|
||||||
|
|
||||||
output_path: Path = file_path.with_suffix(".png")
|
output_path: Path = file_path.with_suffix(".png")
|
||||||
if not output_path.exists():
|
if not output_path.exists():
|
||||||
cairosvg.svg2png(file_obj=file_path, write_to=str(output_path))
|
with file_path.open() as input_file:
|
||||||
|
cairosvg.svg2png(
|
||||||
|
file_obj=input_file, write_to=str(output_path)
|
||||||
|
)
|
||||||
logging.info(f"SVG file is rasterized to {output_path}.")
|
logging.info(f"SVG file is rasterized to {output_path}.")
|
||||||
else:
|
else:
|
||||||
logging.info(f"File {output_path} already exists.")
|
logging.info(f"File {output_path} already exists.")
|
||||||
|
@ -136,7 +139,8 @@ class Tiles:
|
||||||
|
|
||||||
png_path: Path = cache_path / f"{self.boundary_box.get_format()}.png"
|
png_path: Path = cache_path / f"{self.boundary_box.get_format()}.png"
|
||||||
if not png_path.exists():
|
if not png_path.exists():
|
||||||
cairosvg.svg2png(file_obj=output_path, write_to=str(png_path))
|
with output_path.open() as input_file:
|
||||||
|
cairosvg.svg2png(file_obj=input_file, write_to=str(png_path))
|
||||||
logging.info(f"SVG file is rasterized to {png_path}.")
|
logging.info(f"SVG file is rasterized to {png_path}.")
|
||||||
else:
|
else:
|
||||||
logging.info(f"File {png_path} already exists.")
|
logging.info(f"File {png_path} already exists.")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue