[core] Use variant<std::string, Tileset> in TileSource
A tile source can either specify a URL to TileJSON, or inline TileJSON.
This commit is contained in:
@@ -4,15 +4,21 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
VectorSource::VectorSource(std::string id_,
|
||||
std::string url_,
|
||||
std::unique_ptr<Tileset>&& tileset_)
|
||||
: TileSource(SourceType::Vector, std::move(id_), std::move(url_), util::tileSize, std::move(tileset_)) {
|
||||
std::unique_ptr<VectorSource> VectorSource::parse(std::string id, const JSValue& value) {
|
||||
optional<variant<std::string, Tileset>> urlOrTileset = TileSource::parseURLOrTileset(value);
|
||||
if (!urlOrTileset) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_unique<VectorSource>(std::move(id), std::move(*urlOrTileset));
|
||||
}
|
||||
|
||||
VectorSource::VectorSource(std::string id_, variant<std::string, Tileset> urlOrTileset_)
|
||||
: TileSource(SourceType::Vector, std::move(id_), std::move(urlOrTileset_), util::tileSize) {
|
||||
}
|
||||
|
||||
std::unique_ptr<Tile> VectorSource::createTile(const OverscaledTileID& tileID,
|
||||
const UpdateParameters& parameters) {
|
||||
return std::make_unique<VectorTile>(tileID, id, parameters, *tileset);
|
||||
return std::make_unique<VectorTile>(tileID, id, parameters, tileset);
|
||||
}
|
||||
|
||||
} // namespace style
|
||||
|
||||
Reference in New Issue
Block a user