diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-14 10:57:43 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-14 11:25:45 -0700 |
commit | 5bbcca832660f80c42e8bfdb5d1836ea8113bb19 (patch) | |
tree | 08f46011d920f7abd4c86e16f2040df2355cfdb1 /src/mbgl/style | |
parent | 9d3c4fbbb05d37802ebc15210b041392b4d48f15 (diff) | |
download | qtlocation-mapboxgl-5bbcca832660f80c42e8bfdb5d1836ea8113bb19.tar.gz |
[core] Add virtual Source::getTileSize()
Diffstat (limited to 'src/mbgl/style')
-rw-r--r-- | src/mbgl/style/source.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/style/source.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/style/tile_source.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/style/tile_source.hpp | 2 |
6 files changed, 10 insertions, 6 deletions
diff --git a/src/mbgl/style/source.cpp b/src/mbgl/style/source.cpp index 21fb7fee36..ca0943918b 100644 --- a/src/mbgl/style/source.cpp +++ b/src/mbgl/style/source.cpp @@ -32,10 +32,9 @@ namespace style { static SourceObserver nullObserver; -Source::Source(SourceType type_, std::string id_, uint16_t tileSize_) +Source::Source(SourceType type_, std::string id_) : type(type_), id(std::move(id_)), - tileSize(tileSize_), observer(&nullObserver) { } @@ -94,6 +93,7 @@ bool Source::update(const UpdateParameters& parameters) { return allTilesUpdated; } + const uint16_t tileSize = getTileSize(); const Range<uint8_t> zoomRange = getZoomRange(); // Determine the overzooming/underzooming amounts and required tiles. diff --git a/src/mbgl/style/source.hpp b/src/mbgl/style/source.hpp index 99d634a887..575297e326 100644 --- a/src/mbgl/style/source.hpp +++ b/src/mbgl/style/source.hpp @@ -32,7 +32,7 @@ class SourceObserver; class Source : public TileObserver, private util::noncopyable { public: - Source(SourceType, std::string id, uint16_t tileSize); + Source(SourceType, std::string id); ~Source() override; bool loaded = false; @@ -68,7 +68,6 @@ public: const SourceType type; const std::string id; - uint16_t tileSize = util::tileSize; bool enabled = false; private: @@ -77,6 +76,7 @@ private: void onTileError(Tile&, std::exception_ptr) override; void onNeedsRepaint() override; + virtual uint16_t getTileSize() const = 0; virtual Range<uint8_t> getZoomRange() = 0; virtual std::unique_ptr<Tile> createTile(const OverscaledTileID&, const UpdateParameters&) = 0; diff --git a/src/mbgl/style/sources/geojson_source.cpp b/src/mbgl/style/sources/geojson_source.cpp index 7daf148291..01089f2eec 100644 --- a/src/mbgl/style/sources/geojson_source.cpp +++ b/src/mbgl/style/sources/geojson_source.cpp @@ -63,7 +63,7 @@ std::unique_ptr<GeoJSONSource> GeoJSONSource::parse(const std::string& id, GeoJSONSource::GeoJSONSource(std::string id_, std::string url_, std::unique_ptr<mapbox::geojsonvt::GeoJSONVT>&& geojsonvt_) - : Source(SourceType::GeoJSON, std::move(id_), util::tileSize), + : Source(SourceType::GeoJSON, std::move(id_)), url(url_), geojsonvt(std::move(geojsonvt_)) { } diff --git a/src/mbgl/style/sources/geojson_source.hpp b/src/mbgl/style/sources/geojson_source.hpp index 996dac3aca..00d245c878 100644 --- a/src/mbgl/style/sources/geojson_source.hpp +++ b/src/mbgl/style/sources/geojson_source.hpp @@ -31,6 +31,7 @@ public: const std::string& getURL() const { return url; } private: + uint16_t getTileSize() const final { return util::tileSize; } Range<uint8_t> getZoomRange() final; std::unique_ptr<Tile> createTile(const OverscaledTileID&, const UpdateParameters&) final; diff --git a/src/mbgl/style/tile_source.cpp b/src/mbgl/style/tile_source.cpp index 29cbcc7226..a4deb17c4f 100644 --- a/src/mbgl/style/tile_source.cpp +++ b/src/mbgl/style/tile_source.cpp @@ -12,7 +12,8 @@ TileSource::TileSource(SourceType type_, std::string url_, uint16_t tileSize_, std::unique_ptr<Tileset>&& tileset_) - : Source(type_, std::move(id_), tileSize_), + : Source(type_, std::move(id_)), + tileSize(tileSize_), url(std::move(url_)), tileset(std::move(tileset_)) { } diff --git a/src/mbgl/style/tile_source.hpp b/src/mbgl/style/tile_source.hpp index b001d174f6..bc97713a04 100644 --- a/src/mbgl/style/tile_source.hpp +++ b/src/mbgl/style/tile_source.hpp @@ -25,11 +25,13 @@ public: void load(FileSource&) final; const std::string& getURL() const { return url; } + uint16_t getTileSize() const final { return tileSize; } const Tileset* getTileset() const { return tileset.get(); } protected: Range<uint8_t> getZoomRange() final; + const uint16_t tileSize; const std::string url; std::unique_ptr<const Tileset> tileset; std::unique_ptr<AsyncRequest> req; |