[core] Added URL accessor for tile sources
This commit is contained in:
committed by
Minh Nguyễn
parent
906d700ccd
commit
117c8ed1d1
@@ -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
|
||||
|
||||
|
||||
@@ -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 <>
|
||||
|
||||
@@ -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 <>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user