Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] TileJSON conversion clamps bounds longitude to [-180,180], per…
Browse files Browse the repository at this point in the history
… spec
  • Loading branch information
Asheem Mamoowala committed Mar 8, 2018
1 parent c54035a commit 7df451d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/mbgl/style/conversion/tileset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ struct Converter<Tileset> {
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 });
}

Expand Down
10 changes: 10 additions & 0 deletions test/style/conversion/tileset.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ TEST(Tileset, ValidWorldBounds) {
EXPECT_EQ(converted->bounds, LatLngBounds::hull({90, -180}, {-90, 180}));
}

TEST(Tileset, BoundsAreClamped) {
Error error;
mbgl::optional<Tileset> converted = convertJSON<Tileset>(R"JSON({
"tiles": ["http://mytiles"],
"bounds": [-181.0000005,-90,180.00000000000006,90]
})JSON", error);
EXPECT_TRUE((bool) converted);
EXPECT_EQ(converted->bounds, LatLngBounds::hull({90, -180}, {-90, 180}));
}

TEST(Tileset, FullConversion) {
Error error;
Tileset converted = *convertJSON<Tileset>(R"JSON({
Expand Down

0 comments on commit 7df451d

Please sign in to comment.