diff options
author | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2017-05-31 11:53:04 -0700 |
---|---|---|
committer | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2017-06-01 15:38:01 -0700 |
commit | 8b37a0704c7c20b1664fee3dfcc79139982a1ce7 (patch) | |
tree | 9c0a50330b7e4f152a3a9ee25685fcbe8b9a4df4 /src/mbgl/style | |
parent | 843da07b28a840fd850056c4b15d492ccc76a646 (diff) | |
download | qtlocation-mapboxgl-8b37a0704c7c20b1664fee3dfcc79139982a1ce7.tar.gz |
[core] Use fixed-size std::array for ImageSource coordinates
Diffstat (limited to 'src/mbgl/style')
-rw-r--r-- | src/mbgl/style/sources/image_source.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/style/sources/image_source_impl.cpp | 10 | ||||
-rw-r--r-- | src/mbgl/style/sources/image_source_impl.hpp | 15 |
3 files changed, 16 insertions, 21 deletions
diff --git a/src/mbgl/style/sources/image_source.cpp b/src/mbgl/style/sources/image_source.cpp index 79df65697c..9313d8da4a 100644 --- a/src/mbgl/style/sources/image_source.cpp +++ b/src/mbgl/style/sources/image_source.cpp @@ -8,7 +8,7 @@ namespace mbgl { namespace style { -ImageSource::ImageSource(std::string id, const std::vector<LatLng> coords_) +ImageSource::ImageSource(std::string id, const std::array<LatLng, 4> coords_) : Source(makeMutable<Impl>(std::move(id), coords_)) { } @@ -18,12 +18,12 @@ const ImageSource::Impl& ImageSource::impl() const { return static_cast<const Impl&>(*baseImpl); } -void ImageSource::setCoordinates(const std::vector<LatLng>& coords_) { +void ImageSource::setCoordinates(const std::array<LatLng, 4>& coords_) { baseImpl = makeMutable<Impl>(impl(), coords_); observer->onSourceChanged(*this); } -std::vector<LatLng> ImageSource::getCoordinates() const { +std::array<LatLng, 4> ImageSource::getCoordinates() const { return impl().getCoordinates(); } @@ -37,7 +37,7 @@ void ImageSource::setURL(const std::string& url_) { } } -void ImageSource::setImage(mbgl::UnassociatedImage&& image_) { +void ImageSource::setImage(UnassociatedImage&& image_) { url = {}; if (req) { req.reset(); @@ -47,8 +47,8 @@ void ImageSource::setImage(mbgl::UnassociatedImage&& image_) { observer->onSourceChanged(*this); } -const std::string& ImageSource::getURL() const { - return *url; +optional<std::string> ImageSource::getURL() const { + return url; } void ImageSource::loadDescription(FileSource& fileSource) { diff --git a/src/mbgl/style/sources/image_source_impl.cpp b/src/mbgl/style/sources/image_source_impl.cpp index 3678f641cb..98f3cc9db9 100644 --- a/src/mbgl/style/sources/image_source_impl.cpp +++ b/src/mbgl/style/sources/image_source_impl.cpp @@ -4,12 +4,12 @@ namespace mbgl { namespace style { -ImageSource::Impl::Impl(std::string id_, std::vector<LatLng> coords_) +ImageSource::Impl::Impl(std::string id_, std::array<LatLng, 4> coords_) : Source::Impl(SourceType::Image, std::move(id_)), coords(std::move(coords_)) { } -ImageSource::Impl::Impl(const Impl& other, std::vector<LatLng> coords_) +ImageSource::Impl::Impl(const Impl& other, std::array<LatLng, 4> coords_) : Source::Impl(other), coords(std::move(coords_)), image(other.image.clone()) { @@ -22,15 +22,11 @@ ImageSource::Impl::Impl(const Impl& rhs, UnassociatedImage image_) } ImageSource::Impl::~Impl() = default; -void ImageSource::Impl::setImage(UnassociatedImage&& image_) { - image = std::move(image_); -} - const UnassociatedImage& ImageSource::Impl::getImage() const { return image; } -std::vector<LatLng> ImageSource::Impl::getCoordinates() const { +std::array<LatLng, 4> ImageSource::Impl::getCoordinates() const { return coords; } diff --git a/src/mbgl/style/sources/image_source_impl.hpp b/src/mbgl/style/sources/image_source_impl.hpp index 26f025db74..5fd41ac6e6 100644 --- a/src/mbgl/style/sources/image_source_impl.hpp +++ b/src/mbgl/style/sources/image_source_impl.hpp @@ -3,28 +3,27 @@ #include <mbgl/style/source_impl.hpp> #include <mbgl/style/sources/image_source.hpp> #include <mbgl/util/image.hpp> +#include <mbgl/util/geo.hpp> namespace mbgl { -class LatLng; namespace style { class ImageSource::Impl : public Source::Impl { public: - Impl(std::string id, std::vector<LatLng> coords); - Impl(const Impl& rhs, std::vector<LatLng> coords); + Impl(std::string id, std::array<LatLng, 4> coords); + Impl(const Impl& rhs, std::array<LatLng, 4> coords); Impl(const Impl& rhs, UnassociatedImage image); ~Impl() final; - void setImage(UnassociatedImage&& ); - const mbgl::UnassociatedImage& getImage() const; - std::vector<LatLng> getCoordinates() const; + const UnassociatedImage& getImage() const; + std::array<LatLng, 4> getCoordinates() const; optional<std::string> getAttribution() const final; private: - std::vector<LatLng> coords; - mbgl::UnassociatedImage image; + std::array<LatLng, 4> coords; + UnassociatedImage image; }; } // namespace style |