summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMike Morris <michael.patrick.morris@gmail.com>2014-07-10 16:29:49 -0700
committerMike Morris <michael.patrick.morris@gmail.com>2014-07-10 17:12:02 -0700
commit4590adc11571e3973998d7d27db52ca9d4d5b6e2 (patch)
treed2767fb2b1e4822962bd29fdb4c8ee03c70da155 /include
parent356c9ce7e40421bd81eb3415295caf39600d7a35 (diff)
downloadqtlocation-mapboxgl-4590adc11571e3973998d7d27db52ca9d4d5b6e2.tar.gz
break out StyleSource from Source, move getActiveSources and
updateSources into Map::Map, move getAccessToken from Style to Map Conflicts: include/llmr/style/style.hpp src/map/source.cpp src/style/style_layer.cpp src/style/style_parser.cpp
Diffstat (limited to 'include')
-rw-r--r--include/llmr/map/map.hpp6
-rw-r--r--include/llmr/map/source.hpp2
-rw-r--r--include/llmr/style/style.hpp13
-rw-r--r--include/llmr/style/style_bucket.hpp5
-rw-r--r--include/llmr/style/style_parser.hpp9
-rw-r--r--include/llmr/style/style_source.hpp27
6 files changed, 42 insertions, 20 deletions
diff --git a/include/llmr/map/map.hpp b/include/llmr/map/map.hpp
index defc1bef1f..a1c9842fbb 100644
--- a/include/llmr/map/map.hpp
+++ b/include/llmr/map/map.hpp
@@ -52,6 +52,7 @@ public:
void resize(uint16_t width, uint16_t height, float ratio, uint16_t fb_width, uint16_t fb_height);
// Styling
+ const std::set<std::shared_ptr<Source>> getActiveSources() const;
void setAppliedClasses(const std::vector<std::string> &classes);
void toggleClass(const std::string &name);
const std::vector<std::string> &getAppliedClasses() const;
@@ -123,6 +124,9 @@ private:
// Setup
void setup();
+ void updateSources();
+ void updateSources(const std::shared_ptr<StyleLayerGroup> &group);
+
void updateTiles();
void updateRenderState();
@@ -175,6 +179,8 @@ private:
int indent = 0;
+ std::set<std::shared_ptr<Source>> activeSources;
+
private:
bool async = false;
std::shared_ptr<uv::loop> loop;
diff --git a/include/llmr/map/source.hpp b/include/llmr/map/source.hpp
index f746249252..b8ffc27f52 100644
--- a/include/llmr/map/source.hpp
+++ b/include/llmr/map/source.hpp
@@ -5,6 +5,7 @@
#include <llmr/map/tile_data.hpp>
#include <llmr/util/noncopyable.hpp>
#include <llmr/util/time.hpp>
+#include <llmr/style/style_source.hpp>
#include <llmr/style/types.hpp>
#include <list>
@@ -22,6 +23,7 @@ class Texturepool;
class Source : public std::enable_shared_from_this<Source>, private util::noncopyable {
public:
+ Source(StyleSource style_source, const std::string &access_token = "");
Source(SourceType type = SourceType::Vector, const std::string &url = "",
uint32_t tile_size = 512, uint32_t min_zoom = 0, uint32_t max_zoom = 22,
const std::string &access_token = "");
diff --git a/include/llmr/style/style.hpp b/include/llmr/style/style.hpp
index cfaba1898c..cf091ad814 100644
--- a/include/llmr/style/style.hpp
+++ b/include/llmr/style/style.hpp
@@ -2,6 +2,7 @@
#define LLMR_STYLE_STYLE
#include <llmr/style/property_transition.hpp>
+#include <llmr/style/style_source.hpp>
#include <llmr/util/time.hpp>
#include <llmr/util/uv.hpp>
@@ -16,9 +17,7 @@
namespace llmr {
-class Map;
class Sprite;
-class Source;
class StyleLayer;
class StyleLayerGroup;
struct BackgroundProperties;
@@ -28,7 +27,7 @@ public:
struct exception : std::runtime_error { exception(const char *msg) : std::runtime_error(msg) {} };
public:
- Style(Map &map);
+ Style();
void loadJSON(const uint8_t *const data);
@@ -37,8 +36,6 @@ public:
void setDefaultTransitionDuration(uint16_t duration_milliseconds = 0);
- const std::set<std::shared_ptr<Source>> getActiveSources() const;
-
void setAppliedClasses(const std::vector<std::string> &classes);
const std::vector<std::string> &getAppliedClasses() const;
void toggleClass(const std::string &name);
@@ -58,14 +55,8 @@ public:
std::string sprite_url;
std::string glyph_url;
-private:
- void updateSources();
- void updateSources(const std::shared_ptr<StyleLayerGroup> &group);
-
private:
- Map &map;
- std::set<std::shared_ptr<Source>> activeSources;
PropertyTransition defaultTransition;
bool initial_render_complete = false;
diff --git a/include/llmr/style/style_bucket.hpp b/include/llmr/style/style_bucket.hpp
index 55ffeeb18e..c8529fdd23 100644
--- a/include/llmr/style/style_bucket.hpp
+++ b/include/llmr/style/style_bucket.hpp
@@ -3,6 +3,7 @@
#include <llmr/style/types.hpp>
#include <llmr/style/filter_expression.hpp>
+#include <llmr/style/style_source.hpp>
#include <llmr/util/vec.hpp>
#include <llmr/util/variant.hpp>
@@ -11,8 +12,6 @@
namespace llmr {
-class Source;
-
class StyleBucketFill {
public:
WindingType winding = WindingType::Default;
@@ -74,7 +73,7 @@ public:
StyleBucket(StyleLayerType type);
std::string name;
- std::shared_ptr<Source> source;
+ std::shared_ptr<StyleSource> style_source;
std::string source_layer;
FilterExpression filter;
StyleBucketRender render = std::false_type();
diff --git a/include/llmr/style/style_parser.hpp b/include/llmr/style/style_parser.hpp
index 27dfd47579..38ef343e53 100644
--- a/include/llmr/style/style_parser.hpp
+++ b/include/llmr/style/style_parser.hpp
@@ -3,7 +3,7 @@
#include <rapidjson/document.h>
#include <llmr/style/style.hpp>
-#include <llmr/map/source.hpp>
+#include <llmr/style/style_source.hpp>
#include <llmr/style/filter_expression.hpp>
#include <llmr/style/class_properties.hpp>
#include <llmr/style/rasterize_properties.hpp>
@@ -17,7 +17,6 @@ namespace llmr {
enum class ClassID : uint32_t;
-class Map;
class StyleLayer;
class StyleLayerGroup;
@@ -25,7 +24,7 @@ class StyleParser {
public:
using JSVal = const rapidjson::Value&;
- StyleParser(Map &map);
+ StyleParser();
void parse(JSVal document);
@@ -95,11 +94,9 @@ private:
std::forward_list<Value> parseValues(JSVal values);
private:
- Map &map;
-
std::unordered_map<std::string, const rapidjson::Value *> constants;
- std::unordered_map<std::string, const std::shared_ptr<Source>> sources;
+ std::unordered_map<std::string, const std::shared_ptr<StyleSource>> sources;
// This stores the root layer.
std::shared_ptr<StyleLayerGroup> root;
diff --git a/include/llmr/style/style_source.hpp b/include/llmr/style/style_source.hpp
new file mode 100644
index 0000000000..cf55e94be7
--- /dev/null
+++ b/include/llmr/style/style_source.hpp
@@ -0,0 +1,27 @@
+#ifndef LLMR_STYLE_STYLE_SOURCE
+#define LLMR_STYLE_STYLE_SOURCE
+
+#include <llmr/style/types.hpp>
+
+namespace llmr {
+
+struct StyleSource {
+ const SourceType type;
+ const std::string url;
+ const uint32_t tile_size;
+ const int32_t min_zoom;
+ const int32_t max_zoom;
+
+ StyleSource(SourceType type = SourceType::Vector,
+ const std::string &url = "",
+ uint32_t tile_size = 512, uint32_t min_zoom = 0,
+ uint32_t max_zoom = 22)
+ : type(type),
+ url(url),
+ tile_size(tile_size),
+ min_zoom(min_zoom),
+ max_zoom(max_zoom) {}
+ };
+};
+
+#endif