summaryrefslogtreecommitdiff
path: root/src/mbgl/style/sources/vector_source.cpp
blob: 3f8f840b380d6ec9d36fc6283d3a54f5efb3c7b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <mbgl/style/sources/vector_source.hpp>
#include <mbgl/tile/vector_tile.hpp>

namespace mbgl {
namespace style {

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);
}

} // namespace style
} // namespace mbgl