summaryrefslogtreecommitdiff
path: root/src/mbgl/tile
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-05-19 17:19:45 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-06-10 12:42:14 +0200
commit6b729ccb4680e41fd6346aeb5a5e55027ca49052 (patch)
treed01d9e439e3991e4ae0fb14069bc708ac59bdb13 /src/mbgl/tile
parent46b0ebcd3cad1a33a2a70c6e93b885d3be6be9fa (diff)
downloadqtlocation-mapboxgl-6b729ccb4680e41fd6346aeb5a5e55027ca49052.tar.gz
[core] store Resource instead of dependents to build URL
Diffstat (limited to 'src/mbgl/tile')
-rw-r--r--src/mbgl/tile/raster_tile_source.cpp12
-rw-r--r--src/mbgl/tile/raster_tile_source.hpp10
-rw-r--r--src/mbgl/tile/vector_tile_source.cpp12
-rw-r--r--src/mbgl/tile/vector_tile_source.hpp13
4 files changed, 14 insertions, 33 deletions
diff --git a/src/mbgl/tile/raster_tile_source.cpp b/src/mbgl/tile/raster_tile_source.cpp
index 7220ce214e..8d07bad07a 100644
--- a/src/mbgl/tile/raster_tile_source.cpp
+++ b/src/mbgl/tile/raster_tile_source.cpp
@@ -3,17 +3,11 @@
namespace mbgl {
-RasterTileSource::RasterTileSource(const OverscaledTileID& tileID_,
- float pixelRatio_,
- const std::string& urlTemplate_,
- FileSource& fileSource_)
- : tileID(tileID_), pixelRatio(pixelRatio_), urlTemplate(urlTemplate_), fileSource(fileSource_) {
+RasterTileSource::RasterTileSource(const Resource& resource_, FileSource& fileSource_)
+ : resource(resource_), fileSource(fileSource_) {
}
-std::unique_ptr<AsyncRequest>
-RasterTileSource::monitorTile(const Callback& callback) {
- const Resource resource = Resource::tile(urlTemplate, pixelRatio, tileID.canonical.x,
- tileID.canonical.y, tileID.canonical.z);
+std::unique_ptr<AsyncRequest> RasterTileSource::monitorTile(const Callback& callback) {
return fileSource.request(resource, [callback, this](Response res) {
if (res.error) {
callback(std::make_exception_ptr(std::runtime_error(res.error->message)), nullptr,
diff --git a/src/mbgl/tile/raster_tile_source.hpp b/src/mbgl/tile/raster_tile_source.hpp
index fc7a18d1a7..800f31fefb 100644
--- a/src/mbgl/tile/raster_tile_source.hpp
+++ b/src/mbgl/tile/raster_tile_source.hpp
@@ -2,6 +2,7 @@
#include <mbgl/tile/tile_source.hpp>
#include <mbgl/tile/tile_id.hpp>
+#include <mbgl/storage/resource.hpp>
namespace mbgl {
@@ -9,10 +10,7 @@ class FileSource;
class RasterTileSource : public TileSource {
public:
- RasterTileSource(const OverscaledTileID&,
- float pixelRatio,
- const std::string& urlTemplate,
- FileSource&);
+ RasterTileSource(const Resource&, FileSource&);
virtual ~RasterTileSource() = default;
using Callback = std::function<void(std::exception_ptr,
@@ -31,9 +29,7 @@ public:
std::unique_ptr<AsyncRequest> monitorTile(const Callback&);
private:
- OverscaledTileID tileID;
- float pixelRatio;
- std::string urlTemplate;
+ const Resource resource;
FileSource& fileSource;
};
diff --git a/src/mbgl/tile/vector_tile_source.cpp b/src/mbgl/tile/vector_tile_source.cpp
index 9563fb7bee..cfff47f598 100644
--- a/src/mbgl/tile/vector_tile_source.cpp
+++ b/src/mbgl/tile/vector_tile_source.cpp
@@ -4,17 +4,11 @@
namespace mbgl {
-VectorTileSource::VectorTileSource(const OverscaledTileID& tileID_,
- float pixelRatio_,
- const std::string& urlTemplate_,
- FileSource& fileSource_)
- : tileID(tileID_), pixelRatio(pixelRatio_), urlTemplate(urlTemplate_), fileSource(fileSource_) {
+VectorTileSource::VectorTileSource(const Resource& resource_, FileSource& fileSource_)
+ : resource(resource_), fileSource(fileSource_) {
}
-std::unique_ptr<AsyncRequest>
-VectorTileSource::monitorTile(const GeometryTileSource::Callback& callback) {
- const Resource resource = Resource::tile(urlTemplate, pixelRatio, tileID.canonical.x,
- tileID.canonical.y, tileID.canonical.z);
+std::unique_ptr<AsyncRequest> VectorTileSource::monitorTile(const Callback& callback) {
return fileSource.request(resource, [callback, this](Response res) {
if (res.error) {
callback(std::make_exception_ptr(std::runtime_error(res.error->message)), nullptr,
diff --git a/src/mbgl/tile/vector_tile_source.hpp b/src/mbgl/tile/vector_tile_source.hpp
index 03b6be6c79..32f45a1a23 100644
--- a/src/mbgl/tile/vector_tile_source.hpp
+++ b/src/mbgl/tile/vector_tile_source.hpp
@@ -2,6 +2,7 @@
#include <mbgl/tile/tile_source.hpp>
#include <mbgl/tile/tile_id.hpp>
+#include <mbgl/storage/resource.hpp>
namespace mbgl {
@@ -9,17 +10,13 @@ class FileSource;
class VectorTileSource : public GeometryTileSource {
public:
- VectorTileSource(const OverscaledTileID&,
- float pixelRatio,
- const std::string& urlTemplate,
- FileSource&);
+ VectorTileSource(const Resource&, FileSource&);
+ virtual ~VectorTileSource() = default;
- std::unique_ptr<AsyncRequest> monitorTile(const GeometryTileSource::Callback&) override;
+ std::unique_ptr<AsyncRequest> monitorTile(const Callback&) override;
private:
- OverscaledTileID tileID;
- float pixelRatio;
- std::string urlTemplate;
+ const Resource resource;
FileSource& fileSource;
};