Skip to content

Commit

Permalink
Add tests and changelog.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Apr 5, 2024
1 parent 2f199e3 commit 22261ab
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

### ? - ?

##### Additions :tada:

- Added `GlobeRectangle::splitAtAntiMeridian`.

### v0.34.0 - 2024-04-01

##### Breaking Changes :mega:
Expand Down
35 changes: 35 additions & 0 deletions CesiumGeospatial/test/TestGlobeRectangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,39 @@ TEST_CASE("GlobeRectangle") {
CHECK(wrapping.contains(Cartographic(-3.14, 0.2)));
CHECK(!wrapping.contains(Cartographic(0.0, 0.2)));
}

SECTION("splitAtAntiMeridian") {
GlobeRectangle nonCrossing =
GlobeRectangle::fromDegrees(-10.0, -20.0, 30.0, 40.0);
std::pair<GlobeRectangle, std::optional<GlobeRectangle>> split =
nonCrossing.splitAtAntiMeridian();
CHECK(!split.second);
CHECK(memcmp(&split.first, &nonCrossing, sizeof(GlobeRectangle)) == 0);

GlobeRectangle crossing1 =
GlobeRectangle::fromDegrees(160.0, -20.0, -170.0, 40.0);
split = crossing1.splitAtAntiMeridian();
CHECK(split.first.getWest() == crossing1.getWest());
CHECK(split.first.getEast() == Math::OnePi);
CHECK(split.first.getSouth() == crossing1.getSouth());
CHECK(split.first.getNorth() == crossing1.getNorth());
REQUIRE(split.second);
CHECK(split.second->getWest() == -Math::OnePi);
CHECK(split.second->getEast() == crossing1.getEast());
CHECK(split.second->getSouth() == crossing1.getSouth());
CHECK(split.second->getNorth() == crossing1.getNorth());

GlobeRectangle crossing2 =
GlobeRectangle::fromDegrees(170.0, -20.0, -160.0, 40.0);
split = crossing2.splitAtAntiMeridian();
CHECK(split.first.getWest() == -Math::OnePi);
CHECK(split.first.getEast() == crossing2.getEast());
CHECK(split.first.getSouth() == crossing2.getSouth());
CHECK(split.first.getNorth() == crossing2.getNorth());
REQUIRE(split.second);
CHECK(split.second->getWest() == crossing2.getWest());
CHECK(split.second->getEast() == Math::OnePi);
CHECK(split.second->getSouth() == crossing2.getSouth());
CHECK(split.second->getNorth() == crossing2.getNorth());
}
}

0 comments on commit 22261ab

Please sign in to comment.