Fix TileJSON conversion to allow single point bounds
This commit is contained in:
@@ -95,12 +95,12 @@ 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){
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user