[core] *TileMonitor => *TileSource

This commit is contained in:
Konstantin Käfer
2016-05-19 15:34:08 +02:00
parent 6998479d05
commit e8d8f52d2e
21 changed files with 309 additions and 240 deletions

View File

@@ -220,28 +220,4 @@ std::string VectorTileLayer::getName() const {
return name;
}
VectorTileMonitor::VectorTileMonitor(const OverscaledTileID& tileID_, float pixelRatio_,
const std::string& urlTemplate_, FileSource& fileSource_)
: tileID(tileID_),
pixelRatio(pixelRatio_),
urlTemplate(urlTemplate_),
fileSource(fileSource_) {
}
std::unique_ptr<AsyncRequest> VectorTileMonitor::monitorTile(const GeometryTileMonitor::Callback& callback) {
const Resource resource = Resource::tile(urlTemplate, pixelRatio, tileID.canonical.x,
tileID.canonical.y, tileID.canonical.z);
return fileSource.request(resource, [callback, this](Response res) {
if (res.error) {
callback(std::make_exception_ptr(std::runtime_error(res.error->message)), nullptr, res.modified, res.expires);
} else if (res.notModified) {
return;
} else if (res.noContent) {
callback(nullptr, nullptr, res.modified, res.expires);
} else {
callback(nullptr, std::make_unique<VectorTile>(res.data), res.modified, res.expires);
}
});
}
} // namespace mbgl