Skip to content
open-geocodeopen-geocodeopen-geocode
GitHub

Quickstart

Build a Pack for Ontario, Canada, serve it, and send it your first forward and reverse queries. Any other region in the catalog works the same way.

Install og from source with Cargo.

Terminal window
cargo install --git https://github.com/open-geocode-rs/open-geocode --features tui

This installs two binaries:

  • og builds and serves Packs, and opens the interactive interface.
  • open-geocode runs batch CSV geocoding, benchmarks and lower-level Pack tools.

To check that og was installed, run:

Terminal window
og --version
og 0.x.y

Build a Pack for Ontario with og build.

Terminal window
og build --region canada/ontario

og downloads Ontario’s OpenStreetMap extract, then builds a Pack from it. It prints one line per step as it goes, and a Pack ready line with the Pack’s path, record count and size when it is done.

Serve the Pack with og serve.

Terminal window
og serve canada-ontario
Serving <og home>/packs/canada-ontario at http://127.0.0.1:8080

The API is now listening on http://127.0.0.1:8080.

Forward geocode a free-form address with /search.

Terminal window
curl 'http://127.0.0.1:8080/search?q=10+King+Street+Toronto'

Reverse geocode a point with /reverse. Longitude comes first, as in GeoJSON.

Terminal window
curl 'http://127.0.0.1:8080/reverse?lon=-79.38&lat=43.65'

Both return a GeoJSON FeatureCollection, so the result drops straight into a map library. Each feature carries the matched address, its coordinates, an accuracy tier and a score. See Responses for every field.

You’ve built a geocoder for Ontario and queried it.

og can also do all of this from the terminal. Run og with no arguments:

Terminal window
og

Pick a region from the catalog, build it, search it, and geocode CSV files, without remembering a flag.