diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-14 16:07:21 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-16 13:27:15 -0700 |
commit | 900568cfb0b84a298395f4d84488fd9323552c63 (patch) | |
tree | e2c315656ca57a07ba48e38df5743fb05debb115 /src/mbgl/style/sources/raster_source_impl.cpp | |
parent | 19158d9f01909bf566616524f23e0acb635562f7 (diff) | |
download | qtlocation-mapboxgl-900568cfb0b84a298395f4d84488fd9323552c63.tar.gz |
[core] Runtime source API: private impls
Diffstat (limited to 'src/mbgl/style/sources/raster_source_impl.cpp')
-rw-r--r-- | src/mbgl/style/sources/raster_source_impl.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/mbgl/style/sources/raster_source_impl.cpp b/src/mbgl/style/sources/raster_source_impl.cpp new file mode 100644 index 0000000000..a6e19b4757 --- /dev/null +++ b/src/mbgl/style/sources/raster_source_impl.cpp @@ -0,0 +1,40 @@ +#include <mbgl/style/sources/raster_source_impl.hpp> +#include <mbgl/tile/raster_tile.hpp> +#include <mbgl/platform/log.hpp> + +namespace mbgl { +namespace style { + +std::unique_ptr<RasterSource> RasterSource::Impl::parse(std::string id, const JSValue& value) { + optional<variant<std::string, Tileset>> urlOrTileset = TileSourceImpl::parseURLOrTileset(value); + if (!urlOrTileset) { + return nullptr; + } + + uint16_t tileSize = util::tileSize; + if (value.HasMember("tileSize")) { + const JSValue& tileSizeVal = value["tileSize"]; + if (tileSizeVal.IsNumber() && tileSizeVal.GetUint64() <= std::numeric_limits<uint16_t>::max()) { + tileSize = tileSizeVal.GetUint64(); + } else { + Log::Error(Event::ParseStyle, "invalid tileSize"); + return nullptr; + } + } + + return std::make_unique<RasterSource>(std::move(id), std::move(*urlOrTileset), tileSize); +} + +RasterSource::Impl::Impl(std::string id_, Source& base_, + variant<std::string, Tileset> urlOrTileset_, + uint16_t tileSize_) + : TileSourceImpl(SourceType::Raster, std::move(id_), base_, std::move(urlOrTileset_), tileSize_) { +} + +std::unique_ptr<Tile> RasterSource::Impl::createTile(const OverscaledTileID& tileID, + const UpdateParameters& parameters) { + return std::make_unique<RasterTile>(tileID, parameters, tileset); +} + +} // namespace style +} // namespace mbgl |