summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-08-11 16:17:15 +0300
committerKonstantin Käfer <mail@kkaefer.com>2015-08-11 16:40:40 +0300
commit5a79bd832da2c32f715870a653475dc96fea3f20 (patch)
tree9a41888f71980f3a4a0ae1af5d2e9ea569355705 /linux
parent21ec5056489f53601b3d45a0b1c79a85add42b0b (diff)
downloadqtlocation-mapboxgl-5a79bd832da2c32f715870a653475dc96fea3f20.tar.gz
allow setting a location and print the location on exit
Diffstat (limited to 'linux')
-rw-r--r--linux/main.cpp44
1 files changed, 40 insertions, 4 deletions
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;
}