This Rust program:
- parses OSM history files from Geofabrik
- then creates a postgres
{schema}.historytable with the following fields:- id (negative IDs are for relations)
- timestamps
- changesets
- first_timestamps
- last_timestamps
- users_number
- versions_number
The database schema is dynamically computed based on the country code (see Usage section below).
./pbf_history_reader /path/to/history.osh.pbf /path/to/tag_list.txtWrites to schema osm.
./pbf_history_reader /path/to/history.osh.pbf /path/to/tag_list.txt nzWrites to schema osm_nz.
./pbf_history_reader /path/to/history.osh.pbf /path/to/tag_list.txt auWrites to schema osm_au.
./pbf_history_reader --versionInstall rust and cargo with:
curl https://sh.rustup.rs -sSf | shfrom the osm/pbf_history_reader subfolder
cargo build
It creates an executable file in ./target/debug/ directory (by default, cargo builds in debug mode)
cargo run
This command builds then run the executable file.
cargo build --release
It creates an executable file in ./target/release/ directory. With this option, the program is optimized to run
faster.
- Install a cross toolchain:
On mac:
brew tap SergioBenitez/osxct
brew install x86_64-unknown-linux-gnu
then specify it in cargo config file .cargo/config.toml:
# .cargo/config.toml
[target.x86_64-unknown-linux-gnu]
linker = "/opt/homebrew/bin/x86_64-unknown-linux-gnu-gcc"- Specify the compilation target:
rustup target add x86_64-unknown-linux-gnu
- Compile (in release):
cargo build --target x86_64-unknown-linux-gnu -v --release
The executable file is created in osm/pbf_history_reader/target/x86_64-unknown-linux-gnu/release directory
pbf_history_reader needs several environment variables to work:
DB_HOST(required)DB_PASSWORD(required)DB_NAME(default:dataseed)DB_PORT(default:5432)DB_USER(default:dataseed)OSM_ACCOUNT_USER(for history files)OSM_ACCOUNT_PASSWORD(for history files)
They can be provided with env.local or .envrc files (don't forget to pass them to the container
in docker-compose.yml file)
-
Update the version tag in
.github/workflows/rust.ymland inCargo.tomlEdit the
tag_nameandrelease_namefields:
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: target/x86_64-unknown-linux-musl/release/*
tag_name: v1.2.0 # ← update this
release_name: Release v1.2.0 # ← and thisEdit the version fields:
version = "1.2.0". # <- update this
- Commit and push to master
git add .github/workflows/rust.yml
git commit -m "chore: bump version to v1.2.0"
git push origin master- GitHub Actions will automatically:
- Build the binary for
x86_64-unknown-linux-musl - Create a GitHub Release
v1.3.0with the binary attached - The binary will be available at:
- Build the binary for
https://github.com/opendatasoft/osm-pbf-history-reader/releases/download/v1.2.0/pbf_history_reader