diff options
author | artemp <artem@mapnik.org> | 2014-11-03 16:00:40 +0000 |
---|---|---|
committer | artemp <artem@mapnik.org> | 2014-11-03 16:00:40 +0000 |
commit | 1e2c5f988e9e2a6cdd91d7d6644ffd17211cde25 (patch) | |
tree | 42811fc1672abd4fd7688dc49c40115af2b79fd7 /linux | |
parent | 92124d3aa1f53e40b174d82e29771bd292bc2001 (diff) | |
download | qtlocation-mapboxgl-1e2c5f988e9e2a6cdd91d7d6644ffd17211cde25.tar.gz |
add -s,--style command line option to specify path to the style
e.g ./build/Release/mapbox-gl -s ./styles/styles/bright-v5.json
Diffstat (limited to 'linux')
-rw-r--r-- | linux/main.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/linux/main.cpp b/linux/main.cpp index 10d5d45820..b28ad84d14 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -11,7 +11,6 @@ #include <sstream> - GLFWView *view = nullptr; void quit_handler(int) { @@ -28,16 +27,32 @@ int main(int argc, char *argv[]) { mbgl::Log::Set<mbgl::StderrLogBackend>(); int fullscreen_flag = 0; + std::string style; const struct option long_options[] = { - {"fullscreen", no_argument, &fullscreen_flag, 1}, + {"fullscreen", no_argument, &fullscreen_flag, 'f'}, + {"style", required_argument, 0, 's'}, {0, 0, 0, 0} }; while (true) { int option_index = 0; - int c = getopt_long(argc, argv, "f", long_options, &option_index); - if (c == -1) break; + int opt = getopt_long(argc, argv, "fs:", long_options, &option_index); + if (opt == -1) break; + switch (opt) + { + case 0: + if (long_options[option_index].flag != 0) + break; + case 'f': + // handle fullscreen_flag + break; + case 's': + style = std::string("file://") + std::string(optarg); + default: + break; + } + } // sigint handling @@ -65,7 +80,9 @@ int main(int argc, char *argv[]) { } // Load style - const std::string style = std::string("file://") + uv::cwd() + std::string("/../../styles/styles/bright-v5.json"); + if (style.empty()) + style = std::string("file://") + uv::cwd() + std::string("/../../styles/styles/bright-v5.json"); + map.setStyleURL(style); int ret = view->run(); |