Skip to content

Commit c493253

Browse files
committed
Cleanup code fixing multiple clang-tidy warnings
1 parent 1e980ba commit c493253

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

include/osmium/geom/tile.hpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ namespace osmium {
4646

4747
namespace detail {
4848

49-
template <typename T>
50-
constexpr const T clamp(const T value, const T min, const T max) {
51-
return value < min ? min : (max < value ? max : value);
49+
constexpr int32_t clamp(int32_t value, int32_t min, int32_t max) {
50+
if (value < min) {
51+
return min;
52+
}
53+
return max < value ? max : value;
5254
}
5355

5456
} // namespace detail
@@ -75,9 +77,10 @@ namespace osmium {
7577
* to right.
7678
*/
7779
constexpr uint32_t mercx_to_tilex(uint32_t zoom, double x) noexcept {
78-
return static_cast<uint32_t>(detail::clamp<int32_t>(
80+
return static_cast<uint32_t>(detail::clamp(
7981
static_cast<int32_t>((x + detail::max_coordinate_epsg3857) / tile_extent_in_zoom(zoom)),
80-
0, num_tiles_in_zoom(zoom) - 1));
82+
0,
83+
static_cast<int32_t>(num_tiles_in_zoom(zoom) - 1)));
8184
}
8285

8386
/**
@@ -86,9 +89,10 @@ namespace osmium {
8689
* to bottom.
8790
*/
8891
constexpr uint32_t mercy_to_tiley(uint32_t zoom, double y) noexcept {
89-
return static_cast<uint32_t>(detail::clamp<int32_t>(
92+
return static_cast<uint32_t>(detail::clamp(
9093
static_cast<int32_t>((detail::max_coordinate_epsg3857 - y) / tile_extent_in_zoom(zoom)),
91-
0, num_tiles_in_zoom(zoom) - 1));
94+
0,
95+
static_cast<int32_t>(num_tiles_in_zoom(zoom) - 1)));
9296
}
9397

9498
/**

0 commit comments

Comments
 (0)