Fix platform linux (#133)
* minimal changes to get platform linux to compile again * adapt mbgl-glfw api for keyss to mbgl-offline and mbgl-render, use maptiler configuration for all three binaries
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
#include <mbgl/map/map_options.hpp>
|
||||
#include <mbgl/util/image.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
#include <mbgl/util/default_styles.hpp>
|
||||
|
||||
#include <mbgl/gfx/backend.hpp>
|
||||
#include <mbgl/gfx/headless_frontend.hpp>
|
||||
@@ -53,7 +52,6 @@ int main(int argc, char *argv[]) {
|
||||
exit(2);
|
||||
}
|
||||
|
||||
std::string style = styleValue ? args::get(styleValue) : mbgl::util::default_styles::streets.url;
|
||||
const double lat = latValue ? args::get(latValue) : 0;
|
||||
const double lon = lonValue ? args::get(lonValue) : 0;
|
||||
const double zoom = zoomValue ? args::get(zoomValue) : 0;
|
||||
@@ -75,12 +73,15 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
auto mapTilerConfiguration = mbgl::TileServerOptions::MapTilerConfiguration();
|
||||
std::string style = styleValue ? args::get(styleValue) : mapTilerConfiguration.defaultStyles().at(0).getUrl();
|
||||
|
||||
util::RunLoop loop;
|
||||
|
||||
HeadlessFrontend frontend({ width, height }, pixelRatio);
|
||||
Map map(frontend, MapObserver::nullObserver(),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()).withPixelRatio(pixelRatio),
|
||||
ResourceOptions().withCachePath(cache_file).withAssetPath(asset_root).withApiKey(std::string(apikey)));
|
||||
ResourceOptions().withCachePath(cache_file).withAssetPath(asset_root).withApiKey(apikey).withTileServerOptions(mapTilerConfiguration));
|
||||
|
||||
if (style.find("://") == std::string::npos) {
|
||||
style = std::string("file://") + style;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <mbgl/storage/http_file_source.hpp>
|
||||
#include <mbgl/storage/file_source_impl_base.hpp>
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
#include <mbgl/storage/resource.hpp>
|
||||
#include <mbgl/storage/response.hpp>
|
||||
@@ -233,14 +232,14 @@ int HTTPFileSource::Impl::startTimeout(CURLM * /* multi */, long timeout_ms, voi
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HTTPFileSource::setResourceOptions(ResourceOptions options) {
|
||||
void HTTPFileSource::Impl::setResourceOptions(ResourceOptions options) {
|
||||
std::lock_guard<std::mutex> lock(resourceOptionsMutex);
|
||||
resourceOptions = options;
|
||||
}
|
||||
|
||||
ResourceOptions& HTTPFileSource::getResourceOptions() {
|
||||
ResourceOptions HTTPFileSource::Impl::getResourceOptions() {
|
||||
std::lock_guard<std::mutex> lock(resourceOptionsMutex);
|
||||
return resourceOptions;
|
||||
return resourceOptions.clone();
|
||||
}
|
||||
|
||||
HTTPRequest::HTTPRequest(HTTPFileSource::Impl* context_, Resource resource_, FileSource::Callback callback_)
|
||||
@@ -439,7 +438,7 @@ void HTTPFileSource::setResourceOptions(ResourceOptions options) {
|
||||
impl->setResourceOptions(options.clone());
|
||||
}
|
||||
|
||||
ResourceOptions& HTTPFileSource::getResourceOptions() {
|
||||
ResourceOptions HTTPFileSource::getResourceOptions() {
|
||||
return impl->getResourceOptions();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <mbgl/storage/database_file_source.hpp>
|
||||
#include <mbgl/storage/file_source_manager.hpp>
|
||||
#include <mbgl/style/style.hpp>
|
||||
#include <mbgl/util/default_styles.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <mbgl/util/platform.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
@@ -47,6 +46,7 @@ int main(int argc, char *argv[]) {
|
||||
args::ValueFlag<std::string> testDirValue(
|
||||
argumentParser, "directory", "Root directory for test generation", {"testDir"});
|
||||
args::ValueFlag<std::string> backendValue(argumentParser, "backend", "Rendering backend", {"backend"});
|
||||
args::ValueFlag<std::string> apikeyValue(argumentParser, "key", "API key", {'t', "apikey"});
|
||||
args::ValueFlag<std::string> styleValue(argumentParser, "URL", "Map stylesheet", {'s', "style"});
|
||||
args::ValueFlag<std::string> cacheDBValue(argumentParser, "file", "Cache database file name", {'c', "cache"});
|
||||
args::ValueFlag<double> lonValue(argumentParser, "degrees", "Longitude", {'x', "lon"});
|
||||
@@ -96,13 +96,13 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
// Set access token if present
|
||||
std::string token(getenv("MAPBOX_ACCESS_TOKEN") ?: "");
|
||||
if (token.empty()) {
|
||||
mbgl::Log::Warning(mbgl::Event::Setup, "no access token set. mapbox.com tiles won't work.");
|
||||
}
|
||||
const char* apikeyEnv = getenv("MGL_API_KEY");
|
||||
const std::string apikey = apikeyValue ? args::get(apikeyValue) : (apikeyEnv ? apikeyEnv : std::string());
|
||||
|
||||
auto mapTilerConfiguration = mbgl::TileServerOptions::MapTilerConfiguration();
|
||||
mbgl::ResourceOptions resourceOptions;
|
||||
resourceOptions.withCachePath(cacheDB).withApiKey(token);
|
||||
resourceOptions.withCachePath(cacheDB).withApiKey(apikey).withTileServerOptions(mapTilerConfiguration);
|
||||
auto orderedStyles = mapTilerConfiguration.defaultStyles();
|
||||
|
||||
GLFWView backend(fullscreen, benchmark, resourceOptions);
|
||||
view = &backend;
|
||||
@@ -150,18 +150,18 @@ int main(int argc, char *argv[]) {
|
||||
mbgl::Log::Info(mbgl::Event::Setup, "Application is %s. Press `O` to toggle online status.", settings.online ? "online" : "offline");
|
||||
});
|
||||
|
||||
view->setChangeStyleCallback([&map] () {
|
||||
view->setChangeStyleCallback([&map,&orderedStyles] () {
|
||||
static uint8_t currentStyleIndex;
|
||||
|
||||
if (++currentStyleIndex == mbgl::util::default_styles::numOrderedStyles) {
|
||||
if (++currentStyleIndex == orderedStyles.size()) {
|
||||
currentStyleIndex = 0;
|
||||
}
|
||||
|
||||
mbgl::util::default_styles::DefaultStyle newStyle = mbgl::util::default_styles::orderedStyles[currentStyleIndex];
|
||||
map.getStyle().loadURL(newStyle.url);
|
||||
view->setWindowTitle(newStyle.name);
|
||||
mbgl::util::DefaultStyle newStyle = orderedStyles[currentStyleIndex];
|
||||
map.getStyle().loadURL(newStyle.getUrl());
|
||||
view->setWindowTitle(newStyle.getName());
|
||||
|
||||
mbgl::Log::Info(mbgl::Event::Setup, "Changed style to: %s", newStyle.name);
|
||||
mbgl::Log::Info(mbgl::Event::Setup, "Changed style to: %s", newStyle.getName().c_str());
|
||||
});
|
||||
|
||||
// Resource loader controls top-level request processing and can resume / pause all managed sources simultaneously.
|
||||
@@ -194,9 +194,9 @@ int main(int argc, char *argv[]) {
|
||||
if (style.empty()) {
|
||||
const char *url = getenv("MAPBOX_STYLE_URL");
|
||||
if (url == nullptr) {
|
||||
mbgl::util::default_styles::DefaultStyle newStyle = mbgl::util::default_styles::orderedStyles[0];
|
||||
style = newStyle.url;
|
||||
view->setWindowTitle(newStyle.name);
|
||||
mbgl::util::DefaultStyle newStyle = orderedStyles[0];
|
||||
style = newStyle.getUrl();
|
||||
view->setWindowTitle(newStyle.getName());
|
||||
} else {
|
||||
style = url;
|
||||
view->setWindowTitle(url);
|
||||
|
||||
@@ -79,8 +79,8 @@ void ProxyFileSource::setResourceOptions(ResourceOptions options) {
|
||||
resourceOptions = options;
|
||||
}
|
||||
|
||||
ResourceOptions& ProxyFileSource::getResourceOptions() {
|
||||
return resourceOptions;
|
||||
ResourceOptions ProxyFileSource::getResourceOptions() {
|
||||
return resourceOptions.clone();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user