1 #ifndef OSMIUM_GEOM_TILE_HPP 2 #define OSMIUM_GEOM_TILE_HPP 50 inline T restrict_to_range(T value, T min, T max) {
51 if (value < min)
return min;
52 if (value > max)
return max;
80 explicit Tile(uint32_t zoom, uint32_t tx, uint32_t ty) noexcept : x(tx), y(ty), z(zoom) {
82 assert(x < (1u << zoom));
83 assert(y < (1u << zoom));
97 assert(location.
valid());
99 const int32_t n = 1 << zoom;
100 const double scale = detail::max_coordinate_epsg3857 * 2 / n;
101 x = uint32_t(detail::restrict_to_range<int32_t>(int32_t((c.x + detail::max_coordinate_epsg3857) / scale), 0, n-1));
102 y = uint32_t(detail::restrict_to_range<int32_t>(int32_t((detail::max_coordinate_epsg3857 - c.y) / scale), 0, n-1));
114 const uint32_t max = 1 << z;
115 return x < max && y < max;
122 return lhs.
z == rhs.
z && lhs.
x == rhs.
x && lhs.
y == rhs.
y;
126 return ! (lhs == rhs);
133 if (lhs.
z < rhs.
z)
return true;
134 if (lhs.
z > rhs.
z)
return false;
135 if (lhs.
x < rhs.
x)
return true;
136 if (lhs.
x > rhs.
x)
return false;
137 return lhs.
y < rhs.
y;
144 #endif // OSMIUM_GEOM_TILE_HPP
bool valid() const noexcept
Definition: tile.hpp:110
constexpr bool valid() const noexcept
Definition: location.hpp:341
Namespace for everything in the Osmium library.
Definition: assembler.hpp:73
Definition: coordinates.hpp:46
uint32_t x
x coordinate
Definition: tile.hpp:64
Coordinates lonlat_to_mercator(const Coordinates &c)
Definition: mercator_projection.hpp:76
bool operator<(const Tile &lhs, const Tile &rhs)
Definition: tile.hpp:132
uint32_t y
y coordinate
Definition: tile.hpp:67
Definition: location.hpp:266
Tile(uint32_t zoom, uint32_t tx, uint32_t ty) noexcept
Definition: tile.hpp:80
bool operator!=(const Coordinates &lhs, const Coordinates &rhs) noexcept
Definition: coordinates.hpp:83
uint32_t z
Zoom level.
Definition: tile.hpp:70
bool operator==(const Coordinates &lhs, const Coordinates &rhs) noexcept
Definition: coordinates.hpp:76
Tile(uint32_t zoom, const osmium::Location &location)
Definition: tile.hpp:94