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

Add unit tests for TileCoordinate and TilePoint #6626

Merged
merged 3 commits into from
Oct 11, 2016

Conversation

brunoabinader
Copy link
Member

Previously part of #6553.

@brunoabinader brunoabinader added tests Core The cross-platform C++ core, aka mbgl labels Oct 7, 2016
@mention-bot
Copy link

@brunoabinader, thanks for your PR! By analyzing the history of the files in this pull request, we identified @jfirebaugh, @ansis and @kkaefer to be potential reviewers.

@@ -22,8 +22,12 @@
namespace mbgl {
namespace style {

namespace {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary here; static data and functions are already non-visible beyond their translation unit.

@@ -168,7 +172,8 @@ void Source::Impl::updateTiles(const UpdateParameters& parameters) {
parameters.debugOptions & MapDebugOptions::Collision };

for (auto& pair : tiles) {
pair.second->setPlacementConfig(config);
auto& tile = pair.second;
tile->setPlacementConfig(config);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why introduce a temporary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intention is to improve readability (tile vs. pair.second).

If that's agreeable, we can move the object scope out of the for-loop so it only gets updated instead of created/deleted on each pass.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the original -- pair.second->setPlacementConfig(config); -- over introducing any temporary variables. It's clear from the previous line that you're iterating over tiles.

@@ -25,8 +27,22 @@ namespace style {
class Layer;
} // namespace style

using TilePoint = Point<int16_t>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a typedef for this already, currently spelled GeometryCoordinate. I think TilePoint is better, but let's wait to introduce it until we can do a universal rename and at the same time remove GeometryCoordinates and GeometryCollection in favor of geometry.hpp types.

class Tile : private util::noncopyable {
public:
static TilePoint pointFromTileCoordinate(const UnwrappedTileID& tileID, const TileCoordinatePoint& p) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more closely related to to TileCoordinate than Tile -- let's move it there.

@@ -514,3 +520,62 @@ TEST(Transform, DefaultTransform) {
ASSERT_FALSE(transform.resize({{ max, max }}));
testConversions(nullIsland, center);
}

TEST(Transform, TileCoordinate)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put all the TileCoordinate-related tests -- the ones here and in tile_point.test.cpp -- in tile_coordinate.test.cpp.

I've been campaigning to get rid of TileCoordinate for awhile (1, 2, 3) -- keeping it and its tests each confined to a single file at least limits the spread as much as possible.

@brunoabinader brunoabinader force-pushed the 6626-tile-coordinate-utests branch 2 times, most recently from 9d64b3c to 2111b77 Compare October 9, 2016 13:12
@brunoabinader brunoabinader force-pushed the 6626-tile-coordinate-utests branch from 2111b77 to d16eb20 Compare October 9, 2016 15:23
@brunoabinader
Copy link
Member Author

Addressed @jfirebaugh review comments.

@brunoabinader brunoabinader force-pushed the 6626-tile-coordinate-utests branch 4 times, most recently from 4bf0469 to f57f992 Compare October 11, 2016 07:32
mapbox::geometry::box<double> box = mapbox::geometry::envelope(queryGeometry);

for (const auto& tilePtr : renderTiles) {
const RenderTile& tile = tilePtr.second;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep this; it's pair isn't a name that says anything.

@brunoabinader brunoabinader force-pushed the 6626-tile-coordinate-utests branch from f57f992 to 76dc593 Compare October 11, 2016 09:16
@brunoabinader brunoabinader force-pushed the 6626-tile-coordinate-utests branch from 76dc593 to 5861bf3 Compare October 11, 2016 11:05
@brunoabinader brunoabinader force-pushed the 6626-tile-coordinate-utests branch from 5861bf3 to 31c5aa8 Compare October 11, 2016 16:14
@brunoabinader brunoabinader merged commit 9946e60 into master Oct 11, 2016
@brunoabinader brunoabinader deleted the 6626-tile-coordinate-utests branch October 11, 2016 16:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl refactor tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants