Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adds 'map' flags to the 'server' command. #159

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions map_machine/slippy/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import cairosvg

from map_machine.map_configuration import MapConfiguration
from map_machine.scheme import Scheme
from map_machine.slippy.tile import Tile
from map_machine.workspace import workspace

Expand Down Expand Up @@ -48,15 +49,22 @@ def do_GET(self) -> None:
if self.update_cache:
if not png_path.exists():
if not svg_path.exists():
scheme = Scheme.from_file(
workspace.DEFAULT_SCHEME_PATH
if self.options.scheme == "default"
else Path(self.options.scheme)
)
tile.draw(
tile_path,
self.cache,
MapConfiguration(zoom_level=zoom_level),
MapConfiguration.from_options(
scheme,
self.options,
zoom_level,
),
)
with svg_path.open(encoding="utf-8") as input_file:
cairosvg.svg2png(
file_obj=input_file, write_to=str(png_path)
)
cairosvg.svg2png(file_obj=input_file, write_to=str(png_path))
logging.info(f"SVG file is rasterized to {png_path}.")

if png_path.exists():
Expand Down
17 changes: 9 additions & 8 deletions map_machine/ui/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ def parse_arguments(args: list[str]) -> argparse.Namespace:
add_tile_arguments(tile_parser)
add_map_arguments(tile_parser)

add_server_arguments(
subparser.add_parser(
"server",
description="Run in order to display generated tiles as a map "
"(e.g. with Leaflet).",
help="run tile server",
)
)
server_parser = subparser.add_parser(
"server",
description="Run in order to display generated tiles as a map "
"(e.g. with Leaflet).",
help="run tile server",
)
add_server_arguments(server_parser)
add_map_arguments(server_parser)

add_draw_arguments(
subparser.add_parser(
"draw",
Expand Down