[core] Added URL accessor for tile sources

This commit is contained in:
Minh Nguyễn
2016-12-12 16:02:19 -08:00
committed by Minh Nguyễn
parent 906d700ccd
commit 117c8ed1d1
8 changed files with 32 additions and 6 deletions

View File

@@ -43,7 +43,7 @@ public:
void setURL(const std::string& url);
void setGeoJSON(const GeoJSON&);
optional<std::string> getURL();
optional<std::string> getURL() const;
// Private implementation

View File

@@ -11,9 +11,12 @@ class RasterSource : public Source {
public:
RasterSource(std::string id, variant<std::string, Tileset> urlOrTileset, uint16_t tileSize);
optional<std::string> getURL() const;
// Private implementation
class Impl;
Impl* const impl;
};
template <>

View File

@@ -11,9 +11,12 @@ class VectorSource : public Source {
public:
VectorSource(std::string id, variant<std::string, Tileset> urlOrTileset);
optional<std::string> getURL() const;
// Private implementation
class Impl;
Impl* const impl;
};
template <>

View File

@@ -18,7 +18,7 @@ void GeoJSONSource::setGeoJSON(const mapbox::geojson::geojson& geoJSON) {
impl->setGeoJSON(geoJSON);
}
optional<std::string> GeoJSONSource::getURL() {
optional<std::string> GeoJSONSource::getURL() const {
return impl->getURL();
}

View File

@@ -47,7 +47,7 @@ void GeoJSONSource::Impl::setURL(std::string url_) {
}
}
optional<std::string> GeoJSONSource::Impl::getURL() {
optional<std::string> GeoJSONSource::Impl::getURL() const {
return url;
}

View File

@@ -17,7 +17,7 @@ public:
~Impl() final;
void setURL(std::string);
optional<std::string> getURL();
optional<std::string> getURL() const;
void setGeoJSON(const GeoJSON&);
void setTileData(GeoJSONTile&, const OverscaledTileID& tileID);

View File

@@ -5,7 +5,17 @@ namespace mbgl {
namespace style {
RasterSource::RasterSource(std::string id, variant<std::string, Tileset> urlOrTileset, uint16_t tileSize)
: Source(SourceType::Raster, std::make_unique<RasterSource::Impl>(std::move(id), *this, std::move(urlOrTileset), tileSize)) {
: Source(SourceType::Raster, std::make_unique<RasterSource::Impl>(std::move(id), *this, std::move(urlOrTileset), tileSize)),
impl(static_cast<Impl*>(baseImpl.get())) {
}
optional<std::string> RasterSource::getURL() const {
auto urlOrTileset = impl->getURLOrTileset();
if (urlOrTileset.is<std::string>()) {
return urlOrTileset.get<std::string>();
} else {
return {};
}
}
} // namespace style

View File

@@ -5,7 +5,17 @@ namespace mbgl {
namespace style {
VectorSource::VectorSource(std::string id, variant<std::string, Tileset> urlOrTileset)
: Source(SourceType::Vector, std::make_unique<VectorSource::Impl>(std::move(id), *this, std::move(urlOrTileset))) {
: Source(SourceType::Vector, std::make_unique<VectorSource::Impl>(std::move(id), *this, std::move(urlOrTileset))),
impl(static_cast<Impl*>(baseImpl.get())) {
}
optional<std::string> VectorSource::getURL() const {
auto urlOrTileset = impl->getURLOrTileset();
if (urlOrTileset.is<std::string>()) {
return urlOrTileset.get<std::string>();
} else {
return {};
}
}
} // namespace style