{"id":16528391,"url":"https://github.com/danvk/libosmpbfreader","last_synced_at":"2025-04-10T09:52:28.609Z","repository":{"id":6747937,"uuid":"7994280","full_name":"danvk/libosmpbfreader","owner":"danvk","description":"A simple C++ library to read OpenStreetMap binary files","archived":false,"fork":false,"pushed_at":"2012-11-21T11:42:05.000Z","size":74,"stargazers_count":1,"open_issues_count":0,"forks_count":15,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T08:47:45.936Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"hove-io/libosmpbfreader","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danvk.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-03T18:12:16.000Z","updated_at":"2024-02-03T23:58:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"96d3d218-7659-4b72-9852-7a9a2c1f7868","html_url":"https://github.com/danvk/libosmpbfreader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danvk%2Flibosmpbfreader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danvk%2Flibosmpbfreader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danvk%2Flibosmpbfreader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danvk%2Flibosmpbfreader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danvk","download_url":"https://codeload.github.com/danvk/libosmpbfreader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248198159,"owners_count":21063625,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T17:40:13.584Z","updated_at":"2025-04-10T09:52:28.567Z","avatar_url":"https://github.com/danvk.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"libosmpbfreader\n===============\n\nA simple C++ library to read OpenStreetMap binary files.\n\nIt is released under the BSD licence (to be precise, the 3-clause license aka \"New BSD License\" aka \"Modified BSD License\").\n\nGoal\n****\n\nWe hope that this library will help people to parse osm.pbf files in C++.\nThis library only provides a scaffold to read the data. It does no transformation.\n\nWe like a lot http://dev.omniscale.net/imposm.parser/ but wanted the same thing in C++.\n\nCompared to https://github.com/joto/osmium libosmpbfreader is way less ambitious. Where Osmium\nprovides a whole framework for parsing PBF files, we only provide a scaffold for reading those\nfiles. Our main focus was to provide a library that can be used in 10 minutes.\n\nInstall\n*******\n\nThe only dependency is libosmpbf. On debian/ubuntu just run::\n\n\tsudo apt-get install libosmpbf-dev\n\nThe library is a single header. No need to install or build anything.\n\nUsing it\n********\n\nThe easiest is probably to look at the examples.\n\nAs it is a header only library, juste include the header file::\n\n\t#include \"osmpbfreader.h\"\n\tusing namespace CanalTP;\n\nTo use the library you need to implement a struct having the following signature::\n\t\n\tstruct Visitor {\n\t    void node_callback(uint64_t osmid, double lon, double lat, const Tags \u0026tags){}\n\t    void way_callback(uint64_t osmid, const Tags \u0026tags, const std::vector\u003cuint64_t\u003e \u0026refs){}\n\t    void relation_callback(uint64_t osmid, const Tags \u0026tags, const References \u0026refs){}\n\t};\n\nTags and References are just typedefs::\n\n\ttypedef std::map\u003cstd::string, std::string\u003e Tags;\n\ttypedef std::vector\u003cstd::pair\u003cOSMPBF::Relation::MemberType, uint64_t\u003e \u003e References;\n\nThe functions are called every time a node, a way or a relation is encountered while reading the file.\n\n*Warning:* Don't expect the elements to be read in any specific order. For example the nodes of a way might not be parsed already.\n\nCall the main function with the visitor you created::\n\t\n\tVisitor v;\n\tread_osm_pbf(\"your_file.osm.pbf\", v);\n\nPerformances\n************\n\nJust reading (and doing nothing with the data) a europe extract (8Gb) requires 10 minutes on recent desktop computer.\n\nYou must be very careful about the memory consumption if you plan to keep the nodes and ways on large files.\nRoughly count on 1Gb memory usage for an 100Mb .osm.pbf file.\nIf you want to parse large files (like a whole continent or the planet), consider storing them on disk, e.g. using\nhttp://fallabs.com/kyotocabinet/\n\nFuture work\n***********\n\nIt will depend on your feedback ;)\n\nWe might add some concurrency to speed up the parsing. However it will require more dependencies and will\nyield some synchronization problems in the visitor. Is it worth it?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanvk%2Flibosmpbfreader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanvk%2Flibosmpbfreader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanvk%2Flibosmpbfreader/lists"}