summaryrefslogtreecommitdiff
path: root/src/mbgl/tile/tile_id_io.cpp
blob: d8be6b93d611dc40d07f7b2889c350b9bc0143eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <mbgl/tile/tile_id.hpp>
#include <mbgl/util/string.hpp>

#include <iostream>

namespace mbgl {

::std::ostream& operator<<(::std::ostream& os, const CanonicalTileID& rhs) {
    // Uncomment this to create code instead of shorthands.
    // return os << "CanonicalTileID{ " << uint32_t(rhs.z) << ", " << rhs.x << ", " << rhs.y << " }";
    return os << uint32_t(rhs.z) << "/" << rhs.x << "/" << rhs.y;
}

namespace util {
std::string toString(const CanonicalTileID& rhs) {
    return util::toString(rhs.z) + "/" + util::toString(rhs.x) + "/" + util::toString(rhs.y);
}
} // namespace util

::std::ostream& operator<<(::std::ostream& os, const OverscaledTileID& rhs) {
    return os << rhs.canonical << "=>" << uint32_t(rhs.overscaledZ);
}

namespace util {
std::string toString(const OverscaledTileID& rhs) {
    return util::toString(rhs.canonical) + "=>" + util::toString(rhs.overscaledZ);
}
} // namespace util

::std::ostream& operator<<(::std::ostream& os, const UnwrappedTileID& rhs) {
    // Uncomment this to create code instead of shorthands.
    // return os << "UnwrappedTileID{ " << uint32_t(rhs.wrap) << ", { " << uint32_t(rhs.canonical.z)
    //           << ", " << rhs.canonical.x << ", " << rhs.canonical.y << " } }";
    return os << rhs.canonical << (rhs.wrap >= 0 ? "+" : "") << rhs.wrap;
}

namespace util {
std::string toString(const UnwrappedTileID& rhs) {
    return util::toString(rhs.canonical) + (rhs.wrap >= 0 ? "+" : "") + util::toString(rhs.wrap);
}
} // namespace util

} // namespace mbgl