unifiy constants in one place, and allow local override

This commit is contained in:
Konstantin Käfer
2014-06-04 11:22:03 +02:00
parent 580527a16c
commit af69b4fe39
8 changed files with 16 additions and 9 deletions

1
.gitignore vendored
View File

@@ -6,6 +6,7 @@
/ios/build
/config.gypi
/config.mk
/config/constants_local.cpp
/build
/bin/node_modules
/include/llmr/shader/shaders.hpp

View File

@@ -1,5 +1,9 @@
#include <llmr/util/constants.hpp>
const char *llmr::kSpriteURL = "http://mapbox-kkaefer.s3.amazonaws.com/static/outdoors-gl/sprite";
const char *llmr::kVectorTileURL = "http://a.tiles.mapbox.com/v3/mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5/%d/%d/%d.vector.pbf";
const char *llmr::kGlyphURL = "http://mapbox.s3.amazonaws.com/gl-glyphs-256/%s/%d-%d.pbf";
const float llmr::util::tileSize = 512.0f;
#if defined(DEBUG)
@@ -24,4 +28,4 @@ const bool llmr::debug::missingFontStackWarning = false;
const bool llmr::debug::missingFontFaceWarning = false;
const bool llmr::debug::glyphWarning = false;
const bool llmr::debug::shapingWarning = false;
#endif
#endif

View File

@@ -12,9 +12,6 @@ class loop;
}
namespace llmr {
extern const char *kSpriteURL;
namespace platform {
class Request;

View File

@@ -6,6 +6,11 @@
#include "vec.hpp"
namespace llmr {
extern const char *kSpriteURL;
extern const char *kVectorTileURL;
extern const char *kGlyphURL;
namespace util {
extern const float tileSize;

View File

@@ -65,6 +65,7 @@
],
'sources': [
'<!@(find src -name "*.cpp")',
'<!@(test -f "config/constants_local.cpp" && echo "config/constants_local.cpp" || echo "config/constants.cpp")',
'<!@(find src -name "*.c")',
'<!@(find src -name "*.h")',
'<!@(find include -name "*.hpp")',
@@ -131,6 +132,7 @@
],
'sources': [
'<!@(find src/ \( -name "*.cpp" ! -name shaders.hpp ! -name shaders_gles2.cpp ! -name shaders_gl.cpp \))',
'<!@(test -f "config/constants_local.cpp" && echo "config/constants_local.cpp" || echo "config/constants.cpp")',
'<!@(find src -name "*.c")',
'<!@(find src -name "*.h")',
'<!@(find include -name "*.hpp")',

View File

@@ -170,7 +170,7 @@ void Map::setup() {
sources.emplace("outdoors",
std::unique_ptr<Source>(new Source(*this,
painter,
"http://a.tiles.mapbox.com/v3/mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5/%d/%d/%d.vector.pbf",
kVectorTileURL,
Source::Type::vector,
{{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }},
512,

View File

@@ -1,3 +0,0 @@
#include <llmr/platform/platform.hpp>
const char *llmr::kSpriteURL = "http://mapbox-kkaefer.s3.amazonaws.com/static/outdoors-gl/sprite";

View File

@@ -4,6 +4,7 @@
#include <llmr/util/string.hpp>
#include <llmr/util/utf.hpp>
#include <llmr/util/pbf.hpp>
#include <llmr/util/constants.hpp>
#include <llmr/platform/platform.hpp>
#include <uv.h>
#include <algorithm>
@@ -118,7 +119,7 @@ GlyphPBF::GlyphPBF(const std::string &fontStack, GlyphRange glyphRange)
: future(promise.get_future().share())
{
// Load the glyph set URL
std::string url = util::sprintf<255>("http://mapbox.s3.amazonaws.com/gl-glyphs-256/%s/%d-%d.pbf", fontStack.c_str(), glyphRange.first, glyphRange.second);
std::string url = util::sprintf<255>(kGlyphURL, fontStack.c_str(), glyphRange.first, glyphRange.second);
// TODO: Find more reliable URL normalization function
std::replace(url.begin(), url.end(), ' ', '+');