summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mbgl/map/map.hpp1
-rw-r--r--include/mbgl/style/source.hpp3
-rw-r--r--src/mbgl/map/map.cpp4
-rw-r--r--src/mbgl/style/source.cpp4
-rw-r--r--src/mbgl/style/source_impl.hpp2
-rw-r--r--src/mbgl/style/style.cpp24
-rw-r--r--src/mbgl/style/style.hpp1
-rw-r--r--src/mbgl/style/tile_source_impl.cpp8
-rw-r--r--src/mbgl/style/tile_source_impl.hpp2
9 files changed, 16 insertions, 33 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index 2a0d2888bd..914c2cd0b3 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -155,7 +155,6 @@ public:
style::Source* getSource(const std::string& sourceID);
void addSource(std::unique_ptr<style::Source>);
void removeSource(const std::string& sourceID);
- std::vector<std::string> getAttributions() const;
// Layers
style::Layer* getLayer(const std::string& layerID);
diff --git a/include/mbgl/style/source.hpp b/include/mbgl/style/source.hpp
index 92341066b1..870c81fda6 100644
--- a/include/mbgl/style/source.hpp
+++ b/include/mbgl/style/source.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <mbgl/util/noncopyable.hpp>
+#include <mbgl/util/optional.hpp>
#include <mbgl/style/types.hpp>
#include <memory>
@@ -50,6 +51,8 @@ public:
// are copied from this source.
std::unique_ptr<Source> copy(const std::string& id) const;
+ optional<std::string> getAttribution() const;
+
// Private implementation
class Impl;
const std::unique_ptr<Impl> baseImpl;
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index a67de9c2c4..0dfd079926 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -786,10 +786,6 @@ void Map::removeSource(const std::string& sourceID) {
}
}
-std::vector<std::string> Map::getAttributions() const {
- return impl->style ? impl->style->getAttributions() : std::vector<std::string>();
-}
-
style::Layer* Map::getLayer(const std::string& layerID) {
if (impl->style) {
impl->styleMutated = true;
diff --git a/src/mbgl/style/source.cpp b/src/mbgl/style/source.cpp
index 4c83a3ce0e..cfb268006b 100644
--- a/src/mbgl/style/source.cpp
+++ b/src/mbgl/style/source.cpp
@@ -14,5 +14,9 @@ const std::string& Source::getID() const {
return baseImpl->id;
}
+optional<std::string> Source::getAttribution() const {
+ return baseImpl->getAttribution();
+}
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/source_impl.hpp b/src/mbgl/style/source_impl.hpp
index c7ed36b3c2..608a552835 100644
--- a/src/mbgl/style/source_impl.hpp
+++ b/src/mbgl/style/source_impl.hpp
@@ -71,6 +71,8 @@ public:
const SourceType type;
const std::string id;
+ virtual optional<std::string> getAttribution() const { return {}; };
+
bool loaded = false;
// Tracks whether the source is used by any layers visible at the current zoom level. Must
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index f0917c3b60..50de887dbc 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -18,7 +18,6 @@
#include <mbgl/style/update_parameters.hpp>
#include <mbgl/style/cascade_parameters.hpp>
#include <mbgl/style/calculation_parameters.hpp>
-#include <mbgl/style/tile_source_impl.hpp>
#include <mbgl/sprite/sprite_atlas.hpp>
#include <mbgl/text/glyph_atlas.hpp>
#include <mbgl/geometry/line_atlas.hpp>
@@ -26,7 +25,6 @@
#include <mbgl/renderer/render_tile.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/util/string.hpp>
-#include <mbgl/util/tileset.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/math/minmax.hpp>
@@ -295,28 +293,6 @@ Source* Style::getSource(const std::string& id) const {
return it != sources.end() ? it->get() : nullptr;
}
-std::vector<std::string> Style::getAttributions() const {
- std::vector<std::string> result;
- for (const auto& source : sources) {
- switch (source->baseImpl->type) {
- case SourceType::Vector:
- case SourceType::Raster: {
- style::TileSourceImpl* tileSource = static_cast<style::TileSourceImpl*>(source->baseImpl.get());
- auto attribution = tileSource->getAttribution();
- if (!attribution.empty()) {
- result.push_back(std::move(attribution));
- }
- }
-
- case SourceType::GeoJSON:
- case SourceType::Video:
- case SourceType::Annotations:
- break;
- }
- }
- return result;
-}
-
bool Style::hasTransitions() const {
return hasPendingTransitions;
}
diff --git a/src/mbgl/style/style.hpp b/src/mbgl/style/style.hpp
index 5bd886923a..648bd48030 100644
--- a/src/mbgl/style/style.hpp
+++ b/src/mbgl/style/style.hpp
@@ -67,7 +67,6 @@ public:
Source* getSource(const std::string& id) const;
void addSource(std::unique_ptr<Source>);
void removeSource(const std::string& sourceID);
- std::vector<std::string> getAttributions() const;
std::vector<const Layer*> getLayers() const;
Layer* getLayer(const std::string& id) const;
diff --git a/src/mbgl/style/tile_source_impl.cpp b/src/mbgl/style/tile_source_impl.cpp
index a318fdd755..7dd6ae6dbc 100644
--- a/src/mbgl/style/tile_source_impl.cpp
+++ b/src/mbgl/style/tile_source_impl.cpp
@@ -118,8 +118,12 @@ Range<uint8_t> TileSourceImpl::getZoomRange() {
return tileset.zoomRange;
}
-std::string TileSourceImpl::getAttribution() const {
- return loaded ? tileset.attribution : "";
+optional<std::string> TileSourceImpl::getAttribution() const {
+ if (loaded && !tileset.attribution.empty()) {
+ return tileset.attribution;
+ } else {
+ return {};
+ }
}
} // namespace style
diff --git a/src/mbgl/style/tile_source_impl.hpp b/src/mbgl/style/tile_source_impl.hpp
index 4ce1eac223..366e0b60a2 100644
--- a/src/mbgl/style/tile_source_impl.hpp
+++ b/src/mbgl/style/tile_source_impl.hpp
@@ -34,7 +34,7 @@ public:
return urlOrTileset;
}
- std::string getAttribution() const;
+ optional<std::string> getAttribution() const override;
protected:
Range<uint8_t> getZoomRange() final;