add bounds to rendering cli (#3435)
This commit is contained in:
@@ -29,10 +29,17 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
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> pitchValue(argumentParser, "degrees", "Pitch", {'p', "pitch"});
|
||||
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.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) {
|
||||
map.setDebug(debug ? mbgl::MapDebugOptions::TileBorders | mbgl::MapDebugOptions::ParseStatus
|
||||
|
||||
Reference in New Issue
Block a user