diff options
author | Jason Wray <jason@mapbox.com> | 2018-03-13 17:00:26 -0400 |
---|---|---|
committer | Jason Wray <jason@mapbox.com> | 2018-03-13 17:00:26 -0400 |
commit | b01e0b4fcd7e4979493e2292eb129a98fcf86e56 (patch) | |
tree | f675f95200218f827cdb2bf6a3a3a722f73c6b7e | |
parent | 4ea02ff44526c03e775f9d373d3aacbbda4c027c (diff) | |
download | qtlocation-mapboxgl-b01e0b4fcd7e4979493e2292eb129a98fcf86e56.tar.gz |
Fix mismerge in mbgl/style/conversion/tileset.[hpp|cpp]
-rw-r--r-- | include/mbgl/style/conversion/tileset.hpp | 97 | ||||
-rw-r--r-- | src/mbgl/style/conversion/tileset.cpp | 2 |
2 files changed, 2 insertions, 97 deletions
diff --git a/include/mbgl/style/conversion/tileset.hpp b/include/mbgl/style/conversion/tileset.hpp index ade6ebbdbb..1fb4acf70d 100644 --- a/include/mbgl/style/conversion/tileset.hpp +++ b/include/mbgl/style/conversion/tileset.hpp @@ -11,103 +11,6 @@ template <> struct Converter<Tileset> { public: optional<Tileset> operator()(const Convertible& value, Error& error) const; - - bool validateLatitude(const double lat) const { - return lat <= 90 && lat >= -90; - } - - template <class V> - optional<Tileset> operator()(const V& value, Error& error) const { - Tileset result; - - auto tiles = objectMember(value, "tiles"); - if (!tiles) { - error = { "source must have tiles" }; - return {}; - } - - if (!isArray(*tiles)) { - error = { "source tiles must be an array" }; - return {}; - } - - for (std::size_t i = 0; i < arrayLength(*tiles); i++) { - optional<std::string> urlTemplate = toString(arrayMember(*tiles, i)); - if (!urlTemplate) { - error = { "source tiles member must be a string" }; - return {}; - } - result.tiles.push_back(std::move(*urlTemplate)); - } - - auto schemeValue = objectMember(value, "scheme"); - if (schemeValue) { - optional<std::string> scheme = toString(*schemeValue); - if (scheme && *scheme == "tms") { - result.scheme = Tileset::Scheme::TMS; - } - } - - auto minzoomValue = objectMember(value, "minzoom"); - if (minzoomValue) { - optional<float> minzoom = toNumber(*minzoomValue); - if (!minzoom || *minzoom < 0 || *minzoom > std::numeric_limits<uint8_t>::max()) { - error = { "invalid minzoom" }; - return {}; - } - result.zoomRange.min = *minzoom; - } - - auto maxzoomValue = objectMember(value, "maxzoom"); - if (maxzoomValue) { - optional<float> maxzoom = toNumber(*maxzoomValue); - if (!maxzoom || *maxzoom < 0 || *maxzoom > std::numeric_limits<uint8_t>::max()) { - error = { "invalid maxzoom" }; - return {}; - } - result.zoomRange.max = *maxzoom; - } - - auto attributionValue = objectMember(value, "attribution"); - if (attributionValue) { - optional<std::string> attribution = toString(*attributionValue); - if (!attribution) { - error = { "source attribution must be a string" }; - return {}; - } - result.attribution = std::move(*attribution); - } - - auto boundsValue = objectMember(value, "bounds"); - if (boundsValue) { - if (!isArray(*boundsValue) || arrayLength(*boundsValue) != 4) { - error = { "bounds must be an array with left, bottom, top, and right values" }; - return {}; - } - optional<double> left = toDouble(arrayMember(*boundsValue, 0)); - optional<double> bottom = toDouble(arrayMember(*boundsValue, 1)); - optional<double> right = toDouble(arrayMember(*boundsValue, 2)); - optional<double> top = toDouble(arrayMember(*boundsValue, 3)); - - if (!left || !right || !bottom || !top) { - error = { "bounds array must contain numeric longitude and latitude values" }; - return {}; - } - if (!validateLatitude(*bottom) || !validateLatitude(*top) || top <= bottom){ - error = { "bounds latitude values must be between -90 and 90 with bottom less than top" }; - return {}; - } - if(*left >= *right) { - error = { "bounds left longitude should be less than right longitude" }; - return {}; - } - *left = util::max(-180.0, *left); - *right = util::min(180.0, *right); - result.bounds = LatLngBounds::hull({ *bottom, *left }, { *top, *right }); - } - - return result; - } }; } // namespace conversion diff --git a/src/mbgl/style/conversion/tileset.cpp b/src/mbgl/style/conversion/tileset.cpp index 6d89cef944..a2c4aa80b3 100644 --- a/src/mbgl/style/conversion/tileset.cpp +++ b/src/mbgl/style/conversion/tileset.cpp @@ -103,6 +103,8 @@ optional<Tileset> Converter<Tileset>::operator()(const Convertible& value, Error error = { "bounds left longitude should be less than right longitude" }; return {}; } + *left = util::max(-180.0, *left); + *right = util::min(180.0, *right); result.bounds = LatLngBounds::hull({ *bottom, *left }, { *top, *right }); } |