/* This reads ways from an OSM file and writes out the node locations it got from a node cache generated with osmium_create_node_cache. The code in this example file is released into the Public Domain. */ #include #include #include #include #include #include #include #include #include #include typedef osmium::index::map::Dummy index_neg_type; //typedef osmium::index::map::DenseMmapArray index_pos_type; typedef osmium::index::map::DenseFileArray index_pos_type; typedef osmium::handler::NodeLocationsForWays location_handler_type; class MyHandler : public osmium::handler::Handler { public: void way(osmium::Way& way) { for (auto& nr : way.nodes()) { std::cout << nr << "\n"; } } }; // class MyHandler int main(int argc, char* argv[]) { if (argc != 3) { std::cerr << "Usage: " << argv[0] << " OSM_FILE CACHE_FILE\n"; return 1; } std::string input_filename(argv[1]); osmium::io::Reader reader(input_filename, osmium::osm_entity_bits::way); int fd = open(argv[2], O_RDWR); if (fd == -1) { std::cerr << "Can not open node cache file '" << argv[2] << "': " << strerror(errno) << "\n"; return 1; } index_pos_type index_pos {fd}; index_neg_type index_neg; location_handler_type location_handler(index_pos, index_neg); location_handler.ignore_errors(); MyHandler handler; osmium::apply(reader, location_handler, handler); reader.close(); return 0; }