Skip to content

Commit 171e0dc

Browse files
committed
Avoid warnings for use of constants in tile code
The quadkey code uses many magic constants only once or twice, there is no sense in defining them separately.
1 parent edbbcc6 commit 171e0dc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/tile.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ geom::point_t tile_t::to_world_coords(geom::point_t p,
3636

3737
geom::point_t tile_t::center() const noexcept
3838
{
39-
return to_world_coords({0.5, 0.5}, 1);
39+
constexpr double MIDDLE = 0.5;
40+
return to_world_coords({MIDDLE, MIDDLE}, 1);
4041
}
4142

4243
namespace {
4344

4445
// Quadkey implementation uses bit interleaving code from
4546
// https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/2018/01/08/interleave.c
4647

48+
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
49+
4750
uint64_t interleave_uint32_with_zeros(uint32_t input) noexcept
4851
{
4952
uint64_t word = input;
@@ -66,6 +69,8 @@ uint32_t deinterleave_lowuint32(uint64_t word) noexcept
6669
return static_cast<uint32_t>(word);
6770
}
6871

72+
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
73+
6974
uint32_t parse_num_with_max(std::string const &str, uint32_t max)
7075
{
7176
std::size_t pos = 0;

0 commit comments

Comments
 (0)