diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-14 16:07:21 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-16 13:27:15 -0700 |
commit | 900568cfb0b84a298395f4d84488fd9323552c63 (patch) | |
tree | e2c315656ca57a07ba48e38df5743fb05debb115 /src/mbgl/style/tile_source_impl.hpp | |
parent | 19158d9f01909bf566616524f23e0acb635562f7 (diff) | |
download | qtlocation-mapboxgl-900568cfb0b84a298395f4d84488fd9323552c63.tar.gz |
[core] Runtime source API: private impls
Diffstat (limited to 'src/mbgl/style/tile_source_impl.hpp')
-rw-r--r-- | src/mbgl/style/tile_source_impl.hpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/mbgl/style/tile_source_impl.hpp b/src/mbgl/style/tile_source_impl.hpp new file mode 100644 index 0000000000..1ceb1188db --- /dev/null +++ b/src/mbgl/style/tile_source_impl.hpp @@ -0,0 +1,51 @@ +#pragma once + +#include <mbgl/style/source_impl.hpp> +#include <mbgl/util/tileset.hpp> +#include <mbgl/util/variant.hpp> +#include <mbgl/util/optional.hpp> +#include <mbgl/util/rapidjson.hpp> + +namespace mbgl { + +class AsyncRequest; + +namespace style { + +/* + Shared implementation for VectorSource and RasterSource. Should eventually + be refactored to use composition rather than inheritance. +*/ +class TileSourceImpl : public Source::Impl { +public: + // A tile source can either specify a URL to TileJSON, or inline TileJSON. + static optional<variant<std::string, Tileset>> parseURLOrTileset(const JSValue&); + static Tileset parseTileJSON(const std::string& json, const std::string& sourceURL, SourceType, uint16_t tileSize); + + TileSourceImpl(SourceType, std::string id, Source&, + variant<std::string, Tileset> urlOrTileset, + uint16_t tileSize); + ~TileSourceImpl() override; + + void load(FileSource&) final; + + uint16_t getTileSize() const final { + return tileSize; + } + + const variant<std::string, Tileset>& getURLOrTileset() const { + return urlOrTileset; + } + +protected: + Range<uint8_t> getZoomRange() final; + + const variant<std::string, Tileset> urlOrTileset; + const uint16_t tileSize; + + Tileset tileset; + std::unique_ptr<AsyncRequest> req; +}; + +} // namespace style +} // namespace mbgl |