diff options
author | Mike Morris <michael.patrick.morris@gmail.com> | 2014-08-25 16:13:24 -0400 |
---|---|---|
committer | Mike Morris <michael.patrick.morris@gmail.com> | 2014-08-25 16:13:24 -0400 |
commit | 7ae3b8e8ee5f59481fb8373df1d17d25cccce2f0 (patch) | |
tree | 4fd36aa34fc9f5f3096cb60a6eb4c083fced9d43 /include | |
parent | 3466f364121b3a0a157ce62c417c94802484351a (diff) | |
parent | 3d9a2932584b1230c8be47e6935f794cede8fe85 (diff) | |
download | qtlocation-mapboxgl-7ae3b8e8ee5f59481fb8373df1d17d25cccce2f0.tar.gz |
Merge branch 'master' into libuv010
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/geometry/interpolate.hpp | 13 | ||||
-rw-r--r-- | include/mbgl/geometry/resample.hpp | 13 | ||||
-rw-r--r-- | include/mbgl/map/source.hpp | 13 | ||||
-rw-r--r-- | include/mbgl/map/sprite.hpp | 4 | ||||
-rw-r--r-- | include/mbgl/map/tile_data.hpp | 3 | ||||
-rw-r--r-- | include/mbgl/style/style_layer.hpp | 1 | ||||
-rw-r--r-- | include/mbgl/style/style_source.hpp | 33 | ||||
-rw-r--r-- | include/mbgl/util/interpolate.hpp | 25 | ||||
-rw-r--r-- | include/mbgl/util/mapbox.hpp | 17 | ||||
-rw-r--r-- | include/mbgl/util/math.hpp | 5 | ||||
-rw-r--r-- | include/mbgl/util/transition.hpp | 6 | ||||
-rw-r--r-- | include/mbgl/util/url.hpp | 14 |
12 files changed, 99 insertions, 48 deletions
diff --git a/include/mbgl/geometry/interpolate.hpp b/include/mbgl/geometry/interpolate.hpp deleted file mode 100644 index 998cba31cd..0000000000 --- a/include/mbgl/geometry/interpolate.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef MBGL_GEOMETRY_INTERPOLATE -#define MBGL_GEOMETRY_INTERPOLATE - -#include <mbgl/geometry/anchor.hpp> -#include <mbgl/util/math.hpp> - -namespace mbgl { - -Anchors interpolate(const std::vector<Coordinate> &vertices, float spacing, - float minScale, float maxScale, float tilePixelRatio, int start = 0); -} - -#endif diff --git a/include/mbgl/geometry/resample.hpp b/include/mbgl/geometry/resample.hpp new file mode 100644 index 0000000000..bcfe4ca53d --- /dev/null +++ b/include/mbgl/geometry/resample.hpp @@ -0,0 +1,13 @@ +#ifndef MBGL_GEOMETRY_INTERPOLATE +#define MBGL_GEOMETRY_INTERPOLATE + +#include <mbgl/geometry/anchor.hpp> +#include <mbgl/util/math.hpp> + +namespace mbgl { + +Anchors resample(const std::vector<Coordinate> &vertices, float spacing, + float minScale, float maxScale, float tilePixelRatio, int start = 0); +} + +#endif diff --git a/include/mbgl/map/source.hpp b/include/mbgl/map/source.hpp index 4ffd097193..5b51268bfe 100644 --- a/include/mbgl/map/source.hpp +++ b/include/mbgl/map/source.hpp @@ -25,7 +25,9 @@ struct box; class Source : public std::enable_shared_from_this<Source>, private util::noncopyable { public: - Source(SourceInfo info, const std::string &access_token = ""); + Source(SourceInfo& info); + + void load(Map &map); bool update(Map &map); void updateMatrices(const mat4 &projMatrix, const TransformState &transform); @@ -38,11 +40,6 @@ public: std::forward_list<Tile::ID> getIDs() const; void updateClipIDs(const std::map<Tile::ID, ClipID> &mapping); - static std::string normalizeSourceURL(const std::string &url, const std::string &access_token); - -public: - const SourceInfo info; - private: bool findLoadedChildren(const Tile::ID& id, int32_t maxCoveringZoom, std::forward_list<Tile::ID>& retain); bool findLoadedParent(const Tile::ID& id, int32_t minCoveringZoom, std::forward_list<Tile::ID>& retain); @@ -55,7 +52,9 @@ private: double getZoom(const TransformState &state) const; -private: + SourceInfo& info; + bool loaded = false; + // Stores the time when this source was most recently updated. timestamp updated = 0; diff --git a/include/mbgl/map/sprite.hpp b/include/mbgl/map/sprite.hpp index 967f1d6614..7bc6665570 100644 --- a/include/mbgl/map/sprite.hpp +++ b/include/mbgl/map/sprite.hpp @@ -19,7 +19,7 @@ class FileSource; class SpritePosition { public: explicit SpritePosition() {} - explicit SpritePosition(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t pixelRatio = 1); + explicit SpritePosition(uint16_t x, uint16_t y, uint16_t width, uint16_t height, float pixelRatio = 1.0f); operator bool() const { return !(width == 0 && height == 0 && x == 0 && y == 0); @@ -27,7 +27,7 @@ public: uint16_t x = 0, y = 0; uint16_t width = 0, height = 0; - uint8_t pixelRatio = 1; + float pixelRatio = 1.0f; }; class Sprite : public std::enable_shared_from_this<Sprite>, private util::noncopyable { diff --git a/include/mbgl/map/tile_data.hpp b/include/mbgl/map/tile_data.hpp index 5991613a2d..3e639fcea1 100644 --- a/include/mbgl/map/tile_data.hpp +++ b/include/mbgl/map/tile_data.hpp @@ -67,9 +67,6 @@ protected: public: const SourceInfo &source; - // Request-related information. - const std::string url; - protected: std::weak_ptr<platform::Request> req; std::string data; diff --git a/include/mbgl/style/style_layer.hpp b/include/mbgl/style/style_layer.hpp index f8cfff7f63..84981e3fb4 100644 --- a/include/mbgl/style/style_layer.hpp +++ b/include/mbgl/style/style_layer.hpp @@ -51,6 +51,7 @@ private: // aplied classes in order. template <typename T> void applyStyleProperties(float z, timestamp now); template <typename T> void applyStyleProperty(PropertyKey key, T &, float z, timestamp now); + template <typename T> void applyTransitionedStyleProperty(PropertyKey key, T &, float z, timestamp now); // Removes all expired style transitions. void cleanupAppliedStyleProperties(timestamp now); diff --git a/include/mbgl/style/style_source.hpp b/include/mbgl/style/style_source.hpp index fa5c8dfb34..b598550c65 100644 --- a/include/mbgl/style/style_source.hpp +++ b/include/mbgl/style/style_source.hpp @@ -4,6 +4,10 @@ #include <mbgl/style/types.hpp> #include <memory> +#include <vector> +#include <string> + +#include <rapidjson/document.h> namespace mbgl { @@ -11,27 +15,32 @@ class Source; class SourceInfo { public: - const SourceType type; - const std::string url; - const uint32_t tile_size; - const int32_t min_zoom; - const int32_t max_zoom; - - SourceInfo(SourceType type = SourceType::Vector, const std::string &url = "", - uint32_t tile_size = 512, int32_t min_zoom = 0, int32_t max_zoom = 22) - : type(type), url(url), tile_size(tile_size), min_zoom(min_zoom), max_zoom(max_zoom) {} + SourceType type = SourceType::Vector; + std::string url; + std::vector<std::string> tiles; + uint16_t tile_size = 512; + uint16_t min_zoom = 0; + uint16_t max_zoom = 22; + std::string attribution; + std::array<float, 3> center = {{0, 0, 0}}; + std::array<float, 4> bounds = {{-180, -90, 180, 90}}; + + void parseTileJSONProperties(const rapidjson::Value&); }; -class StyleSource { +class StyleSource : public std::enable_shared_from_this<StyleSource> { public: - const SourceInfo info; + SourceInfo info; bool enabled = false; std::shared_ptr<Source> source; - StyleSource(const SourceInfo &info) : info(info) {} + StyleSource(const SourceInfo &info) + : info(info) + {} }; + } #endif diff --git a/include/mbgl/util/interpolate.hpp b/include/mbgl/util/interpolate.hpp new file mode 100644 index 0000000000..e8c3389350 --- /dev/null +++ b/include/mbgl/util/interpolate.hpp @@ -0,0 +1,25 @@ +#ifndef MBGL_UTIL_INTERPOLATE +#define MBGL_UTIL_INTERPOLATE + +namespace mbgl { +namespace util { + +template <typename T> +T interpolate(const T a, const T b, const double t) { + return a * (1.0 - t) + b * t; +} + +template <typename T> +inline std::array<T, 4> interpolate(const std::array<T, 4>& a, const std::array<T, 4>& b, const double t) { + return {{ + interpolate(a[0], b[0], t), + interpolate(a[1], b[1], t), + interpolate(a[2], b[2], t), + interpolate(a[3], b[3], t) + }}; +} + +} +} + +#endif diff --git a/include/mbgl/util/mapbox.hpp b/include/mbgl/util/mapbox.hpp new file mode 100644 index 0000000000..0fbb9a91ed --- /dev/null +++ b/include/mbgl/util/mapbox.hpp @@ -0,0 +1,17 @@ +#ifndef MBGL_UTIL_MAPBOX +#define MBGL_UTIL_MAPBOX + +#include <string> + +namespace mbgl { +namespace util { +namespace mapbox { + +std::string normalizeSourceURL(const std::string& url, const std::string& accessToken); +std::string normalizeGlyphsURL(const std::string& url, const std::string& accessToken); + +} +} +} + +#endif diff --git a/include/mbgl/util/math.hpp b/include/mbgl/util/math.hpp index 277fdc8fc3..fde2a4720b 100644 --- a/include/mbgl/util/math.hpp +++ b/include/mbgl/util/math.hpp @@ -57,11 +57,6 @@ inline T angle_to(const vec2<S>& a, const vec2<S>& b) { return std::atan2(a.y - b.y, a.x - b.x); } -template <typename T, typename S1, typename S2> -inline T interp(S1 a, S2 b, T t) { - return (a * ((T)1 - t)) + (b * t); -} - // Reflect an angle around 0 degrees template <typename T> inline std::array<T, 2> flip(const std::array<T, 2>& c) { diff --git a/include/mbgl/util/transition.hpp b/include/mbgl/util/transition.hpp index b12527124e..8a6836c885 100644 --- a/include/mbgl/util/transition.hpp +++ b/include/mbgl/util/transition.hpp @@ -30,12 +30,6 @@ public: virtual ~transition(); protected: - double interpolateDouble(double from, double to, double t) const; - float interpolateFloat(float from, float to, double t) const; - Color interpolateColor(Color from, Color to, double t) const; - std::array<float, 2> interpolateFloatArray(std::array<float, 2> from, std::array<float, 2> to, double t) const; - -protected: const timestamp start, duration; }; diff --git a/include/mbgl/util/url.hpp b/include/mbgl/util/url.hpp new file mode 100644 index 0000000000..14d9dd3160 --- /dev/null +++ b/include/mbgl/util/url.hpp @@ -0,0 +1,14 @@ +#ifndef MBGL_UTIL_URL +#define MBGL_UTIL_URL + +#include <string> + +namespace mbgl { +namespace util { + +std::string percentEncode(const std::string&); + +} +} + +#endif |