Add optional map mode argument to render (#3109)
This commit is contained in:
@@ -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&) {
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user