From 4590adc11571e3973998d7d27db52ca9d4d5b6e2 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 10 Jul 2014 16:29:49 -0700 Subject: 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 --- include/llmr/map/map.hpp | 6 ++++++ include/llmr/map/source.hpp | 2 ++ include/llmr/style/style.hpp | 13 ++----------- include/llmr/style/style_bucket.hpp | 5 ++--- include/llmr/style/style_parser.hpp | 9 +++------ include/llmr/style/style_source.hpp | 27 +++++++++++++++++++++++++++ 6 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 include/llmr/style/style_source.hpp (limited to 'include') 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> getActiveSources() const; void setAppliedClasses(const std::vector &classes); void toggleClass(const std::string &name); const std::vector &getAppliedClasses() const; @@ -123,6 +124,9 @@ private: // Setup void setup(); + void updateSources(); + void updateSources(const std::shared_ptr &group); + void updateTiles(); void updateRenderState(); @@ -175,6 +179,8 @@ private: int indent = 0; + std::set> activeSources; + private: bool async = false; std::shared_ptr 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 #include #include +#include #include #include @@ -22,6 +23,7 @@ class Texturepool; class Source : public std::enable_shared_from_this, 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 +#include #include #include @@ -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> getActiveSources() const; - void setAppliedClasses(const std::vector &classes); const std::vector &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 &group); - private: - Map ↦ - std::set> 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 #include +#include #include #include @@ -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; + std::shared_ptr 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 #include -#include +#include #include #include #include @@ -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 parseValues(JSVal values); private: - Map ↦ - std::unordered_map constants; - std::unordered_map> sources; + std::unordered_map> sources; // This stores the root layer. std::shared_ptr 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 + +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 -- cgit v1.2.1