summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-12-10 13:24:48 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-12-10 16:50:39 -0800
commit0ff9295ca890114ee962897593f9774711a813f0 (patch)
tree65addcc0864e200109804e5c3b2867b568a2578b /linux
parent93c000dd18f5896b6d0c5b3f1670c999489c2f12 (diff)
downloadqtlocation-mapboxgl-0ff9295ca890114ee962897593f9774711a813f0.tar.gz
[core] Move linux and osx to platform subdirectory
Diffstat (limited to 'linux')
-rw-r--r--linux/main.cpp178
-rw-r--r--linux/mapboxgl-app.gypi60
2 files changed, 0 insertions, 238 deletions
diff --git a/linux/main.cpp b/linux/main.cpp
deleted file mode 100644
index bb571a0093..0000000000
--- a/linux/main.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-#include <mbgl/mbgl.hpp>
-#include <mbgl/util/default_styles.hpp>
-#include <mbgl/platform/log.hpp>
-#include <mbgl/platform/platform.hpp>
-#include <mbgl/platform/default/settings_json.hpp>
-#include <mbgl/platform/default/glfw_view.hpp>
-#include <mbgl/storage/default_file_source.hpp>
-#include <mbgl/storage/sqlite_cache.hpp>
-
-#include <signal.h>
-#include <getopt.h>
-#include <fstream>
-#include <sstream>
-#include <cstdlib>
-#include <cstdio>
-
-namespace {
-
-std::unique_ptr<GLFWView> view;
-
-}
-
-void quit_handler(int) {
- if (view) {
- mbgl::Log::Info(mbgl::Event::Setup, "waiting for quit...");
- view->setShouldClose();
- } else {
- exit(0);
- }
-}
-
-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, pitch = 0;
- 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'},
- {"pitch", required_argument, 0, 'p'},
- {0, 0, 0, 0}
- };
-
- while (true) {
- int option_index = 0;
- int opt = getopt_long(argc, argv, "fbs:", long_options, &option_index);
- if (opt == -1) break;
- switch (opt)
- {
- case 0:
- if (long_options[option_index].flag != 0)
- break;
- case 'f':
- fullscreen = true;
- break;
- case 'b':
- benchmark = true;
- 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;
- case 'p':
- pitch = atof(optarg);
- skipConfig = true;
- break;
- default:
- break;
- }
-
- }
-
- // sigint handling
- struct sigaction sigIntHandler;
- sigIntHandler.sa_handler = quit_handler;
- sigemptyset(&sigIntHandler.sa_mask);
- sigIntHandler.sa_flags = 0;
- sigaction(SIGINT, &sigIntHandler, NULL);
-
- if (benchmark) {
- mbgl::Log::Info(mbgl::Event::General, "BENCHMARK MODE: Some optimizations are disabled.");
- }
-
- view = std::make_unique<GLFWView>(fullscreen, benchmark);
-
- mbgl::SQLiteCache cache("/tmp/mbgl-cache.db");
- mbgl::DefaultFileSource fileSource(&cache);
-
- // Set access token if present
- const char *token = getenv("MAPBOX_ACCESS_TOKEN");
- if (token == nullptr) {
- mbgl::Log::Warning(mbgl::Event::Setup, "no access token set. mapbox.com tiles won't work.");
- } else {
- fileSource.setAccessToken(std::string(token));
- }
-
- mbgl::Map map(*view, fileSource);
-
- // Load settings
- mbgl::Settings_JSON settings;
-
- if (skipConfig) {
- map.setLatLngZoom(mbgl::LatLng(latitude, longitude), zoom);
- map.setBearing(bearing);
- map.setPitch(pitch);
- 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.setPitch(settings.pitch);
- map.setDebug(mbgl::MapDebugOptions(settings.debug));
- }
-
- view->setChangeStyleCallback([&map] () {
- static uint8_t currentStyleIndex;
-
- if (++currentStyleIndex == mbgl::util::default_styles::numOrderedStyles) {
- currentStyleIndex = 0;
- }
-
- mbgl::util::default_styles::DefaultStyle newStyle = mbgl::util::default_styles::orderedStyles[currentStyleIndex];
- map.setStyleURL(newStyle.url);
- view->setWindowTitle(newStyle.name);
-
- mbgl::Log::Info(mbgl::Event::Setup, "Changed style to: %s", newStyle.name);
- });
-
- // Load style
- if (style.empty()) {
- mbgl::util::default_styles::DefaultStyle newStyle = mbgl::util::default_styles::orderedStyles[0];
- style = newStyle.url;
- view->setWindowTitle(newStyle.name);
- }
-
- map.setStyleURL(style);
-
- view->run();
-
- // Save settings
- mbgl::LatLng latLng = map.getLatLng();
- settings.latitude = latLng.latitude;
- settings.longitude = latLng.longitude;
- settings.zoom = map.getZoom();
- settings.bearing = map.getBearing();
- settings.pitch = map.getPitch();
- settings.debug = mbgl::EnumType(map.getDebug());
- 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;
-}
diff --git a/linux/mapboxgl-app.gypi b/linux/mapboxgl-app.gypi
deleted file mode 100644
index 0c9e03ce38..0000000000
--- a/linux/mapboxgl-app.gypi
+++ /dev/null
@@ -1,60 +0,0 @@
-{
- 'includes': [
- '../gyp/common.gypi',
- ],
- 'targets': [
- { 'target_name': 'linuxapp',
- 'product_name': 'mapbox-gl',
- 'type': 'executable',
-
- 'dependencies': [
- 'mbgl.gyp:core',
- 'mbgl.gyp:platform-<(platform_lib)',
- 'mbgl.gyp:http-<(http_lib)',
- 'mbgl.gyp:asset-<(asset_lib)',
- 'mbgl.gyp:cache-<(cache_lib)',
- 'mbgl.gyp:copy_certificate_bundle',
- ],
-
- 'sources': [
- 'main.cpp',
- '../platform/default/settings_json.cpp',
- '../platform/default/glfw_view.hpp',
- '../platform/default/glfw_view.cpp',
- '../platform/default/log_stderr.cpp',
- ],
-
- 'variables' : {
- 'cflags_cc': [
- '<@(opengl_cflags)',
- '<@(boost_cflags)',
- '<@(glfw_cflags)',
- '<@(variant_cflags)',
- ],
- 'ldflags': [
- '<@(glfw_ldflags)',
- ],
- 'libraries': [
- '<@(glfw_static_libs)',
- ],
- },
-
- 'conditions': [
- ['OS == "mac"', {
- 'libraries': [ '<@(libraries)' ],
- 'xcode_settings': {
- 'SDKROOT': 'macosx',
- 'SUPPORTED_PLATFORMS':'macosx',
- 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ],
- 'OTHER_LDFLAGS': [ '<@(ldflags)' ],
- 'SDKROOT': 'macosx',
- 'MACOSX_DEPLOYMENT_TARGET': '10.9',
- }
- }, {
- 'cflags_cc': [ '<@(cflags_cc)' ],
- 'libraries': [ '<@(libraries)', '<@(ldflags)' ],
- }]
- ],
- },
- ],
-}