Skip to content

Commit

Permalink
Add optional map mode argument to render (#3109)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkirov authored Dec 30, 2024
1 parent b7bf486 commit 8023e6d
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions bin/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ int main(int argc, char* argv[]) {
args::ValueFlag<uint32_t> widthValue(argumentParser, "pixels", "Image width", {'w', "width"});
args::ValueFlag<uint32_t> heightValue(argumentParser, "pixels", "Image height", {'h', "height"});

args::ValueFlag<std::string> mapModeValue(
argumentParser, "MapMode", "Map mode (e.g. 'static', 'tile', 'continuous')", {'m', "mode"});

try {
argumentParser.ParseCLI(argc, argv);
} catch (const args::Help&) {
Expand Down Expand Up @@ -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<float>(pixelRatio));
Map map(frontend,
MapObserver::nullObserver(),
MapOptions()
.withMapMode(MapMode::Static)
.withSize(frontend.getSize())
.withPixelRatio(static_cast<float>(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<float>(pixelRatio)),
ResourceOptions()
.withCachePath(cache_file)
.withAssetPath(asset_root)
.withApiKey(apikey)
.withTileServerOptions(mapTilerConfiguration));

if (style.find("://") == std::string::npos) {
style = std::string("file://") + style;
Expand Down

0 comments on commit 8023e6d

Please sign in to comment.