diff options
author | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2018-08-02 11:35:38 -0700 |
---|---|---|
committer | Justyna Janczyszyn <4153982+jjanczyszyn@users.noreply.github.com> | 2018-08-16 16:03:48 +0200 |
commit | 1774d82ff7d2bb29a0169604625b13dfe74a951f (patch) | |
tree | 48564f6f0d9543127fb69a4d65e89cd7c62d41bc | |
parent | 4ef9db6c12da350d24d690073dfaf092d241c8ef (diff) | |
download | qtlocation-mapboxgl-1774d82ff7d2bb29a0169604625b13dfe74a951f.tar.gz |
Fix TileJSON conversion to allow single point bounds
-rw-r--r-- | src/mbgl/style/conversion/tileset.cpp | 13 | ||||
-rw-r--r-- | test/style/conversion/tileset.test.cpp | 10 |
2 files changed, 17 insertions, 6 deletions
diff --git a/src/mbgl/style/conversion/tileset.cpp b/src/mbgl/style/conversion/tileset.cpp index fe3254b149..f302fc782f 100644 --- a/src/mbgl/style/conversion/tileset.cpp +++ b/src/mbgl/style/conversion/tileset.cpp @@ -95,14 +95,15 @@ optional<Tileset> Converter<Tileset>::operator()(const Convertible& value, Error bottom = util::clamp(*bottom, -90.0, 90.0); top = util::clamp(*top, -90.0, 90.0); - if (top <= bottom){ - error = { "bounds bottom latitude must be smaller than top latitude" }; - return {}; + + if (*top < *bottom){ + error.message = "bounds bottom latitude must be smaller than top latitude"; + return nullopt; } - if(*left >= *right) { - error = { "bounds left longitude should be less than right longitude" }; - return {}; + if(*left > *right) { + error.message = "bounds left longitude should be less than right longitude"; + return nullopt; } left = util::max(-180.0, *left); right = util::min(180.0, *right); diff --git a/test/style/conversion/tileset.test.cpp b/test/style/conversion/tileset.test.cpp index f405fb1361..f92ed46786 100644 --- a/test/style/conversion/tileset.test.cpp +++ b/test/style/conversion/tileset.test.cpp @@ -62,6 +62,16 @@ TEST(Tileset, ValidWorldBounds) { EXPECT_EQ(converted->bounds, LatLngBounds::hull({90, -180}, {-90, 180})); } +TEST(Tileset, PointBounds) { + Error error; + mbgl::optional<Tileset> converted = convertJSON<Tileset>(R"JSON({ + "tiles": ["http://mytiles"], + "bounds": [0, 0, 0, 0] + })JSON", error); + EXPECT_TRUE((bool) converted); + EXPECT_EQ(converted->bounds, LatLngBounds::hull({0, 0}, {0, 0})); +} + TEST(Tileset, BoundsAreClamped) { Error error; mbgl::optional<Tileset> converted = convertJSON<Tileset>(R"JSON({ |