From 5a79bd832da2c32f715870a653475dc96fea3f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Tue, 11 Aug 2015 16:17:15 +0300 Subject: allow setting a location and print the location on exit --- linux/main.cpp | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'linux') diff --git a/linux/main.cpp b/linux/main.cpp index 0892ce8f1e..6bd2f7c430 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -34,11 +34,18 @@ int main(int argc, char *argv[]) { bool fullscreen = false; bool benchmark = false; std::string style; + double latitude = 0, longitude = 0; + double bearing = 0, zoom = 1; + bool skipConfig = false; const struct option long_options[] = { {"fullscreen", no_argument, 0, 'f'}, {"benchmark", no_argument, 0, 'b'}, {"style", required_argument, 0, 's'}, + {"lon", required_argument, 0, 'x'}, + {"lat", required_argument, 0, 'y'}, + {"zoom", required_argument, 0, 'z'}, + {"bearing", required_argument, 0, 'r'}, {0, 0, 0, 0} }; @@ -59,6 +66,23 @@ int main(int argc, char *argv[]) { break; case 's': style = std::string("asset://") + std::string(optarg); + break; + case 'x': + longitude = atof(optarg); + skipConfig = true; + break; + case 'y': + latitude = atof(optarg); + skipConfig = true; + break; + case 'z': + zoom = atof(optarg); + skipConfig = true; + break; + case 'r': + bearing = atof(optarg); + skipConfig = true; + break; default: break; } @@ -93,9 +117,16 @@ int main(int argc, char *argv[]) { // Load settings mbgl::Settings_JSON settings; - map.setLatLngZoom(mbgl::LatLng(settings.latitude, settings.longitude), settings.zoom); - map.setBearing(settings.bearing); - map.setDebug(settings.debug); + + if (skipConfig) { + map.setLatLngZoom(mbgl::LatLng(latitude, longitude), zoom); + map.setBearing(bearing); + mbgl::Log::Info(mbgl::Event::General, "Location: %f/%f (z%.2f, %.2f deg)", latitude, longitude, zoom, bearing); + } else { + map.setLatLngZoom(mbgl::LatLng(settings.latitude, settings.longitude), settings.zoom); + map.setBearing(settings.bearing); + map.setDebug(settings.debug); + } view->setChangeStyleCallback([&map] () { static uint8_t currentStyleIndex; @@ -129,7 +160,12 @@ int main(int argc, char *argv[]) { settings.zoom = map.getZoom(); settings.bearing = map.getBearing(); settings.debug = map.getDebug(); - settings.save(); + if (!skipConfig) { + settings.save(); + } + mbgl::Log::Info(mbgl::Event::General, + "Exit location: --lat=\"%f\" --lon=\"%f\" --zoom=\"%f\" --bearing \"%f\"", + settings.latitude, settings.longitude, settings.zoom, settings.bearing); return 0; } -- cgit v1.2.1