Service for searching geospatial information
- Copy the contents of
.env.exampleto.envand modify it if needed - Run
docker compose up
The project is now running at localhost:8080
Prerequisites:
- PostgreSQL 17 or higher with PostGIS extension
- Python 3.12 or higher
- Run
pip install -r requirements.txt - Run
pip install -r requirements-dev.txt(development requirements)
To setup a database compatible with default database settings:
Create user and database
sudo -u postgres createuser -P -R -S geo-search # use password `geo-search`
sudo -u postgres createdb -O geo-search geo-search
Allow user to create test database
sudo -u postgres psql -c 'ALTER USER "geo-search" CREATEDB;'
Create the PostGIS extension if needed
sudo -u postgres psql -c 'CREATE EXTENSION postgis;'
The project includes convenient shell scripts for importing geospatial data from various sources.
scripts/import-municipalities-data.sh- Import municipalities from NLS (requires manual download)scripts/import-digiroad-data.sh- Import address data from Digiroad / Finnish Transport Infrastructure Agencyscripts/import-paavo-data.sh- Import postal code areas from Paavo / Statistics Finlandscripts/import-post-office-data.sh- Import post office names from Postiscripts/delete-address-data.sh- Delete all address data (with confirmation)
Important: Municipality data must be imported first, before importing addresses.
Municipality data must be manually downloaded from NLS:
-
Visit NLS Administrative Areas
-
Download the dataset following NLS's download process
-
Extract the ZIP file to a directory (e.g.,
/tmp/nls/) -
Run the import script:
./scripts/import-municipalities-data.sh /tmp/nls/SuomenKuntajako_2026_10k.shp
After municipalities are imported, import other data:
# Import addresses (required, specify province)
./scripts/import-digiroad-data.sh uusimaa
# Import postal code areas (optional, specify province)
./scripts/import-paavo-data.sh uusimaa
# Import post office names (optional, downloads latest data)
./scripts/import-post-office-data.sh
Available provinces: uusimaa and varsinais-suomi
To re-import data (e.g., after updates):
# Delete existing address data (prompts for confirmation)
./scripts/delete-address-data.sh
# Re-import municipalities if needed
./scripts/import-municipalities-data.sh /path/to/SuomenKuntajako_2026_10k.shp
# Re-import other data
./scripts/import-digiroad-data.sh uusimaa
./scripts/import-paavo-data.sh uusimaa
./scripts/import-post-office-data.sh
You can also use the Django management commands directly:
# Import municipalities (required first, manual download needed)
python manage.py import_municipalities <path-to-shapefile>
# Import addresses
python manage.py import_addresses <path-to-shapefiles> <province>
# Import postal code areas
python manage.py import_postal_code_areas <province> <path-to-shapefiles>
# Import post office names
python manage.py import_post_offices <path-to-zip-file>
# or download directly:
python manage.py import_post_offices --url <url-to-posti-zip>
# Delete all address data
python manage.py delete_address_data
- Add new packages to
requirements.inorrequirements-dev.in - Update
.txtfile for the changed requirements file:pip-compile requirements.inpip-compile requirements-dev.in
- If you want to update dependencies to their newest versions, run:
pip-compile -U requirements.inpip-compile -U requirements-dev.in
- To install Python requirements run:
pip-sync requirements.txt requirements-dev.txt
This project uses Ruff for code formatting and quality checking.
Basic ruff commands:
- lint:
ruff check - apply safe lint fixes:
ruff check --fix - check formatting:
ruff format --check - format:
ruff format
pre-commit can be used to install and
run all the formatting tools as git hooks automatically before a
commit.
New commit messages must adhere to the Conventional Commits specification, and line length is limited to 72 characters.
When pre-commit is in use,
commitlint
checks new commit messages for the correct format.
To use the REST API, you must be either logged in via the Django
admin interface (for debugging purposes), or an API key must be
provided in the Authorization header.
A new API key can be created in the Django admin interface under "API keys". When creating an API key, it will be shown to you only once, so make sure you copy it.
Clients must pass their API key via header. It must be formatted as follows:
Api-Key: <API_KEY>
Where <API_KEY> refers to the full generated API key.
By default, an API key or an active session is required to use the API.
To make the API completely public set REQUIRE_AUTHORIZATION=0 in your
environment variables.