add bounds to rendering cli (#3435)

This commit is contained in:
Michael Schmitz
2025-06-24 19:12:11 +02:00
committed by GitHub
parent 8a5d5a5287
commit db6fb9134c

View File

@@ -29,10 +29,17 @@ int main(int argc, char* argv[]) {
args::ValueFlag<double> pixelRatioValue(argumentParser, "number", "Image scale factor", {'r', "ratio"}); args::ValueFlag<double> pixelRatioValue(argumentParser, "number", "Image scale factor", {'r', "ratio"});
args::ValueFlag<double> zoomValue(argumentParser, "number", "Zoom level", {'z', "zoom"}); // grouping ensures either bounds or center based position is used
args::Group boundsOrCenterZoom(argumentParser, "Position (either one):", args::Group::Validators::AtMostOne);
args::NargsValueFlag<double> boundsValue(
boundsOrCenterZoom, "degrees: north west south east", "Bounds of rendered map", {"bounds"}, 4);
args::Group centerGroup(boundsOrCenterZoom, "Center:", args::Group::Validators::AtLeastOne);
args::ValueFlag<double> zoomValue(centerGroup, "number", "Zoom level", {'z', "zoom"});
args::ValueFlag<double> lonValue(centerGroup, "degrees", "Longitude", {'x', "lon"});
args::ValueFlag<double> latValue(centerGroup, "degrees", "Latitude", {'y', "lat"});
args::ValueFlag<double> lonValue(argumentParser, "degrees", "Longitude", {'x', "lon"});
args::ValueFlag<double> latValue(argumentParser, "degrees", "Latitude", {'y', "lat"});
args::ValueFlag<double> bearingValue(argumentParser, "degrees", "Bearing", {'b', "bearing"}); args::ValueFlag<double> bearingValue(argumentParser, "degrees", "Bearing", {'b', "bearing"});
args::ValueFlag<double> pitchValue(argumentParser, "degrees", "Pitch", {'p', "pitch"}); args::ValueFlag<double> pitchValue(argumentParser, "degrees", "Pitch", {'p', "pitch"});
args::ValueFlag<uint32_t> widthValue(argumentParser, "pixels", "Image width", {'w', "width"}); args::ValueFlag<uint32_t> widthValue(argumentParser, "pixels", "Image width", {'w', "width"});
@@ -108,7 +115,13 @@ int main(int argc, char* argv[]) {
} }
map.getStyle().loadURL(style); map.getStyle().loadURL(style);
map.jumpTo(CameraOptions().withCenter(LatLng{lat, lon}).withZoom(zoom).withBearing(bearing).withPitch(pitch)); std::vector<double> bounds = args::get(boundsValue);
if (bounds.size() == 4) {
LatLngBounds boundingBox = LatLngBounds::hull(LatLng(bounds[0], bounds[1]), LatLng(bounds[2], bounds[3]));
map.jumpTo(map.cameraForLatLngBounds(boundingBox, EdgeInsets(), bearing, pitch));
} else {
map.jumpTo(CameraOptions().withCenter(LatLng{lat, lon}).withZoom(zoom).withBearing(bearing).withPitch(pitch));
}
if (debug) { if (debug) {
map.setDebug(debug ? mbgl::MapDebugOptions::TileBorders | mbgl::MapDebugOptions::ParseStatus map.setDebug(debug ? mbgl::MapDebugOptions::TileBorders | mbgl::MapDebugOptions::ParseStatus