@@ -25,7 +25,7 @@ osmsg --country nepal --country india --country africa # Geofabrik regions, re
2525```
2626
2727> When ` --url ` is omitted, osmsg picks a planet replication granularity that fits the requested
28- > span: minute for spans under 6h, hour for 6h– 7d, day for ≥7d . A warning prints when the
28+ > span: minute for spans under 6h, hour for 6h to 7d, day for 7d or more . A warning prints when the
2929> auto-switch happens; pass ` --url ` explicitly to override (also suppressed by ` --country ` ,
3030> ` --update ` , or multiple ` --url ` values).
3131
@@ -41,7 +41,7 @@ osmsg --boundary '{"type":"Polygon",...}' # inline GeoJSON string
4141```
4242
4343> ` --boundary ` filters changesets whose bounding box intersects the given geometry.
44- > A Geofabrik region name resolves from the same index as ` --country ` — no separate file needed.
44+ > A Geofabrik region name resolves from the same index as ` --country ` , no separate file needed.
4545> ` --boundary ` only filters; it does not change the replication source.
4646> To scope the replication source to a country's diffs, use ` --country ` instead.
4747>
@@ -107,6 +107,72 @@ Downloaded `.osc.gz` files cache to a per-user dir (`~/Library/Caches/osmsg` on
107107` ~/.cache/osmsg` on Linux). Re-running the same range reuses them, so no network is needed.
108108` --cache-dir` to relocate, `--delete-temp` to clean up after a run.
109109
110+ # # Setting up a store
111+
112+ ` --insert` loads history into the store and seeds the resume position, then exits. Follow it with
113+ ` --update` to catch up to now and keep current. DuckDB is the default store; pass `--psql-dsn` to use
114+ Postgres (no separate `-f psql` needed).
115+
116+ ` ` ` bash
117+ osmsg --insert # load all published history into stats.duckdb
118+ osmsg --update # catch up to now, then run on cron
119+
120+ osmsg --insert --psql-dsn "host=localhost dbname=osm user=osm" # into Postgres (bulk first load)
121+ osmsg --insert --start 2020-01-01 --end 2023-01-01 # a slice; --update continues from its end
122+ osmsg --insert --osh-file history.osh.pbf --changeset-file changesets.osm.bz2 # from local files
123+ ` ` `
124+
125+ - No window loads the whole dataset; `--start/--end` loads a slice and resumes from the slice end.
126+ - ` --osh-file` with `--changeset-file` converts local planet files into the store (offline, or a custom
127+ extract). Give both together.
128+ - The Postgres load uses the bulk path (drops indexes and keys, rebuilds after).
129+
130+ ` --insert` and `--update` pick the replication granularity from how far behind the store is. A fresh
131+ store clears the multi-week backlog on day diffs (tens of files), then refines to hour and minute as it
132+ stays current. For near-real-time, run `osmsg --update --url minute`. A store tracks one granularity at
133+ a time; changing it hands off at the day boundary, so the windows stay disjoint. Pass `--url` to either
134+ command to set the granularity yourself.
135+
136+ # # Cloud-native history
137+
138+ Months covered by a published parquet dataset (default `kshitijrajsharma/osmsg-history` on
139+ HuggingFace) are read remotely. The recent uncovered tail uses the live replication path. This is on
140+ by default.
141+
142+ ` ` ` bash
143+ osmsg --start 2015-01-01 --end 2020-01-01 # read from the dataset
144+ osmsg --start 2024-01-01 # covered months remote, current month live
145+ osmsg --last week --no-history # live path only
146+ ` ` `
147+
148+ - ` --no-history` (env `OSMSG_HISTORY=0`) uses the live path.
149+ - ` --history-url` (env `OSMSG_HISTORY_URL`) sets the dataset location.
150+ - The live path is used when the dataset is unreachable, with `--update`, and with `--length`.
151+
152+ # ## Postgres as a source of truth
153+
154+ ` osmsg --insert --psql-dsn ...` loads the dataset into osmsg's schema and seeds the resume position;
155+ ` osmsg --update --psql-dsn ...` then keeps Postgres current. `--psql-bulk` (env `OSMSG_PSQL_BULK`)
156+ forces the bulk path on a plain run; `--insert` already uses it.
157+
158+ # # Maintaining the dataset
159+
160+ ` osmsg maintain` builds and publishes the history parquet.
161+
162+ ` ` ` bash
163+ osmsg maintain month 2026-06 --repo osgeonepal/osmsg-history # build one finished month and upload
164+ osmsg maintain month 2026-06 --no-upload # build locally, review, upload later
165+ osmsg maintain publish out --repo osgeonepal/osmsg-history # write + upload manifest.json
166+ osmsg maintain convert history.osh.pbf changesets.osm.bz2 2005-01-01 2026-06-01 work --parts 24
167+ ` ` `
168+
169+ ` month` builds from the live day diffs, exports the two partitions, uploads, and advances the
170+ manifest. It refuses to publish a month whose data stops short of the month boundary (pass
171+ ` --allow-incomplete` to override), so published months are complete by construction. Re-running
172+ ` osmsg maintain month <YYYY-MM>` rebuilds a month and overwrites its published partition, which repairs
173+ a month that was first generated from a mid-day planet snapshot. `convert` turns local planet files
174+ into the datasets out of core. Uploads use the `hf` CLI (`uvx`), so be logged in to HuggingFace.
175+
110176# # Credentials
111177
112178`--country` and any `geofabrik` URL need OSM credentials. Resolution order :
0 commit comments