/* This reads an OSM file and writes out the node locations to a cache file. The code in this example file is released into the Public Domain. */ #include #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; 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::node); int fd = open(argv[2], O_RDWR | O_CREAT, 0666); 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(); osmium::apply(reader, location_handler); reader.close(); google::protobuf::ShutdownProtobufLibrary(); return 0; }