Self-host OSM geocoding
The Geo Engine can read a local OpenStreetMap dataset for forward geocoding, reverse geocoding, and full-address autocomplete. Import a country, continent, or planet extract into the geo_osm schema in the same PostgreSQL database already configured for the Geo Engine. You do not need another database or additional OSM environment variables.
The map viewer can still browse the whole world using its map tile provider. Geocoding coverage depends on the extracts imported into your database. For example, after importing the Philippines extract, the local geocoder has Philippine data; it does not contain detailed addresses for the rest of the world.
1. Enable PostGIS and text search
Install the PostGIS version that matches your installed PostgreSQL major version and Windows architecture. Use the PostGIS Windows download guide to select the matching installer. The extension is enabled per database, so connect to the database named by your existing DB_NAME setting (the example is geo_db) in pgAdmin or psql and run:
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS pg_trgm;
SELECT postgis_version();
The final query should return the installed PostGIS version. The configured DB_USER must be able to create the geo_osm and temporary geo_osm_stage schemas and their tables and indexes during the import.
2. Install osm2pgsql on Windows
Download the official prebuilt osm2pgsql Windows ZIP for your system and extract it, for example to C:\tools\osm2pgsql. Verify the binary in PowerShell:
Set-Location C:\tools\osm2pgsql
.\osm2pgsql.exe --version
The seed command requires osm2pgsql 2.x with Flex output support. Add the folder containing osm2pgsql.exe to your Windows PATH, open a new terminal, and confirm osm2pgsql --version works there. The tool reads the existing DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASS, and DB_SSL settings from the repository .env file. It passes the password through the process environment and does not put it on the command line.
3. Download an extract and seed it
Download the Philippines extract from Geofabrik. Keep the .osm.pbf file compressed and place it directly in the repository’s ignored imports/ folder, for example:
imports/philippines-latest.osm.pbf
From the repository root, run either command:
make geocoding_seed file=philippines-latest.osm.pbf
npm run geocoding:seed -- --file philippines-latest.osm.pbf
The same command accepts a country, continent, or planet .pbf file inside imports/. It reports the filename, checksum, imported feature count, inserted rows, existing IDs skipped, and rejected features. The importer stages the extract first and publishes its new rows and import record in one transaction. An interrupted import leaves already published data available for API requests.
The first import can take time and needs working disk space for osm2pgsql’s temporary data as well as the resulting features and indexes. Larger regional extracts and the planet require substantially more disk, memory, and import time. The planet-scale configuration has not been exercised as part of this example.
Add overlapping extracts safely
You can add another extract with the same command, for example an Asia file after the Philippines file. Existing rows win: the importer deduplicates by (osm_type, osm_id) and leaves the first imported geometry, tags, and source metadata unchanged. Only IDs not already in the database are inserted. The SHA-256 checksum prevents an identical file from being processed again.
A newer snapshot adds new IDs but does not update or remove existing OSM objects. Refresh and deletion handling require a future update workflow. OSM IDs identify map objects; two different IDs can still represent the same real-world place.
Use the geocoding API
Forward, reverse, and address-autocomplete requests use local PostGIS by default. If local data is unavailable or its query fails temporarily, the engine tries Photon. A successful local search with no matches returns an empty result and does not query Photon.
curl --get 'http://localhost:8000/geocoding/forward' \
--header 'x-app-id: <your-app-slug>' \
--header 'x-api-key: <credential-id>.<secret>' \
--data-urlencode 'q=Quezon Boulevard, Manila' \
--data-urlencode 'countryCode=PH' \
--data-urlencode 'limit=5'
Add x-provider-key: self-hosted to force a local-only request. Use x-provider-key: photon-komoot to request Photon directly. Geoapify remains an explicit BYOK provider; its key stays in the Geo Engine server environment. IP and timezone lookups still use Geoapify.
All requests still use the existing consuming-app authentication and geocoding rate limits. Keep application credentials in a trusted backend or BFF and follow the Geocoding API guide for the response envelope, provider behavior, and other examples.
OpenStreetMap attribution
OpenStreetMap data is licensed under the Open Database License (ODbL). Credit OpenStreetMap and keep attribution visible wherever results are presented, for example © OpenStreetMap contributors. See the official attribution and license page.