From 8023e6dd3b8fe6cd149a1cf41ae51b13fe45bb39 Mon Sep 17 00:00:00 2001 From: Kiril Kirov Date: Sun, 29 Dec 2024 18:04:44 -0700 Subject: [PATCH] Add optional map mode argument to render (#3109) --- bin/render.cpp | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/bin/render.cpp b/bin/render.cpp index 26e1fa11ba0..6520f7baff1 100644 --- a/bin/render.cpp +++ b/bin/render.cpp @@ -38,6 +38,9 @@ int main(int argc, char* argv[]) { args::ValueFlag widthValue(argumentParser, "pixels", "Image width", {'w', "width"}); args::ValueFlag heightValue(argumentParser, "pixels", "Image height", {'h', "height"}); + args::ValueFlag mapModeValue( + argumentParser, "MapMode", "Map mode (e.g. 'static', 'tile', 'continuous')", {'m', "mode"}); + try { argumentParser.ParseCLI(argc, argv); } catch (const args::Help&) { @@ -79,18 +82,26 @@ int main(int argc, char* argv[]) { util::RunLoop loop; + MapMode mapMode = MapMode::Static; + if (mapModeValue) { + const auto modeStr = args::get(mapModeValue); + if (modeStr == "tile") { + mapMode = MapMode::Tile; + } else if (modeStr == "continuous") { + mapMode = MapMode::Continuous; + } + } + HeadlessFrontend frontend({width, height}, static_cast(pixelRatio)); - Map map(frontend, - MapObserver::nullObserver(), - MapOptions() - .withMapMode(MapMode::Static) - .withSize(frontend.getSize()) - .withPixelRatio(static_cast(pixelRatio)), - ResourceOptions() - .withCachePath(cache_file) - .withAssetPath(asset_root) - .withApiKey(apikey) - .withTileServerOptions(mapTilerConfiguration)); + Map map( + frontend, + MapObserver::nullObserver(), + MapOptions().withMapMode(mapMode).withSize(frontend.getSize()).withPixelRatio(static_cast(pixelRatio)), + ResourceOptions() + .withCachePath(cache_file) + .withAssetPath(asset_root) + .withApiKey(apikey) + .withTileServerOptions(mapTilerConfiguration)); if (style.find("://") == std::string::npos) { style = std::string("file://") + style;