/usr/include/osmium/handler/dump.hpp is in libosmium2-dev 2.13.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | #ifndef OSMIUM_HANDLER_DUMP_HPP
#define OSMIUM_HANDLER_DUMP_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <iomanip>
#include <iostream>
#include <string>
#include <osmium/handler.hpp>
#include <osmium/memory/collection.hpp>
#include <osmium/memory/item.hpp>
#include <osmium/osm/area.hpp>
#include <osmium/osm/box.hpp>
#include <osmium/osm/changeset.hpp>
#include <osmium/osm/item_type.hpp>
#include <osmium/osm/location.hpp>
#include <osmium/osm/node.hpp>
#include <osmium/osm/node_ref.hpp>
#include <osmium/osm/object.hpp>
#include <osmium/osm/relation.hpp>
#include <osmium/osm/tag.hpp>
#include <osmium/osm/timestamp.hpp>
#include <osmium/osm/way.hpp>
#include <osmium/visitor.hpp>
namespace osmium {
namespace handler {
class Dump : public osmium::handler::Handler {
std::ostream* m_out;
bool m_with_size;
std::string m_prefix;
void print_title(const char* title, const osmium::memory::Item& item) {
*m_out << m_prefix
<< title
<< ":";
if (m_with_size) {
*m_out << " ["
<< item.byte_size()
<< "]";
}
*m_out << "\n";
}
void print_meta(const osmium::OSMObject& object) {
*m_out << m_prefix
<< " id="
<< object.id()
<< "\n";
*m_out << m_prefix
<< " version="
<< object.version()
<< "\n";
*m_out << m_prefix
<< " uid="
<< object.uid()
<< "\n";
*m_out << m_prefix
<< " user=|"
<< object.user()
<< "|\n";
*m_out << m_prefix
<< " changeset="
<< object.changeset()
<< "\n";
*m_out << m_prefix
<< " timestamp="
<< object.timestamp().to_iso()
<< "\n";
*m_out << m_prefix
<< " visible="
<< (object.visible() ? "yes" : "no")
<< "\n";
Dump dump{*m_out, m_with_size, m_prefix + " "};
osmium::apply(object.cbegin(), object.cend(), dump);
}
void print_location(const osmium::Node& node) {
const osmium::Location& location = node.location();
if (location) {
*m_out << m_prefix
<< " lon="
<< std::fixed
<< std::setprecision(7)
<< location.lon_without_check()
<< "\n";
*m_out << m_prefix
<< " lat="
<< location.lat_without_check()
<< "\n";
} else {
*m_out << m_prefix
<< " lon=\n"
<< m_prefix
<< " lat=\n";
}
}
public:
explicit Dump(std::ostream& out, bool with_size = true, const std::string& prefix = "") :
m_out(&out),
m_with_size(with_size),
m_prefix(prefix) {
}
void tag_list(const osmium::TagList& tags) {
print_title("TAGS", tags);
for (const auto& tag : tags) {
*m_out << m_prefix
<< " k=|"
<< tag.key()
<< "| v=|"
<< tag.value()
<< "|"
<< "\n";
}
}
void way_node_list(const osmium::WayNodeList& wnl) {
print_title("NODES", wnl);
for (const auto& node_ref : wnl) {
*m_out << m_prefix
<< " ref="
<< node_ref.ref();
if (node_ref.location()) {
*m_out << " pos="
<< node_ref.location();
}
*m_out << "\n";
}
}
void relation_member_list(const osmium::RelationMemberList& rml) {
print_title("MEMBERS", rml);
for (const auto& member : rml) {
*m_out << m_prefix
<< " type="
<< item_type_to_name(member.type())
<< " ref="
<< member.ref()
<< " role=|"
<< member.role()
<< "|\n";
if (member.full_member()) {
Dump dump(*m_out, m_with_size, m_prefix + " | ");
osmium::apply_item(member.get_object(), dump);
}
}
}
void outer_ring(const osmium::OuterRing& ring) {
print_title("OUTER RING", ring);
for (const auto& node_ref : ring) {
*m_out << m_prefix
<< " ref="
<< node_ref.ref();
if (node_ref.location()) {
*m_out << " pos="
<< node_ref.location();
}
*m_out << "\n";
}
}
void inner_ring(const osmium::InnerRing& ring) {
print_title("INNER RING", ring);
for (const auto& node_ref : ring) {
*m_out << m_prefix
<< " ref="
<< node_ref.ref();
if (node_ref.location()) {
*m_out << " pos="
<< node_ref.location();
}
*m_out << "\n";
}
}
void node(const osmium::Node& node) {
print_title("NODE", node);
print_meta(node);
print_location(node);
}
void way(const osmium::Way& way) {
print_title("WAY", way);
print_meta(way);
}
void relation(const osmium::Relation& relation) {
print_title("RELATION", relation);
print_meta(relation);
}
void area(const osmium::Area& area) {
print_title("AREA", area);
print_meta(area);
}
void changeset(const osmium::Changeset& changeset) {
print_title("CHANGESET", changeset);
*m_out << m_prefix
<< " id="
<< changeset.id()
<< "\n";
*m_out << m_prefix
<< " num_changes="
<< changeset.num_changes()
<< "\n";
*m_out << m_prefix
<< " uid="
<< changeset.uid()
<< "\n";
*m_out << m_prefix
<< " user=|"
<< changeset.user()
<< "|\n";
*m_out << m_prefix
<< " created_at="
<< changeset.created_at().to_iso()
<< "\n";
*m_out << m_prefix
<< " closed_at="
<< changeset.closed_at().to_iso()
<< "\n";
*m_out << m_prefix
<< " bounds=";
if (changeset.bounds()) {
*m_out << '('
<< changeset.bounds().bottom_left().lon_without_check()
<< ','
<< changeset.bounds().bottom_left().lat_without_check()
<< ','
<< changeset.bounds().top_right().lon_without_check()
<< ','
<< changeset.bounds().top_right().lat_without_check()
<< ')';
} else {
*m_out << "(undefined)";
}
*m_out << "\n";
Dump dump{*m_out, m_with_size, m_prefix + " "};
osmium::apply(changeset.cbegin(), changeset.cend(), dump);
}
}; // class Dump
} // namespace handler
} // namespace osmium
#endif // OSMIUM_HANDLER_DUMP_HPP
|