style::Style::getImage() returns optional<style::Image>
This commit is contained in:
@@ -170,9 +170,7 @@ void Map::Impl::jumpTo(const CameraOptions& camera) {
|
||||
}
|
||||
|
||||
void Map::Impl::onStyleImageMissing(const std::string& id, std::function<void()> done) {
|
||||
if (style->getImage(id) == nullptr) {
|
||||
observer.onStyleImageMissing(id);
|
||||
}
|
||||
if (!style->getImage(id)) observer.onStyleImageMissing(id);
|
||||
|
||||
done();
|
||||
onUpdate();
|
||||
|
||||
@@ -60,11 +60,10 @@ const Light* Style::getLight() const {
|
||||
return impl->getLight();
|
||||
}
|
||||
|
||||
const PremultipliedImage* Style::getImage(const std::string& name) const {
|
||||
if (auto* image = impl->getImage(name)) {
|
||||
return &(image->image);
|
||||
}
|
||||
return nullptr;
|
||||
optional<Image> Style::getImage(const std::string& name) const {
|
||||
auto image = impl->getImage(name);
|
||||
if (!image) return nullopt;
|
||||
return style::Image(std::move(*image));
|
||||
}
|
||||
|
||||
void Style::addImage(std::unique_ptr<Image> image) {
|
||||
|
||||
@@ -301,10 +301,10 @@ void Style::Impl::removeImage(const std::string& id) {
|
||||
images = std::move(newImages);
|
||||
}
|
||||
|
||||
const style::Image::Impl* Style::Impl::getImage(const std::string& id) const {
|
||||
optional<Immutable<style::Image::Impl>> Style::Impl::getImage(const std::string& id) const {
|
||||
auto found = std::find_if(images->begin(), images->end(), [&id](const auto& image) { return image->id == id; });
|
||||
if (found == images->end()) return nullptr;
|
||||
return found->get();
|
||||
if (found == images->end()) return nullopt;
|
||||
return *found;
|
||||
}
|
||||
|
||||
void Style::Impl::setObserver(style::Observer* observer_) {
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
void setLight(std::unique_ptr<Light>);
|
||||
Light* getLight() const;
|
||||
|
||||
const style::Image::Impl* getImage(const std::string&) const;
|
||||
optional<Immutable<style::Image::Impl>> getImage(const std::string&) const;
|
||||
void addImage(std::unique_ptr<style::Image>);
|
||||
void removeImage(const std::string&);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user