diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-12-12 16:02:19 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-12-20 21:05:40 -0800 |
commit | 117c8ed1d100e2b64841f17714178bd1d9ffc40e (patch) | |
tree | 9d0c839442ca17bf749b3a7dae5cf3e43246c6a8 | |
parent | 906d700ccd1aedf262b8a29b88203c614c105805 (diff) | |
download | qtlocation-mapboxgl-117c8ed1d100e2b64841f17714178bd1d9ffc40e.tar.gz |
[core] Added URL accessor for tile sources
-rw-r--r-- | include/mbgl/style/sources/geojson_source.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/style/sources/raster_source.hpp | 3 | ||||
-rw-r--r-- | include/mbgl/style/sources/vector_source.hpp | 3 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source_impl.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source_impl.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/sources/raster_source.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/style/sources/vector_source.cpp | 12 |
8 files changed, 32 insertions, 6 deletions
diff --git a/include/mbgl/style/sources/geojson_source.hpp b/include/mbgl/style/sources/geojson_source.hpp index e633e6efba..ede0301725 100644 --- a/include/mbgl/style/sources/geojson_source.hpp +++ b/include/mbgl/style/sources/geojson_source.hpp @@ -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 diff --git a/include/mbgl/style/sources/raster_source.hpp b/include/mbgl/style/sources/raster_source.hpp index 9bb951992c..395f25e51d 100644 --- a/include/mbgl/style/sources/raster_source.hpp +++ b/include/mbgl/style/sources/raster_source.hpp @@ -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 <> diff --git a/include/mbgl/style/sources/vector_source.hpp b/include/mbgl/style/sources/vector_source.hpp index e16a6a68af..8626ce160a 100644 --- a/include/mbgl/style/sources/vector_source.hpp +++ b/include/mbgl/style/sources/vector_source.hpp @@ -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 <> diff --git a/src/mbgl/style/sources/geojson_source.cpp b/src/mbgl/style/sources/geojson_source.cpp index 7480438132..62726cd127 100644 --- a/src/mbgl/style/sources/geojson_source.cpp +++ b/src/mbgl/style/sources/geojson_source.cpp @@ -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(); } diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index 4800b9c4be..2929d73d39 100644 --- a/src/mbgl/style/sources/geojson_source_impl.cpp +++ b/src/mbgl/style/sources/geojson_source_impl.cpp @@ -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; } diff --git a/src/mbgl/style/sources/geojson_source_impl.hpp b/src/mbgl/style/sources/geojson_source_impl.hpp index 13994d9078..eec7cf0605 100644 --- a/src/mbgl/style/sources/geojson_source_impl.hpp +++ b/src/mbgl/style/sources/geojson_source_impl.hpp @@ -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); diff --git a/src/mbgl/style/sources/raster_source.cpp b/src/mbgl/style/sources/raster_source.cpp index 3c65476df0..94fdbcef12 100644 --- a/src/mbgl/style/sources/raster_source.cpp +++ b/src/mbgl/style/sources/raster_source.cpp @@ -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 diff --git a/src/mbgl/style/sources/vector_source.cpp b/src/mbgl/style/sources/vector_source.cpp index f2a6b166a9..4bcd3b8985 100644 --- a/src/mbgl/style/sources/vector_source.cpp +++ b/src/mbgl/style/sources/vector_source.cpp @@ -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 |