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 /include/mbgl/style/conversion | |
parent | 843da07b28a840fd850056c4b15d492ccc76a646 (diff) | |
download | qtlocation-mapboxgl-8b37a0704c7c20b1664fee3dfcc79139982a1ce7.tar.gz |
[core] Use fixed-size std::array for ImageSource coordinates
Diffstat (limited to 'include/mbgl/style/conversion')
-rw-r--r-- | include/mbgl/style/conversion/coordinate.hpp | 4 | ||||
-rw-r--r-- | include/mbgl/style/conversion/source.hpp | 7 |
2 files changed, 5 insertions, 6 deletions
diff --git a/include/mbgl/style/conversion/coordinate.hpp b/include/mbgl/style/conversion/coordinate.hpp index 736f5e94a2..732624e77f 100644 --- a/include/mbgl/style/conversion/coordinate.hpp +++ b/include/mbgl/style/conversion/coordinate.hpp @@ -13,7 +13,7 @@ public: template <class V> optional<LatLng> operator() (const V& value, Error& error) const { if (!isArray(value) || arrayLength(value) < 2 ) { - error = { "coordinate array must contain numeric longtitude and latitude values" }; + error = { "coordinate array must contain numeric longitude and latitude values" }; return {}; } //Style spec uses GeoJSON convention for specifying coordinates @@ -21,7 +21,7 @@ public: optional<double> longitude = toDouble(arrayMember(value, 0)); if (!latitude || !longitude) { - error = { "coordinate array must contain numeric longtitude and latitude values" }; + error = { "coordinate array must contain numeric longitude and latitude values" }; return {}; } if (*latitude < -90 || *latitude > 90 ){ diff --git a/include/mbgl/style/conversion/source.hpp b/include/mbgl/style/conversion/source.hpp index e121e36955..e0563ac10b 100644 --- a/include/mbgl/style/conversion/source.hpp +++ b/include/mbgl/style/conversion/source.hpp @@ -170,14 +170,13 @@ private: return {}; } - std::vector<LatLng> coordinates; - coordinates.reserve(4); - for( std::size_t i=0; i < arrayLength(*coordinatesValue); i++) { + std::array<LatLng, 4> coordinates; + for (std::size_t i=0; i < 4; i++) { auto latLng = conversion::convert<LatLng>(arrayMember(*coordinatesValue,i), error); if (!latLng) { return {}; } - coordinates.push_back(*latLng); + coordinates[i] = *latLng; } auto result = std::make_unique<ImageSource>(id, coordinates); result->setURL(*urlString); |