Load TileJSON; support inline TileJSON sources
Fixes #412 Refs https://github.com/mapbox/mapbox-gl-style-spec/pull/143
This commit is contained in:
committed by
John Firebaugh
parent
b9c7e1bdd9
commit
0168612ed3
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
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}};
|
||||
|
||||
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) {}
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user