From a5fea5febf908c8cc94222bdbccf53afafc0c1dd Mon Sep 17 00:00:00 2001 From: Asheem Mamoowala Date: Thu, 2 Aug 2018 11:35:38 -0700 Subject: Fix TileJSON conversion to allow single point bounds --- src/mbgl/style/conversion/tileset.cpp | 4 ++-- test/style/conversion/tileset.test.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mbgl/style/conversion/tileset.cpp b/src/mbgl/style/conversion/tileset.cpp index fb2ae6c6a0..b566af0a18 100644 --- a/src/mbgl/style/conversion/tileset.cpp +++ b/src/mbgl/style/conversion/tileset.cpp @@ -95,12 +95,12 @@ optional Converter::operator()(const Convertible& value, Error bottom = util::clamp(*bottom, -90.0, 90.0); top = util::clamp(*top, -90.0, 90.0); - if (top <= bottom){ + if (*top < *bottom){ error.message = "bounds bottom latitude must be smaller than top latitude"; return nullopt; } - if(*left >= *right) { + if(*left > *right) { error.message = "bounds left longitude should be less than right longitude"; return nullopt; } 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 converted = convertJSON(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 converted = convertJSON(R"JSON({ -- cgit v1.2.1