mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 18:37:58 +00:00
Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1187d0ab9a | ||
|
|
ffe32af531 | ||
|
|
5baa827b8a | ||
|
|
3a3475acce | ||
|
|
b17cdb5740 | ||
|
|
069f3f5dea | ||
|
|
18f912b29f | ||
|
|
35e7e52501 | ||
|
|
067719481f | ||
|
|
8b6540c989 | ||
|
|
325392310f | ||
|
|
0265d6dafc | ||
|
|
637ef30af1 | ||
|
|
45c184d45b | ||
|
|
28770146f9 | ||
|
|
a9444a06c5 | ||
|
|
d756e5f0e5 | ||
|
|
fabe45f60a | ||
|
|
1de8bdaafe | ||
|
|
000a70639f | ||
|
|
6eadf6797e | ||
|
|
40b061afd2 | ||
|
|
eb3a6aa509 | ||
|
|
9f7e6da971 | ||
|
|
3729bdde7d | ||
|
|
f8df574b78 | ||
|
|
51f3485874 | ||
|
|
a0e107d57f | ||
|
|
b6ae3f3f09 | ||
|
|
4f1ddcd521 | ||
|
|
34d629f677 | ||
|
|
bb613a1d85 | ||
|
|
2fe0e0629a | ||
|
|
a0e4e123b1 | ||
|
|
92abae7850 | ||
|
|
6fe3dc63f5 | ||
|
|
e2dcc9ebf8 | ||
|
|
9b233362c6 | ||
|
|
a727624b9e | ||
|
|
3313369a39 | ||
|
|
7d140970b7 | ||
|
|
cfd631e99c | ||
|
|
3d39847e26 | ||
|
|
a664beb810 |
@@ -1,7 +0,0 @@
|
|||||||
# https://github.com/codespell-project/codespell
|
|
||||||
|
|
||||||
[codespell]
|
|
||||||
skip = ./man/nominatim.1,data,./docs/styles.css,lib-php,module,munin,osm2pgsql,./test,./settings/*.lua,./settings/*.yaml,./settings/**/*.yaml,./settings/icu-rules,./nominatim/tokenizer/token_analysis/config_variants.py
|
|
||||||
# Need to be lowercase in the list
|
|
||||||
# Unter = Unter den Linden (an example address)
|
|
||||||
ignore-words-list = inout,unter
|
|
||||||
3
.github/ISSUE_TEMPLATE/config.yml
vendored
3
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -2,6 +2,3 @@ contact_links:
|
|||||||
- name: Nominatim Discussions
|
- name: Nominatim Discussions
|
||||||
url: https://github.com/osm-search/Nominatim/discussions
|
url: https://github.com/osm-search/Nominatim/discussions
|
||||||
about: Ask questions, get support, share ideas and discuss with community members.
|
about: Ask questions, get support, share ideas and discuss with community members.
|
||||||
- name: Discussions about OpenStreetMap data
|
|
||||||
url: https://community.openstreetmap.org/
|
|
||||||
about: Ask questions about the data used by Nominatim and discuss with the OSM community.
|
|
||||||
|
|||||||
@@ -7,13 +7,10 @@ assignees: ''
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<!-- Note: if you are installing Nominatim through a docker image, you should report issues with the installation process with the docker repository first.
|
<!-- Note: if you are installing Nominatim through a docker image, you should report issues with the installation process with the docker repository first. -->
|
||||||
|
|
||||||
Do not send screen shots! Copy any console output directly into the issue.
|
|
||||||
-->
|
|
||||||
|
|
||||||
**Describe the bug**
|
**Describe the bug**
|
||||||
<!-- A clear and concise description of what the bug is.-->
|
<!-- A clear and concise description of what the bug is. -->
|
||||||
|
|
||||||
**To Reproduce**
|
**To Reproduce**
|
||||||
<!-- Please describe what you did to get to the issue. -->
|
<!-- Please describe what you did to get to the issue. -->
|
||||||
@@ -28,15 +25,12 @@ assignees: ''
|
|||||||
- RAM:
|
- RAM:
|
||||||
- number of CPUs:
|
- number of CPUs:
|
||||||
- type and size of disks:
|
- type and size of disks:
|
||||||
|
- bare metal/AWS/other cloud service:
|
||||||
|
|
||||||
**Postgresql Configuration:**
|
**Postgresql Configuration:**
|
||||||
|
|
||||||
<!-- List any configuration items you changed in your postgresql configuration. -->
|
<!-- List any configuration items you changed in your postgresql configuration. -->
|
||||||
|
|
||||||
**Nominatim Configuration:**
|
|
||||||
|
|
||||||
<!-- List the contents of your customized `.env` file. -->
|
|
||||||
|
|
||||||
**Additional context**
|
**Additional context**
|
||||||
|
|
||||||
<!-- Add any other context about the problem here. -->
|
<!-- Add any other context about the problem here. -->
|
||||||
|
|||||||
17
.github/actions/build-nominatim/action.yml
vendored
17
.github/actions/build-nominatim/action.yml
vendored
@@ -1,10 +1,10 @@
|
|||||||
name: 'Build Nominatim'
|
name: 'Build Nominatim'
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
flavour:
|
ubuntu:
|
||||||
description: 'Version of Ubuntu to install on'
|
description: 'Version of Ubuntu to install on'
|
||||||
required: false
|
required: false
|
||||||
default: 'ubuntu-20'
|
default: '20'
|
||||||
cmake-args:
|
cmake-args:
|
||||||
description: 'Additional options to hand to cmake'
|
description: 'Additional options to hand to cmake'
|
||||||
required: false
|
required: false
|
||||||
@@ -23,18 +23,17 @@ runs:
|
|||||||
sudo rm -rf /opt/hostedtoolcache/go /opt/hostedtoolcache/CodeQL /usr/lib/jvm /usr/local/share/chromium /usr/local/lib/android
|
sudo rm -rf /opt/hostedtoolcache/go /opt/hostedtoolcache/CodeQL /usr/lib/jvm /usr/local/share/chromium /usr/local/lib/android
|
||||||
df -h
|
df -h
|
||||||
shell: bash
|
shell: bash
|
||||||
- name: Install${{ matrix.flavour }} prerequisites
|
- name: Install prerequisites
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install -y -qq libboost-system-dev libboost-filesystem-dev libexpat1-dev zlib1g-dev libbz2-dev libpq-dev libproj-dev libicu-dev liblua${LUA_VERSION}-dev lua${LUA_VERSION} lua-dkjson nlohmann-json3-dev libspatialite7 libsqlite3-mod-spatialite
|
sudo apt-get install -y -qq libboost-system-dev libboost-filesystem-dev libexpat1-dev zlib1g-dev libbz2-dev libpq-dev libproj-dev libicu-dev liblua${LUA_VERSION}-dev lua${LUA_VERSION}
|
||||||
if [ "$FLAVOUR" == "oldstuff" ]; then
|
if [ "x$UBUNTUVER" == "x18" ]; then
|
||||||
pip3 install MarkupSafe==2.0.1 python-dotenv jinja2==2.8 psutil==5.4.2 pyicu==2.9 osmium PyYAML==5.1 sqlalchemy==1.4.31 psycopg==3.1.7 datrie asyncpg aiosqlite
|
pip3 install python-dotenv psycopg2==2.7.7 jinja2==2.8 psutil==5.4.2 pyicu==2.9 osmium PyYAML==5.1 datrie
|
||||||
else
|
else
|
||||||
sudo apt-get install -y -qq python3-icu python3-datrie python3-pyosmium python3-jinja2 python3-psutil python3-dotenv python3-yaml
|
sudo apt-get install -y -qq python3-icu python3-datrie python3-pyosmium python3-jinja2 python3-psutil python3-psycopg2 python3-dotenv python3-yaml
|
||||||
pip3 install sqlalchemy psycopg aiosqlite
|
|
||||||
fi
|
fi
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
FLAVOUR: ${{ inputs.flavour }}
|
UBUNTUVER: ${{ inputs.ubuntu }}
|
||||||
CMAKE_ARGS: ${{ inputs.cmake-args }}
|
CMAKE_ARGS: ${{ inputs.cmake-args }}
|
||||||
LUA_VERSION: ${{ inputs.lua }}
|
LUA_VERSION: ${{ inputs.lua }}
|
||||||
|
|
||||||
|
|||||||
299
.github/workflows/ci-tests.yml
vendored
299
.github/workflows/ci-tests.yml
vendored
@@ -7,11 +7,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
|
|
||||||
- uses: actions/cache@v4
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
data/country_osm_grid.sql.gz
|
data/country_osm_grid.sql.gz
|
||||||
@@ -27,7 +27,7 @@ jobs:
|
|||||||
mv nominatim-src.tar.bz2 Nominatim
|
mv nominatim-src.tar.bz2 Nominatim
|
||||||
|
|
||||||
- name: 'Upload Artifact'
|
- name: 'Upload Artifact'
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: full-source
|
name: full-source
|
||||||
path: nominatim-src.tar.bz2
|
path: nominatim-src.tar.bz2
|
||||||
@@ -37,38 +37,47 @@ jobs:
|
|||||||
needs: create-archive
|
needs: create-archive
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
flavour: [oldstuff, "ubuntu-20", "ubuntu-22"]
|
ubuntu: [18, 20, 22]
|
||||||
include:
|
include:
|
||||||
- flavour: oldstuff
|
- ubuntu: 18
|
||||||
ubuntu: 20
|
postgresql: 9.6
|
||||||
postgresql: '9.6'
|
postgis: 2.5
|
||||||
postgis: '2.5'
|
pytest: pytest
|
||||||
lua: '5.1'
|
php: 7.2
|
||||||
- flavour: ubuntu-20
|
- ubuntu: 20
|
||||||
ubuntu: 20
|
|
||||||
postgresql: 13
|
postgresql: 13
|
||||||
postgis: 3
|
postgis: 3
|
||||||
lua: '5.3'
|
pytest: py.test-3
|
||||||
- flavour: ubuntu-22
|
php: 7.4
|
||||||
ubuntu: 22
|
- ubuntu: 22
|
||||||
postgresql: 15
|
postgresql: 15
|
||||||
postgis: 3
|
postgis: 3
|
||||||
lua: '5.3'
|
pytest: py.test-3
|
||||||
|
php: 8.1
|
||||||
|
|
||||||
runs-on: ubuntu-${{ matrix.ubuntu }}.04
|
runs-on: ubuntu-${{ matrix.ubuntu }}.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: full-source
|
name: full-source
|
||||||
|
|
||||||
- name: Unpack Nominatim
|
- name: Unpack Nominatim
|
||||||
run: tar xf nominatim-src.tar.bz2
|
run: tar xf nominatim-src.tar.bz2
|
||||||
|
|
||||||
- uses: actions/setup-python@v5
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
python-version: 3.7
|
php-version: ${{ matrix.php }}
|
||||||
if: matrix.flavour == 'oldstuff'
|
tools: phpunit:9, phpcs, composer
|
||||||
|
ini-values: opcache.jit=disable
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: 3.6
|
||||||
|
if: matrix.ubuntu == 18
|
||||||
|
|
||||||
- uses: ./Nominatim/.github/actions/setup-postgresql
|
- uses: ./Nominatim/.github/actions/setup-postgresql
|
||||||
with:
|
with:
|
||||||
@@ -77,70 +86,63 @@ jobs:
|
|||||||
|
|
||||||
- uses: ./Nominatim/.github/actions/build-nominatim
|
- uses: ./Nominatim/.github/actions/build-nominatim
|
||||||
with:
|
with:
|
||||||
flavour: ${{ matrix.flavour }}
|
ubuntu: ${{ matrix.ubuntu }}
|
||||||
lua: ${{ matrix.lua }}
|
|
||||||
|
|
||||||
- name: Install test prerequisites (behave from apt)
|
- name: Install test prerequsites
|
||||||
run: sudo apt-get install -y -qq python3-behave
|
run: sudo apt-get install -y -qq python3-pytest python3-behave
|
||||||
if: matrix.flavour == 'ubuntu-20'
|
if: matrix.ubuntu == 20
|
||||||
|
|
||||||
- name: Install test prerequisites (behave from pip)
|
- name: Install test prerequsites
|
||||||
run: pip3 install behave==1.2.6
|
run: pip3 install pylint pytest behave==1.2.6
|
||||||
if: (matrix.flavour == 'oldstuff') || (matrix.flavour == 'ubuntu-22')
|
if: ${{ (matrix.ubuntu == 18) || (matrix.ubuntu == 22) }}
|
||||||
|
|
||||||
- name: Install test prerequisites (from apt for Ununtu 2x)
|
- name: Install test prerequsites
|
||||||
run: sudo apt-get install -y -qq python3-pytest python3-pytest-asyncio uvicorn
|
run: sudo apt-get install -y -qq python3-pytest
|
||||||
if: matrix.flavour != 'oldstuff'
|
if: matrix.ubuntu == 22
|
||||||
|
|
||||||
- name: Install newer pytest-asyncio
|
- name: Install latest pylint/mypy
|
||||||
run: pip3 install -U pytest-asyncio
|
run: pip3 install -U pylint mypy types-PyYAML types-jinja2 types-psycopg2 types-psutil types-requests typing-extensions
|
||||||
if: matrix.flavour == 'ubuntu-20'
|
if: matrix.ubuntu == 22
|
||||||
|
|
||||||
- name: Install test prerequisites (from pip for Ubuntu 18)
|
- name: PHP linting
|
||||||
run: pip3 install pytest pytest-asyncio uvicorn
|
run: phpcs --report-width=120 .
|
||||||
if: matrix.flavour == 'oldstuff'
|
working-directory: Nominatim
|
||||||
|
if: matrix.ubuntu == 22
|
||||||
- name: Install Python webservers
|
|
||||||
run: pip3 install falcon starlette asgi_lifespan
|
|
||||||
|
|
||||||
- name: Install latest pylint
|
|
||||||
run: pip3 install -U pylint
|
|
||||||
if: matrix.flavour == 'ubuntu-22'
|
|
||||||
|
|
||||||
- name: Python linting
|
- name: Python linting
|
||||||
run: python3 -m pylint src
|
run: pylint nominatim
|
||||||
working-directory: Nominatim
|
working-directory: Nominatim
|
||||||
if: matrix.flavour == 'ubuntu-22'
|
if: matrix.ubuntu == 22
|
||||||
|
|
||||||
|
- name: Python static typechecking
|
||||||
|
run: mypy --strict nominatim
|
||||||
|
working-directory: Nominatim
|
||||||
|
if: matrix.ubuntu == 22
|
||||||
|
|
||||||
|
|
||||||
|
- name: PHP unit tests
|
||||||
|
run: phpunit ./
|
||||||
|
working-directory: Nominatim/test/php
|
||||||
|
if: ${{ (matrix.ubuntu == 20) || (matrix.ubuntu == 22) }}
|
||||||
|
|
||||||
- name: Python unit tests
|
- name: Python unit tests
|
||||||
run: python3 -m pytest test/python
|
run: $PYTEST test/python
|
||||||
working-directory: Nominatim
|
working-directory: Nominatim
|
||||||
|
env:
|
||||||
|
PYTEST: ${{ matrix.pytest }}
|
||||||
|
|
||||||
- name: BDD tests
|
- name: BDD tests
|
||||||
run: |
|
run: |
|
||||||
export PATH=$GITHUB_WORKSPACE/build/osm2pgsql:$PATH
|
behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build --format=progress3
|
||||||
python3 -m behave -DREMOVE_TEMPLATE=1 --format=progress3
|
|
||||||
working-directory: Nominatim/test/bdd
|
working-directory: Nominatim/test/bdd
|
||||||
|
|
||||||
- name: Install mypy and typechecking info
|
|
||||||
run: pip3 install -U mypy osmium uvicorn types-PyYAML types-jinja2 types-psycopg2 types-psutil types-requests types-ujson types-Pygments typing-extensions
|
|
||||||
if: matrix.flavour != 'oldstuff'
|
|
||||||
|
|
||||||
- name: Python static typechecking
|
|
||||||
run: python3 -m mypy --strict src
|
|
||||||
working-directory: Nominatim
|
|
||||||
if: matrix.flavour != 'oldstuff'
|
|
||||||
|
|
||||||
legacy-test:
|
legacy-test:
|
||||||
needs: create-archive
|
needs: create-archive
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
postgresql: ["13", "16"]
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: full-source
|
name: full-source
|
||||||
|
|
||||||
@@ -150,77 +152,27 @@ jobs:
|
|||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '7.4'
|
php-version: 7.4
|
||||||
|
|
||||||
- uses: ./Nominatim/.github/actions/setup-postgresql
|
- uses: ./Nominatim/.github/actions/setup-postgresql
|
||||||
with:
|
with:
|
||||||
postgresql-version: ${{ matrix.postgresql }}
|
postgresql-version: 13
|
||||||
postgis-version: 3
|
postgis-version: 3
|
||||||
|
|
||||||
- name: Install Postgresql server dev
|
- name: Install Postgresql server dev
|
||||||
run: sudo apt-get install postgresql-server-dev-$PGVER
|
run: sudo apt-get install postgresql-server-dev-13
|
||||||
env:
|
|
||||||
PGVER: ${{ matrix.postgresql }}
|
|
||||||
|
|
||||||
- uses: ./Nominatim/.github/actions/build-nominatim
|
- uses: ./Nominatim/.github/actions/build-nominatim
|
||||||
with:
|
with:
|
||||||
|
ubuntu: 20
|
||||||
cmake-args: -DBUILD_MODULE=on
|
cmake-args: -DBUILD_MODULE=on
|
||||||
|
|
||||||
- name: Install test prerequisites
|
- name: Install test prerequsites
|
||||||
run: sudo apt-get install -y -qq python3-behave
|
run: sudo apt-get install -y -qq python3-behave
|
||||||
|
|
||||||
- name: BDD tests (legacy tokenizer)
|
- name: BDD tests (legacy tokenizer)
|
||||||
run: |
|
run: |
|
||||||
export PATH=$GITHUB_WORKSPACE/build/osm2pgsql:$PATH
|
behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build -DTOKENIZER=legacy --format=progress3
|
||||||
python3 -m behave -DREMOVE_TEMPLATE=1 -DSERVER_MODULE_PATH=$GITHUB_WORKSPACE/build/module -DAPI_ENGINE=php -DTOKENIZER=legacy --format=progress3
|
|
||||||
working-directory: Nominatim/test/bdd
|
|
||||||
|
|
||||||
|
|
||||||
php-test:
|
|
||||||
needs: create-archive
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: full-source
|
|
||||||
|
|
||||||
- name: Unpack Nominatim
|
|
||||||
run: tar xf nominatim-src.tar.bz2
|
|
||||||
|
|
||||||
- uses: ./Nominatim/.github/actions/setup-postgresql
|
|
||||||
with:
|
|
||||||
postgresql-version: 15
|
|
||||||
postgis-version: 3
|
|
||||||
|
|
||||||
- name: Setup PHP
|
|
||||||
uses: shivammathur/setup-php@v2
|
|
||||||
with:
|
|
||||||
php-version: 8.1
|
|
||||||
tools: phpunit:9, phpcs, composer
|
|
||||||
ini-values: opcache.jit=disable
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: PHP linting
|
|
||||||
run: phpcs --report-width=120 .
|
|
||||||
working-directory: Nominatim
|
|
||||||
|
|
||||||
- name: PHP unit tests
|
|
||||||
run: phpunit ./
|
|
||||||
working-directory: Nominatim/test/php
|
|
||||||
|
|
||||||
- uses: ./Nominatim/.github/actions/build-nominatim
|
|
||||||
with:
|
|
||||||
flavour: 'ubuntu-22'
|
|
||||||
|
|
||||||
- name: Install test prerequisites
|
|
||||||
run: sudo apt-get install -y -qq python3-behave
|
|
||||||
|
|
||||||
- name: BDD tests (php)
|
|
||||||
run: |
|
|
||||||
export PATH=$GITHUB_WORKSPACE/build/osm2pgsql:$PATH
|
|
||||||
python3 -m behave -DREMOVE_TEMPLATE=1 -DAPI_ENGINE=php --format=progress3
|
|
||||||
working-directory: Nominatim/test/bdd
|
working-directory: Nominatim/test/bdd
|
||||||
|
|
||||||
|
|
||||||
@@ -230,16 +182,23 @@ jobs:
|
|||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
name: [Ubuntu-22, Ubuntu-24]
|
name: [Ubuntu-18, Ubuntu-20, Ubuntu-22]
|
||||||
include:
|
include:
|
||||||
|
- name: Ubuntu-18
|
||||||
|
flavour: ubuntu
|
||||||
|
image: "ubuntu:18.04"
|
||||||
|
ubuntu: 18
|
||||||
|
install_mode: install-nginx
|
||||||
|
- name: Ubuntu-20
|
||||||
|
flavour: ubuntu
|
||||||
|
image: "ubuntu:20.04"
|
||||||
|
ubuntu: 20
|
||||||
|
install_mode: install-apache
|
||||||
- name: Ubuntu-22
|
- name: Ubuntu-22
|
||||||
|
flavour: ubuntu
|
||||||
image: "ubuntu:22.04"
|
image: "ubuntu:22.04"
|
||||||
ubuntu: 22
|
ubuntu: 22
|
||||||
install_mode: install-apache
|
install_mode: install-apache
|
||||||
- name: Ubuntu-24
|
|
||||||
image: "ubuntu:24.04"
|
|
||||||
ubuntu: 24
|
|
||||||
install_mode: install-apache
|
|
||||||
|
|
||||||
container:
|
container:
|
||||||
image: ${{ matrix.image }}
|
image: ${{ matrix.image }}
|
||||||
@@ -259,6 +218,14 @@ jobs:
|
|||||||
apt-get install -y git sudo wget
|
apt-get install -y git sudo wget
|
||||||
ln -snf /usr/share/zoneinfo/$CONTAINER_TIMEZONE /etc/localtime && echo $CONTAINER_TIMEZONE > /etc/timezone
|
ln -snf /usr/share/zoneinfo/$CONTAINER_TIMEZONE /etc/localtime && echo $CONTAINER_TIMEZONE > /etc/timezone
|
||||||
shell: bash
|
shell: bash
|
||||||
|
if: matrix.flavour == 'ubuntu'
|
||||||
|
|
||||||
|
- name: Prepare container (CentOS)
|
||||||
|
run: |
|
||||||
|
dnf update -y
|
||||||
|
dnf install -y sudo glibc-langpack-en
|
||||||
|
shell: bash
|
||||||
|
if: matrix.flavour == 'centos'
|
||||||
|
|
||||||
- name: Setup import user
|
- name: Setup import user
|
||||||
run: |
|
run: |
|
||||||
@@ -270,7 +237,7 @@ jobs:
|
|||||||
OS: ${{ matrix.name }}
|
OS: ${{ matrix.name }}
|
||||||
INSTALL_MODE: ${{ matrix.install_mode }}
|
INSTALL_MODE: ${{ matrix.install_mode }}
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: full-source
|
name: full-source
|
||||||
path: /home/nominatim
|
path: /home/nominatim
|
||||||
@@ -288,35 +255,26 @@ jobs:
|
|||||||
- name: Prepare import environment
|
- name: Prepare import environment
|
||||||
run: |
|
run: |
|
||||||
mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
|
mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
|
||||||
mv Nominatim/settings/flex-base.lua flex-base.lua
|
|
||||||
mv Nominatim/settings/import-extratags.lua import-extratags.lua
|
|
||||||
mv Nominatim/settings/taginfo.lua taginfo.lua
|
|
||||||
rm -rf Nominatim
|
rm -rf Nominatim
|
||||||
mkdir data-env-reverse
|
mkdir data-env-reverse
|
||||||
working-directory: /home/nominatim
|
working-directory: /home/nominatim
|
||||||
|
|
||||||
- name: Add nominatim to path
|
- name: Prepare import environment (CentOS)
|
||||||
run: |
|
run: |
|
||||||
sudo ln -s /home/nominatim/nominatim-venv/bin/nominatim /usr/local/bin/nominatim
|
sudo ln -s /usr/local/bin/nominatim /usr/bin/nominatim
|
||||||
if: matrix.ubuntu == 24
|
echo NOMINATIM_DATABASE_WEBUSER="apache" > nominatim-project/.env
|
||||||
|
cp nominatim-project/.env data-env-reverse/.env
|
||||||
- name: Need lua binary
|
working-directory: /home/nominatim
|
||||||
run: |
|
if: matrix.flavour == 'centos'
|
||||||
sudo apt-get install -y lua5.4 lua-dkjson
|
|
||||||
if: matrix.ubuntu == 24
|
|
||||||
|
|
||||||
- name: Print version
|
- name: Print version
|
||||||
run: nominatim --version
|
run: nominatim --version
|
||||||
working-directory: /home/nominatim/nominatim-project
|
working-directory: /home/nominatim/nominatim-project
|
||||||
|
|
||||||
- name: Print taginfo
|
|
||||||
run: lua taginfo.lua
|
|
||||||
working-directory: /home/nominatim
|
|
||||||
|
|
||||||
- name: Collect host OS information
|
- name: Collect host OS information
|
||||||
run: nominatim admin --collect-os-info
|
run: nominatim admin --collect-os-info
|
||||||
working-directory: /home/nominatim/nominatim-project
|
working-directory: /home/nominatim/nominatim-project
|
||||||
|
|
||||||
- name: Import
|
- name: Import
|
||||||
run: nominatim import --osm-file ../test.pbf
|
run: nominatim import --osm-file ../test.pbf
|
||||||
working-directory: /home/nominatim/nominatim-project
|
working-directory: /home/nominatim/nominatim-project
|
||||||
@@ -336,19 +294,11 @@ jobs:
|
|||||||
- name: Prepare update (Ubuntu)
|
- name: Prepare update (Ubuntu)
|
||||||
run: apt-get install -y python3-pip
|
run: apt-get install -y python3-pip
|
||||||
shell: bash
|
shell: bash
|
||||||
|
if: matrix.flavour == 'ubuntu'
|
||||||
- name: Install osmium (Ubuntu 22)
|
|
||||||
run: |
|
|
||||||
pip3 install --user osmium
|
|
||||||
if: matrix.ubuntu == 22
|
|
||||||
|
|
||||||
- name: Install osmium (Ubuntu 24)
|
|
||||||
run: |
|
|
||||||
/home/nominatim/nominatim-venv/bin/pip install osmium
|
|
||||||
if: matrix.ubuntu == 24
|
|
||||||
|
|
||||||
- name: Run update
|
- name: Run update
|
||||||
run: |
|
run: |
|
||||||
|
pip3 install --user osmium
|
||||||
nominatim replication --init
|
nominatim replication --init
|
||||||
NOMINATIM_REPLICATION_MAX_DIFF=1 nominatim replication --once
|
NOMINATIM_REPLICATION_MAX_DIFF=1 nominatim replication --once
|
||||||
working-directory: /home/nominatim/nominatim-project
|
working-directory: /home/nominatim/nominatim-project
|
||||||
@@ -370,54 +320,3 @@ jobs:
|
|||||||
- name: Clean up database (reverse-only import)
|
- name: Clean up database (reverse-only import)
|
||||||
run: nominatim refresh --postcodes --word-tokens
|
run: nominatim refresh --postcodes --word-tokens
|
||||||
working-directory: /home/nominatim/nominatim-project
|
working-directory: /home/nominatim/nominatim-project
|
||||||
|
|
||||||
install-no-superuser:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: create-archive
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: full-source
|
|
||||||
|
|
||||||
- name: Unpack Nominatim
|
|
||||||
run: tar xf nominatim-src.tar.bz2
|
|
||||||
|
|
||||||
- uses: ./Nominatim/.github/actions/setup-postgresql
|
|
||||||
with:
|
|
||||||
postgresql-version: 16
|
|
||||||
postgis-version: 3
|
|
||||||
|
|
||||||
- uses: ./Nominatim/.github/actions/build-nominatim
|
|
||||||
with:
|
|
||||||
flavour: ubuntu-22
|
|
||||||
lua: 5.3
|
|
||||||
|
|
||||||
- name: Prepare import environment
|
|
||||||
run: |
|
|
||||||
mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
|
|
||||||
rm -rf Nominatim
|
|
||||||
|
|
||||||
- name: Prepare Database
|
|
||||||
run: |
|
|
||||||
nominatim import --prepare-database
|
|
||||||
|
|
||||||
- name: Create import user
|
|
||||||
run: |
|
|
||||||
sudo -u postgres createuser osm-import
|
|
||||||
psql -d nominatim -c "ALTER USER \"osm-import\" WITH PASSWORD 'osm-import'"
|
|
||||||
psql -d nominatim -c 'GRANT CREATE ON SCHEMA public TO "osm-import"'
|
|
||||||
|
|
||||||
- name: Run import
|
|
||||||
run: |
|
|
||||||
NOMINATIM_DATABASE_DSN="pgsql:host=127.0.0.1;dbname=nominatim;user=osm-import;password=osm-import" nominatim import --continue import-from-file --osm-file test.pbf
|
|
||||||
|
|
||||||
- name: Check full import
|
|
||||||
run: nominatim admin --check-database
|
|
||||||
|
|
||||||
codespell:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: codespell-project/actions-codespell@v2
|
|
||||||
with:
|
|
||||||
only_warn: 1
|
|
||||||
|
|||||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,13 +1,9 @@
|
|||||||
*.log
|
*.log
|
||||||
*.pyc
|
*.pyc
|
||||||
*.swp
|
|
||||||
|
|
||||||
docs/develop/*.png
|
docs/develop/*.png
|
||||||
site-html
|
|
||||||
|
|
||||||
build
|
build
|
||||||
dist
|
|
||||||
.coverage
|
|
||||||
|
|
||||||
.vagrant
|
.vagrant
|
||||||
data/country_osm_grid.sql.gz
|
data/country_osm_grid.sql.gz
|
||||||
|
|||||||
12
.mypy.ini
12
.mypy.ini
@@ -1,13 +1,9 @@
|
|||||||
[mypy]
|
[mypy]
|
||||||
plugins = sqlalchemy.ext.mypy.plugin
|
|
||||||
|
|
||||||
[mypy-sanic_cors.*]
|
|
||||||
ignore_missing_imports = True
|
|
||||||
|
|
||||||
[mypy-icu.*]
|
[mypy-icu.*]
|
||||||
ignore_missing_imports = True
|
ignore_missing_imports = True
|
||||||
|
|
||||||
[mypy-asyncpg.*]
|
[mypy-osmium.*]
|
||||||
ignore_missing_imports = True
|
ignore_missing_imports = True
|
||||||
|
|
||||||
[mypy-datrie.*]
|
[mypy-datrie.*]
|
||||||
@@ -15,9 +11,3 @@ ignore_missing_imports = True
|
|||||||
|
|
||||||
[mypy-dotenv.*]
|
[mypy-dotenv.*]
|
||||||
ignore_missing_imports = True
|
ignore_missing_imports = True
|
||||||
|
|
||||||
[mypy-falcon.*]
|
|
||||||
ignore_missing_imports = True
|
|
||||||
|
|
||||||
[mypy-geoalchemy2.*]
|
|
||||||
ignore_missing_imports = True
|
|
||||||
|
|||||||
10
.pylintrc
10
.pylintrc
@@ -1,6 +1,6 @@
|
|||||||
[MASTER]
|
[MASTER]
|
||||||
|
|
||||||
extension-pkg-whitelist=osmium,falcon
|
extension-pkg-whitelist=osmium
|
||||||
ignored-modules=icu,datrie
|
ignored-modules=icu,datrie
|
||||||
|
|
||||||
[MESSAGES CONTROL]
|
[MESSAGES CONTROL]
|
||||||
@@ -13,10 +13,6 @@ ignored-classes=NominatimArgs,closing
|
|||||||
# 'too-many-ancestors' is triggered already by deriving from UserDict
|
# 'too-many-ancestors' is triggered already by deriving from UserDict
|
||||||
# 'not-context-manager' disabled because it causes false positives once
|
# 'not-context-manager' disabled because it causes false positives once
|
||||||
# typed Python is enabled. See also https://github.com/PyCQA/pylint/issues/5273
|
# typed Python is enabled. See also https://github.com/PyCQA/pylint/issues/5273
|
||||||
disable=too-few-public-methods,duplicate-code,too-many-ancestors,bad-option-value,no-self-use,not-context-manager,use-dict-literal,chained-comparison,attribute-defined-outside-init,too-many-boolean-expressions,contextmanager-generator-missing-cleanup
|
disable=too-few-public-methods,duplicate-code,too-many-ancestors,bad-option-value,no-self-use,not-context-manager,use-dict-literal
|
||||||
|
|
||||||
good-names=i,j,x,y,m,t,fd,db,cc,x1,x2,y1,y2,pt,k,v,nr
|
good-names=i,x,y,m,fd,db,cc
|
||||||
|
|
||||||
[DESIGN]
|
|
||||||
|
|
||||||
max-returns=7
|
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
|||||||
project(nominatim)
|
project(nominatim)
|
||||||
|
|
||||||
set(NOMINATIM_VERSION_MAJOR 4)
|
set(NOMINATIM_VERSION_MAJOR 4)
|
||||||
set(NOMINATIM_VERSION_MINOR 5)
|
set(NOMINATIM_VERSION_MINOR 2)
|
||||||
set(NOMINATIM_VERSION_PATCH 0)
|
set(NOMINATIM_VERSION_PATCH 3)
|
||||||
|
|
||||||
set(NOMINATIM_VERSION "${NOMINATIM_VERSION_MAJOR}.${NOMINATIM_VERSION_MINOR}.${NOMINATIM_VERSION_PATCH}")
|
set(NOMINATIM_VERSION "${NOMINATIM_VERSION_MAJOR}.${NOMINATIM_VERSION_MINOR}.${NOMINATIM_VERSION_PATCH}")
|
||||||
|
|
||||||
@@ -46,6 +46,8 @@ set(BUILD_IMPORTER on CACHE BOOL "Build everything for importing/updating the da
|
|||||||
set(BUILD_API on CACHE BOOL "Build everything for the API server")
|
set(BUILD_API on CACHE BOOL "Build everything for the API server")
|
||||||
set(BUILD_MODULE off CACHE BOOL "Build PostgreSQL module for legacy tokenizer")
|
set(BUILD_MODULE off CACHE BOOL "Build PostgreSQL module for legacy tokenizer")
|
||||||
set(BUILD_TESTS on CACHE BOOL "Build test suite")
|
set(BUILD_TESTS on CACHE BOOL "Build test suite")
|
||||||
|
set(BUILD_DOCS on CACHE BOOL "Build documentation")
|
||||||
|
set(BUILD_MANPAGE on CACHE BOOL "Build Manual Page")
|
||||||
set(BUILD_OSM2PGSQL on CACHE BOOL "Build osm2pgsql (expert only)")
|
set(BUILD_OSM2PGSQL on CACHE BOOL "Build osm2pgsql (expert only)")
|
||||||
set(INSTALL_MUNIN_PLUGINS on CACHE BOOL "Install Munin plugins for supervising Nominatim")
|
set(INSTALL_MUNIN_PLUGINS on CACHE BOOL "Install Munin plugins for supervising Nominatim")
|
||||||
|
|
||||||
@@ -70,8 +72,8 @@ endif()
|
|||||||
# python (imports/updates only)
|
# python (imports/updates only)
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
|
|
||||||
if (BUILD_IMPORTER OR BUILD_API)
|
if (BUILD_IMPORTER)
|
||||||
find_package(PythonInterp 3.7 REQUIRED)
|
find_package(PythonInterp 3.6 REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
@@ -80,17 +82,26 @@ endif()
|
|||||||
|
|
||||||
# Setting PHP binary variable as to command line (prevailing) or auto detect
|
# Setting PHP binary variable as to command line (prevailing) or auto detect
|
||||||
|
|
||||||
if (BUILD_API)
|
if (BUILD_API OR BUILD_IMPORTER)
|
||||||
if (NOT PHP_BIN)
|
if (NOT PHP_BIN)
|
||||||
find_program (PHP_BIN php)
|
find_program (PHP_BIN php)
|
||||||
endif()
|
endif()
|
||||||
# sanity check if PHP binary exists
|
# sanity check if PHP binary exists
|
||||||
if (NOT EXISTS ${PHP_BIN})
|
if (NOT EXISTS ${PHP_BIN})
|
||||||
message(WARNING "PHP binary not found. Only Python frontend can be used.")
|
message(FATAL_ERROR "PHP binary not found. Install php or provide location with -DPHP_BIN=/path/php ")
|
||||||
set(PHP_BIN "")
|
|
||||||
else()
|
else()
|
||||||
message (STATUS "Using PHP binary " ${PHP_BIN})
|
message (STATUS "Using PHP binary " ${PHP_BIN})
|
||||||
endif()
|
endif()
|
||||||
|
if (NOT PHPCGI_BIN)
|
||||||
|
find_program (PHPCGI_BIN php-cgi)
|
||||||
|
endif()
|
||||||
|
# sanity check if PHP binary exists
|
||||||
|
if (NOT EXISTS ${PHPCGI_BIN})
|
||||||
|
message(WARNING "php-cgi binary not found. nominatim tool will not provide query functions.")
|
||||||
|
set (PHPCGI_BIN "")
|
||||||
|
else()
|
||||||
|
message (STATUS "Using php-cgi binary " ${PHPCGI_BIN})
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
@@ -186,6 +197,22 @@ if (BUILD_MODULE)
|
|||||||
add_subdirectory(module)
|
add_subdirectory(module)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Documentation
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if (BUILD_DOCS)
|
||||||
|
add_subdirectory(docs)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Manual page
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if (BUILD_MANPAGE)
|
||||||
|
add_subdirectory(man)
|
||||||
|
endif()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Installation
|
# Installation
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
@@ -203,23 +230,10 @@ if (BUILD_IMPORTER)
|
|||||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
RENAME nominatim)
|
RENAME nominatim)
|
||||||
|
|
||||||
if (EXISTS ${PHP_BIN})
|
install(DIRECTORY nominatim
|
||||||
configure_file(${PROJECT_SOURCE_DIR}/cmake/paths-py.tmpl paths-py.installed)
|
DESTINATION ${NOMINATIM_LIBDIR}/lib-python
|
||||||
else()
|
FILES_MATCHING PATTERN "*.py"
|
||||||
configure_file(${PROJECT_SOURCE_DIR}/cmake/paths-py-no-php.tmpl paths-py.installed)
|
PATTERN __pycache__ EXCLUDE)
|
||||||
endif()
|
|
||||||
|
|
||||||
foreach (submodule nominatim_db nominatim_api)
|
|
||||||
install(DIRECTORY src/${submodule}
|
|
||||||
DESTINATION ${NOMINATIM_LIBDIR}/lib-python
|
|
||||||
FILES_MATCHING PATTERN "*.py"
|
|
||||||
PATTERN "paths.py" EXCLUDE
|
|
||||||
PATTERN __pycache__ EXCLUDE)
|
|
||||||
install(FILES ${PROJECT_BINARY_DIR}/paths-py.installed
|
|
||||||
DESTINATION ${NOMINATIM_LIBDIR}/lib-python/${submodule}
|
|
||||||
RENAME paths.py)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
install(DIRECTORY lib-sql DESTINATION ${NOMINATIM_LIBDIR})
|
install(DIRECTORY lib-sql DESTINATION ${NOMINATIM_LIBDIR})
|
||||||
|
|
||||||
install(FILES ${COUNTRY_GRID_FILE}
|
install(FILES ${COUNTRY_GRID_FILE}
|
||||||
@@ -243,13 +257,18 @@ if (BUILD_MODULE)
|
|||||||
DESTINATION ${NOMINATIM_LIBDIR}/module)
|
DESTINATION ${NOMINATIM_LIBDIR}/module)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (BUILD_API AND EXISTS ${PHP_BIN})
|
if (BUILD_API)
|
||||||
install(DIRECTORY lib-php DESTINATION ${NOMINATIM_LIBDIR})
|
install(DIRECTORY lib-php DESTINATION ${NOMINATIM_LIBDIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(FILES settings/env.defaults
|
install(FILES settings/env.defaults
|
||||||
settings/address-levels.json
|
settings/address-levels.json
|
||||||
settings/phrase-settings.json
|
settings/phrase-settings.json
|
||||||
|
settings/import-admin.style
|
||||||
|
settings/import-street.style
|
||||||
|
settings/import-address.style
|
||||||
|
settings/import-full.style
|
||||||
|
settings/import-extratags.style
|
||||||
settings/import-admin.lua
|
settings/import-admin.lua
|
||||||
settings/import-street.lua
|
settings/import-street.lua
|
||||||
settings/import-address.lua
|
settings/import-address.lua
|
||||||
@@ -271,7 +290,3 @@ if (INSTALL_MUNIN_PLUGINS)
|
|||||||
munin/nominatim_requests
|
munin/nominatim_requests
|
||||||
DESTINATION ${NOMINATIM_MUNINDIR})
|
DESTINATION ${NOMINATIM_MUNINDIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(WARNING "Building with CMake is deprecated and will be removed in Nominatim 5.0."
|
|
||||||
"Use Nominatim pip packages instead.\n"
|
|
||||||
"See https://nominatim.org/release-docs/develop/admin/Installation/#downloading-and-building-nominatim")
|
|
||||||
|
|||||||
@@ -69,16 +69,13 @@ Before submitting a pull request make sure that the tests pass:
|
|||||||
|
|
||||||
Nominatim follows semantic versioning. Major releases are done for large changes
|
Nominatim follows semantic versioning. Major releases are done for large changes
|
||||||
that require (or at least strongly recommend) a reimport of the databases.
|
that require (or at least strongly recommend) a reimport of the databases.
|
||||||
Minor releases can usually be applied to existing databases. Patch releases
|
Minor releases can usually be applied to exisiting databases Patch releases
|
||||||
contain bug fixes only and are released from a separate branch where the
|
contain bug fixes only and are released from a separate branch where the
|
||||||
relevant changes are cherry-picked from the master branch.
|
relevant changes are cherry-picked from the master branch.
|
||||||
|
|
||||||
Checklist for releases:
|
Checklist for releases:
|
||||||
|
|
||||||
* [ ] increase versions in
|
* [ ] increase version in `nominatim/version.py` and CMakeLists.txt
|
||||||
* `src/nominatim_api/version.py`
|
|
||||||
* `src/nominatim_db/version.py`
|
|
||||||
* CMakeLists.txt
|
|
||||||
* [ ] update `ChangeLog` (copy information from patch releases from release branch)
|
* [ ] update `ChangeLog` (copy information from patch releases from release branch)
|
||||||
* [ ] complete `docs/admin/Migration.md`
|
* [ ] complete `docs/admin/Migration.md`
|
||||||
* [ ] update EOL dates in `SECURITY.md`
|
* [ ] update EOL dates in `SECURITY.md`
|
||||||
@@ -103,4 +100,3 @@ Checklist for releases:
|
|||||||
* compile and import Nominatim
|
* compile and import Nominatim
|
||||||
* run `nominatim --version` to confirm correct version
|
* run `nominatim --version` to confirm correct version
|
||||||
* [ ] tag new release and add a release on github.com
|
* [ ] tag new release and add a release on github.com
|
||||||
* [ ] build pip packages and upload to pypi
|
|
||||||
|
|||||||
557
COPYING
557
COPYING
@@ -1,232 +1,339 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
Version 2, June 1991
|
||||||
|
|
||||||
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
Preamble
|
|
||||||
|
Preamble
|
||||||
The GNU General Public License is a free, copyleft license for software and other kinds of works.
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and modification follow.
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
TERMS AND CONDITIONS
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
0. Definitions.
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
“This License” refers to version 3 of the GNU General Public License.
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
A “covered work” means either the unmodified Program or a work based on the Program.
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
authors' reputations.
|
||||||
|
|
||||||
1. Source Code.
|
Finally, any free program is threatened constantly by software
|
||||||
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
|
modification follow.
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
The Corresponding Source for a work in source code form is that same work.
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
2. Basic Permissions.
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
4. Conveying Verbatim Copies.
|
is covered only if its contents constitute a work based on the
|
||||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
5. Conveying Modified Source Versions.
|
source code as you receive it, in any medium, provided that you
|
||||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
|
along with the Program.
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
6. Conveying Non-Source Forms.
|
above, provided that you also meet all of these conditions:
|
||||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
7. Additional Terms.
|
sections when you distribute them as separate works. But when you
|
||||||
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
collective works based on the Program.
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
8. Termination.
|
years, to give any third party, for a charge no more than your
|
||||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
9. Acceptance Not Required for Having Copies.
|
received the program in object code or executable form with such
|
||||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
The source code for a work means the preferred form of the work for
|
||||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
11. Patents.
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
13. Use with the GNU Affero General Public License.
|
distribute the Program or its derivative works. These actions are
|
||||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
14. Revised Versions of this License.
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
15. Disclaimer of Warranty.
|
You are not responsible for enforcing compliance by third parties to
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
this License.
|
||||||
|
|
||||||
16. Limitation of Liability.
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
17. Interpretation of Sections 15 and 16.
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
END OF TERMS AND CONDITIONS
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
How to Apply These Terms to Your New Programs
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
any particular circumstance, the balance of the section is intended to
|
||||||
Copyright (C) <year> <name of author>
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and "any
|
||||||
|
later version", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>.
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <https://www.gnu.org/philosophy/why-not-lgpl.html>.
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License.
|
||||||
|
|||||||
117
ChangeLog
117
ChangeLog
@@ -1,110 +1,3 @@
|
|||||||
4.5.0
|
|
||||||
* allow building Nominatim as a pip package
|
|
||||||
* make osm2pgsql building optional
|
|
||||||
* switch importer to psycopg3
|
|
||||||
* allow output format of web search to be customized in self-installations
|
|
||||||
* look up potential postcode areas for postcode results
|
|
||||||
* add word usage statistics for address terms
|
|
||||||
* implement more light-weight CSV format for wiki importance tables
|
|
||||||
* rewrite SQL for place search to use window functions
|
|
||||||
* increase search radius when filtering by postcode
|
|
||||||
* prefer POI points over POI areas
|
|
||||||
* reintroduce full terms for address terms in search_name table
|
|
||||||
* reindex postcodes when their parent is deleted
|
|
||||||
* indexing: precompute counts of affected rows
|
|
||||||
* ensure consistent country assignments for overlapping countries
|
|
||||||
* make Nominatim[Async]API context manager to ensure proper calling of
|
|
||||||
close()
|
|
||||||
* make usage of project dir optional for library
|
|
||||||
* drop interpolations when no parent can be found
|
|
||||||
* style tweaks to reflect OSM usage (man_made, highway and others)
|
|
||||||
* deprecation of: bundled osm2pgsql, legacy tokenizer, PHP frontend
|
|
||||||
* make documentation buildable without CMake
|
|
||||||
* various fixes and improvements to documentation
|
|
||||||
|
|
||||||
4.4.1
|
|
||||||
* fix geocodejson output: admin level output should only print boundaries
|
|
||||||
* updating: restrict invalidation of child objects on large street features
|
|
||||||
* restrict valid interpolation house numbers to 0-999999
|
|
||||||
* fix import error when SQLAlchemy 1.4 and psycopg3 are installed
|
|
||||||
* various typo fixes in the documentation
|
|
||||||
|
|
||||||
4.4.0
|
|
||||||
* add export to SQLite database and SQLite support for the frontend
|
|
||||||
* switch to Python frontend as the default frontend
|
|
||||||
* update to osm2pgsql 1.11.0
|
|
||||||
* add support for new osm2pgsql middle table format
|
|
||||||
* simplify geometry for large polygon objects not used in addresses
|
|
||||||
* various performance tweaks for search in Python frontend
|
|
||||||
* fix regression in search with categories where it was confused with near
|
|
||||||
search
|
|
||||||
* partially roll back use of SQLAlchemy lambda statements due to bugs
|
|
||||||
in SQLAlchemy
|
|
||||||
* fix handling of timezones for timestamps from the database
|
|
||||||
* fix handling of full address searches in connection with a viewbox
|
|
||||||
* fix postcode computation of highway areas
|
|
||||||
* fix handling of timeout errors for Python <= 3.10
|
|
||||||
* fix address computation for postcode areas
|
|
||||||
* fix variable shadowing in osm2pgsql flex script, causing bugs with LuaJIT
|
|
||||||
* make sure extratags are always null when empty
|
|
||||||
* reduce importance of places without wikipedia reference
|
|
||||||
* improve performance of word count computations
|
|
||||||
* drop support for wikipedia tags with full URLs
|
|
||||||
* replace get_addressdata() SQL implementation with a Python function
|
|
||||||
* improve display name for non-address features
|
|
||||||
* fix postcode validation for postcodes with country code
|
|
||||||
(thanks @pawel-wroniszewski)
|
|
||||||
* add possibility to run imports without superuser database rights
|
|
||||||
(thanks @robbe-haesendonck)
|
|
||||||
* new CLI command for cleaning deleted relations (thanks @lujoh)
|
|
||||||
* add check for database version in the CLI check command
|
|
||||||
* updates to import styles ignoring more unused objects
|
|
||||||
* various typo fixes (thanks @kumarUjjawal)
|
|
||||||
|
|
||||||
4.3.2
|
|
||||||
* fix potential SQL injection issue for 'nominatim admin --collect-os-info'
|
|
||||||
* PHP frontend: fix on-the-fly lookup of postcode areas near boundaries
|
|
||||||
* Python frontend: improve handling of viewbox
|
|
||||||
* Python frontend: correct deployment instructions
|
|
||||||
|
|
||||||
4.3.1
|
|
||||||
* reintroduce result rematching
|
|
||||||
* improve search of multi-part names
|
|
||||||
* fix accidentally switched meaning of --reverse-only and --search-only in
|
|
||||||
warm command
|
|
||||||
|
|
||||||
4.3.0
|
|
||||||
* fix failing importance recalculation command
|
|
||||||
* fix merging of linked names into unnamed boundaries
|
|
||||||
* fix a number of corner cases with interpolation splitting resulting in
|
|
||||||
invalid geometries
|
|
||||||
* fix failure in website generation when password contains curly brackets
|
|
||||||
* fix broken use of ST_Project in PostGIS 3.4
|
|
||||||
* new NOMINATIM_SEARCH_WITHIN_COUNTRIES setting to restrict reverse lookups
|
|
||||||
to known countries (thanks @alfmarcua)
|
|
||||||
* allow negative OSM IDs (thanks @alfmarcua)
|
|
||||||
* disallow import of Tiger data in a frozen DB
|
|
||||||
* avoid UPDATE to change settings to be compatible with r/o DBs (thanks @t-tomek)
|
|
||||||
* update bundled osm2pgsql to 1.9.2
|
|
||||||
* reorganise osm2pgsql flex style and make it the default
|
|
||||||
* exclude names ending in :wikipedia from indexing
|
|
||||||
* no longer accept comma as a list separator in name tags
|
|
||||||
* process forward dependencies on update to catch updates in geometries
|
|
||||||
of ways and relations
|
|
||||||
* fix handling of isolated silent letters during transliteration
|
|
||||||
* no longer assign postcodes to large linear features like rivers
|
|
||||||
* introduce nominatim.paths module for finding data and libraries
|
|
||||||
* documentation layout changed to material theme
|
|
||||||
* new documentation section for library
|
|
||||||
* various smaller fixes to existing documentation
|
|
||||||
(thanks @woodpeck, @bloom256, @biswajit-k)
|
|
||||||
* updates to vagrant install scripts, drop support for Ubuntu 18
|
|
||||||
(thanks @n-timofeev)
|
|
||||||
* removed obsolete configuration variables from env.defaults
|
|
||||||
* add script for generating a taginfo description (thanks @biswajit-k)
|
|
||||||
* modernize Python code around BDD test and add testing of Python frontend
|
|
||||||
* lots of new BDD tests for API output
|
|
||||||
|
|
||||||
4.2.3
|
4.2.3
|
||||||
|
|
||||||
* fix deletion handling for 'nominatim add-data'
|
* fix deletion handling for 'nominatim add-data'
|
||||||
@@ -315,7 +208,7 @@
|
|||||||
* increase splitting for large geometries to improve indexing speed
|
* increase splitting for large geometries to improve indexing speed
|
||||||
* remove deprecated get_magic_quotes_gpc() function
|
* remove deprecated get_magic_quotes_gpc() function
|
||||||
* make sure that all postcodes have an entry in word and are thus searchable
|
* make sure that all postcodes have an entry in word and are thus searchable
|
||||||
* remove use of ST_Covers in conjunction with ST_Intersects,
|
* remove use of ST_Covers in conjunction woth ST_Intersects,
|
||||||
causes bad query planning and slow updates in Postgis3
|
causes bad query planning and slow updates in Postgis3
|
||||||
* update osm2pgsql
|
* update osm2pgsql
|
||||||
|
|
||||||
@@ -372,7 +265,7 @@
|
|||||||
* exclude postcode ranges separated by colon from centre point calculation
|
* exclude postcode ranges separated by colon from centre point calculation
|
||||||
* update osm2pgsql, better handling of imports without flatnode file
|
* update osm2pgsql, better handling of imports without flatnode file
|
||||||
* switch to more efficient algorithm for word set computation
|
* switch to more efficient algorithm for word set computation
|
||||||
* use only boundaries for country and state parts of addresses
|
* use only boundries for country and state parts of addresses
|
||||||
* improve updates of addresses with housenumbers and interpolations
|
* improve updates of addresses with housenumbers and interpolations
|
||||||
* remove country from place_addressline table and use country_code instead
|
* remove country from place_addressline table and use country_code instead
|
||||||
* optimise indexes on search_name partition tables
|
* optimise indexes on search_name partition tables
|
||||||
@@ -411,7 +304,7 @@
|
|||||||
|
|
||||||
* complete rewrite of reverse search algorithm
|
* complete rewrite of reverse search algorithm
|
||||||
* add new geojson and geocodejson output formats
|
* add new geojson and geocodejson output formats
|
||||||
* add simple export script to export addresses to CSV
|
* add simple export script to exprot addresses to CSV
|
||||||
* remove is_in terms from address computation
|
* remove is_in terms from address computation
|
||||||
* remove unused search_name_country tables
|
* remove unused search_name_country tables
|
||||||
* various smaller fixes to query parsing
|
* various smaller fixes to query parsing
|
||||||
@@ -476,7 +369,7 @@
|
|||||||
* move installation documentation into this repo
|
* move installation documentation into this repo
|
||||||
* add self-documenting vagrant scripts
|
* add self-documenting vagrant scripts
|
||||||
* remove --create-website, recommend to use website directory in build
|
* remove --create-website, recommend to use website directory in build
|
||||||
* add accessor functions for URL parameters and improve error checking
|
* add accessor functions for URL parameters and improve erro checking
|
||||||
* remove IP blocking and rate-limiting code
|
* remove IP blocking and rate-limiting code
|
||||||
* enable CI via travis
|
* enable CI via travis
|
||||||
* reformatting for more consistent coding style
|
* reformatting for more consistent coding style
|
||||||
@@ -487,7 +380,7 @@
|
|||||||
* update to refactored osm2pgsql which use libosmium based types
|
* update to refactored osm2pgsql which use libosmium based types
|
||||||
* switch from osmosis to pyosmium for updates
|
* switch from osmosis to pyosmium for updates
|
||||||
* be more strict when matching against special search terms
|
* be more strict when matching against special search terms
|
||||||
* handle postcode entries with multiple values correctly
|
* handle postcode entries with mutliple values correctly
|
||||||
|
|
||||||
2.5
|
2.5
|
||||||
|
|
||||||
|
|||||||
@@ -1,202 +0,0 @@
|
|||||||
|
|
||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
@@ -1,339 +0,0 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 2, June 1991
|
|
||||||
|
|
||||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The licenses for most software are designed to take away your
|
|
||||||
freedom to share and change it. By contrast, the GNU General Public
|
|
||||||
License is intended to guarantee your freedom to share and change free
|
|
||||||
software--to make sure the software is free for all its users. This
|
|
||||||
General Public License applies to most of the Free Software
|
|
||||||
Foundation's software and to any other program whose authors commit to
|
|
||||||
using it. (Some other Free Software Foundation software is covered by
|
|
||||||
the GNU Lesser General Public License instead.) You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
this service if you wish), that you receive source code or can get it
|
|
||||||
if you want it, that you can change the software or use pieces of it
|
|
||||||
in new free programs; and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to make restrictions that forbid
|
|
||||||
anyone to deny you these rights or to ask you to surrender the rights.
|
|
||||||
These restrictions translate to certain responsibilities for you if you
|
|
||||||
distribute copies of the software, or if you modify it.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must give the recipients all the rights that
|
|
||||||
you have. You must make sure that they, too, receive or can get the
|
|
||||||
source code. And you must show them these terms so they know their
|
|
||||||
rights.
|
|
||||||
|
|
||||||
We protect your rights with two steps: (1) copyright the software, and
|
|
||||||
(2) offer you this license which gives you legal permission to copy,
|
|
||||||
distribute and/or modify the software.
|
|
||||||
|
|
||||||
Also, for each author's protection and ours, we want to make certain
|
|
||||||
that everyone understands that there is no warranty for this free
|
|
||||||
software. If the software is modified by someone else and passed on, we
|
|
||||||
want its recipients to know that what they have is not the original, so
|
|
||||||
that any problems introduced by others will not reflect on the original
|
|
||||||
authors' reputations.
|
|
||||||
|
|
||||||
Finally, any free program is threatened constantly by software
|
|
||||||
patents. We wish to avoid the danger that redistributors of a free
|
|
||||||
program will individually obtain patent licenses, in effect making the
|
|
||||||
program proprietary. To prevent this, we have made it clear that any
|
|
||||||
patent must be licensed for everyone's free use or not licensed at all.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
||||||
|
|
||||||
0. This License applies to any program or other work which contains
|
|
||||||
a notice placed by the copyright holder saying it may be distributed
|
|
||||||
under the terms of this General Public License. The "Program", below,
|
|
||||||
refers to any such program or work, and a "work based on the Program"
|
|
||||||
means either the Program or any derivative work under copyright law:
|
|
||||||
that is to say, a work containing the Program or a portion of it,
|
|
||||||
either verbatim or with modifications and/or translated into another
|
|
||||||
language. (Hereinafter, translation is included without limitation in
|
|
||||||
the term "modification".) Each licensee is addressed as "you".
|
|
||||||
|
|
||||||
Activities other than copying, distribution and modification are not
|
|
||||||
covered by this License; they are outside its scope. The act of
|
|
||||||
running the Program is not restricted, and the output from the Program
|
|
||||||
is covered only if its contents constitute a work based on the
|
|
||||||
Program (independent of having been made by running the Program).
|
|
||||||
Whether that is true depends on what the Program does.
|
|
||||||
|
|
||||||
1. You may copy and distribute verbatim copies of the Program's
|
|
||||||
source code as you receive it, in any medium, provided that you
|
|
||||||
conspicuously and appropriately publish on each copy an appropriate
|
|
||||||
copyright notice and disclaimer of warranty; keep intact all the
|
|
||||||
notices that refer to this License and to the absence of any warranty;
|
|
||||||
and give any other recipients of the Program a copy of this License
|
|
||||||
along with the Program.
|
|
||||||
|
|
||||||
You may charge a fee for the physical act of transferring a copy, and
|
|
||||||
you may at your option offer warranty protection in exchange for a fee.
|
|
||||||
|
|
||||||
2. You may modify your copy or copies of the Program or any portion
|
|
||||||
of it, thus forming a work based on the Program, and copy and
|
|
||||||
distribute such modifications or work under the terms of Section 1
|
|
||||||
above, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) You must cause the modified files to carry prominent notices
|
|
||||||
stating that you changed the files and the date of any change.
|
|
||||||
|
|
||||||
b) You must cause any work that you distribute or publish, that in
|
|
||||||
whole or in part contains or is derived from the Program or any
|
|
||||||
part thereof, to be licensed as a whole at no charge to all third
|
|
||||||
parties under the terms of this License.
|
|
||||||
|
|
||||||
c) If the modified program normally reads commands interactively
|
|
||||||
when run, you must cause it, when started running for such
|
|
||||||
interactive use in the most ordinary way, to print or display an
|
|
||||||
announcement including an appropriate copyright notice and a
|
|
||||||
notice that there is no warranty (or else, saying that you provide
|
|
||||||
a warranty) and that users may redistribute the program under
|
|
||||||
these conditions, and telling the user how to view a copy of this
|
|
||||||
License. (Exception: if the Program itself is interactive but
|
|
||||||
does not normally print such an announcement, your work based on
|
|
||||||
the Program is not required to print an announcement.)
|
|
||||||
|
|
||||||
These requirements apply to the modified work as a whole. If
|
|
||||||
identifiable sections of that work are not derived from the Program,
|
|
||||||
and can be reasonably considered independent and separate works in
|
|
||||||
themselves, then this License, and its terms, do not apply to those
|
|
||||||
sections when you distribute them as separate works. But when you
|
|
||||||
distribute the same sections as part of a whole which is a work based
|
|
||||||
on the Program, the distribution of the whole must be on the terms of
|
|
||||||
this License, whose permissions for other licensees extend to the
|
|
||||||
entire whole, and thus to each and every part regardless of who wrote it.
|
|
||||||
|
|
||||||
Thus, it is not the intent of this section to claim rights or contest
|
|
||||||
your rights to work written entirely by you; rather, the intent is to
|
|
||||||
exercise the right to control the distribution of derivative or
|
|
||||||
collective works based on the Program.
|
|
||||||
|
|
||||||
In addition, mere aggregation of another work not based on the Program
|
|
||||||
with the Program (or with a work based on the Program) on a volume of
|
|
||||||
a storage or distribution medium does not bring the other work under
|
|
||||||
the scope of this License.
|
|
||||||
|
|
||||||
3. You may copy and distribute the Program (or a work based on it,
|
|
||||||
under Section 2) in object code or executable form under the terms of
|
|
||||||
Sections 1 and 2 above provided that you also do one of the following:
|
|
||||||
|
|
||||||
a) Accompany it with the complete corresponding machine-readable
|
|
||||||
source code, which must be distributed under the terms of Sections
|
|
||||||
1 and 2 above on a medium customarily used for software interchange; or,
|
|
||||||
|
|
||||||
b) Accompany it with a written offer, valid for at least three
|
|
||||||
years, to give any third party, for a charge no more than your
|
|
||||||
cost of physically performing source distribution, a complete
|
|
||||||
machine-readable copy of the corresponding source code, to be
|
|
||||||
distributed under the terms of Sections 1 and 2 above on a medium
|
|
||||||
customarily used for software interchange; or,
|
|
||||||
|
|
||||||
c) Accompany it with the information you received as to the offer
|
|
||||||
to distribute corresponding source code. (This alternative is
|
|
||||||
allowed only for noncommercial distribution and only if you
|
|
||||||
received the program in object code or executable form with such
|
|
||||||
an offer, in accord with Subsection b above.)
|
|
||||||
|
|
||||||
The source code for a work means the preferred form of the work for
|
|
||||||
making modifications to it. For an executable work, complete source
|
|
||||||
code means all the source code for all modules it contains, plus any
|
|
||||||
associated interface definition files, plus the scripts used to
|
|
||||||
control compilation and installation of the executable. However, as a
|
|
||||||
special exception, the source code distributed need not include
|
|
||||||
anything that is normally distributed (in either source or binary
|
|
||||||
form) with the major components (compiler, kernel, and so on) of the
|
|
||||||
operating system on which the executable runs, unless that component
|
|
||||||
itself accompanies the executable.
|
|
||||||
|
|
||||||
If distribution of executable or object code is made by offering
|
|
||||||
access to copy from a designated place, then offering equivalent
|
|
||||||
access to copy the source code from the same place counts as
|
|
||||||
distribution of the source code, even though third parties are not
|
|
||||||
compelled to copy the source along with the object code.
|
|
||||||
|
|
||||||
4. You may not copy, modify, sublicense, or distribute the Program
|
|
||||||
except as expressly provided under this License. Any attempt
|
|
||||||
otherwise to copy, modify, sublicense or distribute the Program is
|
|
||||||
void, and will automatically terminate your rights under this License.
|
|
||||||
However, parties who have received copies, or rights, from you under
|
|
||||||
this License will not have their licenses terminated so long as such
|
|
||||||
parties remain in full compliance.
|
|
||||||
|
|
||||||
5. You are not required to accept this License, since you have not
|
|
||||||
signed it. However, nothing else grants you permission to modify or
|
|
||||||
distribute the Program or its derivative works. These actions are
|
|
||||||
prohibited by law if you do not accept this License. Therefore, by
|
|
||||||
modifying or distributing the Program (or any work based on the
|
|
||||||
Program), you indicate your acceptance of this License to do so, and
|
|
||||||
all its terms and conditions for copying, distributing or modifying
|
|
||||||
the Program or works based on it.
|
|
||||||
|
|
||||||
6. Each time you redistribute the Program (or any work based on the
|
|
||||||
Program), the recipient automatically receives a license from the
|
|
||||||
original licensor to copy, distribute or modify the Program subject to
|
|
||||||
these terms and conditions. You may not impose any further
|
|
||||||
restrictions on the recipients' exercise of the rights granted herein.
|
|
||||||
You are not responsible for enforcing compliance by third parties to
|
|
||||||
this License.
|
|
||||||
|
|
||||||
7. If, as a consequence of a court judgment or allegation of patent
|
|
||||||
infringement or for any other reason (not limited to patent issues),
|
|
||||||
conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot
|
|
||||||
distribute so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you
|
|
||||||
may not distribute the Program at all. For example, if a patent
|
|
||||||
license would not permit royalty-free redistribution of the Program by
|
|
||||||
all those who receive copies directly or indirectly through you, then
|
|
||||||
the only way you could satisfy both it and this License would be to
|
|
||||||
refrain entirely from distribution of the Program.
|
|
||||||
|
|
||||||
If any portion of this section is held invalid or unenforceable under
|
|
||||||
any particular circumstance, the balance of the section is intended to
|
|
||||||
apply and the section as a whole is intended to apply in other
|
|
||||||
circumstances.
|
|
||||||
|
|
||||||
It is not the purpose of this section to induce you to infringe any
|
|
||||||
patents or other property right claims or to contest validity of any
|
|
||||||
such claims; this section has the sole purpose of protecting the
|
|
||||||
integrity of the free software distribution system, which is
|
|
||||||
implemented by public license practices. Many people have made
|
|
||||||
generous contributions to the wide range of software distributed
|
|
||||||
through that system in reliance on consistent application of that
|
|
||||||
system; it is up to the author/donor to decide if he or she is willing
|
|
||||||
to distribute software through any other system and a licensee cannot
|
|
||||||
impose that choice.
|
|
||||||
|
|
||||||
This section is intended to make thoroughly clear what is believed to
|
|
||||||
be a consequence of the rest of this License.
|
|
||||||
|
|
||||||
8. If the distribution and/or use of the Program is restricted in
|
|
||||||
certain countries either by patents or by copyrighted interfaces, the
|
|
||||||
original copyright holder who places the Program under this License
|
|
||||||
may add an explicit geographical distribution limitation excluding
|
|
||||||
those countries, so that distribution is permitted only in or among
|
|
||||||
countries not thus excluded. In such case, this License incorporates
|
|
||||||
the limitation as if written in the body of this License.
|
|
||||||
|
|
||||||
9. The Free Software Foundation may publish revised and/or new versions
|
|
||||||
of the General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Program
|
|
||||||
specifies a version number of this License which applies to it and "any
|
|
||||||
later version", you have the option of following the terms and conditions
|
|
||||||
either of that version or of any later version published by the Free
|
|
||||||
Software Foundation. If the Program does not specify a version number of
|
|
||||||
this License, you may choose any version ever published by the Free Software
|
|
||||||
Foundation.
|
|
||||||
|
|
||||||
10. If you wish to incorporate parts of the Program into other free
|
|
||||||
programs whose distribution conditions are different, write to the author
|
|
||||||
to ask for permission. For software which is copyrighted by the Free
|
|
||||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
|
||||||
make exceptions for this. Our decision will be guided by the two goals
|
|
||||||
of preserving the free status of all derivatives of our free software and
|
|
||||||
of promoting the sharing and reuse of software generally.
|
|
||||||
|
|
||||||
NO WARRANTY
|
|
||||||
|
|
||||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
|
||||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
|
||||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
|
||||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
|
||||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
|
||||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
|
||||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
|
||||||
REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
|
||||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
|
||||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
|
||||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
|
||||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
|
||||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
|
||||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
|
||||||
POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
convey the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along
|
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program is interactive, make it output a short notice like this
|
|
||||||
when it starts in an interactive mode:
|
|
||||||
|
|
||||||
Gnomovision version 69, Copyright (C) year name of author
|
|
||||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, the commands you use may
|
|
||||||
be called something other than `show w' and `show c'; they could even be
|
|
||||||
mouse-clicks or menu items--whatever suits your program.
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or your
|
|
||||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
|
||||||
necessary. Here is a sample; alter the names:
|
|
||||||
|
|
||||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
|
||||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
|
||||||
|
|
||||||
<signature of Ty Coon>, 1 April 1989
|
|
||||||
Ty Coon, President of Vice
|
|
||||||
|
|
||||||
This General Public License does not permit incorporating your program into
|
|
||||||
proprietary programs. If your program is a subroutine library, you may
|
|
||||||
consider it more useful to permit linking proprietary applications with the
|
|
||||||
library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License.
|
|
||||||
44
Makefile
44
Makefile
@@ -1,44 +0,0 @@
|
|||||||
all:
|
|
||||||
|
|
||||||
# Building of wheels
|
|
||||||
|
|
||||||
build: clean-build build-db build-api
|
|
||||||
|
|
||||||
clean-build:
|
|
||||||
rm -f dist/*
|
|
||||||
|
|
||||||
build-db:
|
|
||||||
python3 -m build packaging/nominatim-db --outdir dist/
|
|
||||||
|
|
||||||
build-api:
|
|
||||||
python3 -m build packaging/nominatim-api --outdir dist/
|
|
||||||
|
|
||||||
# Tests
|
|
||||||
|
|
||||||
tests: mypy lint pytest bdd
|
|
||||||
|
|
||||||
mypy:
|
|
||||||
mypy --strict src
|
|
||||||
|
|
||||||
pytest:
|
|
||||||
pytest test/python
|
|
||||||
|
|
||||||
lint:
|
|
||||||
pylint src
|
|
||||||
|
|
||||||
bdd:
|
|
||||||
cd test/bdd; behave -DREMOVE_TEMPLATE=1
|
|
||||||
|
|
||||||
# Documentation
|
|
||||||
|
|
||||||
doc:
|
|
||||||
mkdocs build
|
|
||||||
|
|
||||||
serve-doc:
|
|
||||||
mkdocs serve
|
|
||||||
|
|
||||||
manpage:
|
|
||||||
argparse-manpage --pyfile man/create-manpage.py --function get_parser --project-name Nominatim --url https://nominatim.org > man/nominatim.1 --author 'the Nominatim developer community' --author-email info@nominatim.org
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: tests mypy pytest lint bdd build clean-build build-db build-api doc serve-doc manpage
|
|
||||||
26
README.md
26
README.md
@@ -1,4 +1,5 @@
|
|||||||
[](https://github.com/osm-search/Nominatim/actions?query=workflow%3A%22CI+Tests%22)
|
[](https://github.com/osm-search/Nominatim/actions?query=workflow%3A%22CI+Tests%22)
|
||||||
|
[](https://codecov.io/gh/osm-search/Nominatim)
|
||||||
|
|
||||||
Nominatim
|
Nominatim
|
||||||
=========
|
=========
|
||||||
@@ -47,31 +48,20 @@ A quick summary of the necessary steps:
|
|||||||
License
|
License
|
||||||
=======
|
=======
|
||||||
|
|
||||||
The Python source code is available under a GPL license version 3 or later.
|
The source code is available under a GPLv2 license.
|
||||||
The Lua configuration files for osm2pgsql are released under the
|
|
||||||
Apache License, Version 2.0. All other files are under a GPLv2 license.
|
|
||||||
|
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
============
|
============
|
||||||
|
|
||||||
Contributions, bug reports and pull requests are welcome. When reporting a
|
Contributions, bugreport and pull requests are welcome.
|
||||||
bug, please use one of the
|
For details see [contribution guide](CONTRIBUTING.md).
|
||||||
[issue templates](https://github.com/osm-search/Nominatim/issues/new/choose)
|
|
||||||
and make sure to provide all the information requested. If you are not
|
|
||||||
sure if you have really found a bug, please ask for help in the forums
|
|
||||||
first (see 'Questions' below).
|
|
||||||
|
|
||||||
For details on contributing, have a look at the
|
|
||||||
[contribution guide](CONTRIBUTING.md).
|
|
||||||
|
|
||||||
|
|
||||||
Questions and help
|
Questions and help
|
||||||
==================
|
==================
|
||||||
|
|
||||||
If you have questions about search results and the OpenStreetMap data
|
For questions, community help and discussions you can use the
|
||||||
used in the search, use the [OSM Forum](https://community.openstreetmap.org/).
|
[Github discussions forum](https://github.com/osm-search/Nominatim/discussions)
|
||||||
|
or join the
|
||||||
For questions, community help and discussions around the software and
|
[geocoding mailing list](https://lists.openstreetmap.org/listinfo/geocoding).
|
||||||
your own installation of Nominatim, use the
|
|
||||||
[Github discussions forum](https://github.com/osm-search/Nominatim/discussions).
|
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ versions.
|
|||||||
|
|
||||||
| Version | End of support for security updates |
|
| Version | End of support for security updates |
|
||||||
| ------- | ----------------------------------- |
|
| ------- | ----------------------------------- |
|
||||||
| 4.5.x | 2026-09-12 |
|
|
||||||
| 4.4.x | 2026-03-07 |
|
|
||||||
| 4.3.x | 2025-09-07 |
|
|
||||||
| 4.2.x | 2024-11-24 |
|
| 4.2.x | 2024-11-24 |
|
||||||
|
| 4.1.x | 2024-08-05 |
|
||||||
|
| 4.0.x | 2023-11-02 |
|
||||||
|
| 3.7.x | 2023-04-05 |
|
||||||
|
| 3.6.x | 2022-12-12 |
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
@@ -36,6 +37,4 @@ incident. Announcements will also be published at the
|
|||||||
|
|
||||||
## List of Previous Incidents
|
## List of Previous Incidents
|
||||||
|
|
||||||
* 2023-11-20 - [SQL injection vulnerability](https://nominatim.org/2023/11/20/release-432.html)
|
|
||||||
* 2023-02-21 - [cross-site scripting vulnerability](https://nominatim.org/2023/02/21/release-421.html)
|
|
||||||
* 2020-05-04 - [SQL injection issue on /details endpoint](https://lists.openstreetmap.org/pipermail/geocoding/2020-May/002012.html)
|
* 2020-05-04 - [SQL injection issue on /details endpoint](https://lists.openstreetmap.org/pipermail/geocoding/2020-May/002012.html)
|
||||||
|
|||||||
78
Vagrantfile
vendored
78
Vagrantfile
vendored
@@ -17,14 +17,6 @@ Vagrant.configure("2") do |config|
|
|||||||
checkout = "no"
|
checkout = "no"
|
||||||
end
|
end
|
||||||
|
|
||||||
config.vm.provider "hyperv" do |hv, override|
|
|
||||||
hv.memory = 2048
|
|
||||||
hv.linked_clone = true
|
|
||||||
if ENV['CHECKOUT'] != 'y' then
|
|
||||||
override.vm.synced_folder ".", "/home/vagrant/Nominatim", type: "smb", smb_host: ENV['SMB_HOST'] || ENV['COMPUTERNAME']
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
config.vm.provider "virtualbox" do |vb, override|
|
config.vm.provider "virtualbox" do |vb, override|
|
||||||
vb.gui = false
|
vb.gui = false
|
||||||
vb.memory = 2048
|
vb.memory = 2048
|
||||||
@@ -34,77 +26,85 @@ Vagrant.configure("2") do |config|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
config.vm.provider "parallels" do |prl, override|
|
|
||||||
prl.update_guest_tools = false
|
|
||||||
prl.memory = 2048
|
|
||||||
if ENV['CHECKOUT'] != 'y' then
|
|
||||||
override.vm.synced_folder ".", "/home/vagrant/Nominatim"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
config.vm.provider "libvirt" do |lv, override|
|
config.vm.provider "libvirt" do |lv, override|
|
||||||
lv.memory = 2048
|
lv.memory = 2048
|
||||||
lv.nested = true
|
lv.nested = true
|
||||||
if ENV['CHECKOUT'] != 'y' then
|
if ENV['CHECKOUT'] != 'y' then
|
||||||
override.vm.synced_folder ".", "/home/vagrant/Nominatim", type: 'nfs', nfs_udp: false
|
override.vm.synced_folder ".", "/home/vagrant/Nominatim", type: 'nfs'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
config.vm.define "ubuntu22", primary: true do |sub|
|
config.vm.define "ubuntu", primary: true do |sub|
|
||||||
sub.vm.box = "generic/ubuntu2204"
|
sub.vm.box = "generic/ubuntu2004"
|
||||||
sub.vm.provision :shell do |s|
|
sub.vm.provision :shell do |s|
|
||||||
s.path = "vagrant/Install-on-Ubuntu-22.sh"
|
s.path = "vagrant/Install-on-Ubuntu-20.sh"
|
||||||
s.privileged = false
|
s.privileged = false
|
||||||
s.args = [checkout]
|
s.args = [checkout]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
config.vm.define "ubuntu22-apache" do |sub|
|
config.vm.define "ubuntu-apache" do |sub|
|
||||||
sub.vm.box = "generic/ubuntu2204"
|
sub.vm.box = "generic/ubuntu2004"
|
||||||
sub.vm.provision :shell do |s|
|
sub.vm.provision :shell do |s|
|
||||||
s.path = "vagrant/Install-on-Ubuntu-22.sh"
|
s.path = "vagrant/Install-on-Ubuntu-20.sh"
|
||||||
s.privileged = false
|
s.privileged = false
|
||||||
s.args = [checkout, "install-apache"]
|
s.args = [checkout, "install-apache"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
config.vm.define "ubuntu22-nginx" do |sub|
|
config.vm.define "ubuntu-nginx" do |sub|
|
||||||
sub.vm.box = "generic/ubuntu2204"
|
sub.vm.box = "generic/ubuntu2004"
|
||||||
sub.vm.provision :shell do |s|
|
sub.vm.provision :shell do |s|
|
||||||
s.path = "vagrant/Install-on-Ubuntu-22.sh"
|
s.path = "vagrant/Install-on-Ubuntu-20.sh"
|
||||||
s.privileged = false
|
s.privileged = false
|
||||||
s.args = [checkout, "install-nginx"]
|
s.args = [checkout, "install-nginx"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
config.vm.define "ubuntu24" do |sub|
|
config.vm.define "ubuntu18" do |sub|
|
||||||
sub.vm.box = "bento/ubuntu-24.04"
|
sub.vm.box = "generic/ubuntu1804"
|
||||||
if RUBY_PLATFORM.include?('darwin') && RUBY_PLATFORM.include?('arm64')
|
|
||||||
# Apple M processor
|
|
||||||
sub.vm.box = 'gutehall/ubuntu24-04'
|
|
||||||
end
|
|
||||||
sub.vm.provision :shell do |s|
|
sub.vm.provision :shell do |s|
|
||||||
s.path = "vagrant/Install-on-Ubuntu-24.sh"
|
s.path = "vagrant/Install-on-Ubuntu-18.sh"
|
||||||
s.privileged = false
|
s.privileged = false
|
||||||
s.args = [checkout]
|
s.args = [checkout]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
config.vm.define "ubuntu24-apache" do |sub|
|
config.vm.define "ubuntu18-apache" do |sub|
|
||||||
sub.vm.box = "bento/ubuntu-24.04"
|
sub.vm.box = "generic/ubuntu1804"
|
||||||
sub.vm.provision :shell do |s|
|
sub.vm.provision :shell do |s|
|
||||||
s.path = "vagrant/Install-on-Ubuntu-24.sh"
|
s.path = "vagrant/Install-on-Ubuntu-18.sh"
|
||||||
s.privileged = false
|
s.privileged = false
|
||||||
s.args = [checkout, "install-apache"]
|
s.args = [checkout, "install-apache"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
config.vm.define "ubuntu24-nginx" do |sub|
|
config.vm.define "ubuntu18-nginx" do |sub|
|
||||||
sub.vm.box = "bento/ubuntu-24.04"
|
sub.vm.box = "generic/ubuntu1804"
|
||||||
sub.vm.provision :shell do |s|
|
sub.vm.provision :shell do |s|
|
||||||
s.path = "vagrant/Install-on-Ubuntu-24.sh"
|
s.path = "vagrant/Install-on-Ubuntu-18.sh"
|
||||||
s.privileged = false
|
s.privileged = false
|
||||||
s.args = [checkout, "install-nginx"]
|
s.args = [checkout, "install-nginx"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
config.vm.define "centos7" do |sub|
|
||||||
|
sub.vm.box = "centos/7"
|
||||||
|
sub.vm.provision :shell do |s|
|
||||||
|
s.path = "vagrant/Install-on-Centos-7.sh"
|
||||||
|
s.privileged = false
|
||||||
|
s.args = [checkout]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
config.vm.define "centos" do |sub|
|
||||||
|
sub.vm.box = "generic/centos8"
|
||||||
|
sub.vm.provision :shell do |s|
|
||||||
|
s.path = "vagrant/Install-on-Centos-8.sh"
|
||||||
|
s.privileged = false
|
||||||
|
s.args = [checkout]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
# SPDX-License-Identifier: GPL-2.0-only
|
|
||||||
#
|
|
||||||
# This file is part of Nominatim. (https://nominatim.org)
|
|
||||||
#
|
|
||||||
# Copyright (C) 2022 by the Nominatim developer community.
|
|
||||||
# For a full list of authors see the git log.
|
|
||||||
"""
|
|
||||||
Path settings for extra data used by Nominatim (installed version).
|
|
||||||
"""
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
PHPLIB_DIR = None
|
|
||||||
SQLLIB_DIR = (Path('@NOMINATIM_LIBDIR@') / 'lib-sql').resolve()
|
|
||||||
DATA_DIR = Path('@NOMINATIM_DATADIR@').resolve()
|
|
||||||
CONFIG_DIR = Path('@NOMINATIM_CONFIGDIR@').resolve()
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
# SPDX-License-Identifier: GPL-2.0-only
|
|
||||||
#
|
|
||||||
# This file is part of Nominatim. (https://nominatim.org)
|
|
||||||
#
|
|
||||||
# Copyright (C) 2022 by the Nominatim developer community.
|
|
||||||
# For a full list of authors see the git log.
|
|
||||||
"""
|
|
||||||
Path settings for extra data used by Nominatim (installed version).
|
|
||||||
"""
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
PHPLIB_DIR = (Path('@NOMINATIM_LIBDIR@') / 'lib-php').resolve()
|
|
||||||
SQLLIB_DIR = (Path('@NOMINATIM_LIBDIR@') / 'lib-sql').resolve()
|
|
||||||
DATA_DIR = Path('@NOMINATIM_DATADIR@').resolve()
|
|
||||||
CONFIG_DIR = Path('@NOMINATIM_CONFIGDIR@').resolve()
|
|
||||||
@@ -4,10 +4,17 @@ import os
|
|||||||
|
|
||||||
sys.path.insert(1, '@NOMINATIM_LIBDIR@/lib-python')
|
sys.path.insert(1, '@NOMINATIM_LIBDIR@/lib-python')
|
||||||
|
|
||||||
from nominatim_db import cli
|
os.environ['NOMINATIM_NOMINATIM_TOOL'] = os.path.abspath(__file__)
|
||||||
from nominatim_db import version
|
|
||||||
|
from nominatim import cli
|
||||||
|
from nominatim import version
|
||||||
|
|
||||||
version.GIT_COMMIT_HASH = '@GIT_HASH@'
|
version.GIT_COMMIT_HASH = '@GIT_HASH@'
|
||||||
|
|
||||||
exit(cli.nominatim(module_dir='@NOMINATIM_LIBDIR@/module',
|
exit(cli.nominatim(module_dir='@NOMINATIM_LIBDIR@/module',
|
||||||
osm2pgsql_path='@NOMINATIM_LIBDIR@/osm2pgsql'))
|
osm2pgsql_path='@NOMINATIM_LIBDIR@/osm2pgsql',
|
||||||
|
phplib_dir='@NOMINATIM_LIBDIR@/lib-php',
|
||||||
|
sqllib_dir='@NOMINATIM_LIBDIR@/lib-sql',
|
||||||
|
data_dir='@NOMINATIM_DATADIR@',
|
||||||
|
config_dir='@NOMINATIM_CONFIGDIR@',
|
||||||
|
phpcgi_path='@PHPCGI_BIN@'))
|
||||||
|
|||||||
@@ -2,12 +2,19 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
sys.path.insert(1, '@CMAKE_SOURCE_DIR@/src')
|
sys.path.insert(1, '@CMAKE_SOURCE_DIR@')
|
||||||
|
|
||||||
from nominatim_db import cli
|
os.environ['NOMINATIM_NOMINATIM_TOOL'] = os.path.abspath(__file__)
|
||||||
from nominatim_db import version
|
|
||||||
|
from nominatim import cli
|
||||||
|
from nominatim import version
|
||||||
|
|
||||||
version.GIT_COMMIT_HASH = '@GIT_HASH@'
|
version.GIT_COMMIT_HASH = '@GIT_HASH@'
|
||||||
|
|
||||||
exit(cli.nominatim(module_dir='@CMAKE_BINARY_DIR@/module',
|
exit(cli.nominatim(module_dir='@CMAKE_BINARY_DIR@/module',
|
||||||
osm2pgsql_path='@CMAKE_BINARY_DIR@/osm2pgsql/osm2pgsql'))
|
osm2pgsql_path='@CMAKE_BINARY_DIR@/osm2pgsql/osm2pgsql',
|
||||||
|
phplib_dir='@CMAKE_SOURCE_DIR@/lib-php',
|
||||||
|
sqllib_dir='@CMAKE_SOURCE_DIR@/lib-sql',
|
||||||
|
data_dir='@CMAKE_SOURCE_DIR@/data',
|
||||||
|
config_dir='@CMAKE_SOURCE_DIR@/settings',
|
||||||
|
phpcgi_path='@PHPCGI_BIN@'))
|
||||||
|
|||||||
35
docs/CMakeLists.txt
Normal file
35
docs/CMakeLists.txt
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# Auto-generated vagrant install documentation
|
||||||
|
|
||||||
|
|
||||||
|
# build the actual documentation
|
||||||
|
|
||||||
|
configure_file(mkdocs.yml ../mkdocs.yml)
|
||||||
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/appendix)
|
||||||
|
|
||||||
|
set (DOC_SOURCES
|
||||||
|
admin
|
||||||
|
develop
|
||||||
|
api
|
||||||
|
customize
|
||||||
|
index.md
|
||||||
|
extra.css
|
||||||
|
styles.css
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach (src ${DOC_SOURCES})
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${CMAKE_CURRENT_BINARY_DIR}/${src}
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
ADD_CUSTOM_TARGET(doc
|
||||||
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Ubuntu-18.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Ubuntu-18.md
|
||||||
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Ubuntu-20.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Ubuntu-20.md
|
||||||
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Ubuntu-22.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Ubuntu-22.md
|
||||||
|
COMMAND PYTHONPATH=${PROJECT_SOURCE_DIR} mkdocs build -d ${CMAKE_CURRENT_BINARY_DIR}/../site-html -f ${CMAKE_CURRENT_BINARY_DIR}/../mkdocs.yml
|
||||||
|
)
|
||||||
|
|
||||||
|
ADD_CUSTOM_TARGET(serve-doc
|
||||||
|
COMMAND PYTHONPATH=${PROJECT_SOURCE_DIR} mkdocs serve
|
||||||
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||||
|
)
|
||||||
@@ -5,35 +5,6 @@ your Nominatim database. It is assumed that you have already successfully
|
|||||||
installed the Nominatim software itself, if not return to the
|
installed the Nominatim software itself, if not return to the
|
||||||
[installation page](Installation.md).
|
[installation page](Installation.md).
|
||||||
|
|
||||||
## Importing with a database user without superuser rights
|
|
||||||
|
|
||||||
Nominatim usually creates its own PostgreSQL database at the beginning of the
|
|
||||||
import process. This makes usage easier for the user but means that the
|
|
||||||
database user doing the import needs the appropriate rights.
|
|
||||||
|
|
||||||
If you prefer to run the import with a database user with limited rights,
|
|
||||||
you can do so by changing the import process as follows:
|
|
||||||
|
|
||||||
1. Run the command for database preparation with a database user with
|
|
||||||
superuser rights. For example, to use a db user 'dbadmin' for a
|
|
||||||
database 'nominatim', execute:
|
|
||||||
|
|
||||||
```
|
|
||||||
NOMINATIM_DATABASE_DSN="pgsql:dbname=nominatim;user=dbadmin" nominatim import --prepare-database
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Grant the import user the right to create tables. For example, foe user 'import-user':
|
|
||||||
|
|
||||||
```
|
|
||||||
psql -d nominatim -c 'GRANT CREATE ON SCHEMA public TO "import-user"'
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Now run the reminder of the import with the import user:
|
|
||||||
|
|
||||||
```
|
|
||||||
NOMINATIM_DATABASE_DSN="pgsql:dbname=nominatim;user=import-user" nominatim import --continue import-from-file --osm-file file.pbf
|
|
||||||
```
|
|
||||||
|
|
||||||
## Importing multiple regions (without updates)
|
## Importing multiple regions (without updates)
|
||||||
|
|
||||||
To import multiple regions in your database you can simply give multiple
|
To import multiple regions in your database you can simply give multiple
|
||||||
@@ -65,15 +36,16 @@ which has the following structure:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
update
|
update
|
||||||
├── europe
|
├── europe
|
||||||
│ ├── andorra
|
│ ├── andorra
|
||||||
│ │ └── sequence.state
|
│ │ └── sequence.state
|
||||||
│ └── monaco
|
│ └── monaco
|
||||||
│ └── sequence.state
|
│ └── sequence.state
|
||||||
└── tmp
|
└── tmp
|
||||||
└── europe
|
└── europe
|
||||||
├── andorra-latest.osm.pbf
|
├── andorra-latest.osm.pbf
|
||||||
└── monaco-latest.osm.pbf
|
└── monaco-latest.osm.pbf
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -127,7 +99,7 @@ Change into the project directory and run the following command:
|
|||||||
|
|
||||||
This will get diffs from the replication server, import diffs and index
|
This will get diffs from the replication server, import diffs and index
|
||||||
the database. The default replication server in the
|
the database. The default replication server in the
|
||||||
script ([Geofabrik](https://download.geofabrik.de)) provides daily updates.
|
script([Geofabrik](https://download.geofabrik.de)) provides daily updates.
|
||||||
|
|
||||||
## Using an external PostgreSQL database
|
## Using an external PostgreSQL database
|
||||||
|
|
||||||
@@ -239,6 +211,6 @@ If you are using the legacy tokenizer you might also have to switch to the
|
|||||||
PostgreSQL module that was compiled on your target machine. If you get errors
|
PostgreSQL module that was compiled on your target machine. If you get errors
|
||||||
that PostgreSQL cannot find or access `nominatim.so` then rerun
|
that PostgreSQL cannot find or access `nominatim.so` then rerun
|
||||||
|
|
||||||
nominatim refresh --functions
|
nominatim refresh --functions
|
||||||
|
|
||||||
on the target machine to update the the location of the module.
|
on the target machine to update the the location of the module.
|
||||||
|
|||||||
@@ -1,148 +0,0 @@
|
|||||||
# Deploying the Nominatim Python frontend
|
|
||||||
|
|
||||||
Nominatim can be run as a Python-based
|
|
||||||
[ASGI web application](https://asgi.readthedocs.io/en/latest/). You have the
|
|
||||||
choice between [Falcon](https://falcon.readthedocs.io/en/stable/)
|
|
||||||
and [Starlette](https://www.starlette.io/) as the ASGI framework.
|
|
||||||
|
|
||||||
This section gives a quick overview on how to configure Nginx to serve
|
|
||||||
Nominatim. Please refer to the documentation of
|
|
||||||
[Nginx](https://nginx.org/en/docs/) for background information on how
|
|
||||||
to configure it.
|
|
||||||
|
|
||||||
!!! Note
|
|
||||||
Throughout this page, we assume your Nominatim project directory is
|
|
||||||
located in `/srv/nominatim-project`. If you have put it somewhere else,
|
|
||||||
you need to adjust the commands and configuration accordingly.
|
|
||||||
|
|
||||||
|
|
||||||
### Installing the required packages
|
|
||||||
|
|
||||||
The Nominatim frontend is best run from its own virtual environment. If
|
|
||||||
you have already created one for the database backend during the
|
|
||||||
[installation](Installation.md#building-nominatim), you can use that. Otherwise
|
|
||||||
create one now with:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo apt-get install virtualenv
|
|
||||||
virtualenv /srv/nominatim-venv
|
|
||||||
```
|
|
||||||
|
|
||||||
The Nominatim frontend is contained in the 'nominatim-api' package. To
|
|
||||||
install directly from the source tree run:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cd Nominatim
|
|
||||||
/srv/nominatim-venv/bin/pip install packaging/nominatim-api
|
|
||||||
```
|
|
||||||
|
|
||||||
The recommended way to deploy a Python ASGI application is to run
|
|
||||||
the ASGI runner [uvicorn](https://uvicorn.org/)
|
|
||||||
together with [gunicorn](https://gunicorn.org/) HTTP server. We use
|
|
||||||
Falcon here as the web framework.
|
|
||||||
|
|
||||||
Add the necessary packages to your virtual environment:
|
|
||||||
|
|
||||||
``` sh
|
|
||||||
/srv/nominatim-venv/bin/pip install falcon uvicorn gunicorn
|
|
||||||
```
|
|
||||||
|
|
||||||
### Setting up Nominatim as a systemd job
|
|
||||||
|
|
||||||
Next you need to set up the service that runs the Nominatim frontend. This is
|
|
||||||
easiest done with a systemd job.
|
|
||||||
|
|
||||||
First you need to tell systemd to create a socket file to be used by
|
|
||||||
hunicorn. Create the following file `/etc/systemd/system/nominatim.socket`:
|
|
||||||
|
|
||||||
``` systemd
|
|
||||||
[Unit]
|
|
||||||
Description=Gunicorn socket for Nominatim
|
|
||||||
|
|
||||||
[Socket]
|
|
||||||
ListenStream=/run/nominatim.sock
|
|
||||||
SocketUser=www-data
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
```
|
|
||||||
|
|
||||||
Now you can add the systemd service for Nominatim itself.
|
|
||||||
Create the following file `/etc/systemd/system/nominatim.service`:
|
|
||||||
|
|
||||||
``` systemd
|
|
||||||
[Unit]
|
|
||||||
Description=Nominatim running as a gunicorn application
|
|
||||||
After=network.target
|
|
||||||
Requires=nominatim.socket
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
User=www-data
|
|
||||||
Group=www-data
|
|
||||||
WorkingDirectory=/srv/nominatim-project
|
|
||||||
ExecStart=/srv/nominatim-venv/bin/gunicorn -b unix:/run/nominatim.sock -w 4 -k uvicorn.workers.UvicornWorker nominatim_api.server.falcon.server:run_wsgi
|
|
||||||
ExecReload=/bin/kill -s HUP $MAINPID
|
|
||||||
StandardOutput=append:/var/log/gunicorn-nominatim.log
|
|
||||||
StandardError=inherit
|
|
||||||
PrivateTmp=true
|
|
||||||
TimeoutStopSec=5
|
|
||||||
KillMode=mixed
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
```
|
|
||||||
|
|
||||||
This sets up gunicorn with 4 workers (`-w 4` in ExecStart). Each worker runs
|
|
||||||
its own Python process using
|
|
||||||
[`NOMINATIM_API_POOL_SIZE`](../customize/Settings.md#nominatim_api_pool_size)
|
|
||||||
connections to the database to serve requests in parallel.
|
|
||||||
|
|
||||||
Make the new services known to systemd and start it:
|
|
||||||
|
|
||||||
``` sh
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable nominatim.socket
|
|
||||||
sudo systemctl start nominatim.socket
|
|
||||||
sudo systemctl enable nominatim.service
|
|
||||||
sudo systemctl start nominatim.service
|
|
||||||
```
|
|
||||||
|
|
||||||
This sets the service up, so that Nominatim is automatically started
|
|
||||||
on reboot.
|
|
||||||
|
|
||||||
### Configuring nginx
|
|
||||||
|
|
||||||
To make the service available to the world, you need to proxy it through
|
|
||||||
nginx. Add the following definition to the default configuration:
|
|
||||||
|
|
||||||
``` nginx
|
|
||||||
upstream nominatim_service {
|
|
||||||
server unix:/run/nominatim.sock fail_timeout=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
listen [::]:80;
|
|
||||||
|
|
||||||
root /var/www/html;
|
|
||||||
index /search;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_set_header Host $http_host;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
|
||||||
proxy_redirect off;
|
|
||||||
proxy_pass http://nominatim_service;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Reload nginx with
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo systemctl reload nginx
|
|
||||||
```
|
|
||||||
|
|
||||||
and you should be able to see the status of your server under
|
|
||||||
`http://localhost/status`.
|
|
||||||
@@ -1,7 +1,4 @@
|
|||||||
# Deploying Nominatim using the PHP frontend
|
# Deploying Nominatim
|
||||||
|
|
||||||
!!! danger
|
|
||||||
The PHP frontend is deprecated and will be removed in Nominatim 5.0.
|
|
||||||
|
|
||||||
The Nominatim API is implemented as a PHP application. The `website/` directory
|
The Nominatim API is implemented as a PHP application. The `website/` directory
|
||||||
in the project directory contains the configured website. You can serve this
|
in the project directory contains the configured website. You can serve this
|
||||||
@@ -11,13 +8,13 @@ PHP scripts.
|
|||||||
This section gives a quick overview on how to configure Apache and Nginx to
|
This section gives a quick overview on how to configure Apache and Nginx to
|
||||||
serve Nominatim. It is not meant as a full system administration guide on how
|
serve Nominatim. It is not meant as a full system administration guide on how
|
||||||
to run a web service. Please refer to the documentation of
|
to run a web service. Please refer to the documentation of
|
||||||
[Apache](https://httpd.apache.org/docs/current/) and
|
[Apache](http://httpd.apache.org/docs/current/) and
|
||||||
[Nginx](https://nginx.org/en/docs/)
|
[Nginx](https://nginx.org/en/docs/)
|
||||||
for background information on configuring the services.
|
for background information on configuring the services.
|
||||||
|
|
||||||
!!! Note
|
!!! Note
|
||||||
Throughout this page, we assume your Nominatim project directory is
|
Throughout this page, we assume that your Nominatim project directory is
|
||||||
located in `/srv/nominatim-project` and you have installed Nominatim
|
located in `/srv/nominatim-project` and that you have installed Nominatim
|
||||||
using the default installation prefix `/usr/local`. If you have put it
|
using the default installation prefix `/usr/local`. If you have put it
|
||||||
somewhere else, you need to adjust the commands and configuration
|
somewhere else, you need to adjust the commands and configuration
|
||||||
accordingly.
|
accordingly.
|
||||||
@@ -37,6 +37,40 @@ nominatim import --continue indexing
|
|||||||
Otherwise it's best to start the full setup from the beginning.
|
Otherwise it's best to start the full setup from the beginning.
|
||||||
|
|
||||||
|
|
||||||
|
### PHP "open_basedir restriction in effect" warnings
|
||||||
|
|
||||||
|
PHP Warning: file_get_contents(): open_basedir restriction in effect.
|
||||||
|
|
||||||
|
You need to adjust the
|
||||||
|
[open_basedir](https://www.php.net/manual/en/ini.core.php#ini.open-basedir)
|
||||||
|
setting in your PHP configuration (`php.ini` file). By default this setting may
|
||||||
|
look like this:
|
||||||
|
|
||||||
|
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/
|
||||||
|
|
||||||
|
Either add reported directories to the list or disable this setting temporarily
|
||||||
|
by adding ";" at the beginning of the line. Don't forget to enable this setting
|
||||||
|
again once you are done with the PHP command line operations.
|
||||||
|
|
||||||
|
|
||||||
|
### PHP timezeone warnings
|
||||||
|
|
||||||
|
The Apache log may contain lots of PHP warnings like this:
|
||||||
|
`PHP Warning: date_default_timezone_set() function.`
|
||||||
|
|
||||||
|
You should set the default time zone as instructed in the warning in
|
||||||
|
your `php.ini` file. Find the entry about timezone and set it to
|
||||||
|
something like this:
|
||||||
|
|
||||||
|
; Defines the default timezone used by the date functions
|
||||||
|
; https://php.net/date.timezone
|
||||||
|
date.timezone = 'America/Denver'
|
||||||
|
|
||||||
|
Or
|
||||||
|
|
||||||
|
```
|
||||||
|
echo "date.timezone = 'America/Denver'" > /etc/php.d/timezone.ini
|
||||||
|
```
|
||||||
|
|
||||||
### nominatim.so version mismatch
|
### nominatim.so version mismatch
|
||||||
|
|
||||||
@@ -136,31 +170,12 @@ recreate `nominatim.so`. Try
|
|||||||
cmake $main_Nominatim_path && make
|
cmake $main_Nominatim_path && make
|
||||||
```
|
```
|
||||||
|
|
||||||
### Setup fails with "DB Error: extension not found"
|
### Setup.php fails with "DB Error: extension not found"
|
||||||
|
|
||||||
Make sure you have the PostgreSQL extensions "hstore" and "postgis" installed.
|
Make sure you have the PostgreSQL extensions "hstore" and "postgis" installed.
|
||||||
See the installation instructions for a full list of required packages.
|
See the installation instructions for a full list of required packages.
|
||||||
|
|
||||||
|
|
||||||
### UnicodeEncodeError: 'ascii' codec can't encode character
|
|
||||||
|
|
||||||
Make sure that the operating system's locale is UTF-8. With some prebuilt
|
|
||||||
images (e.g. LXC containers from Proxmox, see
|
|
||||||
[discussion](https://github.com/osm-search/Nominatim/discussions/2343)) or
|
|
||||||
images that optimize for size it might be missing.
|
|
||||||
|
|
||||||
On Ubuntu you can check the locale is installed:
|
|
||||||
|
|
||||||
```
|
|
||||||
grep UTF-8 /etc/default/locale
|
|
||||||
```
|
|
||||||
|
|
||||||
And install it using
|
|
||||||
|
|
||||||
```
|
|
||||||
dpkg-reconfigure locales
|
|
||||||
```
|
|
||||||
|
|
||||||
### I forgot to delete the flatnodes file before starting an import.
|
### I forgot to delete the flatnodes file before starting an import.
|
||||||
|
|
||||||
That's fine. For each import the flatnodes file get overwritten.
|
That's fine. For each import the flatnodes file get overwritten.
|
||||||
|
|||||||
@@ -14,15 +14,15 @@ to a single Nominatim setup: configuration, extra data, etc. Create a project
|
|||||||
directory apart from the Nominatim software and change into the directory:
|
directory apart from the Nominatim software and change into the directory:
|
||||||
|
|
||||||
```
|
```
|
||||||
mkdir ~/nominatim-project
|
mkdir ~/nominatim-planet
|
||||||
cd ~/nominatim-project
|
cd ~/nominatim-planet
|
||||||
```
|
```
|
||||||
|
|
||||||
In the following, we refer to the project directory as `$PROJECT_DIR`. To be
|
In the following, we refer to the project directory as `$PROJECT_DIR`. To be
|
||||||
able to copy&paste instructions, you can export the appropriate variable:
|
able to copy&paste instructions, you can export the appropriate variable:
|
||||||
|
|
||||||
```
|
```
|
||||||
export PROJECT_DIR=~/nominatim-project
|
export PROJECT_DIR=~/nominatim-planet
|
||||||
```
|
```
|
||||||
|
|
||||||
The Nominatim tool assumes per default that the current working directory is
|
The Nominatim tool assumes per default that the current working directory is
|
||||||
@@ -74,18 +74,15 @@ but it will improve the quality of the results if this is installed.
|
|||||||
This data is available as a binary download. Put it into your project directory:
|
This data is available as a binary download. Put it into your project directory:
|
||||||
|
|
||||||
cd $PROJECT_DIR
|
cd $PROJECT_DIR
|
||||||
wget https://nominatim.org/data/wikimedia-importance.csv.gz
|
wget https://nominatim.org/data/wikimedia-importance.sql.gz
|
||||||
wget -O secondary_importance.sql.gz https://nominatim.org/data/wikimedia-secondary-importance.sql.gz
|
|
||||||
|
|
||||||
The files are about 400MB and add around 4GB to the Nominatim database. For
|
The file is about 400MB and adds around 4GB to the Nominatim database.
|
||||||
more information about importance,
|
|
||||||
see [Importance Customization](../customize/Importance.md).
|
|
||||||
|
|
||||||
!!! tip
|
!!! tip
|
||||||
If you forgot to download the wikipedia rankings, then you can
|
If you forgot to download the wikipedia rankings, then you can
|
||||||
also add importances after the import. Download the SQL files, then
|
also add importances after the import. Download the SQL files, then
|
||||||
run `nominatim refresh --wiki-data --secondary-importance --importance`.
|
run `nominatim refresh --wiki-data --importance`. Updating
|
||||||
Updating importances for a planet will take a couple of hours.
|
importances for a planet will take a couple of hours.
|
||||||
|
|
||||||
### External postcodes
|
### External postcodes
|
||||||
|
|
||||||
@@ -156,7 +153,7 @@ if you plan to use the installation only for exports to a
|
|||||||
[photon](https://photon.komoot.io/) database, then you can set up a database
|
[photon](https://photon.komoot.io/) database, then you can set up a database
|
||||||
without search indexes. Add `--reverse-only` to your setup command above.
|
without search indexes. Add `--reverse-only` to your setup command above.
|
||||||
|
|
||||||
This saves about 5% of disk space, import time won't be significant faster.
|
This saves about 5% of disk space.
|
||||||
|
|
||||||
### Filtering Imported Data
|
### Filtering Imported Data
|
||||||
|
|
||||||
@@ -231,7 +228,7 @@ to load the OSM data into the PostgreSQL database. This step is very demanding
|
|||||||
in terms of RAM usage. osm2pgsql and PostgreSQL are running in parallel at
|
in terms of RAM usage. osm2pgsql and PostgreSQL are running in parallel at
|
||||||
this point. PostgreSQL blocks at least the part of RAM that has been configured
|
this point. PostgreSQL blocks at least the part of RAM that has been configured
|
||||||
with the `shared_buffers` parameter during
|
with the `shared_buffers` parameter during
|
||||||
[PostgreSQL tuning](Installation.md#tuning-the-postgresql-database)
|
[PostgreSQL tuning](Installation.md#postgresql-tuning)
|
||||||
and needs some memory on top of that. osm2pgsql needs at least 2GB of RAM for
|
and needs some memory on top of that. osm2pgsql needs at least 2GB of RAM for
|
||||||
its internal data structures, potentially more when it has to process very large
|
its internal data structures, potentially more when it has to process very large
|
||||||
relations. In addition it needs to maintain a cache for node locations. The size
|
relations. In addition it needs to maintain a cache for node locations. The size
|
||||||
@@ -257,74 +254,26 @@ successfully.
|
|||||||
nominatim admin --check-database
|
nominatim admin --check-database
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you can try out your installation by executing a simple query on the
|
Now you can try out your installation by running:
|
||||||
command line:
|
|
||||||
|
|
||||||
``` sh
|
```sh
|
||||||
nominatim search --query Berlin
|
|
||||||
```
|
|
||||||
|
|
||||||
or, when you have a reverse-only installation:
|
|
||||||
|
|
||||||
``` sh
|
|
||||||
nominatim reverse --lat 51 --lon 45
|
|
||||||
```
|
|
||||||
|
|
||||||
If you want to run Nominatim as a service, you need to make a choice between
|
|
||||||
running the modern Python frontend and the legacy PHP frontend.
|
|
||||||
Make sure you have installed the right packages as per
|
|
||||||
[Installation](Installation.md#software).
|
|
||||||
|
|
||||||
#### Testing the Python frontend
|
|
||||||
|
|
||||||
To run the test server against the Python frontend, you must choose a
|
|
||||||
web framework to use, either starlette or falcon. Make sure the appropriate
|
|
||||||
packages are installed. Then run
|
|
||||||
|
|
||||||
``` sh
|
|
||||||
nominatim serve
|
nominatim serve
|
||||||
```
|
```
|
||||||
|
|
||||||
or, if you prefer to use Starlette instead of Falcon as webserver,
|
This runs a small test server normally used for development. You can use it
|
||||||
|
to verify that your installation is working. Go to
|
||||||
|
`http://localhost:8088/status.php` and you should see the message `OK`.
|
||||||
|
You can also run a search query, e.g. `http://localhost:8088/search.php?q=Berlin`.
|
||||||
|
|
||||||
``` sh
|
Note that search query is not supported for reverse-only imports. You can run a
|
||||||
nominatim serve --engine starlette
|
reverse query, e.g. `http://localhost:8088/reverse.php?lat=27.1750090510034&lon=78.04209025`.
|
||||||
```
|
|
||||||
|
|
||||||
Go to `http://localhost:8088/status.php` and you should see the message `OK`.
|
To run Nominatim via webservers like Apache or nginx, please read the
|
||||||
You can also run a search query, e.g. `http://localhost:8088/search.php?q=Berlin`
|
[Deployment chapter](Deployment.md).
|
||||||
or, for reverse-only installations a reverse query,
|
|
||||||
e.g. `http://localhost:8088/reverse.php?lat=27.1750090510034&lon=78.04209025`.
|
|
||||||
|
|
||||||
Do not use this test server in production.
|
## Adding search through category phrases
|
||||||
To run Nominatim via webservers like Apache or nginx, please continue reading
|
|
||||||
[Deploy the Python frontend](Deployment-Python.md).
|
|
||||||
|
|
||||||
#### Testing the PHP frontend
|
If you want to be able to search for places by their type through
|
||||||
|
|
||||||
!!! danger
|
|
||||||
The PHP fronted is deprecated and will be removed in Nominatim 5.0.
|
|
||||||
|
|
||||||
You can run a small test server with the PHP frontend like this:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
nominatim serve --engine php
|
|
||||||
```
|
|
||||||
|
|
||||||
Go to `http://localhost:8088/status.php` and you should see the message `OK`.
|
|
||||||
You can also run a search query, e.g. `http://localhost:8088/search.php?q=Berlin`
|
|
||||||
or, for reverse-only installations a reverse query,
|
|
||||||
e.g. `http://localhost:8088/reverse.php?lat=27.1750090510034&lon=78.04209025`.
|
|
||||||
|
|
||||||
Do not use this test server in production.
|
|
||||||
To run Nominatim via webservers like Apache or nginx, please continue reading
|
|
||||||
[Deploy the PHP frontend](Deployment-PHP.md).
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Enabling search by category phrases
|
|
||||||
|
|
||||||
To be able to search for places by their type using
|
|
||||||
[special phrases](https://wiki.openstreetmap.org/wiki/Nominatim/Special_Phrases)
|
[special phrases](https://wiki.openstreetmap.org/wiki/Nominatim/Special_Phrases)
|
||||||
you also need to import these key phrases like this:
|
you also need to import these key phrases like this:
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ This page contains generic installation instructions for Nominatim and its
|
|||||||
prerequisites. There are also step-by-step instructions available for
|
prerequisites. There are also step-by-step instructions available for
|
||||||
the following operating systems:
|
the following operating systems:
|
||||||
|
|
||||||
* [Ubuntu 24.04](Install-on-Ubuntu-24.md)
|
* [Ubuntu 22.04](../appendix/Install-on-Ubuntu-22.md)
|
||||||
* [Ubuntu 22.04](Install-on-Ubuntu-22.md)
|
* [Ubuntu 20.04](../appendix/Install-on-Ubuntu-20.md)
|
||||||
|
* [Ubuntu 18.04](../appendix/Install-on-Ubuntu-18.md)
|
||||||
|
|
||||||
These OS-specific instructions can also be found in executable form
|
These OS-specific instructions can also be found in executable form
|
||||||
in the `vagrant/` directory.
|
in the `vagrant/` directory.
|
||||||
@@ -27,26 +28,7 @@ and can't offer support.
|
|||||||
otherwise import and queries will be slow to the point of being unusable.
|
otherwise import and queries will be slow to the point of being unusable.
|
||||||
Query performance has marked improvements with PostgreSQL 13+ and PostGIS 3.2+.
|
Query performance has marked improvements with PostgreSQL 13+ and PostGIS 3.2+.
|
||||||
|
|
||||||
For running Nominatim:
|
For compiling:
|
||||||
|
|
||||||
* [PostgreSQL](https://www.postgresql.org) (9.6+ will work, 11+ strongly recommended)
|
|
||||||
* [PostGIS](https://postgis.net) (2.2+ will work, 3.0+ strongly recommended)
|
|
||||||
* [osm2pgsql](https://osm2pgsql.org) (1.8+, optional when building with CMake)
|
|
||||||
* [Python 3](https://www.python.org/) (3.7+)
|
|
||||||
|
|
||||||
Furthermore the following Python libraries are required:
|
|
||||||
|
|
||||||
* [Psycopg3](https://www.psycopg.org)
|
|
||||||
* [Python Dotenv](https://github.com/theskumar/python-dotenv)
|
|
||||||
* [psutil](https://github.com/giampaolo/psutil)
|
|
||||||
* [Jinja2](https://palletsprojects.com/p/jinja/)
|
|
||||||
* [PyICU](https://pypi.org/project/PyICU/)
|
|
||||||
* [PyYaml](https://pyyaml.org/) (5.1+)
|
|
||||||
* [datrie](https://github.com/pytries/datrie)
|
|
||||||
|
|
||||||
These will be installed automatically when using pip installation.
|
|
||||||
|
|
||||||
When using legacy CMake-based installation:
|
|
||||||
|
|
||||||
* [cmake](https://cmake.org/)
|
* [cmake](https://cmake.org/)
|
||||||
* [expat](https://libexpat.github.io/)
|
* [expat](https://libexpat.github.io/)
|
||||||
@@ -54,31 +36,31 @@ When using legacy CMake-based installation:
|
|||||||
* [bzip2](http://www.bzip.org/)
|
* [bzip2](http://www.bzip.org/)
|
||||||
* [zlib](https://www.zlib.net/)
|
* [zlib](https://www.zlib.net/)
|
||||||
* [ICU](http://site.icu-project.org/)
|
* [ICU](http://site.icu-project.org/)
|
||||||
* [nlohmann/json](https://json.nlohmann.me/)
|
* [Boost libraries](https://www.boost.org/), including system and filesystem
|
||||||
* [Boost libraries](https://www.boost.org/), including system and file system
|
|
||||||
* PostgreSQL client libraries
|
* PostgreSQL client libraries
|
||||||
* a recent C++ compiler (gcc 5+ or Clang 3.8+)
|
* a recent C++ compiler (gcc 5+ or Clang 3.8+)
|
||||||
|
|
||||||
|
For running Nominatim:
|
||||||
|
|
||||||
|
* [PostgreSQL](https://www.postgresql.org) (9.6+ will work, 11+ strongly recommended)
|
||||||
|
* [PostGIS](https://postgis.net) (2.2+ will work, 3.0+ strongly recommended)
|
||||||
|
* [Python 3](https://www.python.org/) (3.6+)
|
||||||
|
* [Psycopg2](https://www.psycopg.org) (2.7+)
|
||||||
|
* [Python Dotenv](https://github.com/theskumar/python-dotenv)
|
||||||
|
* [psutil](https://github.com/giampaolo/psutil)
|
||||||
|
* [Jinja2](https://palletsprojects.com/p/jinja/)
|
||||||
|
* [PyICU](https://pypi.org/project/PyICU/)
|
||||||
|
* [PyYaml](https://pyyaml.org/) (5.1+)
|
||||||
|
* [datrie](https://github.com/pytries/datrie)
|
||||||
|
* [PHP](https://php.net) (7.0 or later)
|
||||||
|
* PHP-pgsql
|
||||||
|
* PHP-intl (bundled with PHP)
|
||||||
|
* PHP-cgi (for running queries from the command line)
|
||||||
|
|
||||||
For running continuous updates:
|
For running continuous updates:
|
||||||
|
|
||||||
* [pyosmium](https://osmcode.org/pyosmium/)
|
* [pyosmium](https://osmcode.org/pyosmium/)
|
||||||
|
|
||||||
For running the Python frontend:
|
|
||||||
|
|
||||||
* [SQLAlchemy](https://www.sqlalchemy.org/) (1.4.31+ with greenlet support)
|
|
||||||
* [asyncpg](https://magicstack.github.io/asyncpg) (0.8+, only when using SQLAlchemy < 2.0)
|
|
||||||
* one of the following web frameworks:
|
|
||||||
* [falcon](https://falconframework.org/) (3.0+)
|
|
||||||
* [starlette](https://www.starlette.io/)
|
|
||||||
* [uvicorn](https://www.uvicorn.org/)
|
|
||||||
|
|
||||||
For running the legacy PHP frontend (deprecated, will be removed in Nominatim 5.0):
|
|
||||||
|
|
||||||
* [PHP](https://php.net) (7.3+)
|
|
||||||
* PHP-pgsql
|
|
||||||
* PHP-intl (bundled with PHP)
|
|
||||||
|
|
||||||
|
|
||||||
For dependencies for running tests and building documentation, see
|
For dependencies for running tests and building documentation, see
|
||||||
the [Development section](../develop/Development-Environment.md).
|
the [Development section](../develop/Development-Environment.md).
|
||||||
|
|
||||||
@@ -93,7 +75,7 @@ Take into account that the OSM database is growing fast.
|
|||||||
Fast disks are essential. Using NVME disks is recommended.
|
Fast disks are essential. Using NVME disks is recommended.
|
||||||
|
|
||||||
Even on a well configured machine the import of a full planet takes
|
Even on a well configured machine the import of a full planet takes
|
||||||
around 2.5 days. When using traditional SSDs, 4-5 days are more realistic.
|
around 2 days. On traditional spinning disks, 7-8 days are more realistic.
|
||||||
|
|
||||||
## Tuning the PostgreSQL database
|
## Tuning the PostgreSQL database
|
||||||
|
|
||||||
@@ -105,16 +87,14 @@ your `postgresql.conf` file.
|
|||||||
maintenance_work_mem = (10GB)
|
maintenance_work_mem = (10GB)
|
||||||
autovacuum_work_mem = 2GB
|
autovacuum_work_mem = 2GB
|
||||||
work_mem = (50MB)
|
work_mem = (50MB)
|
||||||
|
effective_cache_size = (24GB)
|
||||||
synchronous_commit = off
|
synchronous_commit = off
|
||||||
max_wal_size = 1GB
|
max_wal_size = 1GB
|
||||||
checkpoint_timeout = 60min
|
checkpoint_timeout = 10min
|
||||||
checkpoint_completion_target = 0.9
|
checkpoint_completion_target = 0.9
|
||||||
random_page_cost = 1.0
|
|
||||||
wal_level = minimal
|
|
||||||
max_wal_senders = 0
|
|
||||||
|
|
||||||
The numbers in brackets behind some parameters seem to work fine for
|
The numbers in brackets behind some parameters seem to work fine for
|
||||||
128GB RAM machine. Adjust to your setup. A higher number for `max_wal_size`
|
64GB RAM machine. Adjust to your setup. A higher number for `max_wal_size`
|
||||||
means that PostgreSQL needs to run checkpoints less often but it does require
|
means that PostgreSQL needs to run checkpoints less often but it does require
|
||||||
the additional space on your disk.
|
the additional space on your disk.
|
||||||
|
|
||||||
@@ -127,6 +107,15 @@ you might consider setting:
|
|||||||
and even reduce `autovacuum_work_mem` further. This will reduce the amount
|
and even reduce `autovacuum_work_mem` further. This will reduce the amount
|
||||||
of memory that autovacuum takes away from the import process.
|
of memory that autovacuum takes away from the import process.
|
||||||
|
|
||||||
|
For the initial import, you should also set:
|
||||||
|
|
||||||
|
fsync = off
|
||||||
|
full_page_writes = off
|
||||||
|
|
||||||
|
Don't forget to re-enable them after the initial import or you risk database
|
||||||
|
corruption.
|
||||||
|
|
||||||
|
|
||||||
## Downloading and building Nominatim
|
## Downloading and building Nominatim
|
||||||
|
|
||||||
### Downloading the latest release
|
### Downloading the latest release
|
||||||
@@ -151,23 +140,6 @@ wget -O Nominatim/data/country_osm_grid.sql.gz https://nominatim.org/data/countr
|
|||||||
|
|
||||||
### Building Nominatim
|
### Building Nominatim
|
||||||
|
|
||||||
#### Building the latest development version with pip
|
|
||||||
|
|
||||||
Nominatim is easiest to run from its own virtual environment. To create one, run:
|
|
||||||
|
|
||||||
sudo apt-get install virtualenv
|
|
||||||
virtualenv /srv/nominatim-venv
|
|
||||||
|
|
||||||
To install Nominatim directly from the source tree into the virtual environment, run:
|
|
||||||
|
|
||||||
/srv/nominatim-venv/bin/pip install packaging/nominatim-{db,api}
|
|
||||||
|
|
||||||
#### Building in legacy CMake mode
|
|
||||||
|
|
||||||
!!! warning
|
|
||||||
Installing Nominatim through CMake is now deprecated. The infrastructure
|
|
||||||
will be removed in Nominatim 5.0. Please switch to pip installation.
|
|
||||||
|
|
||||||
The code must be built in a separate directory. Create the directory and
|
The code must be built in a separate directory. Create the directory and
|
||||||
change into it.
|
change into it.
|
||||||
|
|
||||||
@@ -194,7 +166,6 @@ sudo make install
|
|||||||
cmake: `cmake -DBUILD_MODULE=on ../Nominatim`. To compile the module
|
cmake: `cmake -DBUILD_MODULE=on ../Nominatim`. To compile the module
|
||||||
you need to have the server development headers for PostgreSQL installed.
|
you need to have the server development headers for PostgreSQL installed.
|
||||||
On Ubuntu/Debian run: `sudo apt install postgresql-server-dev-<postgresql version>`
|
On Ubuntu/Debian run: `sudo apt install postgresql-server-dev-<postgresql version>`
|
||||||
The legacy tokenizer is deprecated and will be removed in Nominatim 5.0
|
|
||||||
|
|
||||||
|
|
||||||
Nominatim installs itself into `/usr/local` per default. To choose a different
|
Nominatim installs itself into `/usr/local` per default. To choose a different
|
||||||
|
|||||||
@@ -60,13 +60,16 @@ to finish the recomputation.
|
|||||||
|
|
||||||
## Removing large deleted objects
|
## Removing large deleted objects
|
||||||
|
|
||||||
Command: `nominatim admin --clean-deleted <PostgreSQL Time Interval>`
|
|
||||||
|
|
||||||
Nominatim refuses to delete very large areas because often these deletions are
|
Nominatim refuses to delete very large areas because often these deletions are
|
||||||
accidental and are reverted within hours. Instead the deletions are logged in
|
accidental and are reverted within hours. Instead the deletions are logged in
|
||||||
the `import_polygon_delete` table and left to the administrator to clean up.
|
the `import_polygon_delete` table and left to the administrator to clean up.
|
||||||
|
|
||||||
To run this command you will need to pass a PostgreSQL time interval. For example to
|
There is currently no command to do that. You can use the following SQL
|
||||||
delete any objects that have been deleted more than a month ago you would run:
|
query to force a deletion on all objects that have been deleted more than
|
||||||
`nominatim admin --clean-deleted '1 month'`
|
a certain timespan ago (here: 1 month):
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT place_force_delete(p.place_id) FROM import_polygon_delete d, placex p
|
||||||
|
WHERE p.osm_type = d.osm_type and p.osm_id = d.osm_id
|
||||||
|
and age(p.indexed_date) > '1 month'::interval
|
||||||
|
```
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
# Database Migrations
|
# Database Migrations
|
||||||
|
|
||||||
Nominatim offers automatic migrations since version 3.7. Please follow
|
Since version 3.7.0 Nominatim offers automatic migrations. Please follow
|
||||||
the following steps:
|
the following steps:
|
||||||
|
|
||||||
* Stop any updates that are potentially running
|
* stop any updates that are potentially running
|
||||||
* Update the backend: `pip install -U nominatim-db`
|
* update Nominatim to the newer version
|
||||||
* Go to your project directory and run `nominatim admin --migrate`
|
* go to your project directory and run `nominatim admin --migrate`
|
||||||
* Update the frontend: `pip install -U nominatim-api`
|
* (optionally) restart updates
|
||||||
* (optionally) Restart updates
|
|
||||||
|
|
||||||
If you are still using CMake for the installation of Nominatim, then you
|
|
||||||
need to update the software in one step before migrating the database.
|
|
||||||
It is not recommended to do this while the machine is serving requests.
|
|
||||||
|
|
||||||
Below you find additional migrations and hints about other structural and
|
Below you find additional migrations and hints about other structural and
|
||||||
breaking changes. **Please read them before running the migration.**
|
breaking changes. **Please read them before running the migration.**
|
||||||
@@ -20,41 +15,6 @@ breaking changes. **Please read them before running the migration.**
|
|||||||
If you are migrating from a version <3.6, then you still have to follow
|
If you are migrating from a version <3.6, then you still have to follow
|
||||||
the manual migration steps up to 3.6.
|
the manual migration steps up to 3.6.
|
||||||
|
|
||||||
## 4.4.0 -> 4.5.0
|
|
||||||
|
|
||||||
### New structure for Python packages
|
|
||||||
|
|
||||||
The nominatim Python package has been split into `nominatim-db` and `nominatim-api`.
|
|
||||||
Any imports need to be adapted accordingly.
|
|
||||||
|
|
||||||
If you are running the Python frontend, change the server module from
|
|
||||||
`nominatim.server.falcon.server` to `nominatim_api.server.falcon.server`.
|
|
||||||
|
|
||||||
If you are using the Nominatim library, all imports need to be changed
|
|
||||||
from `nominatim.api.<module>` to `nominatim_api.<module>`.
|
|
||||||
|
|
||||||
If you have written custom tokenizers or sanitizers, the appropriate modules
|
|
||||||
are now found in `nominatim_db`.
|
|
||||||
|
|
||||||
## 4.2.0 -> 4.3.0
|
|
||||||
|
|
||||||
### New indexes for reverse lookup
|
|
||||||
|
|
||||||
The reverse lookup algorithm has changed slightly to improve performance.
|
|
||||||
This change needs a different index in the database. The required index
|
|
||||||
will be automatically build during migration. Until the new index is available
|
|
||||||
performance of the /reverse endpoint is significantly reduced. You should
|
|
||||||
therefore either remove traffic from the machine before attempting a
|
|
||||||
version update or create the index manually **before** starting the update
|
|
||||||
using the following SQL:
|
|
||||||
|
|
||||||
```sql
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_placex_geometry_reverse_lookupPlaceNode
|
|
||||||
ON placex USING gist (ST_Buffer(geometry, reverse_place_diameter(rank_search)))
|
|
||||||
WHERE rank_address between 4 and 25 AND type != 'postcode'
|
|
||||||
AND name is not null AND linked_place_id is null AND osm_type = 'N';
|
|
||||||
```
|
|
||||||
|
|
||||||
## 4.0.0 -> 4.1.0
|
## 4.0.0 -> 4.1.0
|
||||||
|
|
||||||
### ICU tokenizer is the new default
|
### ICU tokenizer is the new default
|
||||||
|
|||||||
@@ -59,6 +59,47 @@ imported multiple country extracts and want to keep them
|
|||||||
up-to-date, [Advanced installations section](Advanced-Installations.md)
|
up-to-date, [Advanced installations section](Advanced-Installations.md)
|
||||||
contains instructions to set up and update multiple country extracts.
|
contains instructions to set up and update multiple country extracts.
|
||||||
|
|
||||||
|
#### Continuous updates
|
||||||
|
|
||||||
|
This is the easiest mode. Simply run the replication command without any
|
||||||
|
parameters:
|
||||||
|
|
||||||
|
nominatim replication
|
||||||
|
|
||||||
|
The update application keeps running forever and retrieves and applies
|
||||||
|
new updates from the server as they are published.
|
||||||
|
|
||||||
|
You can run this command as a simple systemd service. Create a service
|
||||||
|
description like that in `/etc/systemd/system/nominatim-updates.service`:
|
||||||
|
|
||||||
|
```
|
||||||
|
[Unit]
|
||||||
|
Description=Continuous updates of Nominatim
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=/srv/nominatim
|
||||||
|
ExecStart=nominatim replication
|
||||||
|
StandardOutput=append:/var/log/nominatim-updates.log
|
||||||
|
StandardError=append:/var/log/nominatim-updates.error.log
|
||||||
|
User=nominatim
|
||||||
|
Group=nominatim
|
||||||
|
Type=simple
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the `WorkingDirectory` with your project directory. Also adapt user
|
||||||
|
and group names as required.
|
||||||
|
|
||||||
|
Now activate the service and start the updates:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable nominatim-updates
|
||||||
|
sudo systemctl start nominatim-updates
|
||||||
|
```
|
||||||
|
|
||||||
#### One-time mode
|
#### One-time mode
|
||||||
|
|
||||||
When the `--once` parameter is given, then Nominatim will download exactly one
|
When the `--once` parameter is given, then Nominatim will download exactly one
|
||||||
@@ -180,53 +221,3 @@ replication catch-up at whatever interval you desire.
|
|||||||
updated source with daily updates), use the
|
updated source with daily updates), use the
|
||||||
continuous update mode. It ensures to re-request the newest update until it
|
continuous update mode. It ensures to re-request the newest update until it
|
||||||
is published.
|
is published.
|
||||||
|
|
||||||
|
|
||||||
#### Continuous updates
|
|
||||||
|
|
||||||
!!! danger
|
|
||||||
This mode is no longer recommended to use and will removed in future
|
|
||||||
releases. systemd is much better
|
|
||||||
suited for running regular updates. Please refer to the setup
|
|
||||||
instructions for running one-time mode with systemd above.
|
|
||||||
|
|
||||||
This is the easiest mode. Simply run the replication command without any
|
|
||||||
parameters:
|
|
||||||
|
|
||||||
nominatim replication
|
|
||||||
|
|
||||||
The update application keeps running forever and retrieves and applies
|
|
||||||
new updates from the server as they are published.
|
|
||||||
|
|
||||||
You can run this command as a simple systemd service. Create a service
|
|
||||||
description like that in `/etc/systemd/system/nominatim-updates.service`:
|
|
||||||
|
|
||||||
```
|
|
||||||
[Unit]
|
|
||||||
Description=Continuous updates of Nominatim
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
WorkingDirectory=/srv/nominatim
|
|
||||||
ExecStart=nominatim replication
|
|
||||||
StandardOutput=append:/var/log/nominatim-updates.log
|
|
||||||
StandardError=append:/var/log/nominatim-updates.error.log
|
|
||||||
User=nominatim
|
|
||||||
Group=nominatim
|
|
||||||
Type=simple
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
```
|
|
||||||
|
|
||||||
Replace the `WorkingDirectory` with your project directory. Also adapt user
|
|
||||||
and group names as required.
|
|
||||||
|
|
||||||
Now activate the service and start the updates:
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable nominatim-updates
|
|
||||||
sudo systemctl start nominatim-updates
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,17 +2,13 @@
|
|||||||
|
|
||||||
Show all details about a single place saved in the database.
|
Show all details about a single place saved in the database.
|
||||||
|
|
||||||
This API endpoint is meant for visual inspection of the data in the database,
|
|
||||||
mainly together with [Nominatim-UI](https://github.com/osm-search/nominatim-ui/).
|
|
||||||
The parameters of the endpoint and the output may change occasionally between
|
|
||||||
versions of Nominatim. Do not rely on the output in scripts or applications.
|
|
||||||
|
|
||||||
!!! warning
|
!!! warning
|
||||||
The details endpoint at https://nominatim.openstreetmap.org
|
The details page exists for debugging only. You may not use it in scripts
|
||||||
may not used in scripts or bots at all.
|
or to automatically query details about a result.
|
||||||
See [Nominatim Usage Policy](https://operations.osmfoundation.org/policies/nominatim/).
|
See [Nominatim Usage Policy](https://operations.osmfoundation.org/policies/nominatim/).
|
||||||
|
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
The details API supports the following two request formats:
|
The details API supports the following two request formats:
|
||||||
|
|
||||||
@@ -39,90 +35,59 @@ for a place is different between Nominatim installation (servers) and
|
|||||||
changes when data gets reimported. Therefore it cannot be used as
|
changes when data gets reimported. Therefore it cannot be used as
|
||||||
a permanent id and shouldn't be used in bug reports.
|
a permanent id and shouldn't be used in bug reports.
|
||||||
|
|
||||||
!!! danger "Deprecation warning"
|
|
||||||
The API can also be used with the URL
|
|
||||||
`https://nominatim.openstreetmap.org/details.php`. This is now deprecated
|
|
||||||
and will be removed in future versions.
|
|
||||||
|
|
||||||
|
Additional optional parameters are explained below.
|
||||||
## Parameters
|
|
||||||
|
|
||||||
This section lists additional optional parameters.
|
|
||||||
|
|
||||||
### Output format
|
### Output format
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `json_callback=<string>`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| json_callback | function name | _unset_ |
|
|
||||||
|
|
||||||
When set, then JSON output will be wrapped in a callback function with
|
Wrap JSON output in a callback function (JSONP) i.e. `<string>(<json>)`.
|
||||||
the given name. See [JSONP](https://en.wikipedia.org/wiki/JSONP) for more
|
|
||||||
information.
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `pretty=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| pretty | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
`[PHP-only]` Add indentation to the output to make it more human-readable.
|
Add indentation to make it more human-readable. (Default: 0)
|
||||||
|
|
||||||
|
|
||||||
### Output details
|
### Output details
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `addressdetails=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| addressdetails | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
When set to 1, include a breakdown of the address into elements.
|
Include a breakdown of the address into elements. (Default: 0)
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `keywords=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| keywords | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
When set to 1, include a list of name keywords and address keywords
|
Include a list of name keywords and address keywords (word ids). (Default: 0)
|
||||||
in the result.
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `linkedplaces=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| linkedplaces | 0 or 1 | 1 |
|
|
||||||
|
|
||||||
Include details of places that are linked with this one. Places get linked
|
Include a details of places that are linked with this one. Places get linked
|
||||||
together when they are different forms of the same physical object. Nominatim
|
together when they are different forms of the same physical object. Nominatim
|
||||||
links two kinds of objects together: place nodes get linked with the
|
links two kinds of objects together: place nodes get linked with the
|
||||||
corresponding administrative boundaries. Waterway relations get linked together with their
|
corresponding administrative boundaries. Waterway relations get linked together with their
|
||||||
members.
|
members.
|
||||||
|
(Default: 1)
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `hierarchy=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| hierarchy | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
Include details of places lower in the address hierarchy.
|
Include details of places lower in the address hierarchy. (Default: 0)
|
||||||
|
|
||||||
`[Python-only]` will only return properly parented places. These are address
|
* `group_hierarchy=[0|1]`
|
||||||
or POI-like places that reuse the address of their parent street or place.
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
For JSON output will group the places by type. (Default: 0)
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| group_hierarchy | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
When set to 1, the output of the address hierarchy will be
|
* `polygon_geojson=[0|1]`
|
||||||
grouped by type.
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
Include geometry of result. (Default: 0)
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| polygon_geojson | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
|
|
||||||
Include geometry of result.
|
|
||||||
|
|
||||||
### Language of results
|
### Language of results
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `accept-language=<browser language string>`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| accept-language | browser language string | content of "Accept-Language" HTTP header |
|
|
||||||
|
|
||||||
Preferred language order for showing search results. This may either be
|
Preferred language order for showing result, overrides the value
|
||||||
a simple comma-separated list of language codes or have the same format
|
specified in the "Accept-Language" HTTP header.
|
||||||
as the ["Accept-Language" HTTP header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language).
|
Either use a standard RFC2616 accept-language string or a simple
|
||||||
|
comma-separated list of language codes.
|
||||||
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
The lookup API allows to query the address and other details of one or
|
The lookup API allows to query the address and other details of one or
|
||||||
multiple OSM objects like node, way or relation.
|
multiple OSM objects like node, way or relation.
|
||||||
|
|
||||||
## Endpoint
|
## Parameters
|
||||||
|
|
||||||
The lookup API has the following format:
|
The lookup API has the following format:
|
||||||
|
|
||||||
@@ -15,129 +15,75 @@ The lookup API has the following format:
|
|||||||
prefixed with its type, one of node(N), way(W) or relation(R). Up to 50 ids
|
prefixed with its type, one of node(N), way(W) or relation(R). Up to 50 ids
|
||||||
can be queried at the same time.
|
can be queried at the same time.
|
||||||
|
|
||||||
!!! danger "Deprecation warning"
|
Additional optional parameters are explained below.
|
||||||
The API can also be used with the URL
|
|
||||||
`https://nominatim.openstreetmap.org/lookup.php`. This is now deprecated
|
|
||||||
and will be removed in future versions.
|
|
||||||
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
This section lists additional optional parameters.
|
|
||||||
|
|
||||||
### Output format
|
### Output format
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `format=[xml|json|jsonv2|geojson|geocodejson]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| format | one of: `xml`, `json`, `jsonv2`, `geojson`, `geocodejson` | `jsonv2` |
|
|
||||||
|
|
||||||
See [Place Output Formats](Output.md) for details on each format.
|
See [Place Output Formats](Output.md) for details on each format. (Default: xml)
|
||||||
|
|
||||||
|
* `json_callback=<string>`
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
Wrap JSON output in a callback function (JSONP) i.e. `<string>(<json>)`.
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| json_callback | function name | _unset_ |
|
|
||||||
|
|
||||||
When given, then JSON output will be wrapped in a callback function with
|
|
||||||
the given name. See [JSONP](https://en.wikipedia.org/wiki/JSONP) for more
|
|
||||||
information.
|
|
||||||
|
|
||||||
Only has an effect for JSON output formats.
|
Only has an effect for JSON output formats.
|
||||||
|
|
||||||
|
|
||||||
### Output details
|
### Output details
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `addressdetails=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| addressdetails | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
When set to 1, include a breakdown of the address into elements.
|
Include a breakdown of the address into elements. (Default: 0)
|
||||||
The exact content of the address breakdown depends on the output format.
|
|
||||||
|
|
||||||
!!! tip
|
|
||||||
If you are interested in a stable classification of address categories
|
|
||||||
(suburb, city, state, etc), have a look at the `geocodejson` format.
|
|
||||||
All other formats return classifications according to OSM tagging.
|
|
||||||
There is a much larger set of categories and they are not always consistent,
|
|
||||||
which makes them very hard to work with.
|
|
||||||
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `extratags=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| extratags | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
When set to 1, the response include any additional information in the result
|
Include additional information in the result if available,
|
||||||
that is available in the database, e.g. wikipedia link, opening hours.
|
e.g. wikipedia link, opening hours. (Default: 0)
|
||||||
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `namedetails=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| namedetails | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
When set to 1, include a full list of names for the result. These may include
|
Include a list of alternative names in the results. These may include
|
||||||
language variants, older names, references and brand.
|
language variants, references, operator and brand. (Default: 0)
|
||||||
|
|
||||||
|
|
||||||
### Language of results
|
### Language of results
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `accept-language=<browser language string>`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| accept-language | browser language string | content of "Accept-Language" HTTP header |
|
|
||||||
|
|
||||||
Preferred language order for showing search results. This may either be
|
|
||||||
a simple comma-separated list of language codes or have the same format
|
|
||||||
as the ["Accept-Language" HTTP header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language).
|
|
||||||
|
|
||||||
!!! tip
|
|
||||||
First-time users of Nominatim tend to be confused that they get different
|
|
||||||
results when using Nominatim in the browser versus in a command-line tool
|
|
||||||
like wget or curl. The command-line tools
|
|
||||||
usually don't send any Accept-Language header, prompting Nominatim
|
|
||||||
to show results in the local language. Browsers on the contrary always
|
|
||||||
send the currently chosen browser language.
|
|
||||||
|
|
||||||
|
Preferred language order for showing search results, overrides the value
|
||||||
|
specified in the "Accept-Language" HTTP header.
|
||||||
|
Either use a standard RFC2616 accept-language string or a simple
|
||||||
|
comma-separated list of language codes.
|
||||||
|
|
||||||
### Polygon output
|
### Polygon output
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `polygon_geojson=1`
|
||||||
|-----------| ----- | ------- |
|
* `polygon_kml=1`
|
||||||
| polygon_geojson | 0 or 1 | 0 |
|
* `polygon_svg=1`
|
||||||
| polygon_kml | 0 or 1 | 0 |
|
* `polygon_text=1`
|
||||||
| polygon_svg | 0 or 1 | 0 |
|
|
||||||
| polygon_text | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
Add the full geometry of the place to the result output. Output formats
|
Output geometry of results as a GeoJSON, KML, SVG or WKT. Only one of these
|
||||||
in GeoJSON, KML, SVG or WKT are supported. Only one of these
|
options can be used at a time. (Default: 0)
|
||||||
options can be used at a time.
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `polygon_threshold=0.0`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| polygon_threshold | floating-point number | 0.0 |
|
|
||||||
|
|
||||||
When one of the polygon_* outputs is chosen, return a simplified version
|
Return a simplified version of the output geometry. The parameter is the
|
||||||
of the output geometry. The parameter describes the
|
|
||||||
tolerance in degrees with which the geometry may differ from the original
|
tolerance in degrees with which the geometry may differ from the original
|
||||||
geometry. Topology is preserved in the geometry.
|
geometry. Topology is preserved in the result. (Default: 0.0)
|
||||||
|
|
||||||
|
|
||||||
### Other
|
### Other
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `email=<valid email address>`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| email | valid email address | _unset_ |
|
|
||||||
|
|
||||||
If you are making large numbers of request please include an appropriate email
|
If you are making large numbers of request please include an appropriate email
|
||||||
address to identify your requests. See Nominatim's
|
address to identify your requests. See Nominatim's [Usage Policy](https://operations.osmfoundation.org/policies/nominatim/) for more details.
|
||||||
[Usage Policy](https://operations.osmfoundation.org/policies/nominatim/) for more details.
|
|
||||||
|
|
||||||
|
* `debug=[0|1]`
|
||||||
| Parameter | Value | Default |
|
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| debug | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
Output assorted developer debug information. Data on internals of Nominatim's
|
Output assorted developer debug information. Data on internals of Nominatim's
|
||||||
"search loop" logic, and SQL queries. The output is HTML format.
|
"Search Loop" logic, and SQL queries. The output is (rough) HTML format.
|
||||||
This overrides the specified machine readable format.
|
This overrides the specified machine readable format. (Default: 0)
|
||||||
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ a single place (for reverse) of the following format:
|
|||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"place_id": 100149,
|
"place_id": "100149",
|
||||||
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
|
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
|
||||||
"osm_type": "node",
|
"osm_type": "node",
|
||||||
"osm_id": "107775",
|
"osm_id": "107775",
|
||||||
|
|||||||
@@ -1,14 +1,8 @@
|
|||||||
!!! Attention
|
### Nominatim API
|
||||||
The current version of Nominatim implements two different search frontends:
|
|
||||||
the old PHP frontend and the new Python frontend. They have a very similar
|
|
||||||
API but differ in some implementation details. These are marked in the
|
|
||||||
documentation as `[Python-only]` or `[PHP-only]`.
|
|
||||||
|
|
||||||
`https://nominatim.openstreetmap.org` implements the **Python frontend**.
|
Nominatim indexes named (or numbered) features within the OpenStreetMap (OSM) dataset and a subset of other unnamed features (pubs, hotels, churches, etc).
|
||||||
So users should refer to the **`[Python-only]`** comments.
|
|
||||||
|
|
||||||
This section describes the API V1 of the Nominatim web service. The
|
Its API has the following endpoints for querying the data:
|
||||||
service offers the following endpoints:
|
|
||||||
|
|
||||||
* __[/search](Search.md)__ - search OSM objects by name or type
|
* __[/search](Search.md)__ - search OSM objects by name or type
|
||||||
* __[/reverse](Reverse.md)__ - search OSM object by their location
|
* __[/reverse](Reverse.md)__ - search OSM object by their location
|
||||||
@@ -18,6 +12,3 @@ service offers the following endpoints:
|
|||||||
back in Nominatim in case the deletion was accidental
|
back in Nominatim in case the deletion was accidental
|
||||||
* __/polygons__ - list of broken polygons detected by Nominatim
|
* __/polygons__ - list of broken polygons detected by Nominatim
|
||||||
* __[/details](Details.md)__ - show internal details for an object (for debugging only)
|
* __[/details](Details.md)__ - show internal details for an object (for debugging only)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
# Reverse Geocoding
|
# Reverse Geocoding
|
||||||
|
|
||||||
Reverse geocoding generates an address from a coordinate given as
|
Reverse geocoding generates an address from a latitude and longitude.
|
||||||
latitude and longitude.
|
|
||||||
|
|
||||||
## How it works
|
## How it works
|
||||||
|
|
||||||
@@ -19,7 +18,8 @@ The other issue to be aware of is that the closest OSM object may not always
|
|||||||
have a similar enough address to the coordinate you were requesting. For
|
have a similar enough address to the coordinate you were requesting. For
|
||||||
example, in dense city areas it may belong to a completely different street.
|
example, in dense city areas it may belong to a completely different street.
|
||||||
|
|
||||||
## Endpoint
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
The main format of the reverse API is
|
The main format of the reverse API is
|
||||||
|
|
||||||
@@ -31,101 +31,57 @@ where `lat` and `lon` are latitude and longitude of a coordinate in WGS84
|
|||||||
projection. The API returns exactly one result or an error when the coordinate
|
projection. The API returns exactly one result or an error when the coordinate
|
||||||
is in an area with no OSM data coverage.
|
is in an area with no OSM data coverage.
|
||||||
|
|
||||||
|
Additional parameters are accepted as listed below.
|
||||||
|
|
||||||
!!! danger "Deprecation warning"
|
!!! warning "Deprecation warning"
|
||||||
The reverse API used to allow address lookup for a single OSM object by
|
The reverse API used to allow address lookup for a single OSM object by
|
||||||
its OSM id for `[PHP-only]`. The use is considered deprecated.
|
its OSM id. This use is now deprecated. Use the [Address Lookup API](Lookup.md)
|
||||||
Use the [Address Lookup API](Lookup.md) instead.
|
instead.
|
||||||
|
|
||||||
!!! danger "Deprecation warning"
|
|
||||||
The API can also be used with the URL
|
|
||||||
`https://nominatim.openstreetmap.org/reverse.php`. This is now deprecated
|
|
||||||
and will be removed in future versions.
|
|
||||||
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
This section lists additional parameters to further influence the output.
|
|
||||||
|
|
||||||
### Output format
|
### Output format
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `format=[xml|json|jsonv2|geojson|geocodejson]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| format | one of: `xml`, `json`, `jsonv2`, `geojson`, `geocodejson` | `xml` |
|
|
||||||
|
|
||||||
See [Place Output Formats](Output.md) for details on each format.
|
See [Place Output Formats](Output.md) for details on each format. (Default: xml)
|
||||||
|
|
||||||
|
* `json_callback=<string>`
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
Wrap JSON output in a callback function ([JSONP](https://en.wikipedia.org/wiki/JSONP)) i.e. `<string>(<json>)`.
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| json_callback | function name | _unset_ |
|
|
||||||
|
|
||||||
When given, then JSON output will be wrapped in a callback function with
|
|
||||||
the given name. See [JSONP](https://en.wikipedia.org/wiki/JSONP) for more
|
|
||||||
information.
|
|
||||||
|
|
||||||
Only has an effect for JSON output formats.
|
Only has an effect for JSON output formats.
|
||||||
|
|
||||||
|
|
||||||
### Output details
|
### Output details
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `addressdetails=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| addressdetails | 0 or 1 | 1 |
|
|
||||||
|
|
||||||
When set to 1, include a breakdown of the address into elements.
|
Include a breakdown of the address into elements. (Default: 1)
|
||||||
The exact content of the address breakdown depends on the output format.
|
|
||||||
|
|
||||||
!!! tip
|
|
||||||
If you are interested in a stable classification of address categories
|
|
||||||
(suburb, city, state, etc), have a look at the `geocodejson` format.
|
|
||||||
All other formats return classifications according to OSM tagging.
|
|
||||||
There is a much larger set of categories and they are not always consistent,
|
|
||||||
which makes them very hard to work with.
|
|
||||||
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `extratags=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| extratags | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
When set to 1, the response include any additional information in the result
|
Include additional information in the result if available,
|
||||||
that is available in the database, e.g. wikipedia link, opening hours.
|
e.g. wikipedia link, opening hours. (Default: 0)
|
||||||
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `namedetails=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| namedetails | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
When set to 1, include a full list of names for the result. These may include
|
Include a list of alternative names in the results. These may include
|
||||||
language variants, older names, references and brand.
|
language variants, references, operator and brand. (Default: 0)
|
||||||
|
|
||||||
|
|
||||||
### Language of results
|
### Language of results
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `accept-language=<browser language string>`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| accept-language | browser language string | content of "Accept-Language" HTTP header |
|
|
||||||
|
|
||||||
Preferred language order for showing search results. This may either be
|
Preferred language order for showing search results, overrides the value
|
||||||
a simple comma-separated list of language codes or have the same format
|
specified in the "Accept-Language" HTTP header.
|
||||||
as the ["Accept-Language" HTTP header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language).
|
Either use a standard RFC2616 accept-language string or a simple
|
||||||
|
comma-separated list of language codes.
|
||||||
|
|
||||||
!!! tip
|
### Result limitation
|
||||||
First-time users of Nominatim tend to be confused that they get different
|
|
||||||
results when using Nominatim in the browser versus in a command-line tool
|
|
||||||
like wget or curl. The command-line tools
|
|
||||||
usually don't send any Accept-Language header, prompting Nominatim
|
|
||||||
to show results in the local language. Browsers on the contrary always
|
|
||||||
send the currently chosen browser language.
|
|
||||||
|
|
||||||
|
* `zoom=[0-18]`
|
||||||
|
|
||||||
### Result restriction
|
Level of detail required for the address. Default: 18. This is a number that
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| zoom | 0-18 | 18 |
|
|
||||||
|
|
||||||
Level of detail required for the address. This is a number that
|
|
||||||
corresponds roughly to the zoom level used in XYZ tile sources in frameworks
|
corresponds roughly to the zoom level used in XYZ tile sources in frameworks
|
||||||
like Leaflet.js, Openlayers etc.
|
like Leaflet.js, Openlayers etc.
|
||||||
In terms of address details the zoom levels are as follows:
|
In terms of address details the zoom levels are as follows:
|
||||||
@@ -136,81 +92,41 @@ In terms of address details the zoom levels are as follows:
|
|||||||
5 | state
|
5 | state
|
||||||
8 | county
|
8 | county
|
||||||
10 | city
|
10 | city
|
||||||
12 | town / borough
|
14 | suburb
|
||||||
13 | village / suburb
|
|
||||||
14 | neighbourhood
|
|
||||||
15 | any settlement
|
|
||||||
16 | major streets
|
16 | major streets
|
||||||
17 | major and minor streets
|
17 | major and minor streets
|
||||||
18 | building
|
18 | building
|
||||||
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| layer | comma-separated list of: `address`, `poi`, `railway`, `natural`, `manmade` | _unset_ (no restriction) |
|
|
||||||
|
|
||||||
**`[Python-only]`**
|
|
||||||
|
|
||||||
The layer filter allows to select places by themes.
|
|
||||||
|
|
||||||
The `address` layer contains all places that make up an address:
|
|
||||||
address points with house numbers, streets, inhabited places (suburbs, villages,
|
|
||||||
cities, states etc.) and administrative boundaries.
|
|
||||||
|
|
||||||
The `poi` layer selects all point of interest. This includes classic points
|
|
||||||
of interest like restaurants, shops, hotels but also less obvious features
|
|
||||||
like recycling bins, guideposts or benches.
|
|
||||||
|
|
||||||
The `railway` layer includes railway infrastructure like tracks.
|
|
||||||
Note that in Nominatim's standard configuration, only very few railway
|
|
||||||
features are imported into the database.
|
|
||||||
|
|
||||||
The `natural` layer collects features like rivers, lakes and mountains while
|
|
||||||
the `manmade` layer functions as a catch-all for features not covered by the
|
|
||||||
other layers.
|
|
||||||
|
|
||||||
|
|
||||||
### Polygon output
|
### Polygon output
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `polygon_geojson=1`
|
||||||
|-----------| ----- | ------- |
|
* `polygon_kml=1`
|
||||||
| polygon_geojson | 0 or 1 | 0 |
|
* `polygon_svg=1`
|
||||||
| polygon_kml | 0 or 1 | 0 |
|
* `polygon_text=1`
|
||||||
| polygon_svg | 0 or 1 | 0 |
|
|
||||||
| polygon_text | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
Add the full geometry of the place to the result output. Output formats
|
Output geometry of results as a GeoJSON, KML, SVG or WKT. Only one of these
|
||||||
in GeoJSON, KML, SVG or WKT are supported. Only one of these
|
options can be used at a time. (Default: 0)
|
||||||
options can be used at a time.
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `polygon_threshold=0.0`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| polygon_threshold | floating-point number | 0.0 |
|
|
||||||
|
|
||||||
When one of the polygon_* outputs is chosen, return a simplified version
|
Return a simplified version of the output geometry. The parameter is the
|
||||||
of the output geometry. The parameter describes the
|
|
||||||
tolerance in degrees with which the geometry may differ from the original
|
tolerance in degrees with which the geometry may differ from the original
|
||||||
geometry. Topology is preserved in the geometry.
|
geometry. Topology is preserved in the result. (Default: 0.0)
|
||||||
|
|
||||||
|
|
||||||
### Other
|
### Other
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `email=<valid email address>`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| email | valid email address | _unset_ |
|
|
||||||
|
|
||||||
If you are making large numbers of request please include an appropriate email
|
If you are making a large number of requests, please include an appropriate email
|
||||||
address to identify your requests. See Nominatim's
|
address to identify your requests. See Nominatim's [Usage Policy](https://operations.osmfoundation.org/policies/nominatim/) for more details.
|
||||||
[Usage Policy](https://operations.osmfoundation.org/policies/nominatim/) for more details.
|
|
||||||
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `debug=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| debug | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
Output assorted developer debug information. Data on internals of Nominatim's
|
Output assorted developer debug information. Data on internals of Nominatim's
|
||||||
"search loop" logic, and SQL queries. The output is HTML format.
|
"Search Loop" logic, and SQL queries. The output is (rough) HTML format.
|
||||||
This overrides the specified machine readable format.
|
This overrides the specified machine readable format. (Default: 0)
|
||||||
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ The search query may also contain
|
|||||||
which are translated into specific OpenStreetMap (OSM) tags (e.g. Pub => `amenity=pub`).
|
which are translated into specific OpenStreetMap (OSM) tags (e.g. Pub => `amenity=pub`).
|
||||||
This can be used to narrow down the kind of objects to be returned.
|
This can be used to narrow down the kind of objects to be returned.
|
||||||
|
|
||||||
!!! note
|
!!! warning
|
||||||
Special phrases are not suitable to query all objects of a certain type in an
|
Special phrases are not suitable to query all objects of a certain type in an
|
||||||
area. Nominatim will always just return a collection of the best matches. To
|
area. Nominatim will always just return a collection of the best matches. To
|
||||||
download OSM data by object type, use the [Overpass API](https://overpass-api.de/).
|
download OSM data by object type, use the [Overpass API](https://overpass-api.de/).
|
||||||
|
|
||||||
## Endpoint
|
## Parameters
|
||||||
|
|
||||||
The search API has the following format:
|
The search API has the following format:
|
||||||
|
|
||||||
@@ -21,62 +21,35 @@ The search API has the following format:
|
|||||||
https://nominatim.openstreetmap.org/search?<params>
|
https://nominatim.openstreetmap.org/search?<params>
|
||||||
```
|
```
|
||||||
|
|
||||||
!!! danger "Deprecation warning"
|
The search term may be specified with two different sets of parameters:
|
||||||
The API can also be used with the URL
|
|
||||||
`https://nominatim.openstreetmap.org/search.php`. This is now deprecated
|
|
||||||
and will be removed in future versions.
|
|
||||||
|
|
||||||
The query term can be given in two different forms: free-form or structured.
|
* `q=<query>`
|
||||||
|
|
||||||
### Free-form query
|
Free-form query string to search for.
|
||||||
|
Free-form queries are processed first left-to-right and then right-to-left if that fails. So you may search for
|
||||||
|
[pilkington avenue, birmingham](https://nominatim.openstreetmap.org/search?q=pilkington+avenue,birmingham) as well as for
|
||||||
|
[birmingham, pilkington avenue](https://nominatim.openstreetmap.org/search?q=birmingham,+pilkington+avenue).
|
||||||
|
Commas are optional, but improve performance by reducing the complexity of the search.
|
||||||
|
|
||||||
| Parameter | Value |
|
|
||||||
|-----------| ----- |
|
|
||||||
| q | Free-form query string to search for |
|
|
||||||
|
|
||||||
In this form, the query can be unstructured.
|
* `street=<housenumber> <streetname>`
|
||||||
Free-form queries are processed first left-to-right and then right-to-left if that fails. So you may search for
|
* `city=<city>`
|
||||||
[pilkington avenue, birmingham](https://nominatim.openstreetmap.org/search?q=pilkington+avenue,birmingham) as well as for
|
* `county=<county>`
|
||||||
[birmingham, pilkington avenue](https://nominatim.openstreetmap.org/search?q=birmingham,+pilkington+avenue).
|
* `state=<state>`
|
||||||
Commas are optional, but improve performance by reducing the complexity of the search.
|
* `country=<country>`
|
||||||
|
* `postalcode=<postalcode>`
|
||||||
|
|
||||||
The free-form may also contain special phrases to describe the type of
|
Alternative query string format split into several parameters for structured requests.
|
||||||
place to be returned or a coordinate to search close to a position.
|
Structured requests are faster but are less robust against alternative
|
||||||
|
OSM tagging schemas. **Do not combine with** `q=<query>` **parameter**.
|
||||||
|
|
||||||
### Structured query
|
Both query forms accept the additional parameters listed below.
|
||||||
|
|
||||||
| Parameter | Value |
|
|
||||||
|----------- | ----- |
|
|
||||||
| amenity | name and/or type of POI |
|
|
||||||
| street | housenumber and streetname |
|
|
||||||
| city | city |
|
|
||||||
| county | county |
|
|
||||||
| state | state |
|
|
||||||
| country | country |
|
|
||||||
| postalcode | postal code |
|
|
||||||
|
|
||||||
The structured form of the search query allows to lookup up an address
|
|
||||||
that is already split into its components. Each parameter represents a field
|
|
||||||
of the address. All parameters are optional. You should only use the ones
|
|
||||||
that are relevant for the address you want to geocode.
|
|
||||||
|
|
||||||
!!! Attention
|
|
||||||
Cannot be combined with the `q=<query>` parameter. Newer versions of
|
|
||||||
the API will return an error if you do so. Older versions simply return
|
|
||||||
unexpected results.
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
The following parameters can be used to further restrict the search and
|
|
||||||
change the output. They are usable for both forms of the search query.
|
|
||||||
|
|
||||||
### Output format
|
### Output format
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `format=[xml|json|jsonv2|geojson|geocodejson]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| format | one of: `xml`, `json`, `jsonv2`, `geojson`, `geocodejson` | `jsonv2` |
|
|
||||||
|
|
||||||
See [Place Output Formats](Output.md) for details on each format.
|
See [Place Output Formats](Output.md) for details on each format. (Default: jsonv2)
|
||||||
|
|
||||||
!!! note
|
!!! note
|
||||||
The Nominatim service at
|
The Nominatim service at
|
||||||
@@ -84,150 +57,52 @@ See [Place Output Formats](Output.md) for details on each format.
|
|||||||
has a different default behaviour for historical reasons. When the
|
has a different default behaviour for historical reasons. When the
|
||||||
`format` parameter is omitted, the request will be forwarded to the Web UI.
|
`format` parameter is omitted, the request will be forwarded to the Web UI.
|
||||||
|
|
||||||
|
* `json_callback=<string>`
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
Wrap JSON output in a callback function ([JSONP](https://en.wikipedia.org/wiki/JSONP)) i.e. `<string>(<json>)`.
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| json_callback | function name | _unset_ |
|
|
||||||
|
|
||||||
When given, then JSON output will be wrapped in a callback function with
|
|
||||||
the given name. See [JSONP](https://en.wikipedia.org/wiki/JSONP) for more
|
|
||||||
information.
|
|
||||||
|
|
||||||
Only has an effect for JSON output formats.
|
Only has an effect for JSON output formats.
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| limit | number | 10 |
|
|
||||||
|
|
||||||
Limit the maximum number of returned results. Cannot be more than 40.
|
|
||||||
Nominatim may decide to return less results than given, if additional
|
|
||||||
results do not sufficiently match the query.
|
|
||||||
|
|
||||||
|
|
||||||
### Output details
|
### Output details
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `addressdetails=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| addressdetails | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
When set to 1, include a breakdown of the address into elements.
|
Include a breakdown of the address into elements. (Default: 0)
|
||||||
The exact content of the address breakdown depends on the output format.
|
|
||||||
|
|
||||||
!!! tip
|
|
||||||
If you are interested in a stable classification of address categories
|
|
||||||
(suburb, city, state, etc), have a look at the `geocodejson` format.
|
|
||||||
All other formats return classifications according to OSM tagging.
|
|
||||||
There is a much larger set of categories and they are not always consistent,
|
|
||||||
which makes them very hard to work with.
|
|
||||||
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `extratags=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| extratags | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
When set to 1, the response include any additional information in the result
|
Include additional information in the result if available,
|
||||||
that is available in the database, e.g. wikipedia link, opening hours.
|
e.g. wikipedia link, opening hours. (Default: 0)
|
||||||
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `namedetails=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| namedetails | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
When set to 1, include a full list of names for the result. These may include
|
Include a list of alternative names in the results. These may include
|
||||||
language variants, older names, references and brand.
|
language variants, references, operator and brand. (Default: 0)
|
||||||
|
|
||||||
|
|
||||||
### Language of results
|
### Language of results
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `accept-language=<browser language string>`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| accept-language | browser language string | content of "Accept-Language" HTTP header |
|
|
||||||
|
|
||||||
Preferred language order for showing search results. This may either be
|
Preferred language order for showing search results, overrides the value
|
||||||
a simple comma-separated list of language codes or have the same format
|
specified in the ["Accept-Language" HTTP header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language).
|
||||||
as the ["Accept-Language" HTTP header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language).
|
Either use a standard RFC2616 accept-language string or a simple
|
||||||
|
comma-separated list of language codes.
|
||||||
|
|
||||||
!!! tip
|
### Result limitation
|
||||||
First-time users of Nominatim tend to be confused that they get different
|
|
||||||
results when using Nominatim in the browser versus in a command-line tool
|
|
||||||
like wget or curl. The command-line tools
|
|
||||||
usually don't send any Accept-Language header, prompting Nominatim
|
|
||||||
to show results in the local language. Browsers on the contrary always
|
|
||||||
send the currently chosen browser language.
|
|
||||||
|
|
||||||
### Result restriction
|
* `countrycodes=<countrycode>[,<countrycode>][,<countrycode>]...`
|
||||||
|
|
||||||
There are two ways to influence the results. *Filters* exclude certain
|
Limit search results to one or more countries. `<countrycode>` must be the
|
||||||
kinds of results completely. *Boost parameters* only change the order of the
|
[ISO 3166-1alpha2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code,
|
||||||
results and thus give a preference to some results over others.
|
e.g. `gb` for the United Kingdom, `de` for Germany.
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| countrycodes | comma-separated list of country codes | _unset_ |
|
|
||||||
|
|
||||||
Filter that limits the search results to one or more countries.
|
|
||||||
The country code must be the
|
|
||||||
[ISO 3166-1alpha2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code
|
|
||||||
of the country, e.g. `gb` for the United Kingdom, `de` for Germany.
|
|
||||||
|
|
||||||
Each place in Nominatim is assigned to one country code based
|
Each place in Nominatim is assigned to one country code based
|
||||||
on OSM country boundaries. In rare cases a place may not be in any country
|
on OSM country boundaries. In rare cases a place may not be in any country
|
||||||
at all, for example, when it is in international waters. These places are
|
at all, for example, in international waters.
|
||||||
also excluded when the filter is set.
|
|
||||||
|
|
||||||
!!! Note
|
* `exclude_place_ids=<place_id,[place_id],[place_id]`
|
||||||
This parameter should not be confused with the 'country' parameter of
|
|
||||||
the structured query. The 'country' parameter contains a search term
|
|
||||||
and will be handled with some fuzziness. The `countrycodes` parameter
|
|
||||||
is a hard filter and as such should be preferred. Having both parameters
|
|
||||||
in the same query will work. If the parameters contradict each other,
|
|
||||||
the search will come up empty.
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| layer | comma-separated list of: `address`, `poi`, `railway`, `natural`, `manmade` | _unset_ (no restriction) |
|
|
||||||
|
|
||||||
**`[Python-only]`**
|
|
||||||
|
|
||||||
The layer filter allows to select places by themes.
|
|
||||||
|
|
||||||
The `address` layer contains all places that make up an address:
|
|
||||||
address points with house numbers, streets, inhabited places (suburbs, villages,
|
|
||||||
cities, states tec.) and administrative boundaries.
|
|
||||||
|
|
||||||
The `poi` layer selects all point of interest. This includes classic POIs like
|
|
||||||
restaurants, shops, hotels but also less obvious features like recycling bins,
|
|
||||||
guideposts or benches.
|
|
||||||
|
|
||||||
The `railway` layer includes railway infrastructure like tracks.
|
|
||||||
Note that in Nominatim's standard configuration, only very few railway
|
|
||||||
features are imported into the database.
|
|
||||||
|
|
||||||
The `natural` layer collects features like rivers, lakes and mountains while
|
|
||||||
the `manmade` layer functions as a catch-all for features not covered by the
|
|
||||||
other layers.
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| featureType | one of: `country`, `state`, `city`, `settlement` | _unset_ |
|
|
||||||
|
|
||||||
The featureType allows to have a more fine-grained selection for places
|
|
||||||
from the address layer. Results can be restricted to places that make up
|
|
||||||
the 'state', 'country' or 'city' part of an address. A featureType of
|
|
||||||
settlement selects any human inhabited feature from 'state' down to
|
|
||||||
'neighbourhood'.
|
|
||||||
|
|
||||||
When featureType is set, then results are automatically restricted
|
|
||||||
to the address layer (see above).
|
|
||||||
|
|
||||||
!!! tip
|
|
||||||
Instead of using the featureType filters `country`, `state` or `city`,
|
|
||||||
you can also use a structured query without the finer-grained parameters
|
|
||||||
amenity or street.
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| exclude_place_ids | comma-separated list of place ids |
|
|
||||||
|
|
||||||
If you do not want certain OSM objects to appear in the search
|
If you do not want certain OSM objects to appear in the search
|
||||||
result, give a comma separated list of the `place_id`s you want to skip.
|
result, give a comma separated list of the `place_id`s you want to skip.
|
||||||
@@ -235,212 +110,180 @@ This can be used to retrieve additional search results. For example, if a
|
|||||||
previous query only returned a few results, then including those here would
|
previous query only returned a few results, then including those here would
|
||||||
cause the search to return other, less accurate, matches (if possible).
|
cause the search to return other, less accurate, matches (if possible).
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| viewbox | `<x1>,<y1>,<x2>,<y2>` | _unset_ |
|
|
||||||
|
|
||||||
Boost parameter which focuses the search on the given area.
|
* `limit=<integer>`
|
||||||
Any two corner points of the box are accepted as long as they make a proper
|
|
||||||
box. `x` is longitude, `y` is latitude.
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
Limit the number of returned results. (Default: 10, Maximum: 50)
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| bounded | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
When set to 1, then it turns the 'viewbox' parameter (see above) into
|
|
||||||
a filter parameter, excluding any results outside the viewbox.
|
|
||||||
|
|
||||||
When `bounded=1` is given and the viewbox is small enough, then an amenity-only
|
* `viewbox=<x1>,<y1>,<x2>,<y2>`
|
||||||
search is allowed. Give the special keyword for the amenity in square
|
|
||||||
|
The preferred area to find search results. Any two corner points of the box
|
||||||
|
are accepted as long as they span a real box. `x` is longitude,
|
||||||
|
`y` is latitude.
|
||||||
|
|
||||||
|
|
||||||
|
* `bounded=[0|1]`
|
||||||
|
|
||||||
|
When a viewbox is given, restrict the result to items contained within that
|
||||||
|
viewbox (see above). When `viewbox` and `bounded=1` are given, an amenity
|
||||||
|
only search is allowed. Give the special keyword for the amenity in square
|
||||||
brackets, e.g. `[pub]` and a selection of objects of this type is returned.
|
brackets, e.g. `[pub]` and a selection of objects of this type is returned.
|
||||||
There is no guarantee that the result returns all objects in the area.
|
There is no guarantee that the result is complete. (Default: 0)
|
||||||
|
|
||||||
|
|
||||||
### Polygon output
|
### Polygon output
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `polygon_geojson=1`
|
||||||
|-----------| ----- | ------- |
|
* `polygon_kml=1`
|
||||||
| polygon_geojson | 0 or 1 | 0 |
|
* `polygon_svg=1`
|
||||||
| polygon_kml | 0 or 1 | 0 |
|
* `polygon_text=1`
|
||||||
| polygon_svg | 0 or 1 | 0 |
|
|
||||||
| polygon_text | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
Add the full geometry of the place to the result output. Output formats
|
Output geometry of results as a GeoJSON, KML, SVG or WKT. Only one of these
|
||||||
in GeoJSON, KML, SVG or WKT are supported. Only one of these
|
options can be used at a time. (Default: 0)
|
||||||
options can be used at a time.
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `polygon_threshold=0.0`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| polygon_threshold | floating-point number | 0.0 |
|
|
||||||
|
|
||||||
When one of the polygon_* outputs is chosen, return a simplified version
|
Return a simplified version of the output geometry. The parameter is the
|
||||||
of the output geometry. The parameter describes the
|
|
||||||
tolerance in degrees with which the geometry may differ from the original
|
tolerance in degrees with which the geometry may differ from the original
|
||||||
geometry. Topology is preserved in the geometry.
|
geometry. Topology is preserved in the result. (Default: 0.0)
|
||||||
|
|
||||||
### Other
|
### Other
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `email=<valid email address>`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| email | valid email address | _unset_ |
|
|
||||||
|
|
||||||
If you are making large numbers of request please include an appropriate email
|
If you are making large numbers of request please include an appropriate email
|
||||||
address to identify your requests. See Nominatim's
|
address to identify your requests. See Nominatim's [Usage Policy](https://operations.osmfoundation.org/policies/nominatim/) for more details.
|
||||||
[Usage Policy](https://operations.osmfoundation.org/policies/nominatim/) for more details.
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `dedupe=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| dedupe | 0 or 1 | 1 |
|
|
||||||
|
|
||||||
Sometimes you have several objects in OSM identifying the same place or
|
Sometimes you have several objects in OSM identifying the same place or
|
||||||
object in reality. The simplest case is a street being split into many
|
object in reality. The simplest case is a street being split into many
|
||||||
different OSM ways due to different characteristics. Nominatim will
|
different OSM ways due to different characteristics. Nominatim will
|
||||||
attempt to detect such duplicates and only return one match. Setting
|
attempt to detect such duplicates and only return one match unless
|
||||||
this parameter to 0 disables this deduplication mechanism and
|
this parameter is set to 0. (Default: 1)
|
||||||
ensures that all results are returned.
|
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
* `debug=[0|1]`
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| debug | 0 or 1 | 0 |
|
|
||||||
|
|
||||||
Output assorted developer debug information. Data on internals of Nominatim's
|
Output assorted developer debug information. Data on internals of Nominatim's
|
||||||
"search loop" logic, and SQL queries. The output is HTML format.
|
"Search Loop" logic, and SQL queries. The output is (rough) HTML format.
|
||||||
This overrides the specified machine readable format.
|
This overrides the specified machine readable format. (Default: 0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
|
||||||
##### XML with KML polygon
|
##### XML with kml polygon
|
||||||
|
|
||||||
* [https://nominatim.openstreetmap.org/search?q=135+pilkington+avenue,+birmingham&format=xml&polygon_kml=1&addressdetails=1](https://nominatim.openstreetmap.org/search?q=135+pilkington+avenue,+birmingham&format=xml&polygon_kml=1&addressdetails=1)
|
* [https://nominatim.openstreetmap.org/search?q=135+pilkington+avenue,+birmingham&format=xml&polygon_geojson=1&addressdetails=1](https://nominatim.openstreetmap.org/search?q=135+pilkington+avenue,+birmingham&format=xml&polygon_geojson=1&addressdetails=1)
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<searchresults timestamp="Sat, 07 Nov 09 14:42:10 +0000" querystring="135 pilkington, avenue birmingham" polygon="true">
|
||||||
<searchresults timestamp="Tue, 08 Aug 2023 15:45:41 +00:00"
|
<place
|
||||||
attribution="Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright"
|
place_id="1620612" osm_type="node" osm_id="452010817"
|
||||||
querystring="135 pilkington avenue, birmingham"
|
boundingbox="52.548641204834,52.5488433837891,-1.81612110137939,-1.81592094898224"
|
||||||
more_url="https://nominatim.openstreetmap.org/search?q=135+pilkington+avenue%2C+birmingham&polygon_kml=1&addressdetails=1&limit=20&exclude_place_ids=125279639&format=xml"
|
lat="52.5487429714954" lon="-1.81602098644987"
|
||||||
exclude_place_ids="125279639">
|
display_name="135, Pilkington Avenue, Wylde Green, City of Birmingham, West Midlands (county), B72, United Kingdom"
|
||||||
<place place_id="125279639"
|
class="place" type="house">
|
||||||
osm_type="way"
|
<geokml>
|
||||||
osm_id="90394480"
|
<Polygon>
|
||||||
lat="52.5487921"
|
<outerBoundaryIs>
|
||||||
lon="-1.8164308"
|
<LinearRing>
|
||||||
boundingbox="52.5487473,52.5488481,-1.8165130,-1.8163464"
|
<coordinates>-1.816513,52.548756599999997 -1.816434,52.548747300000002 -1.816429,52.5487629 -1.8163717,52.548756099999999 -1.8163464,52.548834599999999 -1.8164599,52.548848100000001 -1.8164685,52.5488213 -1.8164913,52.548824000000003 -1.816513,52.548756599999997</coordinates>
|
||||||
place_rank="30"
|
</LinearRing>
|
||||||
address_rank="30"
|
</outerBoundaryIs>
|
||||||
display_name="135, Pilkington Avenue, Maney, Sutton Coldfield, Wylde Green, Birmingham, West Midlands Combined Authority, England, B72 1LH, United Kingdom"
|
</Polygon>
|
||||||
class="building"
|
</geokml>
|
||||||
type="residential"
|
<house_number>135</house_number>
|
||||||
importance="9.999999994736442e-08">
|
<road>Pilkington Avenue</road>
|
||||||
<geokml>
|
<village>Wylde Green</village>
|
||||||
<Polygon>
|
<town>Sutton Coldfield</town>
|
||||||
<outerBoundaryIs>
|
<city>City of Birmingham</city>
|
||||||
<LinearRing>
|
<county>West Midlands (county)</county>
|
||||||
<coordinates>-1.816513,52.5487566 -1.816434,52.5487473 -1.816429,52.5487629 -1.8163717,52.5487561 -1.8163464,52.5488346 -1.8164599,52.5488481 -1.8164685,52.5488213 -1.8164913,52.548824 -1.816513,52.5487566</coordinates>
|
<postcode>B72</postcode>
|
||||||
</LinearRing>
|
<country>United Kingdom</country>
|
||||||
</outerBoundaryIs>
|
<country_code>gb</country_code>
|
||||||
</Polygon>
|
</place>
|
||||||
</geokml>
|
</searchresults>
|
||||||
<house_number>135</house_number>
|
|
||||||
<road>Pilkington Avenue</road>
|
|
||||||
<hamlet>Maney</hamlet>
|
|
||||||
<town>Sutton Coldfield</town>
|
|
||||||
<village>Wylde Green</village>
|
|
||||||
<city>Birmingham</city>
|
|
||||||
<ISO3166-2-lvl8>GB-BIR</ISO3166-2-lvl8>
|
|
||||||
<state_district>West Midlands Combined Authority</state_district>
|
|
||||||
<state>England</state>
|
|
||||||
<ISO3166-2-lvl4>GB-ENG</ISO3166-2-lvl4>
|
|
||||||
<postcode>B72 1LH</postcode>
|
|
||||||
<country>United Kingdom</country>
|
|
||||||
<country_code>gb</country_code>
|
|
||||||
</place>
|
|
||||||
</searchresults>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
##### JSON with SVG polygon
|
##### JSON with SVG polygon
|
||||||
|
|
||||||
[https://nominatim.openstreetmap.org/search?q=Unter%20den%20Linden%201%20Berlin&format=json&addressdetails=1&limit=1&polygon_svg=1](https://nominatim.openstreetmap.org/search?q=Unter%20den%20Linden%201%20Berlin&format=json&addressdetails=1&limit=1&polygon_svg=1)
|
[https://nominatim.openstreetmap.org/search/Unter%20den%20Linden%201%20Berlin?format=json&addressdetails=1&limit=1&polygon_svg=1](https://nominatim.openstreetmap.org/search/Unter%20den%20Linden%201%20Berlin?format=json&addressdetails=1&limit=1&polygon_svg=1)
|
||||||
|
|
||||||
```json
|
```json
|
||||||
[
|
{
|
||||||
{
|
"address": {
|
||||||
"address": {
|
"city": "Berlin",
|
||||||
"ISO3166-2-lvl4": "DE-BE",
|
"city_district": "Mitte",
|
||||||
"borough": "Mitte",
|
"construction": "Unter den Linden",
|
||||||
"city": "Berlin",
|
"continent": "European Union",
|
||||||
"country": "Deutschland",
|
"country": "Deutschland",
|
||||||
"country_code": "de",
|
"country_code": "de",
|
||||||
"historic": "Kommandantenhaus",
|
"house_number": "1",
|
||||||
"house_number": "1",
|
"neighbourhood": "Scheunenviertel",
|
||||||
"neighbourhood": "Friedrichswerder",
|
"postcode": "10117",
|
||||||
"postcode": "10117",
|
"public_building": "Kommandantenhaus",
|
||||||
"road": "Unter den Linden",
|
"state": "Berlin",
|
||||||
"suburb": "Mitte"
|
"suburb": "Mitte"
|
||||||
},
|
},
|
||||||
"boundingbox": [
|
"boundingbox": [
|
||||||
"52.5170798",
|
"52.5170783996582",
|
||||||
"52.5173311",
|
"52.5173187255859",
|
||||||
"13.3975116",
|
"13.3975105285645",
|
||||||
"13.3981577"
|
"13.3981599807739"
|
||||||
],
|
],
|
||||||
"class": "historic",
|
"class": "amenity",
|
||||||
"display_name": "Kommandantenhaus, 1, Unter den Linden, Friedrichswerder, Mitte, Berlin, 10117, Deutschland",
|
"display_name": "Kommandantenhaus, 1, Unter den Linden, Scheunenviertel, Mitte, Berlin, 10117, Deutschland, European Union",
|
||||||
"importance": 0.8135042058306902,
|
"importance": 0.73606775332943,
|
||||||
"lat": "52.51720765",
|
"lat": "52.51719785",
|
||||||
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
|
"licence": "Data \u00a9 OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright",
|
||||||
"lon": "13.397834399325466",
|
"lon": "13.3978352028938",
|
||||||
"osm_id": 15976890,
|
"osm_id": "15976890",
|
||||||
"osm_type": "way",
|
"osm_type": "way",
|
||||||
"place_id": 108681845,
|
"place_id": "30848715",
|
||||||
"svg": "M 13.3975116 -52.5172905 L 13.397549 -52.5170798 13.397715 -52.5170906 13.3977122 -52.5171064 13.3977392 -52.5171086 13.3977417 -52.5170924 13.3979655 -52.5171069 13.3979623 -52.5171233 13.3979893 -52.5171248 13.3979922 -52.5171093 13.3981577 -52.5171203 13.398121 -52.5173311 13.3978115 -52.5173103 Z",
|
"svg": "M 13.397511 -52.517283599999999 L 13.397829400000001 -52.517299800000004 13.398131599999999 -52.517315099999998 13.398159400000001 -52.517112099999999 13.3975388 -52.517080700000001 Z",
|
||||||
"type": "house"
|
"type": "public_building"
|
||||||
}
|
}
|
||||||
]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
##### JSON with address details
|
##### JSON with address details
|
||||||
|
|
||||||
[https://nominatim.openstreetmap.org/search?addressdetails=1&q=bakery+in+berlin+wedding&format=jsonv2&limit=1](https://nominatim.openstreetmap.org/search?addressdetails=1&q=bakery+in+berlin+wedding&format=jsonv2&limit=1)
|
[https://nominatim.openstreetmap.org/?addressdetails=1&q=bakery+in+berlin+wedding&format=json&limit=1](https://nominatim.openstreetmap.org/?addressdetails=1&q=bakery+in+berlin+wedding&format=json&limit=1)
|
||||||
|
|
||||||
```json
|
```json
|
||||||
[
|
{
|
||||||
{
|
"address": {
|
||||||
"address": {
|
"bakery": "B\u00e4cker Kamps",
|
||||||
"ISO3166-2-lvl4": "DE-BE",
|
"city_district": "Mitte",
|
||||||
"borough": "Mitte",
|
"continent": "European Union",
|
||||||
"city": "Berlin",
|
"country": "Deutschland",
|
||||||
"country": "Deutschland",
|
"country_code": "de",
|
||||||
"country_code": "de",
|
"footway": "Bahnsteig U6",
|
||||||
"neighbourhood": "Sprengelkiez",
|
"neighbourhood": "Sprengelkiez",
|
||||||
"postcode": "13347",
|
"postcode": "13353",
|
||||||
"road": "Lindower Straße",
|
"state": "Berlin",
|
||||||
"shop": "Ditsch",
|
"suburb": "Wedding"
|
||||||
"suburb": "Wedding"
|
},
|
||||||
},
|
"boundingbox": [
|
||||||
"addresstype": "shop",
|
"52.5460929870605",
|
||||||
"boundingbox": [
|
"52.5460968017578",
|
||||||
"52.5427201",
|
"13.3591794967651",
|
||||||
"52.5427654",
|
"13.3591804504395"
|
||||||
"13.3668619",
|
],
|
||||||
"13.3669442"
|
"class": "shop",
|
||||||
],
|
"display_name": "B\u00e4cker Kamps, Bahnsteig U6, Sprengelkiez, Wedding, Mitte, Berlin, 13353, Deutschland, European Union",
|
||||||
"category": "shop",
|
"icon": "https://nominatim.openstreetmap.org/images/mapicons/shopping_bakery.p.20.png",
|
||||||
"display_name": "Ditsch, Lindower Straße, Sprengelkiez, Wedding, Mitte, Berlin, 13347, Deutschland",
|
"importance": 0.201,
|
||||||
"importance": 9.99999999995449e-06,
|
"lat": "52.5460941",
|
||||||
"lat": "52.54274275",
|
"licence": "Data \u00a9 OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright",
|
||||||
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright",
|
"lon": "13.35918",
|
||||||
"lon": "13.36690305710228",
|
"osm_id": "317179427",
|
||||||
"name": "Ditsch",
|
"osm_type": "node",
|
||||||
"osm_id": 437595031,
|
"place_id": "1453068",
|
||||||
"osm_type": "way",
|
"type": "bakery"
|
||||||
"place_id": 204751033,
|
}
|
||||||
"place_rank": 30,
|
|
||||||
"type": "bakery"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
##### GeoJSON
|
##### GeoJSON
|
||||||
|
|||||||
@@ -1,50 +1,35 @@
|
|||||||
# Status
|
# Status
|
||||||
|
|
||||||
Report on the state of the service and database. Useful for checking if the
|
Useful for checking if the service and database is running. The JSON output also shows
|
||||||
service is up and running. The JSON output also reports
|
|
||||||
when the database was last updated.
|
when the database was last updated.
|
||||||
|
|
||||||
## Endpoint
|
|
||||||
|
|
||||||
The status API has the following format:
|
|
||||||
|
|
||||||
```
|
|
||||||
https://nominatim.openstreetmap.org/status
|
|
||||||
```
|
|
||||||
|
|
||||||
!!! danger "Deprecation warning"
|
|
||||||
The API can also be used with the URL
|
|
||||||
`https://nominatim.openstreetmap.org/status.php`. This is now deprecated
|
|
||||||
and will be removed in future versions.
|
|
||||||
|
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
The status endpoint takes a single optional parameter:
|
* `format=[text|json]` (defaults to 'text')
|
||||||
|
|
||||||
| Parameter | Value | Default |
|
|
||||||
|-----------| ----- | ------- |
|
|
||||||
| format | one of: `text`, `json` | 'text' |
|
|
||||||
|
|
||||||
Selects the output format. See below.
|
|
||||||
|
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
|
|
||||||
#### Text format
|
#### Text format
|
||||||
|
|
||||||
When everything is okay, a status code 200 is returned and a simple message: `OK`
|
```
|
||||||
|
https://nominatim.openstreetmap.org/status.php
|
||||||
|
```
|
||||||
|
|
||||||
On error it will return HTTP status code 500 and print a detailed error message, e.g.
|
will return HTTP status code 200 and print `OK`.
|
||||||
|
|
||||||
|
On error it will return HTTP status code 500 and print a message, e.g.
|
||||||
`ERROR: Database connection failed`.
|
`ERROR: Database connection failed`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### JSON format
|
#### JSON format
|
||||||
|
|
||||||
Always returns a HTTP code 200, when the status call could be executed.
|
```
|
||||||
|
https://nominatim.openstreetmap.org/status.php?format=json
|
||||||
|
```
|
||||||
|
|
||||||
On success a JSON dictionary with the following structure is returned:
|
will return HTTP code 200 and a structure
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -60,8 +45,8 @@ The `software_version` field contains the version of Nominatim used to serve
|
|||||||
the API. The `database_version` field contains the version of the data format
|
the API. The `database_version` field contains the version of the data format
|
||||||
in the database.
|
in the database.
|
||||||
|
|
||||||
On error will return a shorter JSON dictionary with the error message
|
On error will also return HTTP status code 200 and a structure with error
|
||||||
and status only, e.g.
|
code and message, e.g.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -69,3 +54,14 @@ and status only, e.g.
|
|||||||
"message": "Database connection failed"
|
"message": "Database connection failed"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Possible status codes are
|
||||||
|
|
||||||
|
| | message | notes |
|
||||||
|
| --- | ------------------------------ | ----------------------------------------------------------------- |
|
||||||
|
| 700 | "No database" | connection failed |
|
||||||
|
| 701 | "Module failed" | database could not load nominatim.so |
|
||||||
|
| 702 | "Module call failed" | nominatim.so loaded but calling a function failed |
|
||||||
|
| 703 | "Query failed" | test query against a database table failed |
|
||||||
|
| 704 | "No value" | test query worked but returned no results |
|
||||||
|
| 705 | "Import date is not available" | No import dates were returned (enabling replication can fix this) |
|
||||||
|
|||||||
7
docs/bash2md.sh
Executable file
7
docs/bash2md.sh
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Extract markdown-formatted documentation from a source file
|
||||||
|
#
|
||||||
|
# Usage: bash2md.sh <infile> <outfile>
|
||||||
|
|
||||||
|
sed '/^#!/d;s:^#\( \|$\)::;s/.*#DOCS://' $1 > $2
|
||||||
@@ -1,439 +1,149 @@
|
|||||||
## Configuring the Import
|
## Configuring the Import
|
||||||
|
|
||||||
In the very first step of a Nominatim import, OSM data is loaded into the
|
Which OSM objects are added to the database and which of the tags are used
|
||||||
database. Nominatim uses [osm2pgsql](https://osm2pgsql.org) for this task.
|
can be configured via the import style configuration file. This
|
||||||
It comes with a [flex style](https://osm2pgsql.org/doc/manual.html#the-flex-output)
|
is a JSON file which contains a list of rules which are matched against every
|
||||||
specifically tailored to filter and convert OSM data into Nominatim's
|
tag of every object and then assign the tag its specific role.
|
||||||
internal data representation.
|
|
||||||
|
|
||||||
There are a number of default configurations for the flex style which
|
The style to use is given by the `NOMINATIM_IMPORT_STYLE` configuration
|
||||||
result in geocoding databases of different detail. The
|
option. There are a number of default styles, which are explained in detail
|
||||||
[Import section](../admin/Import.md#filtering-imported-data) explains
|
in the [Import section](../admin/Import.md#filtering-imported-data). These
|
||||||
these default configurations in detail.
|
standard styles may be referenced by their name.
|
||||||
|
|
||||||
You can also create your own custom style. Put the style file into your
|
You can also create your own custom style. Put the style file into your
|
||||||
project directory and then set `NOMINATIM_IMPORT_STYLE` to the name of the file.
|
project directory and then set `NOMINATIM_IMPORT_STYLE` to the name of the file.
|
||||||
It is always recommended to start with one of the standard styles and customize
|
It is always recommended to start with one of the standard styles and customize
|
||||||
those. You find the standard styles under the name `import-<stylename>.lua`
|
those. You find the standard styles under the name `import-<stylename>.style`
|
||||||
in the standard Nominatim configuration path (usually `/etc/nominatim` or
|
in the standard Nominatim configuration path (usually `/etc/nominatim` or
|
||||||
`/usr/local/etc/nominatim`).
|
`/usr/local/etc/nominatim`).
|
||||||
|
|
||||||
The remainder of the page describes how the flex style works and how to
|
The remainder of the page describes the format of the file.
|
||||||
customize it.
|
|
||||||
|
|
||||||
### The `flex-base.lua` module
|
### Configuration Rules
|
||||||
|
|
||||||
The core of Nominatim's flex import configuration is the `flex-base` module.
|
A single rule looks like this:
|
||||||
It defines the table layout used by Nominatim and provides standard
|
|
||||||
implementations for the import callbacks that make it easy to customize
|
|
||||||
how OSM tags are used by Nominatim.
|
|
||||||
|
|
||||||
Every custom style should include this module to make sure that the correct
|
|
||||||
tables are created. Thus start your custom style as follows:
|
|
||||||
|
|
||||||
``` lua
|
|
||||||
local flex = require('flex-base')
|
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"keys" : ["key1", "key2", ...],
|
||||||
|
"values" : {
|
||||||
|
"value1" : "prop",
|
||||||
|
"value2" : "prop1,prop2"
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The following sections explain how the module can be customized.
|
A rule first defines a list of keys to apply the rule to. This is always a list
|
||||||
|
of strings. The string may have four forms. An empty string matches against
|
||||||
|
any key. A string that ends in an asterisk `*` is a prefix match and accordingly
|
||||||
### Changing the recognized tags
|
matches against any key that starts with the given string (minus the `*`). A
|
||||||
|
suffix match can be defined similarly with a string that starts with a `*`. Any
|
||||||
If you just want to change which OSM tags are recognized during import,
|
other string constitutes an exact match.
|
||||||
then there are a number of convenience functions to set the tag lists used
|
|
||||||
during the processing.
|
|
||||||
|
|
||||||
!!! warning
|
|
||||||
There are no built-in defaults for the tag lists, so all the functions
|
|
||||||
need to be called from your style script to fully process the data.
|
|
||||||
Make sure you start from one of the default style and only modify
|
|
||||||
the data you are interested in. You can also derive your style from an
|
|
||||||
existing style by importing the appropriate module, e.g.
|
|
||||||
`local flex = require('import-street')`.
|
|
||||||
|
|
||||||
Many of the following functions take _key match lists_. These lists can
|
|
||||||
contain three kinds of strings to match against tag keys:
|
|
||||||
A string that ends in an asterisk `*` is a prefix match and accordingly matches
|
|
||||||
against any key that starts with the given string (minus the `*`).
|
|
||||||
A suffix match can be defined similarly with a string that starts with a `*`.
|
|
||||||
Any other string is matched exactly against tag keys.
|
|
||||||
|
|
||||||
|
|
||||||
#### `set_main_tags()` - principal tags
|
|
||||||
|
|
||||||
If a principal or main tag is found on an OSM object, then the object
|
|
||||||
is included in Nominatim's search index. A single object may also have
|
|
||||||
multiple main tags. In that case, the object will be included multiple
|
|
||||||
times in the index, once for each main tag.
|
|
||||||
|
|
||||||
The flex script distinguishes between four types of main tags:
|
|
||||||
|
|
||||||
* __always__: a main tag that is used unconditionally
|
|
||||||
* __named__: consider this main tag only, if the object has a proper name
|
|
||||||
(a reference is not enough, see below).
|
|
||||||
* __named_with_key__: consider this main tag only, when the object has
|
|
||||||
a proper name with a domain prefix. For example, if the main tag is
|
|
||||||
`bridge=yes`, then it will only be added as an extra row, if there is
|
|
||||||
a tag `bridge:name[:XXX]` for the same object. If this property is set,
|
|
||||||
all other names that are not domain-specific are ignored.
|
|
||||||
* __fallback__: use this main tag only, if there is no other main tag.
|
|
||||||
Fallback always implied `named`, i.e. fallbacks are only tried for
|
|
||||||
named objects.
|
|
||||||
|
|
||||||
The `set_main_tags()` function takes exactly one table parameter which
|
|
||||||
defines the keys and key/value combinations to include and the kind of
|
|
||||||
main tag. Each lua table key defines an OSM tag key. The value may
|
|
||||||
be a string defining the kind of main key as described above. Then the tag will
|
|
||||||
be considered a main tag for any possible value. To further restrict
|
|
||||||
which values are acceptable, give a table with the permitted values
|
|
||||||
and their kind of main tag. If the table contains a simple value without
|
|
||||||
key, then this is used as default for values that are not listed.
|
|
||||||
|
|
||||||
!!! example
|
|
||||||
``` lua
|
|
||||||
local flex = require('import-full')
|
|
||||||
|
|
||||||
flex.set_main_tags{
|
|
||||||
boundary = {administrative = 'named'},
|
|
||||||
highway = {'always', street_lamp = 'named'},
|
|
||||||
landuse = 'fallback'
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
In this example an object with a `boundary` tag will only be included
|
|
||||||
when it has a value of `administrative`. Objects with `highway` tags are
|
|
||||||
always included. However when the value is `street_lamp` then the object
|
|
||||||
must have a name, too. With any other value, the object is included
|
|
||||||
independently of the name. Finally, if a `landuse` tag is present then
|
|
||||||
it will be used independely of the concrete value if neither boundary
|
|
||||||
nor highway tags were found and the object is named.
|
|
||||||
|
|
||||||
|
|
||||||
#### `set_prefilters()` - ignoring tags
|
|
||||||
|
|
||||||
Pre-filtering of tags allows to ignore them for any further processing.
|
|
||||||
Thus pre-filtering takes precedence over any other tag processing. This is
|
|
||||||
useful when some specific key/value combinations need to be excluded from
|
|
||||||
processing. When tags are filtered, they may either be deleted completely
|
|
||||||
or moved to `extratags`. Extra tags are saved with the object and returned
|
|
||||||
to the user when requested, but are not used otherwise.
|
|
||||||
|
|
||||||
`set_prefilters()` takes a table with four optional fields:
|
|
||||||
|
|
||||||
* __delete_keys__ is a _key match list_ for tags that should be deleted
|
|
||||||
* __delete_tags__ contains a table of tag keys pointing to a list of tag
|
|
||||||
values. Tags with matching key/value pairs are deleted.
|
|
||||||
* __extra_keys__ is a _key match list_ for tags which should be saved into
|
|
||||||
extratags
|
|
||||||
* __extra_tags__ contains a table of tag keys pointing to a list of tag
|
|
||||||
values. Tags with matching key/value pairs are moved to extratags.
|
|
||||||
|
|
||||||
Key list may contain three kinds of strings:
|
|
||||||
A string that ends in an asterisk `*` is a prefix match and accordingly matches
|
|
||||||
against any key that starts with the given string (minus the `*`).
|
|
||||||
A suffix match can be defined similarly with a string that starts with a `*`.
|
|
||||||
Any other string is matched exactly against tag keys.
|
|
||||||
|
|
||||||
!!! example
|
|
||||||
``` lua
|
|
||||||
local flex = require('import-full')
|
|
||||||
|
|
||||||
flex.set_prefilters{
|
|
||||||
delete_keys = {'source', 'source:*'},
|
|
||||||
extra_tags = {amenity = {'yes', 'no'}}
|
|
||||||
}
|
|
||||||
flex.set_main_tags{
|
|
||||||
amenity = 'always'
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
In this example any tags `source` and tags that begin with `source:` are
|
|
||||||
deleted before any other processing is done. Getting rid of frequent tags
|
|
||||||
this way can speed up the import.
|
|
||||||
|
|
||||||
Tags with `amenity=yes` or `amenity=no` are moved to extratags. Later
|
|
||||||
all tags with an `amenity` key are made a main tag. This effectively means
|
|
||||||
that Nominatim will use all amenity tags except for those with value
|
|
||||||
yes and no.
|
|
||||||
|
|
||||||
#### `set_name_tags()` - defining names
|
|
||||||
|
|
||||||
The flex script distinguishes between two kinds of names:
|
|
||||||
|
|
||||||
* __main__: the primary names make an object fully searchable.
|
|
||||||
Main tags of type _named_ will only cause the object to be included when
|
|
||||||
such a primary name is present. Primary names are usually those found
|
|
||||||
in the `name` tag and its variants.
|
|
||||||
* __extra__: extra names are still added to the search index but they are
|
|
||||||
alone not sufficient to make an object named.
|
|
||||||
|
|
||||||
`set_name_tags()` takes a table with two optional fields `main` and `extra`.
|
|
||||||
They take _key match lists_ for main and extra names respectively.
|
|
||||||
|
|
||||||
!!! example
|
|
||||||
``` lua
|
|
||||||
local flex = require('flex-base')
|
|
||||||
|
|
||||||
flex.set_main_tags{highway = {traffic_light = 'named'}}
|
|
||||||
flex.set_name_tags{main = {'name', 'name:*'},
|
|
||||||
extra = {'ref'}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
This example creates a search index over traffic lights but will
|
|
||||||
only include those that have a common name and not those which just
|
|
||||||
have some reference ID from the city.
|
|
||||||
|
|
||||||
#### `set_address_tags()` - defining address parts
|
|
||||||
|
|
||||||
Address tags will be used to build up the address of an object.
|
|
||||||
|
|
||||||
`set_address_tags()` takes a table with arbitrary fields pointing to
|
|
||||||
_key match lists_. Two fields have a special meaning:
|
|
||||||
|
|
||||||
* __main__: defines
|
|
||||||
the tags that make a full address object out of the OSM object. This
|
|
||||||
is usually the housenumber or variants thereof. If a main address tag
|
|
||||||
appears, then the object will always be included, if necessary with a
|
|
||||||
fallback of `place=house`. If the key has a prefix of `addr:` or `is_in:`
|
|
||||||
this will be stripped.
|
|
||||||
|
|
||||||
* __extra__: defines all supplementary tags for addresses, tags like `addr:street`, `addr:city` etc. If the key has a prefix of `addr:` or `is_in:` this will be stripped.
|
|
||||||
|
|
||||||
All other fields will be handled as summary fields. If a key matches the
|
|
||||||
key match list, then its value will be added to the address tags with the
|
|
||||||
name of the field as key. If multiple tags match, then an arbitrary one
|
|
||||||
wins.
|
|
||||||
|
|
||||||
Country tags are handled slightly special. Only tags with a two-letter code
|
|
||||||
are accepted, all other values are discarded.
|
|
||||||
|
|
||||||
!!! example
|
|
||||||
``` lua
|
|
||||||
local flex = require('import-full')
|
|
||||||
|
|
||||||
flex.set_address_tags{
|
|
||||||
main = {'addr:housenumber'},
|
|
||||||
extra = {'addr:*'},
|
|
||||||
postcode = {'postal_code', 'postcode', 'addr:postcode'},
|
|
||||||
country = {'country_code', 'ISO3166-1'}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
In this example all tags which begin with `addr:` will be saved in
|
|
||||||
the address tag list. If one of the tags is `addr:housenumber`, the
|
|
||||||
object will fall back to be entered as a `place=house` in the database
|
|
||||||
unless there is another interested main tag to be found.
|
|
||||||
|
|
||||||
Tags with keys `country_code` and `ISO3166-1` are saved with their
|
|
||||||
value under `country` in the address tag list. The same thing happens
|
|
||||||
to postcodes, they will always be saved under the key `postcode` thus
|
|
||||||
normalizing the multitude of keys that are used in the OSM database.
|
|
||||||
|
|
||||||
|
|
||||||
#### `set_unused_handling()` - processing remaining tags
|
|
||||||
|
|
||||||
This function defines what to do with tags that remain after all tags
|
|
||||||
have been classified using the functions above. There are two ways in
|
|
||||||
which the function can be used:
|
|
||||||
|
|
||||||
`set_unused_handling(delete_keys = ..., delete_tags = ...)` deletes all
|
|
||||||
keys that match the descriptions in the parameters and moves all remaining
|
|
||||||
tags into the extratags list.
|
|
||||||
`set_unused_handling(extra_keys = ..., extra_tags = ...)` moves all tags
|
|
||||||
matching the parameters into the extratags list and then deletes the remaining
|
|
||||||
tags. For the format of the parameters see the description in `set_prefilters()`
|
|
||||||
above.
|
|
||||||
|
|
||||||
!!! example
|
The second part of the rules defines a list of values and the properties that
|
||||||
``` lua
|
apply to a successful match. Value strings may be either empty, which
|
||||||
local flex = require('import-full')
|
means that they match any value, or describe an exact match. Prefix
|
||||||
|
or suffix matching of values is not possible.
|
||||||
|
|
||||||
flex.set_address_tags{
|
For a rule to match, it has to find a valid combination of keys and values. The
|
||||||
main = {'addr:housenumber'},
|
resulting property is that of the matched values.
|
||||||
extra = {'addr:*', 'tiger:county'}
|
|
||||||
}
|
|
||||||
flex.set_unused_handling{delete_keys = {'tiger:*'}}
|
|
||||||
```
|
|
||||||
|
|
||||||
In this example all remaining tags except those beginning with `tiger:`
|
The rules in a configuration file are processed sequentially and the first
|
||||||
are moved to the extratags list. Note that it is not possible to
|
match for each tag wins.
|
||||||
already delete the tiger tags with `set_prefilters()` because that
|
|
||||||
would remove tiger:county before the address tags are processed.
|
|
||||||
|
|
||||||
### Customizing osm2pgsql callbacks
|
|
||||||
|
|
||||||
osm2pgsql expects the flex style to implement three callbacks, one process
|
A rule where key and value are the empty string is special. This defines the
|
||||||
function per OSM type. If you want to implement special handling for
|
fallback when none of the rules match. The fallback is always used as a last
|
||||||
certain OSM types, you can override the default implementations provided
|
resort when nothing else matches, no matter where the rule appears in the file.
|
||||||
by the flex-base module.
|
Defining multiple fallback rules is not allowed. What happens in this case,
|
||||||
|
is undefined.
|
||||||
|
|
||||||
#### Changing the relation types to be handled
|
### Tag Properties
|
||||||
|
|
||||||
The default scripts only allows relations of type `multipolygon`, `boundary`
|
One or more of the following properties may be given for each tag:
|
||||||
and `waterway`. To add other types relations, set `RELATION_TYPES` for
|
|
||||||
the type to the kind of geometry that should be created. The following
|
* `main`
|
||||||
kinds of geometries can be used:
|
|
||||||
|
A principal tag. A new row will be added for the object with key and value
|
||||||
* __relation_as_multipolygon__ creates a (Multi)Polygon from the ways in
|
as `class` and `type`.
|
||||||
the relation. If the ways do not form a valid area, then the object is
|
|
||||||
silently discarded.
|
* `with_name`
|
||||||
* __relation_as_multiline__ creates a (Multi)LineString from the ways in
|
|
||||||
the relations. Ways are combined as much as possible without any regards
|
When the tag is a principal tag (`main` property set): only really add a new
|
||||||
to their order in the relation.
|
row, if there is any name tag found (a reference tag is not sufficient, see
|
||||||
|
below).
|
||||||
!!! Example
|
|
||||||
``` lua
|
* `with_name_key`
|
||||||
local flex = require('import-full')
|
|
||||||
|
When the tag is a principal tag (`main` property set): only really add a new
|
||||||
flex.RELATION_TYPES['site'] = flex.relation_as_multipolygon
|
row, if there is also a name tag that matches the key of the principal tag.
|
||||||
```
|
For example, if the main tag is `bridge=yes`, then it will only be added as
|
||||||
|
an extra row, if there is a tag `bridge:name[:XXX]` for the same object.
|
||||||
With this line relations of `type=site` will be included in the index
|
If this property is set, all other names that are not domain-specific are
|
||||||
according to main tags found. This only works when the site relation
|
ignored.
|
||||||
resolves to a valid area. Nodes in the site relation are not part of the
|
|
||||||
geometry.
|
* `fallback`
|
||||||
|
|
||||||
|
When the tag is a principal tag (`main` property set): only really add a new
|
||||||
#### Adding additional logic to processing functions
|
row, when no other principal tags for this object have been found. Only one
|
||||||
|
fallback tag can win for an object.
|
||||||
The default processing functions are also exported by the flex-base module
|
|
||||||
as `process_node`, `process_way` and `process_relation`. These can be used
|
* `operator`
|
||||||
to implement your own processing functions with some additional processing
|
|
||||||
logic.
|
When the tag is a principal tag (`main` property set): also include the
|
||||||
|
`operator` tag in the list of names. This is a special construct for an
|
||||||
!!! Example
|
out-dated tagging practise in OSM. Fuel stations and chain restaurants
|
||||||
``` lua
|
in particular used to have the name of the chain tagged as `operator`.
|
||||||
local flex = require('import-full')
|
These days the chain can be more commonly found in the `brand` tag but
|
||||||
|
there is still enough old data around to warrant this special case.
|
||||||
function osm2pgsql.process_relation(object)
|
|
||||||
if object.tags.boundary ~= 'administrative' or object.tags.admin_level ~= '2' then
|
* `name`
|
||||||
flex.process_relation(object)
|
|
||||||
end
|
Add tag to the list of names.
|
||||||
end
|
|
||||||
```
|
* `ref`
|
||||||
|
|
||||||
This example discards all country-level boundaries and uses standard
|
Add tag to the list of names as a reference. At the moment this only means
|
||||||
handling for everything else. This can be useful if you want to use
|
that the object is not considered to be named for `with_name`.
|
||||||
your own custom country boundaries.
|
|
||||||
|
* `address`
|
||||||
|
|
||||||
### Customizing the main processing function
|
Add tag to the list of address tags. If the tag starts with `addr:` or
|
||||||
|
`is_in:`, then this prefix is cut off before adding it to the list.
|
||||||
The main processing function of the flex style can be found in the function
|
|
||||||
`process_tags`. This function is called for all OSM object kinds and is
|
* `postcode`
|
||||||
responsible for filtering the tags and writing out the rows into Postgresql.
|
|
||||||
|
Add the value as a postcode to the address tags. If multiple tags are
|
||||||
!!! Example
|
candidate for postcodes, one wins out and the others are dropped.
|
||||||
``` lua
|
|
||||||
local flex = require('import-full')
|
* `country`
|
||||||
|
|
||||||
local original_process_tags = flex.process_tags
|
Add the value as a country code to the address tags. The value must be a
|
||||||
|
two letter country code, otherwise it is ignored. If there are multiple
|
||||||
function flex.process_tags(o)
|
tags that match, then one wins out and the others are dropped.
|
||||||
if o.object.tags.highway ~= nil and o.object.tags.access == 'no' then
|
|
||||||
return
|
* `house`
|
||||||
end
|
|
||||||
|
If no principle tags can be found for the object, still add the object with
|
||||||
original_process_tags(o)
|
`class`=`place` and `type`=`house`. Use this for address nodes that have no
|
||||||
end
|
other function.
|
||||||
```
|
|
||||||
|
* `interpolation`
|
||||||
This example shows the most simple customization of the process_tags function.
|
|
||||||
It simply adds some additional processing before running the original code.
|
Add this object as an address interpolation (appears as `class`=`place` and
|
||||||
To do that, first save the original function and then overwrite process_tags
|
`type`=`houses` in the database).
|
||||||
from the module. In this example all highways which are not accessible
|
|
||||||
by anyone will be ignored.
|
* `extra`
|
||||||
|
|
||||||
|
Add tag to the list of extra tags.
|
||||||
#### The `Place` class
|
|
||||||
|
* `skip`
|
||||||
The `process_tags` function receives a Lua object of `Place` type which comes
|
|
||||||
with some handy functions to collect the data necessary for geocoding and
|
Skip the tag completely. Useful when a custom default fallback is defined
|
||||||
writing it into the place table. Always use this object to fill the table.
|
or to define exceptions to rules.
|
||||||
|
|
||||||
The Place class has some attributes which you may access read-only:
|
A rule can define as many of these properties for one match as it likes. For
|
||||||
|
example, if the property is `"main,extra"` then the tag will open a new row
|
||||||
* __object__ is the original OSM object data handed in by osm2pgsql
|
but also have the tag appear in the list of extra tags.
|
||||||
* __admin_level__ is the content of the admin_level tag, parsed into an
|
|
||||||
integer and normalized to a value between 0 and 15
|
|
||||||
* __has_name__ is a boolean indicating if the object has a full name
|
|
||||||
* __names__ is a table with the collected list of name tags
|
|
||||||
* __address__ is a table with the collected list of address tags
|
|
||||||
* __extratags__ is a table with the collected list of additional tags to save
|
|
||||||
|
|
||||||
There are a number of functions to fill these fields. All functions expect
|
|
||||||
a table parameter with fields as indicated in the description.
|
|
||||||
Many of these functions expect match functions which are described in detail
|
|
||||||
further below.
|
|
||||||
|
|
||||||
* __delete{match=...}__ removes all tags that match the match function given
|
|
||||||
in _match_.
|
|
||||||
* __grab_extratags{match=...}__ moves all tags that match the match function
|
|
||||||
given in _match_ into extratags. Returns the number of tags moved.
|
|
||||||
* __clean{delete=..., extra=...}__ deletes all tags that match _delete_ and
|
|
||||||
moves the ones that match _extra_ into extratags
|
|
||||||
* __grab_address_parts{groups=...}__ moves matching tags into the address table.
|
|
||||||
_groups_ must be a group match function. Tags of the group `main` and
|
|
||||||
`extra` are added to the address table as is but with `addr:` and `is_in:`
|
|
||||||
prefixes removed from the tag key. All other groups are added with the
|
|
||||||
group name as key and the value from the tag. Multiple values of the same
|
|
||||||
group overwrite each other. The function returns the number of tags saved
|
|
||||||
from the main group.
|
|
||||||
* __grab_main_parts{groups=...}__ moves matching tags into the name table.
|
|
||||||
_groups_ must be a group match function. If a tags of the group `main` is
|
|
||||||
present, the object will be marked as having a name. Tags of group `house`
|
|
||||||
produce a fallback to `place=house`. This fallback is return by the function
|
|
||||||
if present.
|
|
||||||
|
|
||||||
There are two functions to write a row into the place table. Both functions
|
|
||||||
expect the main tag (key and value) for the row and then use the collected
|
|
||||||
information from the name, address, extratags etc. fields to complete the row.
|
|
||||||
They also have a boolean parameter `save_extra_mains` which defines how any
|
|
||||||
unprocessed tags are handled: when True, the tags will be saved as extratags,
|
|
||||||
when False, they will be simply discarded.
|
|
||||||
|
|
||||||
* __write_row(key, value, save_extra_mains)__ creates a new table row from
|
|
||||||
the current state of the Place object.
|
|
||||||
* __write_place(key, value, mtype, save_extra_mains)__ creates a new row
|
|
||||||
conditionally. When value is nil, the function will attempt to look up the
|
|
||||||
value in the object tags. If value is still nil or mtype is nil, the row
|
|
||||||
is ignored. An mtype of `always` will then always write out the row,
|
|
||||||
a mtype of `named` only, when the object has a full name. When mtype
|
|
||||||
is `named_with_key`, the function checks for a domain name, i.e. a name
|
|
||||||
tag prefixed with the name of the main key. Only if at least one is found,
|
|
||||||
the row will be written. The names are replaced with the domain names found.
|
|
||||||
|
|
||||||
#### Match functions
|
|
||||||
|
|
||||||
The Place functions usually expect either a _match function_ or a
|
|
||||||
_group match function_ to find the tags to apply their function to.
|
|
||||||
|
|
||||||
The __match function__ is a Lua function which takes two parameters,
|
|
||||||
key and value, and returns a boolean to indicate that a tag matches. The
|
|
||||||
flex-base module has a convenience function `tag_match()` to create such a
|
|
||||||
function. It takes a table with two optional fields: `keys` takes a key match
|
|
||||||
list (see above), `tags` takes a table with keys that point to a list of
|
|
||||||
possible values, thus defining key/value matches.
|
|
||||||
|
|
||||||
The __group match function__ is a Lua function which also takes two parameters,
|
|
||||||
key and value, and returns a string indicating to which group or type they
|
|
||||||
belong to. The `tag_group()` can be used to create such a function. It expects
|
|
||||||
a table where the group names are the keys and the values are a key match list.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Using the gazetteer output of osm2pgsql
|
|
||||||
|
|
||||||
Nominatim still allows you to configure the gazetteer output to remain
|
|
||||||
backwards compatible with older imports. It will be automatically used
|
|
||||||
when the style file name ends in `.style`. For documentation of the
|
|
||||||
old import style, please refer to the documentation of older releases
|
|
||||||
of Nominatim. Do not use the gazetteer output for new imports. There is no
|
|
||||||
guarantee that new versions of Nominatim are fully compatible with the
|
|
||||||
gazetteer output.
|
|
||||||
|
|
||||||
### Changing the Style of Existing Databases
|
### Changing the Style of Existing Databases
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ customize them.
|
|||||||
The main value for importance is derived from page ranking values for Wikipedia
|
The main value for importance is derived from page ranking values for Wikipedia
|
||||||
pages for a place. For places that do not have their own
|
pages for a place. For places that do not have their own
|
||||||
Wikipedia page, a formula is used that derives a static importance from the
|
Wikipedia page, a formula is used that derives a static importance from the
|
||||||
place's [search rank](../customize/Ranking.md#search-rank).
|
places [search rank](../customize/Ranking.md#search-rank).
|
||||||
|
|
||||||
In a second step, a secondary importance value is added which is meant to
|
In a second step, a secondary importance value is added which is meant to
|
||||||
represent how well-known the general area is where the place is located. It
|
represent how well-known the general area is where the place is located. It
|
||||||
@@ -21,13 +21,7 @@ importance values.
|
|||||||
|
|
||||||
nominatim.org has preprocessed importance tables for the
|
nominatim.org has preprocessed importance tables for the
|
||||||
[primary Wikipedia rankings](https://nominatim.org/data/wikimedia-importance.sql.gz)
|
[primary Wikipedia rankings](https://nominatim.org/data/wikimedia-importance.sql.gz)
|
||||||
and for [secondary importance](https://nominatim.org/data/wikimedia-secondary-importance.sql.gz)
|
and for a secondary importance based on the number of tile views on openstreetmap.org.
|
||||||
based on Wikipedia importance of the administrative areas.
|
|
||||||
|
|
||||||
The source code for creating these files is available in the Github projects
|
|
||||||
[osm-search/wikipedia-wikidata](https://github.com/osm-search/wikipedia-wikidata)
|
|
||||||
and
|
|
||||||
[osm-search/secondary-importance](https://github.com/osm-search/secondary-importance).
|
|
||||||
|
|
||||||
### Customizing secondary importance
|
### Customizing secondary importance
|
||||||
|
|
||||||
@@ -47,8 +41,8 @@ table will be ignored. You must furthermore create an index as follows:
|
|||||||
CREATE INDEX ON secondary_importance USING gist(ST_ConvexHull(gist))
|
CREATE INDEX ON secondary_importance USING gist(ST_ConvexHull(gist))
|
||||||
```
|
```
|
||||||
|
|
||||||
The following raster2pgsql command will create a table from a tiff file
|
The following raster2pgsql command will create a table that conforms to
|
||||||
that conforms to the requirements:
|
the requirements:
|
||||||
|
|
||||||
```
|
```
|
||||||
raster2pgsql -I -C -Y -d -t 128x128 input.tiff public.secondary_importance
|
raster2pgsql -I -C -Y -d -t 128x128 input.tiff public.secondary_importance
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ the following configurable parts:
|
|||||||
can be set in your local `.env` configuration
|
can be set in your local `.env` configuration
|
||||||
* [Import styles](Import-Styles.md) explains how to write your own import style
|
* [Import styles](Import-Styles.md) explains how to write your own import style
|
||||||
in order to control what kind of OSM data will be imported
|
in order to control what kind of OSM data will be imported
|
||||||
* [API Result Formatting](Result-Formatting.md) shows how to change the
|
|
||||||
output of the Nominatim API
|
|
||||||
* [Place ranking](Ranking.md) describes the configuration around classifing
|
* [Place ranking](Ranking.md) describes the configuration around classifing
|
||||||
places in terms of their importance and their role in an address
|
places in terms of their importance and their role in an address
|
||||||
* [Tokenizers](Tokenizers.md) describes the configuration of the module
|
* [Tokenizers](Tokenizers.md) describes the configuration of the module
|
||||||
|
|||||||
@@ -1,259 +0,0 @@
|
|||||||
# Changing the Appearance of Results in the Server API
|
|
||||||
|
|
||||||
The Nominatim Server API offers a number of formatting options that
|
|
||||||
present search results in [different output formats](../api/Output.md).
|
|
||||||
These results only contain a subset of all the information that Nominatim
|
|
||||||
has about the result. This page explains how to adapt the result output
|
|
||||||
or add additional result formatting.
|
|
||||||
|
|
||||||
## Defining custom result formatting
|
|
||||||
|
|
||||||
To change the result output, you need to place a file `api/v1/format.py`
|
|
||||||
into your project directory. This file needs to define a single variable
|
|
||||||
`dispatch` containing a [FormatDispatcher](#formatdispatcher). This class
|
|
||||||
serves to collect the functions for formatting the different result types
|
|
||||||
and offers helper functions to apply the formatters.
|
|
||||||
|
|
||||||
There are two ways to define the `dispatch` variable. If you want to reuse
|
|
||||||
the default output formatting and just make some changes or add an additional
|
|
||||||
format type, then import the dispatch object from the default API:
|
|
||||||
|
|
||||||
``` python
|
|
||||||
from nominatim_api.v1.format import dispatch as dispatch
|
|
||||||
```
|
|
||||||
|
|
||||||
If you prefer to define a completely new result output, then you can
|
|
||||||
create an empty dispatcher object:
|
|
||||||
|
|
||||||
``` python
|
|
||||||
from nominatim_api import FormatDispatcher
|
|
||||||
|
|
||||||
dispatch = FormatDispatcher()
|
|
||||||
```
|
|
||||||
|
|
||||||
## The formatting function
|
|
||||||
|
|
||||||
The dispatcher organises the formatting functions by format and result type.
|
|
||||||
The format corresponds to the `format` parameter of the API. It can contain
|
|
||||||
one of the predefined format names or you can invent your own new format.
|
|
||||||
|
|
||||||
API calls return data classes or an array of a data class which represent
|
|
||||||
the result. You need to make sure there are formatters defined for the
|
|
||||||
following result types:
|
|
||||||
|
|
||||||
* StatusResult (single object, returned by `/status`)
|
|
||||||
* DetailedResult (single object, returned by `/details`)
|
|
||||||
* SearchResults (list of objects, returned by `/search`)
|
|
||||||
* ReverseResults (list of objects, returned by `/reverse` and `/lookup`)
|
|
||||||
* RawDataList (simple object, returned by `/deletable` and `/polygons`)
|
|
||||||
|
|
||||||
A formatter function has the following signature:
|
|
||||||
|
|
||||||
``` python
|
|
||||||
def format_func(result: ResultType, options: Mapping[str, Any]) -> str
|
|
||||||
```
|
|
||||||
|
|
||||||
The options dictionary contains additional information about the original
|
|
||||||
query. See the [reference below](#options-for-different-result-types)
|
|
||||||
about the possible options.
|
|
||||||
|
|
||||||
To set the result formatter for a certain result type and format, you need
|
|
||||||
to write the format function and decorate it with the
|
|
||||||
[`format_func`](#nominatim_api.FormatDispatcher.format_func)
|
|
||||||
decorator.
|
|
||||||
|
|
||||||
For example, let us extend the result for the status call in text format
|
|
||||||
and add the server URL. Such a formatter would look like this:
|
|
||||||
|
|
||||||
``` python
|
|
||||||
from nominatim_api import StatusResult
|
|
||||||
|
|
||||||
@dispatch.format_func(StatusResult, 'text')
|
|
||||||
def _format_status_text(result, _):
|
|
||||||
header = 'Status for server nominatim.openstreetmap.org'
|
|
||||||
if result.status:
|
|
||||||
return f"{header}\n\nERROR: {result.message}"
|
|
||||||
|
|
||||||
return f"{header}\n\nOK"
|
|
||||||
```
|
|
||||||
|
|
||||||
If your dispatcher is derived from the default one, then this definition
|
|
||||||
will overwrite the original formatter function. This way it is possible
|
|
||||||
to customize the output of selected results.
|
|
||||||
|
|
||||||
## Adding new formats
|
|
||||||
|
|
||||||
You may also define a completely different output format. This is as simple
|
|
||||||
as adding formatting functions for all result types using the custom
|
|
||||||
format name:
|
|
||||||
|
|
||||||
``` python
|
|
||||||
from nominatim_api import StatusResult
|
|
||||||
|
|
||||||
@dispatch.format_func(StatusResult, 'chatty')
|
|
||||||
def _format_status_text(result, _):
|
|
||||||
if result.status:
|
|
||||||
return f"The server is currently not running. {result.message}"
|
|
||||||
|
|
||||||
return "Good news! The server is running just fine."
|
|
||||||
```
|
|
||||||
|
|
||||||
That's all. Nominatim will automatically pick up the new format name and
|
|
||||||
will allow the user to use it. There is no need to implement formatter
|
|
||||||
functions for all the result types, when you invent a new one. The
|
|
||||||
available formats will be determined for each API endpoint separately.
|
|
||||||
To find out which formats are available, you can use the `--list-formats`
|
|
||||||
option of the CLI tool:
|
|
||||||
|
|
||||||
```
|
|
||||||
me@machine:planet-project$ nominatim status --list-formats
|
|
||||||
2024-08-16 19:54:00: Using project directory: /home/nominatim/planet-project
|
|
||||||
text
|
|
||||||
json
|
|
||||||
chatty
|
|
||||||
debug
|
|
||||||
me@machine:planet-project$
|
|
||||||
```
|
|
||||||
|
|
||||||
The `debug` format listed in the last line will always appear. It is a
|
|
||||||
special format that enables debug output via the command line (the same
|
|
||||||
as the `debug=1` parameter enables for the server API). To not clash
|
|
||||||
with this built-in function, you shouldn't name your own format 'debug'.
|
|
||||||
|
|
||||||
### Content type of new formats
|
|
||||||
|
|
||||||
All responses will be returned with the content type application/json by
|
|
||||||
default. If your format produces a different content type, you need
|
|
||||||
to configure the content type with the `set_content_type()` function.
|
|
||||||
|
|
||||||
For example, the 'chatty' format above returns just simple text. So the
|
|
||||||
content type should be set up as:
|
|
||||||
|
|
||||||
``` python
|
|
||||||
from nominatim_api.server.content_types import CONTENT_TEXT
|
|
||||||
|
|
||||||
dispatch.set_content_type('chatty', CONTENT_TEXT)
|
|
||||||
```
|
|
||||||
|
|
||||||
The `content_types` module used above provides constants for the most
|
|
||||||
frequent content types. You set the content type to an arbitrary string,
|
|
||||||
if the content type you need is not available.
|
|
||||||
|
|
||||||
## Formatting error messages
|
|
||||||
|
|
||||||
Any exception thrown during processing of a request is given to
|
|
||||||
a special error formatting function. It takes the requested content type,
|
|
||||||
the status code and the error message. It should return the error message
|
|
||||||
in a form appropriate for the given content type.
|
|
||||||
|
|
||||||
You can overwrite the default formatting function with the decorator
|
|
||||||
`error_format_func`:
|
|
||||||
|
|
||||||
``` python
|
|
||||||
import nominatim_api.server.content_types as ct
|
|
||||||
|
|
||||||
@dispatch.error_format_func
|
|
||||||
def _format_error(content_type: str, msg: str, status: int) -> str:
|
|
||||||
if content_type == ct.CONTENT_XML:
|
|
||||||
return f"""<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<message>{msg}</message>
|
|
||||||
"""
|
|
||||||
if content_type == ct.CONTENT_JSON:
|
|
||||||
return f'"{msg}"'
|
|
||||||
|
|
||||||
return f"ERROR: {msg}"
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Debugging custom formatters
|
|
||||||
|
|
||||||
The easiest way to try out your custom formatter is by using the Nominatim
|
|
||||||
CLI commands. Custom formats can be chosen with the `--format` parameter:
|
|
||||||
|
|
||||||
```
|
|
||||||
me@machine:planet-project$ nominatim status --format chatty
|
|
||||||
2024-08-16 19:54:00: Using project directory: /home/nominatim/planet-project
|
|
||||||
Good news! The server is running just fine.
|
|
||||||
me@machine:planet-project$
|
|
||||||
```
|
|
||||||
|
|
||||||
They will also emit full error messages when there is a problem with the
|
|
||||||
code you need to debug.
|
|
||||||
|
|
||||||
!!! danger
|
|
||||||
In some cases, when you make an error with your import statement, the
|
|
||||||
CLI will not give you an error but instead tell you, that the API
|
|
||||||
commands are no longer available:
|
|
||||||
|
|
||||||
me@machine: nominatim status
|
|
||||||
usage: nominatim [-h] [--version] {import,freeze,replication,special-phrases,add-data,index,refresh,admin} ...
|
|
||||||
nominatim: error: argument subcommand: invalid choice: 'status'
|
|
||||||
|
|
||||||
This happens because the CLI tool is meant to still work when the
|
|
||||||
nominatim-api package is not installed. Import errors involving
|
|
||||||
`nominatim_api` are interpreted as "package not installed".
|
|
||||||
|
|
||||||
Use the help command to find out which is the offending import that
|
|
||||||
could not be found:
|
|
||||||
|
|
||||||
me@machine: nominatim -h
|
|
||||||
... [other help text] ...
|
|
||||||
Nominatim API package not found (was looking for module: nominatim_api.xxx).
|
|
||||||
|
|
||||||
## Reference
|
|
||||||
|
|
||||||
### FormatDispatcher
|
|
||||||
|
|
||||||
::: nominatim_api.FormatDispatcher
|
|
||||||
options:
|
|
||||||
heading_level: 6
|
|
||||||
group_by_category: False
|
|
||||||
|
|
||||||
### JsonWriter
|
|
||||||
|
|
||||||
::: nominatim_api.utils.json_writer.JsonWriter
|
|
||||||
options:
|
|
||||||
heading_level: 6
|
|
||||||
group_by_category: False
|
|
||||||
|
|
||||||
### Options for different result types
|
|
||||||
|
|
||||||
This section lists the options that may be handed in with the different result
|
|
||||||
types in the v1 version of the Nominatim API.
|
|
||||||
|
|
||||||
#### StatusResult
|
|
||||||
|
|
||||||
_None._
|
|
||||||
|
|
||||||
#### DetailedResult
|
|
||||||
|
|
||||||
| Option | Description |
|
|
||||||
|-----------------|-------------|
|
|
||||||
| locales | [Locale](../library/Result-Handling.md#locale) object for the requested language(s) |
|
|
||||||
| group_hierarchy | Setting of [group_hierarchy](../api/Details.md#output-details) parameter |
|
|
||||||
| icon_base_url | (optional) URL pointing to icons as set in [NOMINATIM_MAPICON_URL](Settings.md#nominatim_mapicon_url) |
|
|
||||||
|
|
||||||
#### SearchResults
|
|
||||||
|
|
||||||
| Option | Description |
|
|
||||||
|-----------------|-------------|
|
|
||||||
| query | Original query string |
|
|
||||||
| more_url | URL for requesting additional results for the same query |
|
|
||||||
| exclude_place_ids | List of place IDs already returned |
|
|
||||||
| viewbox | Setting of [viewbox](../api/Search.md#result-restriction) parameter |
|
|
||||||
| extratags | Setting of [extratags](../api/Search.md#output-details) parameter |
|
|
||||||
| namedetails | Setting of [namedetails](../api/Search.md#output-details) parameter |
|
|
||||||
| addressdetails | Setting of [addressdetails](../api/Search.md#output-details) parameter |
|
|
||||||
|
|
||||||
#### ReverseResults
|
|
||||||
|
|
||||||
| Option | Description |
|
|
||||||
|-----------------|-------------|
|
|
||||||
| query | Original query string |
|
|
||||||
| extratags | Setting of [extratags](../api/Search.md#output-details) parameter |
|
|
||||||
| namedetails | Setting of [namedetails](../api/Search.md#output-details) parameter |
|
|
||||||
| addressdetails | Setting of [addressdetails](../api/Search.md#output-details) parameter |
|
|
||||||
|
|
||||||
#### RawDataList
|
|
||||||
|
|
||||||
_None._
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
A Nominatim database can be converted into an SQLite database and used as
|
|
||||||
a read-only source for geocoding queries. This sections describes how to
|
|
||||||
create and use an SQLite database.
|
|
||||||
|
|
||||||
!!! danger
|
|
||||||
This feature is in an experimental state at the moment. Use at your own
|
|
||||||
risk.
|
|
||||||
|
|
||||||
## Installing prerequisites
|
|
||||||
|
|
||||||
To use a SQLite database, you need to install:
|
|
||||||
|
|
||||||
* SQLite (>= 3.30)
|
|
||||||
* Spatialite (> 5.0.0)
|
|
||||||
* aiosqlite
|
|
||||||
|
|
||||||
On Ubuntu/Debian, you can run:
|
|
||||||
|
|
||||||
sudo apt install sqlite3 libsqlite3-mod-spatialite libspatialite7
|
|
||||||
|
|
||||||
Install the aiosqlite Python package in your virtual environment:
|
|
||||||
|
|
||||||
/srv/nominatim-venv/bin/pip install aiosqlite
|
|
||||||
|
|
||||||
## Creating a new SQLite database
|
|
||||||
|
|
||||||
Nominatim cannot import directly into SQLite database. Instead you have to
|
|
||||||
first create a geocoding database in PostgreSQL by running a
|
|
||||||
[regular Nominatim import](../admin/Import.md).
|
|
||||||
|
|
||||||
Once this is done, the database can be converted to SQLite with
|
|
||||||
|
|
||||||
nominatim convert -o mydb.sqlite
|
|
||||||
|
|
||||||
This will create a database where all geocoding functions are available.
|
|
||||||
Depending on what functions you need, the database can be made smaller:
|
|
||||||
|
|
||||||
* `--without-reverse` omits indexes only needed for reverse geocoding
|
|
||||||
* `--without-search` omit tables and indexes used for forward search
|
|
||||||
* `--without-details` leaves out extra information only available in the
|
|
||||||
details API
|
|
||||||
|
|
||||||
## Using an SQLite database
|
|
||||||
|
|
||||||
Once you have created the database, you can use it by simply pointing the
|
|
||||||
database DSN to the SQLite file:
|
|
||||||
|
|
||||||
NOMINATIM_DATABASE_DSN=sqlite:dbname=mydb.sqlite
|
|
||||||
|
|
||||||
Please note that SQLite support is only available for the Python frontend. To
|
|
||||||
use the test server with an SQLite database, you therefore need to switch
|
|
||||||
the frontend engine:
|
|
||||||
|
|
||||||
nominatim serve --engine falcon
|
|
||||||
|
|
||||||
You need to install falcon or starlette for this, depending on which engine
|
|
||||||
you choose.
|
|
||||||
|
|
||||||
The CLI query commands and the library interface already use the new Python
|
|
||||||
frontend and therefore work right out of the box.
|
|
||||||
@@ -91,7 +91,7 @@ The option is only used by the Legacy tokenizer and ignored otherwise.
|
|||||||
| -------------- | --------------------------------------------------- |
|
| -------------- | --------------------------------------------------- |
|
||||||
| **Description:** | Tokenizer used for normalizing and parsing queries and names |
|
| **Description:** | Tokenizer used for normalizing and parsing queries and names |
|
||||||
| **Format:** | string |
|
| **Format:** | string |
|
||||||
| **Default:** | icu |
|
| **Default:** | legacy |
|
||||||
| **After Changes:** | cannot be changed after import |
|
| **After Changes:** | cannot be changed after import |
|
||||||
|
|
||||||
Sets the tokenizer type to use for the import. For more information on
|
Sets the tokenizer type to use for the import. For more information on
|
||||||
@@ -148,6 +148,29 @@ Setting this option to 'yes' means that Nominatim skips reindexing of contained
|
|||||||
objects when the area becomes too large.
|
objects when the area becomes too large.
|
||||||
|
|
||||||
|
|
||||||
|
#### NOMINATIM_UPDATE_FORWARD_DEPENDENCIES
|
||||||
|
|
||||||
|
| Summary | |
|
||||||
|
| -------------- | --------------------------------------------------- |
|
||||||
|
| **Description:** | Forward geometry changes to dependet objects |
|
||||||
|
| **Format:** | bool |
|
||||||
|
| **Default:** | no |
|
||||||
|
| **Comment:** | EXPERT ONLY. Must not be enabled after import. |
|
||||||
|
|
||||||
|
The geometry of OSM ways and relations may change when a node that is part
|
||||||
|
of the object is moved around. These changes are not propagated per default.
|
||||||
|
The geometry of ways/relations is only updated the next time that the object
|
||||||
|
itself is touched. When enabling this option, then dependent objects will
|
||||||
|
be marked for update when one of its member objects changes.
|
||||||
|
|
||||||
|
Enabling this option may slow down updates significantly.
|
||||||
|
|
||||||
|
!!! warning
|
||||||
|
If you want to enable this option, it must be set already on import.
|
||||||
|
Do not enable this option on an existing database that was imported with
|
||||||
|
NOMINATIM_UPDATE_FORWARD_DEPENDENCIES=no.
|
||||||
|
Updates will become unusably slow.
|
||||||
|
|
||||||
#### NOMINATIM_LANGUAGES
|
#### NOMINATIM_LANGUAGES
|
||||||
|
|
||||||
| Summary | |
|
| Summary | |
|
||||||
@@ -552,8 +575,6 @@ used.
|
|||||||
| **Format:** | boolean |
|
| **Format:** | boolean |
|
||||||
| **Default:** | no |
|
| **Default:** | no |
|
||||||
| **After Changes:** | run `nominatim refresh --website` |
|
| **After Changes:** | run `nominatim refresh --website` |
|
||||||
| **Comment:** | PHP frontend only |
|
|
||||||
|
|
||||||
|
|
||||||
This feature is currently undocumented and potentially broken.
|
This feature is currently undocumented and potentially broken.
|
||||||
|
|
||||||
@@ -566,7 +587,6 @@ This feature is currently undocumented and potentially broken.
|
|||||||
| **Format:** | integer |
|
| **Format:** | integer |
|
||||||
| **Default:** | 500 |
|
| **Default:** | 500 |
|
||||||
| **After Changes:** | run `nominatim refresh --website` |
|
| **After Changes:** | run `nominatim refresh --website` |
|
||||||
| **Comment:** | PHP frontend only |
|
|
||||||
|
|
||||||
This setting defines the threshold over which a name is no longer considered
|
This setting defines the threshold over which a name is no longer considered
|
||||||
as rare. When searching for places with rare names, only the name is used
|
as rare. When searching for places with rare names, only the name is used
|
||||||
@@ -607,88 +627,6 @@ with a single query.
|
|||||||
|
|
||||||
Setting this parameter to 0 disables polygon output completely.
|
Setting this parameter to 0 disables polygon output completely.
|
||||||
|
|
||||||
|
|
||||||
#### NOMINATIM_SEARCH_WITHIN_COUNTRIES
|
|
||||||
|
|
||||||
| Summary | |
|
|
||||||
| -------------- | --------------------------------------------------- |
|
|
||||||
| **Description:** | Disable search for elements that are not in the country grid |
|
|
||||||
| **Format:** | boolean |
|
|
||||||
| **Default:** | no |
|
|
||||||
| **After Changes:** | run `nominatim refresh --website` |
|
|
||||||
| **Comment:** | PHP frontend only |
|
|
||||||
|
|
||||||
Enable to search elements just within countries.
|
|
||||||
|
|
||||||
When enabled, if, despite not finding a point within the static grid of countries, it
|
|
||||||
finds a geometry of a region, do not return the geometry.
|
|
||||||
Return "Unable to geocode" instead.
|
|
||||||
|
|
||||||
|
|
||||||
#### NOMINATIM_SERVE_LEGACY_URLS
|
|
||||||
|
|
||||||
| Summary | |
|
|
||||||
| -------------- | --------------------------------------------------- |
|
|
||||||
| **Description:** | Enable serving via URLs with a .php suffix |
|
|
||||||
| **Format:** | boolean |
|
|
||||||
| **Default:** | yes |
|
|
||||||
| **Comment:** | Python frontend only |
|
|
||||||
|
|
||||||
When enabled, then endpoints are reachable as `/<name>` as well as `/<name>.php`.
|
|
||||||
This can be useful when you want to be backwards-compatible with previous
|
|
||||||
versions of Nominatim.
|
|
||||||
|
|
||||||
|
|
||||||
#### NOMINATIM_API_POOL_SIZE
|
|
||||||
|
|
||||||
| Summary | |
|
|
||||||
| -------------- | --------------------------------------------------- |
|
|
||||||
| **Description:** | Number of parallel database connections per worker |
|
|
||||||
| **Format:** | number |
|
|
||||||
| **Default:** | 10 |
|
|
||||||
| **Comment:** | Python frontend only |
|
|
||||||
|
|
||||||
Sets the maximum number of database connections available for a single instance
|
|
||||||
of Nominatim. When configuring the maximum number of connections that your
|
|
||||||
PostgreSQL database can handle, you need at least
|
|
||||||
`NOMINATIM_API_POOL_SIZE` * `<number of configured workers>` connections.
|
|
||||||
For configuring the number of workers, refer to the section about
|
|
||||||
[Deploying the Python frontend](../admin/Deployment-Python.md).
|
|
||||||
|
|
||||||
#### NOMINATIM_QUERY_TIMEOUT
|
|
||||||
|
|
||||||
| Summary | |
|
|
||||||
| -------------- | --------------------------------------------------- |
|
|
||||||
| **Description:** | Timeout for SQL queries to the database |
|
|
||||||
| **Format:** | number (seconds) |
|
|
||||||
| **Default:** | 10 |
|
|
||||||
| **Comment:** | Python frontend only |
|
|
||||||
|
|
||||||
When this timeout is set, then all SQL queries that run longer than the
|
|
||||||
specified numbers of seconds will be cancelled and the user receives a
|
|
||||||
timeout exceptions. Users of the API see a 503 HTTP error.
|
|
||||||
|
|
||||||
The timeout does ont apply when using the
|
|
||||||
[low-level DB access](../library/Low-Level-DB-Access.md)
|
|
||||||
of the library. A timeout can be manually set, if required.
|
|
||||||
|
|
||||||
|
|
||||||
#### NOMINATIM_REQUEST_TIMEOUT
|
|
||||||
|
|
||||||
| Summary | |
|
|
||||||
| -------------- | --------------------------------------------------- |
|
|
||||||
| **Description:** | Timeout for search queries |
|
|
||||||
| **Format:** | number (seconds) |
|
|
||||||
| **Default:** | 60 |
|
|
||||||
| **Comment:** | Python frontend only |
|
|
||||||
|
|
||||||
When this timeout is set, a search query will finish sending queries
|
|
||||||
to the database after the timeout has passed and immediately return the
|
|
||||||
results gathered so far.
|
|
||||||
|
|
||||||
Note that under high load you may observe that users receive different results
|
|
||||||
than usual without seeing an error. This may cause some confusion.
|
|
||||||
|
|
||||||
### Logging Settings
|
### Logging Settings
|
||||||
|
|
||||||
#### NOMINATIM_LOG_DB
|
#### NOMINATIM_LOG_DB
|
||||||
@@ -732,20 +670,3 @@ given in seconds and corresponds to the time the query took executing in PHP.
|
|||||||
type contains the name of the endpoint used.
|
type contains the name of the endpoint used.
|
||||||
|
|
||||||
Can be used as the same time as NOMINATIM_LOG_DB.
|
Can be used as the same time as NOMINATIM_LOG_DB.
|
||||||
|
|
||||||
#### NOMINATIM_DEBUG_SQL
|
|
||||||
|
|
||||||
| Summary | |
|
|
||||||
| -------------- | --------------------------------------------------- |
|
|
||||||
| **Description:** | Enable printing of raw SQL by SQLAlchemy |
|
|
||||||
| **Format:** | boolean |
|
|
||||||
| **Default:** | no |
|
|
||||||
| **Comment:** | **For developers only.** |
|
|
||||||
|
|
||||||
This settings enables
|
|
||||||
[SQL debugging](https://docs.sqlalchemy.org/en/20/core/engines.html#dbengine-logging)
|
|
||||||
by SQLAlchemy. This can be helpful when debugging some bugs with internal
|
|
||||||
query handling. It should only be used together with the CLI query functions.
|
|
||||||
Enabling it for server mode may have unintended consequences. Use the `debug`
|
|
||||||
parameter instead, which prints information on how the search is executed
|
|
||||||
including SQL statements.
|
|
||||||
|
|||||||
@@ -11,31 +11,16 @@ nominatim special-phrases --import-from-wiki
|
|||||||
|
|
||||||
## Importing custom special phrases
|
## Importing custom special phrases
|
||||||
|
|
||||||
Special phrases may also be imported from any custom CSV file. The file needs
|
But, it is also possible to import some phrases from a csv file.
|
||||||
to have a header line, use comma as delimiter and define the following
|
To do so, you have access to the following command:
|
||||||
columns:
|
|
||||||
|
|
||||||
* **phrase**: the keyword to look for
|
|
||||||
* **class**: key of the main tag of the place to find
|
|
||||||
(see [principal tags in import style](Import-Styles.md#set_main_tags-principal-tags)
|
|
||||||
* **type**: value of the main tag
|
|
||||||
* **operator**: type of special phrase, may be one of:
|
|
||||||
* *in*: place is within the place defined by the search term (e.g. "_Hotels in_ Berlin")
|
|
||||||
* *near*: place is near the place defined by the search term (e.g. "_bus stops near_ Big Ben")
|
|
||||||
* *named*: special phrase is a classifier (e.g. "_hotel_ California")
|
|
||||||
* *-*: unspecified, can be any of the above
|
|
||||||
|
|
||||||
If the file contains any other columns, then they are silently ignored
|
|
||||||
|
|
||||||
To import the CSV file, use the following command:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
nominatim special-phrases --import-from-csv <csv file>
|
nominatim special-phrases --import-from-csv <csv file>
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that the two previous import commands will update the phrases from your database.
|
Note that the two previous import commands will update the phrases from your database.
|
||||||
This means that if you import some phrases from a CSV file, only the phrases
|
This means that if you import some phrases from a csv file, only the phrases
|
||||||
present in the CSV file will be kept in the database. All other phrases will
|
present in the csv file will be kept into the database. All other phrases will
|
||||||
be removed.
|
be removed.
|
||||||
|
|
||||||
If you want to only add new phrases and not update the other ones you can add
|
If you want to only add new phrases and not update the other ones you can add
|
||||||
@@ -45,5 +30,5 @@ the argument `--no-replace` to the import command. For example:
|
|||||||
nominatim special-phrases --import-from-csv <csv file> --no-replace
|
nominatim special-phrases --import-from-csv <csv file> --no-replace
|
||||||
```
|
```
|
||||||
|
|
||||||
This will add the phrases present in the CSV file into the database without
|
This will add the phrases present in the csv file into the database without
|
||||||
removing the other ones.
|
removing the other ones.
|
||||||
|
|||||||
@@ -17,11 +17,6 @@ they can be configured.
|
|||||||
|
|
||||||
## Legacy tokenizer
|
## Legacy tokenizer
|
||||||
|
|
||||||
!!! danger
|
|
||||||
The Legacy tokenizer is deprecated and will be removed in Nominatim 5.0.
|
|
||||||
If you still use a database with the legacy tokenizer, you must reimport
|
|
||||||
it using the ICU tokenizer below.
|
|
||||||
|
|
||||||
The legacy tokenizer implements the analysis algorithms of older Nominatim
|
The legacy tokenizer implements the analysis algorithms of older Nominatim
|
||||||
versions. It uses a special Postgresql module to normalize names and queries.
|
versions. It uses a special Postgresql module to normalize names and queries.
|
||||||
This tokenizer is automatically installed and used when upgrading an older
|
This tokenizer is automatically installed and used when upgrading an older
|
||||||
@@ -57,7 +52,7 @@ NOMINATIM_DATABASE_MODULE_PATH=<path to directory where nominatim.so resides>
|
|||||||
```
|
```
|
||||||
|
|
||||||
This is in particular useful when the database runs on a different server.
|
This is in particular useful when the database runs on a different server.
|
||||||
See [Advanced installations](../admin/Advanced-Installations.md#using-an-external-postgresql-database) for details.
|
See [Advanced installations](../admin/Advanced-Installations.md#importing-nominatim-to-an-external-postgresql-database) for details.
|
||||||
|
|
||||||
There are no other configuration options for the legacy tokenizer. All
|
There are no other configuration options for the legacy tokenizer. All
|
||||||
normalization functions are hard-coded.
|
normalization functions are hard-coded.
|
||||||
@@ -107,7 +102,7 @@ Here is an example configuration file:
|
|||||||
``` yaml
|
``` yaml
|
||||||
normalization:
|
normalization:
|
||||||
- ":: lower ()"
|
- ":: lower ()"
|
||||||
- "ß > 'ss'" # German szet is unambiguously equal to double ss
|
- "ß > 'ss'" # German szet is unimbigiously equal to double ss
|
||||||
transliteration:
|
transliteration:
|
||||||
- !include /etc/nominatim/icu-rules/extended-unicode-to-asccii.yaml
|
- !include /etc/nominatim/icu-rules/extended-unicode-to-asccii.yaml
|
||||||
- ":: Ascii ()"
|
- ":: Ascii ()"
|
||||||
@@ -133,7 +128,7 @@ The configuration file contains four sections:
|
|||||||
The normalization and transliteration sections each define a set of
|
The normalization and transliteration sections each define a set of
|
||||||
ICU rules that are applied to the names.
|
ICU rules that are applied to the names.
|
||||||
|
|
||||||
The **normalization** rules are applied after sanitation. They should remove
|
The **normalisation** rules are applied after sanitation. They should remove
|
||||||
any information that is not relevant for search at all. Usual rules to be
|
any information that is not relevant for search at all. Usual rules to be
|
||||||
applied here are: lower-casing, removing of special characters, cleanup of
|
applied here are: lower-casing, removing of special characters, cleanup of
|
||||||
spaces.
|
spaces.
|
||||||
@@ -180,67 +175,53 @@ The following is a list of sanitizers that are shipped with Nominatim.
|
|||||||
|
|
||||||
##### split-name-list
|
##### split-name-list
|
||||||
|
|
||||||
::: nominatim_db.tokenizer.sanitizers.split_name_list
|
::: nominatim.tokenizer.sanitizers.split_name_list
|
||||||
options:
|
selection:
|
||||||
members: False
|
members: False
|
||||||
|
rendering:
|
||||||
heading_level: 6
|
heading_level: 6
|
||||||
docstring_section_style: spacy
|
|
||||||
|
|
||||||
##### strip-brace-terms
|
##### strip-brace-terms
|
||||||
|
|
||||||
::: nominatim_db.tokenizer.sanitizers.strip_brace_terms
|
::: nominatim.tokenizer.sanitizers.strip_brace_terms
|
||||||
options:
|
selection:
|
||||||
members: False
|
members: False
|
||||||
|
rendering:
|
||||||
heading_level: 6
|
heading_level: 6
|
||||||
docstring_section_style: spacy
|
|
||||||
|
|
||||||
##### tag-analyzer-by-language
|
##### tag-analyzer-by-language
|
||||||
|
|
||||||
::: nominatim_db.tokenizer.sanitizers.tag_analyzer_by_language
|
::: nominatim.tokenizer.sanitizers.tag_analyzer_by_language
|
||||||
options:
|
selection:
|
||||||
members: False
|
members: False
|
||||||
|
rendering:
|
||||||
heading_level: 6
|
heading_level: 6
|
||||||
docstring_section_style: spacy
|
|
||||||
|
|
||||||
##### clean-housenumbers
|
##### clean-housenumbers
|
||||||
|
|
||||||
::: nominatim_db.tokenizer.sanitizers.clean_housenumbers
|
::: nominatim.tokenizer.sanitizers.clean_housenumbers
|
||||||
options:
|
selection:
|
||||||
members: False
|
members: False
|
||||||
|
rendering:
|
||||||
heading_level: 6
|
heading_level: 6
|
||||||
docstring_section_style: spacy
|
|
||||||
|
|
||||||
##### clean-postcodes
|
##### clean-postcodes
|
||||||
|
|
||||||
::: nominatim_db.tokenizer.sanitizers.clean_postcodes
|
::: nominatim.tokenizer.sanitizers.clean_postcodes
|
||||||
options:
|
selection:
|
||||||
members: False
|
members: False
|
||||||
|
rendering:
|
||||||
heading_level: 6
|
heading_level: 6
|
||||||
docstring_section_style: spacy
|
|
||||||
|
|
||||||
##### clean-tiger-tags
|
##### clean-tiger-tags
|
||||||
|
|
||||||
::: nominatim_db.tokenizer.sanitizers.clean_tiger_tags
|
::: nominatim.tokenizer.sanitizers.clean_tiger_tags
|
||||||
options:
|
selection:
|
||||||
members: False
|
members: False
|
||||||
|
rendering:
|
||||||
heading_level: 6
|
heading_level: 6
|
||||||
docstring_section_style: spacy
|
|
||||||
|
|
||||||
#### delete-tags
|
|
||||||
|
|
||||||
::: nominatim_db.tokenizer.sanitizers.delete_tags
|
|
||||||
options:
|
|
||||||
members: False
|
|
||||||
heading_level: 6
|
|
||||||
docstring_section_style: spacy
|
|
||||||
|
|
||||||
#### tag-japanese
|
|
||||||
|
|
||||||
::: nominatim_db.tokenizer.sanitizers.tag_japanese
|
|
||||||
options:
|
|
||||||
members: False
|
|
||||||
heading_level: 6
|
|
||||||
docstring_section_style: spacy
|
|
||||||
|
|
||||||
#### Token Analysis
|
#### Token Analysis
|
||||||
|
|
||||||
@@ -399,7 +380,7 @@ The analyzer cannot be customized.
|
|||||||
##### Postcode token analyzer
|
##### Postcode token analyzer
|
||||||
|
|
||||||
The analyzer `postcodes` is pupose-made to analyze postcodes. It supports
|
The analyzer `postcodes` is pupose-made to analyze postcodes. It supports
|
||||||
a 'lookup' variant of the token, which produces variants with optional
|
a 'lookup' varaint of the token, which produces variants with optional
|
||||||
spaces. Use together with the clean-postcodes sanitizer.
|
spaces. Use together with the clean-postcodes sanitizer.
|
||||||
|
|
||||||
The analyzer cannot be customized.
|
The analyzer cannot be customized.
|
||||||
|
|||||||
@@ -4,19 +4,19 @@ This chapter gives an overview how to set up Nominatim for development
|
|||||||
and how to run tests.
|
and how to run tests.
|
||||||
|
|
||||||
!!! Important
|
!!! Important
|
||||||
This guide assumes you develop under the latest version of Debian/Ubuntu.
|
This guide assumes that you develop under the latest version of Ubuntu. You
|
||||||
You can of course also use your favourite distribution. You just might have
|
can of course also use your favourite distribution. You just might have to
|
||||||
to adapt the commands below slightly, in particular the commands for
|
adapt the commands below slightly, in particular the commands for installing
|
||||||
installing additional software.
|
additional software.
|
||||||
|
|
||||||
## Installing Nominatim
|
## Installing Nominatim
|
||||||
|
|
||||||
The first step is to install Nominatim itself. Please follow the installation
|
The first step is to install Nominatim itself. Please follow the installation
|
||||||
instructions in the [Admin section](../admin/Installation.md). You don't need
|
instructions in the [Admin section](../admin/Installation.md). You don't need
|
||||||
to set up a webserver for development, the webserver that can be started
|
to set up a webserver for development, the webserver that is included with PHP
|
||||||
via `nominatim serve` is sufficient.
|
is sufficient.
|
||||||
|
|
||||||
If you want to run Nominatim in a VM via Vagrant, use the default `ubuntu24` setup.
|
If you want to run Nominatim in a VM via Vagrant, use the default `ubuntu` setup.
|
||||||
Vagrant's libvirt provider runs out-of-the-box under Ubuntu. You also need to
|
Vagrant's libvirt provider runs out-of-the-box under Ubuntu. You also need to
|
||||||
install an NFS daemon to enable directory sharing between host and guest. The
|
install an NFS daemon to enable directory sharing between host and guest. The
|
||||||
following packages should get you started:
|
following packages should get you started:
|
||||||
@@ -36,60 +36,34 @@ It has the following additional requirements:
|
|||||||
* [mypy](http://mypy-lang.org/) (plus typing information for external libs)
|
* [mypy](http://mypy-lang.org/) (plus typing information for external libs)
|
||||||
* [Python Typing Extensions](https://github.com/python/typing_extensions) (for Python < 3.9)
|
* [Python Typing Extensions](https://github.com/python/typing_extensions) (for Python < 3.9)
|
||||||
* [pytest](https://pytest.org)
|
* [pytest](https://pytest.org)
|
||||||
* [pytest-asyncio](https://pytest-asyncio.readthedocs.io)
|
|
||||||
|
|
||||||
For testing the Python search frontend, you need to install extra dependencies
|
|
||||||
depending on your choice of webserver framework:
|
|
||||||
|
|
||||||
* [httpx](https://www.python-httpx.org/) (Starlette only)
|
|
||||||
* [asgi-lifespan](https://github.com/florimondmanca/asgi-lifespan) (Starlette only)
|
|
||||||
|
|
||||||
The documentation is built with mkdocs:
|
The documentation is built with mkdocs:
|
||||||
|
|
||||||
* [mkdocs](https://www.mkdocs.org/) >= 1.1.2
|
* [mkdocs](https://www.mkdocs.org/) >= 1.1.2
|
||||||
* [mkdocstrings](https://mkdocstrings.github.io/) >= 0.25
|
* [mkdocstrings](https://mkdocstrings.github.io/) >= 0.16
|
||||||
* [mkdocs-material](https://squidfunk.github.io/mkdocs-material/)
|
* [mkdocstrings-python-legacy](https://mkdocstrings.github.io/python-legacy/)
|
||||||
* [mkdocs-gen-files](https://oprypin.github.io/mkdocs-gen-files/)
|
|
||||||
|
|
||||||
Please be aware that tests always run against the globally installed
|
|
||||||
osm2pgsql, so you need to have this set up. If you want to test against
|
|
||||||
the vendored version of osm2pgsql, you need to set the PATH accordingly.
|
|
||||||
|
|
||||||
### Installing prerequisites on Ubuntu/Debian
|
### Installing prerequisites on Ubuntu/Debian
|
||||||
|
|
||||||
The Python tools should always be run with the most recent version.
|
Some of the Python packages require the newest version which is not yet
|
||||||
In particular, pylint tends to have a lot of breaking changes between versions.
|
available with the current distributions. Therefore it is recommended to
|
||||||
The easiest way, to handle these Python dependencies is to run your
|
install pip to get the newest versions.
|
||||||
development from within a virtual environment.
|
|
||||||
|
To install all necessary packages run:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo apt install libsqlite3-mod-spatialite php-cli
|
sudo apt install php-cgi phpunit php-codesniffer \
|
||||||
|
python3-pip python3-setuptools python3-dev
|
||||||
|
|
||||||
|
pip3 install --user behave mkdocs mkdocstrings pytest pylint \
|
||||||
|
mypy types-PyYAML types-jinja2 types-psycopg2 types-psutil
|
||||||
```
|
```
|
||||||
|
|
||||||
To set up the virtual environment with all necessary packages run:
|
The `mkdocs` executable will be located in `.local/bin`. You may have to add
|
||||||
|
this directory to your path, for example by running:
|
||||||
|
|
||||||
```sh
|
|
||||||
virtualenv ~/nominatim-dev-venv
|
|
||||||
~/nominatim-dev-venv/bin/pip install\
|
|
||||||
psutil psycopg[binary] PyICU SQLAlchemy \
|
|
||||||
python-dotenv jinja2 pyYAML datrie behave \
|
|
||||||
mkdocs mkdocstrings mkdocs-gen-files pytest pytest-asyncio pylint \
|
|
||||||
types-jinja2 types-markupsafe types-psutil types-psycopg2 \
|
|
||||||
types-pygments types-pyyaml types-requests types-ujson \
|
|
||||||
types-urllib3 typing-extensions unicorn falcon starlette \
|
|
||||||
uvicorn mypy osmium aiosqlite
|
|
||||||
```
|
```
|
||||||
|
echo 'export PATH=~/.local/bin:$PATH' > ~/.profile
|
||||||
Now enter the virtual environment whenever you want to develop:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
. ~/nominatim-dev-venv/bin/activate
|
|
||||||
```
|
|
||||||
|
|
||||||
For installing the PHP development tools, run:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo apt install php-cgi phpunit php-codesniffer
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If your distribution does not have PHPUnit 7.3+, you can install it (as well
|
If your distribution does not have PHPUnit 7.3+, you can install it (as well
|
||||||
@@ -102,47 +76,24 @@ composer global require "phpunit/phpunit=8.*"
|
|||||||
```
|
```
|
||||||
|
|
||||||
The binaries are found in `.config/composer/vendor/bin`. You need to add this
|
The binaries are found in `.config/composer/vendor/bin`. You need to add this
|
||||||
to your PATH:
|
to your PATH as well:
|
||||||
|
|
||||||
```
|
```
|
||||||
echo 'export PATH=~/.config/composer/vendor/bin:$PATH' > ~/.profile
|
echo 'export PATH=~/.config/composer/vendor/bin:$PATH' > ~/.profile
|
||||||
```
|
```
|
||||||
|
|
||||||
### Running Nominatim during development
|
|
||||||
|
|
||||||
The source code for Nominatim can be found in the `src` directory and can
|
|
||||||
be run in-place. The source directory features a special script
|
|
||||||
`nominatim-cli.py` which does the same as the installed 'nominatim' binary
|
|
||||||
but executes against the code in the source tree. For example:
|
|
||||||
|
|
||||||
```
|
|
||||||
me@machine:~$ cd Nominatim
|
|
||||||
me@machine:~Nominatim$ ./nominatim-cli.py --version
|
|
||||||
Nominatim version 4.4.99-1
|
|
||||||
```
|
|
||||||
|
|
||||||
Make sure you have activated the virtual environment holding all
|
|
||||||
necessary dependencies.
|
|
||||||
|
|
||||||
## Executing Tests
|
## Executing Tests
|
||||||
|
|
||||||
All tests are located in the `/test` directory.
|
All tests are located in the `/test` directory.
|
||||||
|
|
||||||
To run all tests, run make from the source root:
|
To run all tests just go to the build directory and run make:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make tests
|
cd build
|
||||||
|
make test
|
||||||
```
|
```
|
||||||
|
|
||||||
There are also make targets for executing only parts of the test suite.
|
|
||||||
For example to run linting only use:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
make lint
|
|
||||||
```
|
|
||||||
|
|
||||||
The possible testing targets are: mypy, lint, pytest, bdd.
|
|
||||||
|
|
||||||
For more information about the structure of the tests and how to change and
|
For more information about the structure of the tests and how to change and
|
||||||
extend the test suite, see the [Testing chapter](Testing.md).
|
extend the test suite, see the [Testing chapter](Testing.md).
|
||||||
|
|
||||||
@@ -153,14 +104,18 @@ built using the [MkDocs](https://www.mkdocs.org/) static site generation
|
|||||||
framework. The master branch is automatically deployed every night on
|
framework. The master branch is automatically deployed every night on
|
||||||
[https://nominatim.org/release-docs/develop/](https://nominatim.org/release-docs/develop/)
|
[https://nominatim.org/release-docs/develop/](https://nominatim.org/release-docs/develop/)
|
||||||
|
|
||||||
To build the documentation run
|
To build the documentation, go to the build directory and run
|
||||||
|
|
||||||
```
|
```
|
||||||
make doc
|
make doc
|
||||||
|
INFO - Cleaning site directory
|
||||||
|
INFO - Building documentation to directory: /home/vagrant/build/site-html
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This runs `mkdocs build` plus extra transformation of some files and adds
|
||||||
|
symlinks (see `CMakeLists.txt` for the exact steps).
|
||||||
|
|
||||||
For local testing, you can start webserver:
|
Now you can start webserver for local testing
|
||||||
|
|
||||||
```
|
```
|
||||||
build> make serve-doc
|
build> make serve-doc
|
||||||
@@ -172,7 +127,7 @@ If you develop inside a Vagrant virtual machine, use a port that is forwarded
|
|||||||
to your host:
|
to your host:
|
||||||
|
|
||||||
```
|
```
|
||||||
build> mkdocs serve --dev-addr 0.0.0.0:8088
|
build> PYTHONPATH=$SRCDIR mkdocs serve --dev-addr 0.0.0.0:8088
|
||||||
[server:296] Serving on http://0.0.0.0:8088
|
[server:296] Serving on http://0.0.0.0:8088
|
||||||
[handlers:62] Start watching changes
|
[handlers:62] Start watching changes
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -52,8 +52,9 @@ the function.
|
|||||||
|
|
||||||
### Sanitizer configuration
|
### Sanitizer configuration
|
||||||
|
|
||||||
::: nominatim_db.tokenizer.sanitizers.config.SanitizerConfig
|
::: nominatim.tokenizer.sanitizers.config.SanitizerConfig
|
||||||
options:
|
rendering:
|
||||||
|
show_source: no
|
||||||
heading_level: 6
|
heading_level: 6
|
||||||
|
|
||||||
### The main filter function of the sanitizer
|
### The main filter function of the sanitizer
|
||||||
@@ -61,10 +62,12 @@ the function.
|
|||||||
The filter function receives a single object of type `ProcessInfo`
|
The filter function receives a single object of type `ProcessInfo`
|
||||||
which has with three members:
|
which has with three members:
|
||||||
|
|
||||||
* `place: PlaceInfo`: read-only information about the place being processed.
|
* `place`: read-only information about the place being processed.
|
||||||
See PlaceInfo below.
|
See PlaceInfo below.
|
||||||
* `names: List[PlaceName]`: The current list of names for the place.
|
* `names`: The current list of names for the place. Each name is a
|
||||||
* `address: List[PlaceName]`: The current list of address names for the place.
|
PlaceName object.
|
||||||
|
* `address`: The current list of address names for the place. Each name
|
||||||
|
is a PlaceName object.
|
||||||
|
|
||||||
While the `place` member is provided for information only, the `names` and
|
While the `place` member is provided for information only, the `names` and
|
||||||
`address` lists are meant to be manipulated by the sanitizer. It may add and
|
`address` lists are meant to be manipulated by the sanitizer. It may add and
|
||||||
@@ -73,15 +76,17 @@ adding extra attributes) or completely replace the list with a different one.
|
|||||||
|
|
||||||
#### PlaceInfo - information about the place
|
#### PlaceInfo - information about the place
|
||||||
|
|
||||||
::: nominatim_db.data.place_info.PlaceInfo
|
::: nominatim.data.place_info.PlaceInfo
|
||||||
options:
|
rendering:
|
||||||
|
show_source: no
|
||||||
heading_level: 6
|
heading_level: 6
|
||||||
|
|
||||||
|
|
||||||
#### PlaceName - extended naming information
|
#### PlaceName - extended naming information
|
||||||
|
|
||||||
::: nominatim_db.data.place_name.PlaceName
|
::: nominatim.data.place_name.PlaceName
|
||||||
options:
|
rendering:
|
||||||
|
show_source: no
|
||||||
heading_level: 6
|
heading_level: 6
|
||||||
|
|
||||||
|
|
||||||
@@ -129,7 +134,7 @@ sanitizers:
|
|||||||
!!! warning
|
!!! warning
|
||||||
This example is just a simplified show case on how to create a sanitizer.
|
This example is just a simplified show case on how to create a sanitizer.
|
||||||
It is not really read for real-world use: while the sanitizer would
|
It is not really read for real-world use: while the sanitizer would
|
||||||
correctly transform `West 5th Street` into `5th Street`. it would also
|
correcly transform `West 5th Street` into `5th Street`. it would also
|
||||||
shorten a simple `North Street` to `Street`.
|
shorten a simple `North Street` to `Street`.
|
||||||
|
|
||||||
For more sanitizer examples, have a look at the sanitizers provided by Nominatim.
|
For more sanitizer examples, have a look at the sanitizers provided by Nominatim.
|
||||||
@@ -139,13 +144,15 @@ They can be found in the directory
|
|||||||
|
|
||||||
## Custom token analysis module
|
## Custom token analysis module
|
||||||
|
|
||||||
::: nominatim_db.tokenizer.token_analysis.base.AnalysisModule
|
::: nominatim.tokenizer.token_analysis.base.AnalysisModule
|
||||||
options:
|
rendering:
|
||||||
|
show_source: no
|
||||||
heading_level: 6
|
heading_level: 6
|
||||||
|
|
||||||
|
|
||||||
::: nominatim_db.tokenizer.token_analysis.base.Analyzer
|
::: nominatim.tokenizer.token_analysis.base.Analyzer
|
||||||
options:
|
rendering:
|
||||||
|
show_source: no
|
||||||
heading_level: 6
|
heading_level: 6
|
||||||
|
|
||||||
### Example: Creating acronym variants for long names
|
### Example: Creating acronym variants for long names
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ There are two kind of tests in this test suite. There are functional tests
|
|||||||
which test the API interface using a BDD test framework and there are unit
|
which test the API interface using a BDD test framework and there are unit
|
||||||
tests for specific PHP functions.
|
tests for specific PHP functions.
|
||||||
|
|
||||||
This test directory is structured as follows:
|
This test directory is sturctured as follows:
|
||||||
|
|
||||||
```
|
```
|
||||||
-+- bdd Functional API tests
|
-+- bdd Functional API tests
|
||||||
@@ -78,19 +78,18 @@ To run the functional tests, do
|
|||||||
|
|
||||||
The tests can be configured with a set of environment variables (`behave -D key=val`):
|
The tests can be configured with a set of environment variables (`behave -D key=val`):
|
||||||
|
|
||||||
|
* `BUILDDIR` - build directory of Nominatim installation to test
|
||||||
* `TEMPLATE_DB` - name of template database used as a skeleton for
|
* `TEMPLATE_DB` - name of template database used as a skeleton for
|
||||||
the test databases (db tests)
|
the test databases (db tests)
|
||||||
* `TEST_DB` - name of test database (db tests)
|
* `TEST_DB` - name of test database (db tests)
|
||||||
* `API_TEST_DB` - name of the database containing the API test data (api tests)
|
* `API_TEST_DB` - name of the database containing the API test data (api tests)
|
||||||
* `API_TEST_FILE` - OSM file to be imported into the API test database (api tests)
|
* `API_TEST_FILE` - OSM file to be imported into the API test database (api tests)
|
||||||
* `API_ENGINE` - webframe to use for running search queries, same values as
|
|
||||||
`nominatim serve --engine` parameter
|
|
||||||
* `DB_HOST` - (optional) hostname of database host
|
* `DB_HOST` - (optional) hostname of database host
|
||||||
* `DB_PORT` - (optional) port of database on host
|
* `DB_PORT` - (optional) port of database on host
|
||||||
* `DB_USER` - (optional) username of database login
|
* `DB_USER` - (optional) username of database login
|
||||||
* `DB_PASS` - (optional) password for database login
|
* `DB_PASS` - (optional) password for database login
|
||||||
* `SERVER_MODULE_PATH` - (optional) path on the Postgres server to Nominatim
|
* `SERVER_MODULE_PATH` - (optional) path on the Postgres server to Nominatim
|
||||||
module shared library file (only needed for legacy tokenizer)
|
module shared library file
|
||||||
* `REMOVE_TEMPLATE` - if true, the template and API database will not be reused
|
* `REMOVE_TEMPLATE` - if true, the template and API database will not be reused
|
||||||
during the next run. Reusing the base templates speeds
|
during the next run. Reusing the base templates speeds
|
||||||
up tests considerably but might lead to outdated errors
|
up tests considerably but might lead to outdated errors
|
||||||
@@ -121,6 +120,23 @@ and compromises the following data:
|
|||||||
API tests should only be testing the functionality of the website PHP code.
|
API tests should only be testing the functionality of the website PHP code.
|
||||||
Most tests should be formulated as BDD DB creation tests (see below) instead.
|
Most tests should be formulated as BDD DB creation tests (see below) instead.
|
||||||
|
|
||||||
|
#### Code Coverage
|
||||||
|
|
||||||
|
The API tests also support code coverage tests. You need to install
|
||||||
|
[PHP_CodeCoverage](https://github.com/sebastianbergmann/php-code-coverage).
|
||||||
|
On Debian/Ubuntu run:
|
||||||
|
|
||||||
|
apt-get install php-codecoverage php-xdebug
|
||||||
|
|
||||||
|
Then run the API tests as follows:
|
||||||
|
|
||||||
|
behave api -DPHPCOV=<coverage output dir>
|
||||||
|
|
||||||
|
The output directory must be an absolute path. To generate reports, you can use
|
||||||
|
the [phpcov](https://github.com/sebastianbergmann/phpcov) tool:
|
||||||
|
|
||||||
|
phpcov merge --html=<report output dir> <coverage output dir>
|
||||||
|
|
||||||
### DB Creation Tests (`test/bdd/db`)
|
### DB Creation Tests (`test/bdd/db`)
|
||||||
|
|
||||||
These tests check the import and update of the Nominatim database. They do not
|
These tests check the import and update of the Nominatim database. They do not
|
||||||
@@ -137,3 +153,7 @@ needs superuser rights for postgres.
|
|||||||
|
|
||||||
These tests check that data is imported correctly into the place table. They
|
These tests check that data is imported correctly into the place table. They
|
||||||
use the same template database as the DB Creation tests, so the same remarks apply.
|
use the same template database as the DB Creation tests, so the same remarks apply.
|
||||||
|
|
||||||
|
Note that most testing of the gazetteer output of osm2pgsql is done in the tests
|
||||||
|
of osm2pgsql itself. The BDD tests are just there to ensure compatibility of
|
||||||
|
the osm2pgsql and Nominatim code.
|
||||||
|
|||||||
@@ -130,18 +130,18 @@ class as defined below.
|
|||||||
|
|
||||||
### Python Tokenizer Class
|
### Python Tokenizer Class
|
||||||
|
|
||||||
All tokenizers must inherit from `nominatim_db.tokenizer.base.AbstractTokenizer`
|
All tokenizers must inherit from `nominatim.tokenizer.base.AbstractTokenizer`
|
||||||
and implement the abstract functions defined there.
|
and implement the abstract functions defined there.
|
||||||
|
|
||||||
::: nominatim_db.tokenizer.base.AbstractTokenizer
|
::: nominatim.tokenizer.base.AbstractTokenizer
|
||||||
options:
|
rendering:
|
||||||
heading_level: 6
|
heading_level: 4
|
||||||
|
|
||||||
### Python Analyzer Class
|
### Python Analyzer Class
|
||||||
|
|
||||||
::: nominatim_db.tokenizer.base.AbstractAnalyzer
|
::: nominatim.tokenizer.base.AbstractAnalyzer
|
||||||
options:
|
rendering:
|
||||||
heading_level: 6
|
heading_level: 4
|
||||||
|
|
||||||
### PL/pgSQL Functions
|
### PL/pgSQL Functions
|
||||||
|
|
||||||
@@ -189,28 +189,6 @@ a house number token text. If a place has multiple house numbers they must
|
|||||||
be listed with a semicolon as delimiter. Must be NULL when the place has no
|
be listed with a semicolon as delimiter. Must be NULL when the place has no
|
||||||
house numbers.
|
house numbers.
|
||||||
|
|
||||||
```sql
|
|
||||||
FUNCTION token_is_street_address(info JSONB) RETURNS BOOLEAN
|
|
||||||
```
|
|
||||||
|
|
||||||
Return true if this is an object that should be parented against a street.
|
|
||||||
Only relevant for objects with address rank 30.
|
|
||||||
|
|
||||||
```sql
|
|
||||||
FUNCTION token_has_addr_street(info JSONB) RETURNS BOOLEAN
|
|
||||||
```
|
|
||||||
|
|
||||||
Return true if there are street names to match against for finding the
|
|
||||||
parent of the object.
|
|
||||||
|
|
||||||
|
|
||||||
```sql
|
|
||||||
FUNCTION token_has_addr_place(info JSONB) RETURNS BOOLEAN
|
|
||||||
```
|
|
||||||
|
|
||||||
Return true if there are place names to match against for finding the
|
|
||||||
parent of the object.
|
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
FUNCTION token_matches_street(info JSONB, street_tokens INTEGER[]) RETURNS BOOLEAN
|
FUNCTION token_matches_street(info JSONB, street_tokens INTEGER[]) RETURNS BOOLEAN
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ elseif (has 'addr:place'?) then (yes)
|
|||||||
**with same name**;
|
**with same name**;
|
||||||
kill
|
kill
|
||||||
else (no)
|
else (no)
|
||||||
:add addr:place to address;
|
:add addr:place to adress;
|
||||||
:**Use closest place**\n**rank 16 to 25**;
|
:**Use closest place**\n**rank 16 to 25**;
|
||||||
kill
|
kill
|
||||||
endif
|
endif
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.8 KiB |
@@ -2,10 +2,6 @@
|
|||||||
display: none!important
|
display: none!important
|
||||||
}
|
}
|
||||||
|
|
||||||
.wy-nav-content {
|
|
||||||
max-width: 900px!important
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
table {
|
||||||
margin-bottom: 12pt
|
margin-bottom: 12pt
|
||||||
}
|
}
|
||||||
@@ -20,22 +16,9 @@ th {
|
|||||||
|
|
||||||
.doc-object h6 {
|
.doc-object h6 {
|
||||||
margin-bottom: 0.8em;
|
margin-bottom: 0.8em;
|
||||||
font-size: 130%;
|
font-size: 120%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-object {
|
.doc-object {
|
||||||
margin-bottom: 1.3em;
|
margin-bottom: 1.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-children .doc-contents {
|
|
||||||
margin-left: 3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.md-footer__inner {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.headerlink {
|
|
||||||
filter: grayscale(100%);
|
|
||||||
font-size: 80%;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
Nominatim (from the Latin, 'by name') is a tool to search OSM data by name and
|
Nominatim (from the Latin, 'by name') is a tool to search OSM data by name and address and to generate synthetic addresses of OSM points (reverse geocoding).
|
||||||
address and to generate synthetic addresses of OSM points (reverse geocoding).
|
|
||||||
It has also limited capability to search features by their type
|
|
||||||
(pubs, hotels, churches, etc).
|
|
||||||
|
|
||||||
This guide comes in five parts:
|
This guide comes in four parts:
|
||||||
|
|
||||||
* __[API reference](api/Overview.md)__ for users of Nominatim
|
* __[API reference](api/Overview.md)__ for users of Nominatim
|
||||||
* __[Administration Guide](admin/Installation.md)__ for those who want
|
* __[Administration Guide](admin/Installation.md)__ for those who want
|
||||||
to install their own Nominatim server
|
to install their own Nominatim server
|
||||||
* __[Customization Guide](customize/Overview.md)__ for those who want to
|
* __[Customization Guide](customize/Overview.md)__ for those who want to
|
||||||
adapt their own installation to their special requirements
|
adapt their own installation to their special requirements
|
||||||
* __[Library Guide](library/Getting-Started.md)__ for Python developers who
|
|
||||||
want to use Nominatim as a library in their project
|
|
||||||
* __[Developer's Guide](develop/overview.md)__ for developers of the software
|
* __[Developer's Guide](develop/overview.md)__ for developers of the software
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
# Configuration
|
|
||||||
|
|
||||||
When using Nominatim through the library, it can be configured in exactly
|
|
||||||
the same way as when running as a service. You may instantiate the library
|
|
||||||
against the [project directory](../admin/Import.md#creating-the-project-directory)
|
|
||||||
of your Nominatim installation. It contains all files belonging to the
|
|
||||||
Nominatim instance. This may include an `.env` file with configuration options.
|
|
||||||
Setting configuration parameters via environment variables works as well.
|
|
||||||
Alternatively to using the operating system's environment, a set of
|
|
||||||
configuration parameters may also be passed to the Nomiantim API object.
|
|
||||||
|
|
||||||
Configuration options are resolved in the following order:
|
|
||||||
|
|
||||||
* from the OS environment (or the dictionary given in `environ`,
|
|
||||||
(see NominatimAPI.md#nominatim.api.core.NominatimAPI.__init__)
|
|
||||||
* from the .env file in the project directory of the installation
|
|
||||||
* from the default installation in the configuration directory
|
|
||||||
|
|
||||||
For more information on configuration via dotenv and a list of possible
|
|
||||||
configuration parameters, see the [Configuration page](../customize/Settings.md).
|
|
||||||
|
|
||||||
|
|
||||||
## `Configuration` class
|
|
||||||
|
|
||||||
::: nominatim_api.Configuration
|
|
||||||
options:
|
|
||||||
members:
|
|
||||||
- get_bool
|
|
||||||
- get_int
|
|
||||||
- get_str_list
|
|
||||||
- get_path
|
|
||||||
heading_level: 6
|
|
||||||
show_signature_annotations: True
|
|
||||||
@@ -1,289 +0,0 @@
|
|||||||
# Getting Started
|
|
||||||
|
|
||||||
The Nominatim search frontend is implemented as a Python library and can as
|
|
||||||
such directly be used in Python scripts and applications. You don't need to
|
|
||||||
set up a web frontend and access it through HTTP calls. The library gives
|
|
||||||
direct access to the Nominatim database through similar search functions as
|
|
||||||
offered by the web API. In addition, it will give you a more complete and
|
|
||||||
detailed view on the search objects stored in the database.
|
|
||||||
|
|
||||||
!!! warning
|
|
||||||
|
|
||||||
The Nominatim library is used for accessing a local Nominatim database.
|
|
||||||
It is not meant to be used against web services of Nominatim like the
|
|
||||||
one on https://nominatim.openstreetmap.org. If you need a Python library
|
|
||||||
to access these web services, have a look at
|
|
||||||
[GeoPy](https://geopy.readthedocs.io). Don't forget to consult the
|
|
||||||
usage policy of the service you want to use before accessing such
|
|
||||||
a web service.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
To use the Nominatim library, you need access to a local Nominatim database.
|
|
||||||
Follow the [installation](../admin/Installation.md) and
|
|
||||||
[import](../admin/Import.md) instructions to set up your database.
|
|
||||||
|
|
||||||
The Nominatim frontend library is contained in the Python package `nominatim-api`.
|
|
||||||
You can install the latest released version directly from pip:
|
|
||||||
|
|
||||||
pip install nominatim-api
|
|
||||||
|
|
||||||
To install the package from the source tree directly, run:
|
|
||||||
|
|
||||||
pip install packaging/nominatim-api
|
|
||||||
|
|
||||||
Usually you would want to run this in a virtual environment.
|
|
||||||
|
|
||||||
## A simple search example
|
|
||||||
|
|
||||||
To query the Nominatim database you need to first set up a connection. This
|
|
||||||
is done by creating an Nominatim API object. This object exposes all the
|
|
||||||
search functions of Nominatim that are also known from its web API.
|
|
||||||
|
|
||||||
This code snippet implements a simple search for the town of 'Brugge':
|
|
||||||
|
|
||||||
!!! example
|
|
||||||
=== "NominatimAPIAsync"
|
|
||||||
``` python
|
|
||||||
import asyncio
|
|
||||||
|
|
||||||
import nominatim_api as napi
|
|
||||||
|
|
||||||
async def search(query):
|
|
||||||
async with napi.NominatimAPIAsync() as api:
|
|
||||||
return await api.search(query)
|
|
||||||
|
|
||||||
results = asyncio.run(search('Brugge'))
|
|
||||||
if not results:
|
|
||||||
print('Cannot find Brugge')
|
|
||||||
else:
|
|
||||||
print(f'Found a place at {results[0].centroid.x},{results[0].centroid.y}')
|
|
||||||
```
|
|
||||||
|
|
||||||
=== "NominatimAPI"
|
|
||||||
``` python
|
|
||||||
import nominatim_api as napi
|
|
||||||
|
|
||||||
with napi.NominatimAPI() as api:
|
|
||||||
results = api.search('Brugge')
|
|
||||||
|
|
||||||
if not results:
|
|
||||||
print('Cannot find Brugge')
|
|
||||||
else:
|
|
||||||
print(f'Found a place at {results[0].centroid.x},{results[0].centroid.y}')
|
|
||||||
```
|
|
||||||
|
|
||||||
The Nominatim library is designed around
|
|
||||||
[asyncio](https://docs.python.org/3/library/asyncio.html). `NominatimAPIAsync`
|
|
||||||
provides you with an interface of coroutines.
|
|
||||||
If you have many requests to make, coroutines can speed up your applications
|
|
||||||
significantly.
|
|
||||||
|
|
||||||
For smaller scripts there is also a synchronous wrapper around the API. By
|
|
||||||
using `NominatimAPI`, you get exactly the same interface using classic functions.
|
|
||||||
|
|
||||||
The examples in this chapter will always show-case both
|
|
||||||
implementations. The documentation itself will usually refer only to
|
|
||||||
'Nominatim API class' when both flavours are meant. If a functionality is
|
|
||||||
available only for the synchronous or asynchronous version, this will be
|
|
||||||
explicitly mentioned.
|
|
||||||
|
|
||||||
## Defining which database to use
|
|
||||||
|
|
||||||
The [Configuration](../admin/Import.md#configuration-setup-in-env)
|
|
||||||
section explains how Nominatim is configured using the
|
|
||||||
[dotenv](https://github.com/theskumar/python-dotenv) library.
|
|
||||||
The same configuration mechanism is used with the
|
|
||||||
Nominatim API library. You should therefore be sure you are familiar with
|
|
||||||
the section.
|
|
||||||
|
|
||||||
There are three different ways, how configuration options can be set for
|
|
||||||
a 'Nominatim API class'. When you have set up your Nominatim database, you
|
|
||||||
have normally created a [project directory](../admin/Import.md#creating-the-project-directory)
|
|
||||||
which stores the various configuration and customization files that Nominatim
|
|
||||||
needs. You may pass the location of the project directory to your
|
|
||||||
'Nominatim API class' constructor and it will read the .env file in the
|
|
||||||
directory and set the configuration accordingly. Here is the simple search
|
|
||||||
example, using the configuration from a pre-defined project directory in
|
|
||||||
`/srv/nominatim-project`:
|
|
||||||
|
|
||||||
!!! example
|
|
||||||
=== "NominatimAPIAsync"
|
|
||||||
``` python
|
|
||||||
import asyncio
|
|
||||||
|
|
||||||
import nominatim_api as napi
|
|
||||||
|
|
||||||
async def search(query):
|
|
||||||
async with napi.NominatimAPIAsync('/srv/nominatim-project') as api:
|
|
||||||
return await api.search(query)
|
|
||||||
|
|
||||||
results = asyncio.run(search('Brugge'))
|
|
||||||
if not results:
|
|
||||||
print('Cannot find Brugge')
|
|
||||||
else:
|
|
||||||
print(f'Found a place at {results[0].centroid.x},{results[0].centroid.y}')
|
|
||||||
```
|
|
||||||
|
|
||||||
=== "NominatimAPI"
|
|
||||||
``` python
|
|
||||||
import nominatim_api as napi
|
|
||||||
|
|
||||||
with napi.NominatimAPI('/srv/nominatim-project') as api:
|
|
||||||
results = api.search('Brugge')
|
|
||||||
|
|
||||||
if not results:
|
|
||||||
print('Cannot find Brugge')
|
|
||||||
else:
|
|
||||||
print(f'Found a place at {results[0].centroid.x},{results[0].centroid.y}')
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
You may also configure Nominatim by setting environment variables.
|
|
||||||
Normally Nominatim will check the operating system environment. Lets
|
|
||||||
say you want to look up 'Brugge' in the special database named 'belgium' instead of the
|
|
||||||
standard 'nominatim' database. You can run the example script above like this:
|
|
||||||
|
|
||||||
```
|
|
||||||
NOMINATIM_DATABASE_DSN=pgsql:dbname=belgium python3 example.py
|
|
||||||
```
|
|
||||||
|
|
||||||
The third option to configure the library is to hand in the configuration
|
|
||||||
parameters into the 'Nominatim API class'. Changing the database would look
|
|
||||||
like this:
|
|
||||||
|
|
||||||
!!! example
|
|
||||||
=== "NominatimAPIAsync"
|
|
||||||
``` python
|
|
||||||
import asyncio
|
|
||||||
import nominatim_api as napi
|
|
||||||
|
|
||||||
config_params = {
|
|
||||||
'NOMINATIM_DATABASE_DSN': 'pgsql:dbname=belgium'
|
|
||||||
}
|
|
||||||
|
|
||||||
async def search(query):
|
|
||||||
async with napi.NominatimAPIAsync(environ=config_params) as api:
|
|
||||||
return await api.search(query)
|
|
||||||
|
|
||||||
results = asyncio.run(search('Brugge'))
|
|
||||||
```
|
|
||||||
|
|
||||||
=== "NominatimAPI"
|
|
||||||
``` python
|
|
||||||
import nominatim_api as napi
|
|
||||||
|
|
||||||
config_params = {
|
|
||||||
'NOMINATIM_DATABASE_DSN': 'pgsql:dbname=belgium'
|
|
||||||
}
|
|
||||||
|
|
||||||
with napi.NominatimAPI(environ=config_params) as api:
|
|
||||||
results = api.search('Brugge')
|
|
||||||
```
|
|
||||||
|
|
||||||
When the `environ` parameter is given, then only configuration variables
|
|
||||||
from this dictionary will be used. The operating system's environment
|
|
||||||
variables will be ignored.
|
|
||||||
|
|
||||||
## Presenting results to humans
|
|
||||||
|
|
||||||
All search functions return full result objects from the database. Such a
|
|
||||||
result object contains lots of details: names, address information, OSM tags etc.
|
|
||||||
This gives you lots of flexibility what to do with the results.
|
|
||||||
|
|
||||||
One of the most common things to get is some kind of human-readable label
|
|
||||||
that describes the result in a compact form. Usually this would be the name
|
|
||||||
of the object and some parts of the address to explain where in the world
|
|
||||||
it is. To create such a label, you need two things:
|
|
||||||
|
|
||||||
* the address details of the place
|
|
||||||
* all names for the label adapted to the language you wish to use for display
|
|
||||||
|
|
||||||
Again searching for 'Brugge', this time with a nicely formatted result:
|
|
||||||
|
|
||||||
!!! example
|
|
||||||
=== "NominatimAPIAsync"
|
|
||||||
``` python
|
|
||||||
import asyncio
|
|
||||||
|
|
||||||
import nominatim_api as napi
|
|
||||||
|
|
||||||
async def search(query):
|
|
||||||
async with napi.NominatimAPIAsync() as api:
|
|
||||||
return await api.search(query, address_details=True)
|
|
||||||
|
|
||||||
results = asyncio.run(search('Brugge'))
|
|
||||||
|
|
||||||
locale = napi.Locales(['fr', 'en'])
|
|
||||||
for i, result in enumerate(results):
|
|
||||||
address_parts = result.address_rows.localize(locale)
|
|
||||||
print(f"{i + 1}. {', '.join(address_parts)}")
|
|
||||||
```
|
|
||||||
|
|
||||||
=== "NominatimAPI"
|
|
||||||
``` python
|
|
||||||
import nominatim_api as napi
|
|
||||||
|
|
||||||
with napi.NominatimAPI() as api:
|
|
||||||
results = api.search('Brugge', address_details=True)
|
|
||||||
|
|
||||||
locale = napi.Locales(['fr', 'en'])
|
|
||||||
for i, result in enumerate(results):
|
|
||||||
address_parts = result.address_rows.localize(locale)
|
|
||||||
print(f"{i + 1}. {', '.join(address_parts)}")
|
|
||||||
```
|
|
||||||
|
|
||||||
To request information about the address of a result, add the optional
|
|
||||||
parameter 'address_details' to your search:
|
|
||||||
|
|
||||||
``` python
|
|
||||||
>>> results = api.search('Brugge', address_details=True)
|
|
||||||
```
|
|
||||||
|
|
||||||
An additional field `address_rows` will set in results that are returned.
|
|
||||||
It contains a list of all places that make up the address of the place. For
|
|
||||||
simplicity, this includes name and house number of the place itself. With
|
|
||||||
the names in this list it is possible to create a human-readable description
|
|
||||||
of the result. To do that, you first need to decide in which language the
|
|
||||||
results should be presented. As with the names in the result itself, the
|
|
||||||
places in `address_rows` contain all possible name translation for each row.
|
|
||||||
|
|
||||||
The library has a helper class `Locale` which helps extracting a name of a
|
|
||||||
place in the preferred language. It takes a single parameter with a list
|
|
||||||
of language codes in the order of preference. So
|
|
||||||
|
|
||||||
``` python
|
|
||||||
locale = napi.Locale(['fr', 'en'])
|
|
||||||
```
|
|
||||||
|
|
||||||
creates a helper class that returns the name preferably in French. If that is
|
|
||||||
not possible, it tries English and eventually falls back to the default `name`
|
|
||||||
or `ref`.
|
|
||||||
|
|
||||||
The `Locale` object can be applied to a name dictionary to return the best-matching
|
|
||||||
name out of it:
|
|
||||||
|
|
||||||
``` python
|
|
||||||
>>> print(locale.display_name(results[0].names))
|
|
||||||
'Brugges'
|
|
||||||
```
|
|
||||||
|
|
||||||
The `address_row` field has a helper function to apply the function to all
|
|
||||||
its members and save the result in the `local_name` field. It also returns
|
|
||||||
all the localized names as a convenient simple list. This list can be used
|
|
||||||
to create a human-readable output:
|
|
||||||
|
|
||||||
``` python
|
|
||||||
>>> address_parts = results[0].address_rows.localize(locale)
|
|
||||||
>>> print(', '.join(address_parts))
|
|
||||||
Bruges, Flandre-Occidentale, Flandre, Belgique
|
|
||||||
```
|
|
||||||
|
|
||||||
This is a fairly simple way to create a human-readable description. The
|
|
||||||
place information in `address_rows` contains further information about each
|
|
||||||
place. For example, which OSM `admin_level` was used, what category the place
|
|
||||||
belongs to or what rank Nominatim has assigned. Use this to adapt the output
|
|
||||||
to local address formats.
|
|
||||||
|
|
||||||
For more information on address rows, see
|
|
||||||
[detailed address description](Result-Handling.md#detailed-address-description).
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
# Input Parameter Types
|
|
||||||
|
|
||||||
This page describes in more detail some of the input parameter types used
|
|
||||||
in the query functions of the API object.
|
|
||||||
|
|
||||||
## Place identification
|
|
||||||
|
|
||||||
The [details](NominatimAPI.md#nominatim_api.NominatimAPI.details) and
|
|
||||||
[lookup](NominatimAPI.md#nominatim_api.NominatimAPI.lookup) functions
|
|
||||||
require references to places in the database. Below the possible
|
|
||||||
types for place identification are listed. All types are dataclasses.
|
|
||||||
|
|
||||||
### PlaceID
|
|
||||||
|
|
||||||
::: nominatim_api.PlaceID
|
|
||||||
options:
|
|
||||||
heading_level: 6
|
|
||||||
|
|
||||||
### OsmID
|
|
||||||
|
|
||||||
::: nominatim_api.OsmID
|
|
||||||
options:
|
|
||||||
heading_level: 6
|
|
||||||
|
|
||||||
## Geometry types
|
|
||||||
|
|
||||||
::: nominatim_api.GeometryFormat
|
|
||||||
options:
|
|
||||||
heading_level: 6
|
|
||||||
members_order: source
|
|
||||||
|
|
||||||
## Geometry input
|
|
||||||
|
|
||||||
### Point
|
|
||||||
|
|
||||||
::: nominatim_api.Point
|
|
||||||
options:
|
|
||||||
heading_level: 6
|
|
||||||
show_signature_annotations: True
|
|
||||||
|
|
||||||
### Bbox
|
|
||||||
|
|
||||||
::: nominatim_api.Bbox
|
|
||||||
options:
|
|
||||||
heading_level: 6
|
|
||||||
show_signature_annotations: True
|
|
||||||
members_order: source
|
|
||||||
group_by_category: False
|
|
||||||
|
|
||||||
## Layers
|
|
||||||
|
|
||||||
Layers allow to restrict the search result to thematic groups. This is
|
|
||||||
orthogonal to restriction by address ranks, which groups places by their
|
|
||||||
geographic extent.
|
|
||||||
|
|
||||||
|
|
||||||
::: nominatim_api.DataLayer
|
|
||||||
options:
|
|
||||||
heading_level: 6
|
|
||||||
members_order: source
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
# Low-level connections
|
|
||||||
|
|
||||||
The `NominatimAPIAsync` class allows to directly access the underlying
|
|
||||||
database connection to explore the raw data. Nominatim uses
|
|
||||||
[SQLAlchemy](https://docs.sqlalchemy.org/) for building queries. Please
|
|
||||||
refer to the documentation of the library to understand how to write SQL.
|
|
||||||
|
|
||||||
To get access to a search connection, use the `begin()` function of your
|
|
||||||
API object. This returns a `SearchConnection` object described below
|
|
||||||
wrapped in a context manager. Its
|
|
||||||
`t` property has definitions for all Nominatim search tables. For an
|
|
||||||
overview of available tables, refer to the
|
|
||||||
[Development Layout](../develop/Database-Layout.md) in in the development
|
|
||||||
chapter. Note that only tables that are needed for search are accessible
|
|
||||||
as SQLAlchemy tables.
|
|
||||||
|
|
||||||
!!! warning
|
|
||||||
The database layout is not part of the API definition and may change
|
|
||||||
without notice. If you play with the low-level access functions, you
|
|
||||||
need to be prepared for such changes.
|
|
||||||
|
|
||||||
Here is a simple example, which prints how many places are available in
|
|
||||||
the placex table:
|
|
||||||
|
|
||||||
```
|
|
||||||
import asyncio
|
|
||||||
import sqlalchemy as sa
|
|
||||||
from nominatim_api import NominatimAPIAsync
|
|
||||||
|
|
||||||
async def print_table_size():
|
|
||||||
api = NominatimAPIAsync()
|
|
||||||
|
|
||||||
async with api.begin() as conn:
|
|
||||||
cnt = await conn.scalar(sa.select(sa.func.count()).select_from(conn.t.placex))
|
|
||||||
print(f'placex table has {cnt} rows.')
|
|
||||||
|
|
||||||
asyncio.run(print_table_size())
|
|
||||||
```
|
|
||||||
|
|
||||||
!!! warning
|
|
||||||
Low-level connections may only be used to read data from the database.
|
|
||||||
Do not use it to add or modify data or you might break Nominatim's
|
|
||||||
normal functions.
|
|
||||||
|
|
||||||
## SearchConnection class
|
|
||||||
|
|
||||||
::: nominatim_api.SearchConnection
|
|
||||||
options:
|
|
||||||
members:
|
|
||||||
- scalar
|
|
||||||
- execute
|
|
||||||
- get_class_table
|
|
||||||
- get_db_property
|
|
||||||
- get_property
|
|
||||||
heading_level: 6
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
# The Nominatim API classes
|
|
||||||
|
|
||||||
The API classes are the core object of the search library. Always instantiate
|
|
||||||
one of these classes first. The API classes are **not threadsafe**. You need
|
|
||||||
to instantiate a separate instance for each thread.
|
|
||||||
|
|
||||||
### NominatimAPI
|
|
||||||
|
|
||||||
::: nominatim_api.NominatimAPI
|
|
||||||
options:
|
|
||||||
members:
|
|
||||||
- __init__
|
|
||||||
- config
|
|
||||||
- close
|
|
||||||
- status
|
|
||||||
- details
|
|
||||||
- lookup
|
|
||||||
- reverse
|
|
||||||
- search
|
|
||||||
- search_address
|
|
||||||
- search_category
|
|
||||||
heading_level: 6
|
|
||||||
group_by_category: False
|
|
||||||
|
|
||||||
|
|
||||||
### NominatimAPIAsync
|
|
||||||
|
|
||||||
::: nominatim_api.NominatimAPIAsync
|
|
||||||
options:
|
|
||||||
members:
|
|
||||||
- __init__
|
|
||||||
- setup_database
|
|
||||||
- close
|
|
||||||
- begin
|
|
||||||
heading_level: 6
|
|
||||||
group_by_category: False
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
# Result handling
|
|
||||||
|
|
||||||
The search functions of the Nominatim API always return a result object
|
|
||||||
with the raw information about the place that is available in the
|
|
||||||
database. This section discusses data types used in the results and utility
|
|
||||||
functions that allow further processing of the results.
|
|
||||||
|
|
||||||
## Result fields
|
|
||||||
|
|
||||||
### Sources
|
|
||||||
|
|
||||||
Nominatim takes the result data from multiple sources. The `source_table` field
|
|
||||||
in the result describes, from which source the result was retrieved.
|
|
||||||
|
|
||||||
::: nominatim_api.SourceTable
|
|
||||||
options:
|
|
||||||
heading_level: 6
|
|
||||||
members_order: source
|
|
||||||
|
|
||||||
### Detailed address description
|
|
||||||
|
|
||||||
When the `address_details` parameter is set, then functions return not
|
|
||||||
only information about the result place but also about the place that
|
|
||||||
make up the address. This information is almost always required when you
|
|
||||||
want to present the user with a human-readable description of the result.
|
|
||||||
See also [Localization](#localization) below.
|
|
||||||
|
|
||||||
The address details are available in the `address_rows` field as a ordered
|
|
||||||
list of `AddressLine` objects with the country information last. The list also
|
|
||||||
contains the result place itself and some artificial entries, for example,
|
|
||||||
for the house number or the country code. This makes processing and creating
|
|
||||||
a full address easier.
|
|
||||||
|
|
||||||
::: nominatim_api.AddressLine
|
|
||||||
options:
|
|
||||||
heading_level: 6
|
|
||||||
members_order: source
|
|
||||||
|
|
||||||
### Detailed search terms
|
|
||||||
|
|
||||||
The `details` function can return detailed information about which search terms
|
|
||||||
may be used to find a place, when the `keywords` parameter is set. Search
|
|
||||||
terms are split into terms for the name of the place and search terms for
|
|
||||||
its address.
|
|
||||||
|
|
||||||
::: nominatim_api.WordInfo
|
|
||||||
options:
|
|
||||||
heading_level: 6
|
|
||||||
|
|
||||||
## Localization
|
|
||||||
|
|
||||||
Results are always returned with the full list of available names.
|
|
||||||
|
|
||||||
### Locale
|
|
||||||
|
|
||||||
::: nominatim_api.Locales
|
|
||||||
options:
|
|
||||||
heading_level: 6
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# This file is part of Nominatim. (https://nominatim.org)
|
|
||||||
#
|
|
||||||
# Copyright (C) 2024 by the Nominatim developer community.
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import mkdocs_gen_files
|
|
||||||
|
|
||||||
VAGRANT_PATH = Path(__file__, '..', '..', 'vagrant').resolve()
|
|
||||||
|
|
||||||
for infile in VAGRANT_PATH.glob('Install-on-*.sh'):
|
|
||||||
outfile = f"admin/{infile.stem}.md"
|
|
||||||
title = infile.stem.replace('-', ' ')
|
|
||||||
|
|
||||||
with mkdocs_gen_files.open(outfile, "w") as outfd, infile.open() as infd:
|
|
||||||
print("#", title, file=outfd)
|
|
||||||
has_empty = False
|
|
||||||
for line in infd:
|
|
||||||
line = line.rstrip()
|
|
||||||
docpos = line.find('#DOCS:')
|
|
||||||
if docpos >= 0:
|
|
||||||
line = line[docpos + 6:]
|
|
||||||
elif line == '#' or line.startswith('#!'):
|
|
||||||
line = ''
|
|
||||||
elif line.startswith('# '):
|
|
||||||
line = line[2:]
|
|
||||||
if line or not has_empty:
|
|
||||||
print(line, file=outfd)
|
|
||||||
has_empty = not bool(line)
|
|
||||||
|
|
||||||
mkdocs_gen_files.set_edit_path(outfile, "docs/mk_install_instructions.py")
|
|
||||||
@@ -1,14 +1,6 @@
|
|||||||
site_name: Nominatim Manual
|
site_name: Nominatim Documentation
|
||||||
theme:
|
theme: readthedocs
|
||||||
font: false
|
docs_dir: ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
name: material
|
|
||||||
features:
|
|
||||||
- navigation.tabs
|
|
||||||
- toc.integrate
|
|
||||||
plugins:
|
|
||||||
- privacy
|
|
||||||
copyright: Copyright © Nominatim developer community
|
|
||||||
docs_dir: docs
|
|
||||||
site_url: https://nominatim.org
|
site_url: https://nominatim.org
|
||||||
repo_url: https://github.com/openstreetmap/Nominatim
|
repo_url: https://github.com/openstreetmap/Nominatim
|
||||||
nav:
|
nav:
|
||||||
@@ -26,20 +18,16 @@ nav:
|
|||||||
- 'Basic Installation': 'admin/Installation.md'
|
- 'Basic Installation': 'admin/Installation.md'
|
||||||
- 'Import' : 'admin/Import.md'
|
- 'Import' : 'admin/Import.md'
|
||||||
- 'Update' : 'admin/Update.md'
|
- 'Update' : 'admin/Update.md'
|
||||||
- 'Deploy (Python frontend)' : 'admin/Deployment-Python.md'
|
- 'Deploy' : 'admin/Deployment.md'
|
||||||
- 'Deploy (PHP frontend)' : 'admin/Deployment-PHP.md'
|
|
||||||
- 'Nominatim UI' : 'admin/Setup-Nominatim-UI.md'
|
- 'Nominatim UI' : 'admin/Setup-Nominatim-UI.md'
|
||||||
- 'Advanced Installations' : 'admin/Advanced-Installations.md'
|
- 'Advanced Installations' : 'admin/Advanced-Installations.md'
|
||||||
- 'Maintenance' : 'admin/Maintenance.md'
|
- 'Maintenance' : 'admin/Maintenance.md'
|
||||||
- 'Migration from older Versions' : 'admin/Migration.md'
|
- 'Migration from older Versions' : 'admin/Migration.md'
|
||||||
- 'Troubleshooting' : 'admin/Faq.md'
|
- 'Troubleshooting' : 'admin/Faq.md'
|
||||||
- 'Installation on Ubuntu 22' : 'admin/Install-on-Ubuntu-22.md'
|
|
||||||
- 'Installation on Ubuntu 24' : 'admin/Install-on-Ubuntu-24.md'
|
|
||||||
- 'Customization Guide':
|
- 'Customization Guide':
|
||||||
- 'Overview': 'customize/Overview.md'
|
- 'Overview': 'customize/Overview.md'
|
||||||
- 'Import Styles': 'customize/Import-Styles.md'
|
- 'Import Styles': 'customize/Import-Styles.md'
|
||||||
- 'Configuration Settings': 'customize/Settings.md'
|
- 'Configuration Settings': 'customize/Settings.md'
|
||||||
- 'API Result Formatting': 'customize/Result-Formatting.md'
|
|
||||||
- 'Per-Country Data': 'customize/Country-Settings.md'
|
- 'Per-Country Data': 'customize/Country-Settings.md'
|
||||||
- 'Place Ranking' : 'customize/Ranking.md'
|
- 'Place Ranking' : 'customize/Ranking.md'
|
||||||
- 'Importance' : 'customize/Importance.md'
|
- 'Importance' : 'customize/Importance.md'
|
||||||
@@ -47,14 +35,6 @@ nav:
|
|||||||
- 'Special Phrases': 'customize/Special-Phrases.md'
|
- 'Special Phrases': 'customize/Special-Phrases.md'
|
||||||
- 'External data: US housenumbers from TIGER': 'customize/Tiger.md'
|
- 'External data: US housenumbers from TIGER': 'customize/Tiger.md'
|
||||||
- 'External data: Postcodes': 'customize/Postcodes.md'
|
- 'External data: Postcodes': 'customize/Postcodes.md'
|
||||||
- 'Conversion to SQLite': 'customize/SQLite.md'
|
|
||||||
- 'Library Guide':
|
|
||||||
- 'Getting Started': 'library/Getting-Started.md'
|
|
||||||
- 'Nominatim API class': 'library/NominatimAPI.md'
|
|
||||||
- 'Configuration': 'library/Configuration.md'
|
|
||||||
- 'Input Parameter Types': 'library/Input-Parameter-Types.md'
|
|
||||||
- 'Result Handling': 'library/Result-Handling.md'
|
|
||||||
- 'Low-level DB Access': 'library/Low-Level-DB-Access.md'
|
|
||||||
- 'Developers Guide':
|
- 'Developers Guide':
|
||||||
- 'Architecture Overview' : 'develop/overview.md'
|
- 'Architecture Overview' : 'develop/overview.md'
|
||||||
- 'Database Layout' : 'develop/Database-Layout.md'
|
- 'Database Layout' : 'develop/Database-Layout.md'
|
||||||
@@ -64,29 +44,22 @@ nav:
|
|||||||
- 'Setup for Development' : 'develop/Development-Environment.md'
|
- 'Setup for Development' : 'develop/Development-Environment.md'
|
||||||
- 'Testing' : 'develop/Testing.md'
|
- 'Testing' : 'develop/Testing.md'
|
||||||
- 'External Data Sources': 'develop/data-sources.md'
|
- 'External Data Sources': 'develop/data-sources.md'
|
||||||
|
- 'Appendix':
|
||||||
|
- 'Installation on Ubuntu 18' : 'appendix/Install-on-Ubuntu-18.md'
|
||||||
|
- 'Installation on Ubuntu 20' : 'appendix/Install-on-Ubuntu-20.md'
|
||||||
|
- 'Installation on Ubuntu 22' : 'appendix/Install-on-Ubuntu-22.md'
|
||||||
markdown_extensions:
|
markdown_extensions:
|
||||||
- codehilite
|
- codehilite
|
||||||
- admonition
|
- admonition
|
||||||
- pymdownx.superfences
|
|
||||||
- pymdownx.tabbed:
|
|
||||||
alternate_style: true
|
|
||||||
- def_list
|
- def_list
|
||||||
- toc:
|
- toc:
|
||||||
toc_depth: 4
|
permalink:
|
||||||
permalink: 🔗
|
|
||||||
extra_css: [extra.css, styles.css]
|
extra_css: [extra.css, styles.css]
|
||||||
exclude_docs: |
|
|
||||||
mk_install_instructions.py
|
|
||||||
site_dir: site-html
|
|
||||||
plugins:
|
plugins:
|
||||||
- search
|
- search
|
||||||
- mkdocstrings:
|
- mkdocstrings:
|
||||||
handlers:
|
handlers:
|
||||||
python:
|
python-legacy:
|
||||||
paths: ["src"]
|
rendering:
|
||||||
options:
|
show_source: false
|
||||||
show_source: False
|
show_signature_annotations: false
|
||||||
show_bases: False
|
|
||||||
- gen-files:
|
|
||||||
scripts:
|
|
||||||
- docs/mk_install_instructions.py
|
|
||||||
@@ -38,25 +38,23 @@ class DB
|
|||||||
|
|
||||||
// https://secure.php.net/manual/en/ref.pdo-pgsql.connection.php
|
// https://secure.php.net/manual/en/ref.pdo-pgsql.connection.php
|
||||||
try {
|
try {
|
||||||
$this->connection = new \PDO($this->sDSN, null, null, $aConnOptions);
|
$conn = new \PDO($this->sDSN, null, null, $aConnOptions);
|
||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
$sMsg = 'Failed to establish database connection:' . $e->getMessage();
|
$sMsg = 'Failed to establish database connection:' . $e->getMessage();
|
||||||
throw new \Nominatim\DatabaseError($sMsg, 500, null, $e->getMessage());
|
throw new \Nominatim\DatabaseError($sMsg, 500, null, $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->connection->exec("SET DateStyle TO 'sql,european'");
|
$conn->exec("SET DateStyle TO 'sql,european'");
|
||||||
$this->connection->exec("SET client_encoding TO 'utf-8'");
|
$conn->exec("SET client_encoding TO 'utf-8'");
|
||||||
// Disable JIT and parallel workers. They interfere badly with search SQL.
|
// Disable JIT and parallel workers. They interfere badly with search SQL.
|
||||||
$this->connection->exec('SET max_parallel_workers_per_gather TO 0');
|
$conn->exec("UPDATE pg_settings SET setting = -1 WHERE name = 'jit_above_cost'");
|
||||||
if ($this->getPostgresVersion() >= 11) {
|
$conn->exec("UPDATE pg_settings SET setting = 0 WHERE name = 'max_parallel_workers_per_gather'");
|
||||||
$this->connection->exec('SET jit_above_cost TO -1');
|
|
||||||
}
|
|
||||||
|
|
||||||
$iMaxExecution = ini_get('max_execution_time');
|
$iMaxExecution = ini_get('max_execution_time');
|
||||||
if ($iMaxExecution > 0) {
|
if ($iMaxExecution > 0) {
|
||||||
$this->connection->setAttribute(\PDO::ATTR_TIMEOUT, $iMaxExecution); // seconds
|
$conn->setAttribute(\PDO::ATTR_TIMEOUT, $iMaxExecution); // seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->connection = $conn;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ class Debug
|
|||||||
|
|
||||||
public static function printSQL($sSQL)
|
public static function printSQL($sSQL)
|
||||||
{
|
{
|
||||||
echo '<p><tt><b>'.date('c').'</b> <font color="#aaa">'.htmlspecialchars($sSQL, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401).'</font></tt></p>'."\n";
|
echo '<p><tt><font color="#aaa">'.htmlspecialchars($sSQL, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401).'</font></tt></p>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function outputVar($mVar, $sPreNL)
|
private static function outputVar($mVar, $sPreNL)
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class PlaceLookup
|
|||||||
($this->bIncludePolygonAsSVG ? 1 : 0);
|
($this->bIncludePolygonAsSVG ? 1 : 0);
|
||||||
if ($iWantedTypes > CONST_PolygonOutput_MaximumTypes) {
|
if ($iWantedTypes > CONST_PolygonOutput_MaximumTypes) {
|
||||||
if (CONST_PolygonOutput_MaximumTypes) {
|
if (CONST_PolygonOutput_MaximumTypes) {
|
||||||
userError('Select only '.CONST_PolygonOutput_MaximumTypes.' polygon output option');
|
userError('Select only '.CONST_PolygonOutput_MaximumTypes.' polgyon output option');
|
||||||
} else {
|
} else {
|
||||||
userError('Polygon output is disabled');
|
userError('Polygon output is disabled');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ class ReverseGeocode
|
|||||||
9 => 12,
|
9 => 12,
|
||||||
10 => 17, // City
|
10 => 17, // City
|
||||||
11 => 17,
|
11 => 17,
|
||||||
12 => 18, // Town
|
12 => 18, // Town / Village
|
||||||
13 => 19, // Village
|
13 => 18,
|
||||||
14 => 22, // Neighbourhood
|
14 => 22, // Suburb
|
||||||
15 => 25, // Locality
|
15 => 22,
|
||||||
16 => 26, // major street
|
16 => 26, // major street
|
||||||
17 => 27, // minor street
|
17 => 27, // minor street
|
||||||
18 => 30, // or >, Building
|
18 => 30, // or >, Building
|
||||||
@@ -85,11 +85,6 @@ class ReverseGeocode
|
|||||||
|
|
||||||
protected function lookupLargeArea($sPointSQL, $iMaxRank)
|
protected function lookupLargeArea($sPointSQL, $iMaxRank)
|
||||||
{
|
{
|
||||||
$sCountryCode = $this->getCountryCode($sPointSQL);
|
|
||||||
if (CONST_Search_WithinCountries and $sCountryCode == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($iMaxRank > 4) {
|
if ($iMaxRank > 4) {
|
||||||
$aPlace = $this->lookupPolygon($sPointSQL, $iMaxRank);
|
$aPlace = $this->lookupPolygon($sPointSQL, $iMaxRank);
|
||||||
if ($aPlace) {
|
if ($aPlace) {
|
||||||
@@ -99,12 +94,12 @@ class ReverseGeocode
|
|||||||
|
|
||||||
// If no polygon which contains the searchpoint is found,
|
// If no polygon which contains the searchpoint is found,
|
||||||
// searches in the country_osm_grid table for a polygon.
|
// searches in the country_osm_grid table for a polygon.
|
||||||
return $this->lookupInCountry($sPointSQL, $iMaxRank, $sCountryCode);
|
return $this->lookupInCountry($sPointSQL, $iMaxRank);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getCountryCode($sPointSQL)
|
protected function lookupInCountry($sPointSQL, $iMaxRank)
|
||||||
{
|
{
|
||||||
Debug::newFunction('getCountryCode');
|
Debug::newFunction('lookupInCountry');
|
||||||
// searches for polygon in table country_osm_grid which contains the searchpoint
|
// searches for polygon in table country_osm_grid which contains the searchpoint
|
||||||
// and searches for the nearest place node to the searchpoint in this polygon
|
// and searches for the nearest place node to the searchpoint in this polygon
|
||||||
$sSQL = 'SELECT country_code FROM country_osm_grid';
|
$sSQL = 'SELECT country_code FROM country_osm_grid';
|
||||||
@@ -116,12 +111,8 @@ class ReverseGeocode
|
|||||||
null,
|
null,
|
||||||
'Could not determine country polygon containing the point.'
|
'Could not determine country polygon containing the point.'
|
||||||
);
|
);
|
||||||
return $sCountryCode;
|
Debug::printVar('Country code', $sCountryCode);
|
||||||
}
|
|
||||||
|
|
||||||
protected function lookupInCountry($sPointSQL, $iMaxRank, $sCountryCode)
|
|
||||||
{
|
|
||||||
Debug::newFunction('lookupInCountry');
|
|
||||||
if ($sCountryCode) {
|
if ($sCountryCode) {
|
||||||
if ($iMaxRank > 4) {
|
if ($iMaxRank > 4) {
|
||||||
// look for place nodes with the given country code
|
// look for place nodes with the given country code
|
||||||
@@ -131,13 +122,12 @@ class ReverseGeocode
|
|||||||
$sSQL .= ' FROM placex';
|
$sSQL .= ' FROM placex';
|
||||||
$sSQL .= ' WHERE osm_type = \'N\'';
|
$sSQL .= ' WHERE osm_type = \'N\'';
|
||||||
$sSQL .= ' AND country_code = \''.$sCountryCode.'\'';
|
$sSQL .= ' AND country_code = \''.$sCountryCode.'\'';
|
||||||
$sSQL .= ' AND rank_address between 4 and 25'; // needed to select right index
|
$sSQL .= ' AND rank_search < 26 '; // needed to select right index
|
||||||
$sSQL .= ' AND rank_search between 5 and ' .min(25, $iMaxRank);
|
$sSQL .= ' AND rank_search between 5 and ' .min(25, $iMaxRank);
|
||||||
$sSQL .= ' AND type != \'postcode\'';
|
$sSQL .= ' AND class = \'place\' AND type != \'postcode\'';
|
||||||
$sSQL .= ' AND name IS NOT NULL ';
|
$sSQL .= ' AND name IS NOT NULL ';
|
||||||
$sSQL .= ' and indexed_status = 0 and linked_place_id is null';
|
$sSQL .= ' and indexed_status = 0 and linked_place_id is null';
|
||||||
$sSQL .= ' AND ST_Buffer(geometry, reverse_place_diameter(rank_search)) && '.$sPointSQL;
|
$sSQL .= ' AND ST_DWithin('.$sPointSQL.', geometry, 1.8)) p ';
|
||||||
$sSQL .= ') as a ';
|
|
||||||
$sSQL .= 'WHERE distance <= reverse_place_diameter(rank_search)';
|
$sSQL .= 'WHERE distance <= reverse_place_diameter(rank_search)';
|
||||||
$sSQL .= ' ORDER BY rank_search DESC, distance ASC';
|
$sSQL .= ' ORDER BY rank_search DESC, distance ASC';
|
||||||
$sSQL .= ' LIMIT 1';
|
$sSQL .= ' LIMIT 1';
|
||||||
@@ -226,18 +216,23 @@ class ReverseGeocode
|
|||||||
$sSQL .= ' ST_distance('.$sPointSQL.', geometry) as distance';
|
$sSQL .= ' ST_distance('.$sPointSQL.', geometry) as distance';
|
||||||
$sSQL .= ' FROM placex';
|
$sSQL .= ' FROM placex';
|
||||||
$sSQL .= ' WHERE osm_type = \'N\'';
|
$sSQL .= ' WHERE osm_type = \'N\'';
|
||||||
|
// using rank_search because of a better differentiation
|
||||||
|
// for place nodes at rank_address 16
|
||||||
$sSQL .= ' AND rank_search > '.$iRankSearch;
|
$sSQL .= ' AND rank_search > '.$iRankSearch;
|
||||||
$sSQL .= ' AND rank_search <= '.$iMaxRank;
|
$sSQL .= ' AND rank_search <= '.$iMaxRank;
|
||||||
$sSQL .= ' AND rank_address between 4 and 25'; // needed to select right index
|
$sSQL .= ' AND rank_search < 26 '; // needed to select right index
|
||||||
|
$sSQL .= ' AND rank_address > 0';
|
||||||
|
$sSQL .= ' AND class = \'place\'';
|
||||||
$sSQL .= ' AND type != \'postcode\'';
|
$sSQL .= ' AND type != \'postcode\'';
|
||||||
$sSQL .= ' AND name IS NOT NULL ';
|
$sSQL .= ' AND name IS NOT NULL ';
|
||||||
$sSQL .= ' AND indexed_status = 0 AND linked_place_id is null';
|
$sSQL .= ' AND indexed_status = 0 AND linked_place_id is null';
|
||||||
$sSQL .= ' AND ST_Buffer(geometry, reverse_place_diameter(rank_search)) && '.$sPointSQL;
|
$sSQL .= ' AND ST_DWithin('.$sPointSQL.', geometry, reverse_place_diameter('.$iRankSearch.'::smallint))';
|
||||||
$sSQL .= ' ORDER BY rank_search DESC, distance ASC';
|
$sSQL .= ' ORDER BY distance ASC,';
|
||||||
$sSQL .= ' limit 100) as a';
|
$sSQL .= ' rank_address DESC';
|
||||||
$sSQL .= ' WHERE ST_Contains((SELECT geometry FROM placex WHERE place_id = '.$iPlaceID.'), geometry )';
|
$sSQL .= ' limit 500) as a';
|
||||||
|
$sSQL .= ' WHERE ST_CONTAINS((SELECT geometry FROM placex WHERE place_id = '.$iPlaceID.'), geometry )';
|
||||||
$sSQL .= ' AND distance <= reverse_place_diameter(rank_search)';
|
$sSQL .= ' AND distance <= reverse_place_diameter(rank_search)';
|
||||||
$sSQL .= ' ORDER BY rank_search DESC, distance ASC';
|
$sSQL .= ' ORDER BY distance ASC, rank_search DESC';
|
||||||
$sSQL .= ' LIMIT 1';
|
$sSQL .= ' LIMIT 1';
|
||||||
Debug::printSQL($sSQL);
|
Debug::printSQL($sSQL);
|
||||||
|
|
||||||
|
|||||||
190
lib-php/admin/export.php
Normal file
190
lib-php/admin/export.php
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
*
|
||||||
|
* This file is part of Nominatim. (https://nominatim.org)
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 by the Nominatim developer community.
|
||||||
|
* For a full list of authors see the git log.
|
||||||
|
*/
|
||||||
|
@define('CONST_LibDir', dirname(dirname(__FILE__)));
|
||||||
|
// Script to extract structured city and street data
|
||||||
|
// from a running nominatim instance as CSV data
|
||||||
|
|
||||||
|
|
||||||
|
require_once(CONST_LibDir.'/init-cmd.php');
|
||||||
|
require_once(CONST_LibDir.'/ParameterParser.php');
|
||||||
|
ini_set('memory_limit', '800M');
|
||||||
|
|
||||||
|
$aCMDOptions = array(
|
||||||
|
'Export addresses as CSV file from a Nominatim database',
|
||||||
|
array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
|
||||||
|
array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
|
||||||
|
array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
|
||||||
|
|
||||||
|
array('output-type', '', 0, 1, 1, 1, 'str', 'Type of places to output (see below)'),
|
||||||
|
array('output-format', '', 0, 1, 1, 1, 'str', 'Column mapping (see below)'),
|
||||||
|
array('output-all-postcodes', '', 0, 1, 0, 0, 'bool', 'List all postcodes for address instead of just the most likely one'),
|
||||||
|
array('language', '', 0, 1, 1, 1, 'str', 'Preferred language for output (local name, if omitted)'),
|
||||||
|
array('restrict-to-country', '', 0, 1, 1, 1, 'str', 'Export only objects within country (country code)'),
|
||||||
|
array('restrict-to-osm-node', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM node'),
|
||||||
|
array('restrict-to-osm-way', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM way'),
|
||||||
|
array('restrict-to-osm-relation', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM relation'),
|
||||||
|
array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory of the Nominatim installation (default: .)'),
|
||||||
|
"\nAddress ranks: continent, country, state, county, city, suburb, street, path",
|
||||||
|
'Additional output types: postcode, placeid (placeid for each object)',
|
||||||
|
"\noutput-format must be a semicolon-separated list of address ranks. Multiple ranks",
|
||||||
|
'can be merged into one column by simply using a comma-separated list.',
|
||||||
|
"\nDefault output-type: street",
|
||||||
|
'Default output format: street;suburb;city;county;state;country'
|
||||||
|
);
|
||||||
|
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
||||||
|
|
||||||
|
loadSettings($aCMDResult['project-dir'] ?? getcwd());
|
||||||
|
|
||||||
|
$aRankmap = array(
|
||||||
|
'continent' => 1,
|
||||||
|
'country' => 4,
|
||||||
|
'state' => 8,
|
||||||
|
'county' => 12,
|
||||||
|
'city' => 16,
|
||||||
|
'suburb' => 20,
|
||||||
|
'street' => 26,
|
||||||
|
'path' => 27
|
||||||
|
);
|
||||||
|
|
||||||
|
$oDB = new Nominatim\DB();
|
||||||
|
$oDB->connect();
|
||||||
|
|
||||||
|
if (isset($aCMDResult['output-type'])) {
|
||||||
|
if (!isset($aRankmap[$aCMDResult['output-type']])) {
|
||||||
|
fail('unknown output-type: '.$aCMDResult['output-type']);
|
||||||
|
}
|
||||||
|
$iOutputRank = $aRankmap[$aCMDResult['output-type']];
|
||||||
|
} else {
|
||||||
|
$iOutputRank = $aRankmap['street'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Preferred language
|
||||||
|
$oParams = new Nominatim\ParameterParser();
|
||||||
|
if (!isset($aCMDResult['language'])) {
|
||||||
|
$aCMDResult['language'] = 'xx';
|
||||||
|
}
|
||||||
|
$aLangPrefOrder = $oParams->getPreferredLanguages($aCMDResult['language']);
|
||||||
|
$sLanguagePrefArraySQL = $oDB->getArraySQL($oDB->getDBQuotedList($aLangPrefOrder));
|
||||||
|
|
||||||
|
// output formatting: build up a lookup table that maps address ranks to columns
|
||||||
|
$aColumnMapping = array();
|
||||||
|
$iNumCol = 0;
|
||||||
|
if (!isset($aCMDResult['output-format'])) {
|
||||||
|
$aCMDResult['output-format'] = 'street;suburb;city;county;state;country';
|
||||||
|
}
|
||||||
|
foreach (preg_split('/\s*;\s*/', $aCMDResult['output-format']) as $sColumn) {
|
||||||
|
$bHasData = false;
|
||||||
|
foreach (preg_split('/\s*,\s*/', $sColumn) as $sRank) {
|
||||||
|
if ($sRank == 'postcode' || $sRank == 'placeid') {
|
||||||
|
$aColumnMapping[$sRank] = $iNumCol;
|
||||||
|
$bHasData = true;
|
||||||
|
} elseif (isset($aRankmap[$sRank])) {
|
||||||
|
$iRank = $aRankmap[$sRank];
|
||||||
|
if ($iRank <= $iOutputRank) {
|
||||||
|
$aColumnMapping[(string)$iRank] = $iNumCol;
|
||||||
|
$bHasData = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($bHasData) {
|
||||||
|
$iNumCol++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// build the query for objects
|
||||||
|
$sPlacexSQL = 'select min(place_id) as place_id, ';
|
||||||
|
$sPlacexSQL .= 'array_agg(place_id) as place_ids, ';
|
||||||
|
$sPlacexSQL .= 'country_code as cc, ';
|
||||||
|
$sPlacexSQL .= 'postcode, ';
|
||||||
|
// get the address places excluding postcodes
|
||||||
|
$sPlacexSQL .= 'array(select address_place_id from place_addressline a';
|
||||||
|
$sPlacexSQL .= ' where a.place_id = placex.place_id and isaddress';
|
||||||
|
$sPlacexSQL .= ' and address_place_id != placex.place_id';
|
||||||
|
$sPlacexSQL .= ' and not cached_rank_address in (5,11)';
|
||||||
|
$sPlacexSQL .= ' and cached_rank_address > 2 order by cached_rank_address)';
|
||||||
|
$sPlacexSQL .= ' as address';
|
||||||
|
$sPlacexSQL .= ' from placex where name is not null and linked_place_id is null';
|
||||||
|
|
||||||
|
$sPlacexSQL .= ' and rank_address = '.$iOutputRank;
|
||||||
|
|
||||||
|
if (isset($aCMDResult['restrict-to-country'])) {
|
||||||
|
$sPlacexSQL .= ' and country_code = '.$oDB->getDBQuoted($aCMDResult['restrict-to-country']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// restriction to parent place id
|
||||||
|
$sParentId = false;
|
||||||
|
$sOsmType = false;
|
||||||
|
|
||||||
|
if (isset($aCMDResult['restrict-to-osm-node'])) {
|
||||||
|
$sOsmType = 'N';
|
||||||
|
$sOsmId = $aCMDResult['restrict-to-osm-node'];
|
||||||
|
}
|
||||||
|
if (isset($aCMDResult['restrict-to-osm-way'])) {
|
||||||
|
$sOsmType = 'W';
|
||||||
|
$sOsmId = $aCMDResult['restrict-to-osm-way'];
|
||||||
|
}
|
||||||
|
if (isset($aCMDResult['restrict-to-osm-relation'])) {
|
||||||
|
$sOsmType = 'R';
|
||||||
|
$sOsmId = $aCMDResult['restrict-to-osm-relation'];
|
||||||
|
}
|
||||||
|
if ($sOsmType) {
|
||||||
|
$sSQL = 'select place_id from placex where osm_type = :osm_type and osm_id = :osm_id';
|
||||||
|
$sParentId = $oDB->getOne($sSQL, array('osm_type' => $sOsmType, 'osm_id' => $sOsmId));
|
||||||
|
if (!$sParentId) {
|
||||||
|
fail('Could not find place '.$sOsmType.' '.$sOsmId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($sParentId) {
|
||||||
|
$sPlacexSQL .= ' and place_id in (select place_id from place_addressline where address_place_id = '.$sParentId.' and isaddress)';
|
||||||
|
}
|
||||||
|
|
||||||
|
$sPlacexSQL .= " group by name->'name', address, postcode, country_code, placex.place_id";
|
||||||
|
|
||||||
|
// Iterate over placeids
|
||||||
|
// to get further hierarchical information
|
||||||
|
//var_dump($sPlacexSQL);
|
||||||
|
$oResults = $oDB->getQueryStatement($sPlacexSQL);
|
||||||
|
$fOutstream = fopen('php://output', 'w');
|
||||||
|
while ($aRow = $oResults->fetch()) {
|
||||||
|
$iPlaceID = $aRow['place_id'];
|
||||||
|
$sSQL = "select rank_address,get_name_by_language(name,$sLanguagePrefArraySQL) as localname from get_addressdata(:place_id, -1)";
|
||||||
|
$sSQL .= ' WHERE isaddress';
|
||||||
|
$sSQL .= ' order by rank_address desc,isaddress desc';
|
||||||
|
$aAddressLines = $oDB->getAll($sSQL, array('place_id' => $iPlaceID));
|
||||||
|
|
||||||
|
$aOutput = array_fill(0, $iNumCol, '');
|
||||||
|
// output address parts
|
||||||
|
foreach ($aAddressLines as $aAddress) {
|
||||||
|
if (isset($aColumnMapping[$aAddress['rank_address']])) {
|
||||||
|
$aOutput[$aColumnMapping[$aAddress['rank_address']]] = $aAddress['localname'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// output postcode
|
||||||
|
if (isset($aColumnMapping['postcode'])) {
|
||||||
|
if ($aCMDResult['output-all-postcodes']) {
|
||||||
|
$sSQL = 'select array_agg(px.postcode) from placex px join place_addressline pa ';
|
||||||
|
$sSQL .= 'on px.place_id = pa.address_place_id ';
|
||||||
|
$sSQL .= 'where pa.cached_rank_address in (5,11) ';
|
||||||
|
$sSQL .= 'and pa.place_id in (select place_id from place_addressline where address_place_id in (:first_place_id)) ';
|
||||||
|
$sSQL .= 'group by postcode order by count(*) desc limit 1';
|
||||||
|
$sRes = $oDB->getOne($sSQL, array('first_place_id' => substr($aRow['place_ids'], 1, -1)));
|
||||||
|
|
||||||
|
$aOutput[$aColumnMapping['postcode']] = substr($sRes, 1, -1);
|
||||||
|
} else {
|
||||||
|
$aOutput[$aColumnMapping['postcode']] = $aRow['postcode'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset($aColumnMapping['placeid'])) {
|
||||||
|
$aOutput[$aColumnMapping['placeid']] = substr($aRow['place_ids'], 1, -1);
|
||||||
|
}
|
||||||
|
fputcsv($fOutstream, $aOutput);
|
||||||
|
}
|
||||||
|
fclose($fOutstream);
|
||||||
114
lib-php/admin/warm.php
Normal file
114
lib-php/admin/warm.php
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
*
|
||||||
|
* This file is part of Nominatim. (https://nominatim.org)
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 by the Nominatim developer community.
|
||||||
|
* For a full list of authors see the git log.
|
||||||
|
*/
|
||||||
|
@define('CONST_LibDir', dirname(dirname(__FILE__)));
|
||||||
|
|
||||||
|
require_once(CONST_LibDir.'/init-cmd.php');
|
||||||
|
require_once(CONST_LibDir.'/log.php');
|
||||||
|
require_once(CONST_LibDir.'/PlaceLookup.php');
|
||||||
|
require_once(CONST_LibDir.'/ReverseGeocode.php');
|
||||||
|
|
||||||
|
ini_set('memory_limit', '800M');
|
||||||
|
|
||||||
|
$aCMDOptions = array(
|
||||||
|
'Tools to warm nominatim db',
|
||||||
|
array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
|
||||||
|
array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
|
||||||
|
array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
|
||||||
|
array('reverse-only', '', 0, 1, 0, 0, 'bool', 'Warm reverse only'),
|
||||||
|
array('search-only', '', 0, 1, 0, 0, 'bool', 'Warm search only'),
|
||||||
|
array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory of the Nominatim installation (default: .)'),
|
||||||
|
);
|
||||||
|
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true);
|
||||||
|
|
||||||
|
loadSettings($aCMDResult['project-dir'] ?? getcwd());
|
||||||
|
|
||||||
|
@define('CONST_Database_DSN', getSetting('DATABASE_DSN'));
|
||||||
|
@define('CONST_Default_Language', getSetting('DEFAULT_LANGUAGE', false));
|
||||||
|
@define('CONST_Log_DB', getSettingBool('LOG_DB'));
|
||||||
|
@define('CONST_Log_File', getSetting('LOG_FILE', false));
|
||||||
|
@define('CONST_NoAccessControl', getSettingBool('CORS_NOACCESSCONTROL'));
|
||||||
|
@define('CONST_Places_Max_ID_count', getSetting('LOOKUP_MAX_COUNT'));
|
||||||
|
@define('CONST_PolygonOutput_MaximumTypes', getSetting('POLYGON_OUTPUT_MAX_TYPES'));
|
||||||
|
@define('CONST_Search_BatchMode', getSettingBool('SEARCH_BATCH_MODE'));
|
||||||
|
@define('CONST_Search_NameOnlySearchFrequencyThreshold', getSetting('SEARCH_NAME_ONLY_THRESHOLD'));
|
||||||
|
@define('CONST_Use_US_Tiger_Data', getSettingBool('USE_US_TIGER_DATA'));
|
||||||
|
@define('CONST_MapIcon_URL', getSetting('MAPICON_URL', false));
|
||||||
|
@define('CONST_TokenizerDir', CONST_InstallDir.'/tokenizer');
|
||||||
|
|
||||||
|
require_once(CONST_LibDir.'/Geocode.php');
|
||||||
|
|
||||||
|
$oDB = new Nominatim\DB();
|
||||||
|
$oDB->connect();
|
||||||
|
|
||||||
|
$bVerbose = $aResult['verbose'];
|
||||||
|
|
||||||
|
function print_results($aResults, $bVerbose)
|
||||||
|
{
|
||||||
|
if ($bVerbose) {
|
||||||
|
if ($aResults && count($aResults)) {
|
||||||
|
echo $aResults[0]['langaddress']."\n";
|
||||||
|
} else {
|
||||||
|
echo "<not found>\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo '.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$aResult['search-only']) {
|
||||||
|
$oReverseGeocode = new Nominatim\ReverseGeocode($oDB);
|
||||||
|
$oReverseGeocode->setZoom(20);
|
||||||
|
$oPlaceLookup = new Nominatim\PlaceLookup($oDB);
|
||||||
|
$oPlaceLookup->setIncludeAddressDetails(true);
|
||||||
|
$oPlaceLookup->setLanguagePreference(array('en'));
|
||||||
|
|
||||||
|
echo 'Warm reverse: ';
|
||||||
|
if ($bVerbose) {
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
for ($i = 0; $i < 1000; $i++) {
|
||||||
|
$fLat = rand(-9000, 9000) / 100;
|
||||||
|
$fLon = rand(-18000, 18000) / 100;
|
||||||
|
if ($bVerbose) {
|
||||||
|
echo "$fLat, $fLon = ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$oLookup = $oReverseGeocode->lookup($fLat, $fLon);
|
||||||
|
$aSearchResults = $oLookup ? $oPlaceLookup->lookup(array($oLookup->iId => $oLookup)) : null;
|
||||||
|
print_results($aSearchResults, $bVerbose);
|
||||||
|
}
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$aResult['reverse-only']) {
|
||||||
|
$oGeocode = new Nominatim\Geocode($oDB);
|
||||||
|
|
||||||
|
echo 'Warm search: ';
|
||||||
|
if ($bVerbose) {
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$oTokenizer = new \Nominatim\Tokenizer($oDB);
|
||||||
|
|
||||||
|
$aWords = $oTokenizer->mostFrequentWords(1000);
|
||||||
|
|
||||||
|
$sSQL = 'SELECT word FROM word WHERE word is not null ORDER BY search_name_count DESC LIMIT 1000';
|
||||||
|
foreach ($aWords as $sWord) {
|
||||||
|
if ($bVerbose) {
|
||||||
|
echo "$sWord = ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$oGeocode->setLanguagePreference(array('en'));
|
||||||
|
$oGeocode->setQuery($sWord);
|
||||||
|
$aSearchResults = $oGeocode->lookup();
|
||||||
|
print_results($aSearchResults, $bVerbose);
|
||||||
|
}
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
@@ -23,7 +23,7 @@ $aLangPrefOrder = $oParams->getPreferredLanguages();
|
|||||||
|
|
||||||
$sPlaceId = $oParams->getString('place_id');
|
$sPlaceId = $oParams->getString('place_id');
|
||||||
$sOsmType = $oParams->getSet('osmtype', array('N', 'W', 'R'));
|
$sOsmType = $oParams->getSet('osmtype', array('N', 'W', 'R'));
|
||||||
$iOsmId = $oParams->getInt('osmid', 0);
|
$iOsmId = $oParams->getInt('osmid', -1);
|
||||||
$sClass = $oParams->getString('class');
|
$sClass = $oParams->getString('class');
|
||||||
|
|
||||||
$bIncludeKeywords = $oParams->getBool('keywords', false);
|
$bIncludeKeywords = $oParams->getBool('keywords', false);
|
||||||
@@ -38,7 +38,7 @@ $oDB->connect();
|
|||||||
|
|
||||||
$sLanguagePrefArraySQL = $oDB->getArraySQL($oDB->getDBQuotedList($aLangPrefOrder));
|
$sLanguagePrefArraySQL = $oDB->getArraySQL($oDB->getDBQuotedList($aLangPrefOrder));
|
||||||
|
|
||||||
if ($sOsmType && $iOsmId !== 0) {
|
if ($sOsmType && $iOsmId > 0) {
|
||||||
$sSQL = 'SELECT place_id FROM placex WHERE osm_type = :type AND osm_id = :id';
|
$sSQL = 'SELECT place_id FROM placex WHERE osm_type = :type AND osm_id = :id';
|
||||||
$aSQLParams = array(':type' => $sOsmType, ':id' => $iOsmId);
|
$aSQLParams = array(':type' => $sOsmType, ':id' => $iOsmId);
|
||||||
// osm_type and osm_id are not unique enough
|
// osm_type and osm_id are not unique enough
|
||||||
|
|||||||
@@ -187,7 +187,6 @@ BEGIN
|
|||||||
|
|
||||||
-- --- Return the record for the base entry.
|
-- --- Return the record for the base entry.
|
||||||
|
|
||||||
current_rank_address := 1000;
|
|
||||||
FOR location IN
|
FOR location IN
|
||||||
SELECT placex.place_id, osm_type, osm_id, name,
|
SELECT placex.place_id, osm_type, osm_id, name,
|
||||||
coalesce(extratags->'linked_place', extratags->'place') as place_type,
|
coalesce(extratags->'linked_place', extratags->'place') as place_type,
|
||||||
@@ -262,7 +261,7 @@ BEGIN
|
|||||||
-- If the place had a postcode assigned, take this one only
|
-- If the place had a postcode assigned, take this one only
|
||||||
-- into consideration when it is an area and the place does not have
|
-- into consideration when it is an area and the place does not have
|
||||||
-- a postcode itself.
|
-- a postcode itself.
|
||||||
IF location.fromarea AND location_isaddress
|
IF location.fromarea AND location.isaddress
|
||||||
AND (place.address is null or not place.address ? 'postcode')
|
AND (place.address is null or not place.address ? 'postcode')
|
||||||
THEN
|
THEN
|
||||||
place.postcode := null; -- remove the less exact postcode
|
place.postcode := null; -- remove the less exact postcode
|
||||||
|
|||||||
@@ -20,54 +20,6 @@ CREATE TYPE place_importance as (
|
|||||||
wikipedia TEXT
|
wikipedia TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
{% if 'wikimedia_importance' in db.tables %}
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION get_wikipedia_match(extratags HSTORE, country_code varchar(2))
|
|
||||||
RETURNS wikipedia_article_match
|
|
||||||
AS $$
|
|
||||||
DECLARE
|
|
||||||
i INT;
|
|
||||||
wiki_article_title TEXT;
|
|
||||||
wiki_article_language TEXT;
|
|
||||||
result wikipedia_article_match;
|
|
||||||
entry RECORD;
|
|
||||||
BEGIN
|
|
||||||
IF extratags ? 'wikipedia' and strpos(extratags->'wikipedia', ':') IN (3,4) THEN
|
|
||||||
wiki_article_language := lower(trim(split_part(extratags->'wikipedia', ':', 1)));
|
|
||||||
wiki_article_title := trim(substr(extratags->'wikipedia',
|
|
||||||
strpos(extratags->'wikipedia', ':') + 1));
|
|
||||||
|
|
||||||
FOR result IN
|
|
||||||
SELECT language, title, importance FROM wikimedia_importance
|
|
||||||
WHERE language = wiki_article_language
|
|
||||||
and title = replace(wiki_article_title, ' ', '_')
|
|
||||||
LOOP
|
|
||||||
RETURN result;
|
|
||||||
END LOOP;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
FOREACH wiki_article_language IN ARRAY ARRAY['ar','bg','ca','cs','da','de','en','es','eo','eu','fa','fr','ko','hi','hr','id','it','he','lt','hu','ms','nl','ja','no','pl','pt','kk','ro','ru','sk','sl','sr','fi','sv','tr','uk','vi','vo','war','zh']
|
|
||||||
LOOP
|
|
||||||
IF extratags ? ('wikipedia:' || wiki_article_language) THEN
|
|
||||||
wiki_article_title := extratags->('wikipedia:' || wiki_article_language);
|
|
||||||
|
|
||||||
FOR result IN
|
|
||||||
SELECT language, title, importance FROM wikimedia_importance
|
|
||||||
WHERE language = wiki_article_language
|
|
||||||
and title = replace(wiki_article_title, ' ', '_')
|
|
||||||
LOOP
|
|
||||||
RETURN result;
|
|
||||||
END LOOP;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
END LOOP;
|
|
||||||
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$
|
|
||||||
LANGUAGE plpgsql IMMUTABLE;
|
|
||||||
|
|
||||||
{% else %}
|
|
||||||
|
|
||||||
-- See: http://stackoverflow.com/questions/6410088/how-can-i-mimic-the-php-urldecode-function-in-postgresql
|
-- See: http://stackoverflow.com/questions/6410088/how-can-i-mimic-the-php-urldecode-function-in-postgresql
|
||||||
CREATE OR REPLACE FUNCTION decode_url_part(p varchar)
|
CREATE OR REPLACE FUNCTION decode_url_part(p varchar)
|
||||||
@@ -110,6 +62,10 @@ BEGIN
|
|||||||
WHILE langs[i] IS NOT NULL LOOP
|
WHILE langs[i] IS NOT NULL LOOP
|
||||||
wiki_article := extratags->(case when langs[i] in ('english','country') THEN 'wikipedia' ELSE 'wikipedia:'||langs[i] END);
|
wiki_article := extratags->(case when langs[i] in ('english','country') THEN 'wikipedia' ELSE 'wikipedia:'||langs[i] END);
|
||||||
IF wiki_article is not null THEN
|
IF wiki_article is not null THEN
|
||||||
|
wiki_article := regexp_replace(wiki_article,E'^(.*?)([a-z]{2,3}).wikipedia.org/wiki/',E'\\2:');
|
||||||
|
wiki_article := regexp_replace(wiki_article,E'^(.*?)([a-z]{2,3}).wikipedia.org/w/index.php\\?title=',E'\\2:');
|
||||||
|
wiki_article := regexp_replace(wiki_article,E'^(.*?)/([a-z]{2,3})/wiki/',E'\\2:');
|
||||||
|
--wiki_article := regexp_replace(wiki_article,E'^(.*?)([a-z]{2,3})[=:]',E'\\2:');
|
||||||
wiki_article := replace(wiki_article,' ','_');
|
wiki_article := replace(wiki_article,' ','_');
|
||||||
IF strpos(wiki_article, ':') IN (3,4) THEN
|
IF strpos(wiki_article, ':') IN (3,4) THEN
|
||||||
wiki_article_language := lower(trim(split_part(wiki_article, ':', 1)));
|
wiki_article_language := lower(trim(split_part(wiki_article, ':', 1)));
|
||||||
@@ -141,7 +97,6 @@ END;
|
|||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql STABLE;
|
LANGUAGE plpgsql STABLE;
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION compute_importance(extratags HSTORE,
|
CREATE OR REPLACE FUNCTION compute_importance(extratags HSTORE,
|
||||||
country_code varchar(2),
|
country_code varchar(2),
|
||||||
@@ -167,16 +122,9 @@ BEGIN
|
|||||||
|
|
||||||
-- Nothing? Then try with the wikidata tag.
|
-- Nothing? Then try with the wikidata tag.
|
||||||
IF result.importance is null AND extratags ? 'wikidata' THEN
|
IF result.importance is null AND extratags ? 'wikidata' THEN
|
||||||
FOR match IN
|
FOR match IN SELECT * FROM wikipedia_article
|
||||||
{% if 'wikimedia_importance' in db.tables %}
|
WHERE wd_page_title = extratags->'wikidata'
|
||||||
SELECT * FROM wikimedia_importance
|
ORDER BY language = 'en' DESC, langcount DESC LIMIT 1
|
||||||
WHERE wikidata = extratags->'wikidata'
|
|
||||||
LIMIT 1
|
|
||||||
{% else %}
|
|
||||||
SELECT * FROM wikipedia_article
|
|
||||||
WHERE wd_page_title = extratags->'wikidata'
|
|
||||||
ORDER BY language = 'en' DESC, langcount DESC LIMIT 1
|
|
||||||
{% endif %}
|
|
||||||
LOOP
|
LOOP
|
||||||
result.importance := match.importance;
|
result.importance := match.importance;
|
||||||
result.wikipedia := match.language || ':' || match.title;
|
result.wikipedia := match.language || ':' || match.title;
|
||||||
@@ -186,7 +134,7 @@ BEGIN
|
|||||||
|
|
||||||
-- Still nothing? Fall back to a default.
|
-- Still nothing? Fall back to a default.
|
||||||
IF result.importance is null THEN
|
IF result.importance is null THEN
|
||||||
result.importance := 0.40001 - (rank_search::float / 75);
|
result.importance := 0.75001 - (rank_search::float / 40);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
{% if 'secondary_importance' in db.tables %}
|
{% if 'secondary_importance' in db.tables %}
|
||||||
|
|||||||
@@ -67,6 +67,10 @@ BEGIN
|
|||||||
END LOOP;
|
END LOOP;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
IF parent_place_id is null THEN
|
||||||
|
RETURN 0;
|
||||||
|
END IF;
|
||||||
|
|
||||||
RETURN parent_place_id;
|
RETURN parent_place_id;
|
||||||
END;
|
END;
|
||||||
$$
|
$$
|
||||||
@@ -179,13 +183,6 @@ BEGIN
|
|||||||
ST_PointOnSurface(NEW.linegeo),
|
ST_PointOnSurface(NEW.linegeo),
|
||||||
NEW.linegeo);
|
NEW.linegeo);
|
||||||
|
|
||||||
-- Cannot find a parent street. We will not be able to display a reliable
|
|
||||||
-- address, so drop entire interpolation.
|
|
||||||
IF NEW.parent_place_id is NULL THEN
|
|
||||||
DELETE FROM location_property_osmline where place_id = OLD.place_id;
|
|
||||||
RETURN NULL;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
NEW.token_info := token_strip_info(NEW.token_info);
|
NEW.token_info := token_strip_info(NEW.token_info);
|
||||||
IF NEW.address ? '_inherited' THEN
|
IF NEW.address ? '_inherited' THEN
|
||||||
NEW.address := hstore('interpolation', NEW.address->'interpolation');
|
NEW.address := hstore('interpolation', NEW.address->'interpolation');
|
||||||
@@ -222,11 +219,10 @@ BEGIN
|
|||||||
-- formatted postcode and therefore 'postcode' contains a derived
|
-- formatted postcode and therefore 'postcode' contains a derived
|
||||||
-- variant.
|
-- variant.
|
||||||
CASE WHEN address ? 'postcode' THEN placex.postcode ELSE NULL::text END as postcode,
|
CASE WHEN address ? 'postcode' THEN placex.postcode ELSE NULL::text END as postcode,
|
||||||
(address->'housenumber')::integer as hnr
|
substring(address->'housenumber','[0-9]+')::integer as hnr
|
||||||
FROM placex, generate_series(1, array_upper(waynodes, 1)) nodeidpos
|
FROM placex, generate_series(1, array_upper(waynodes, 1)) nodeidpos
|
||||||
WHERE osm_type = 'N' and osm_id = waynodes[nodeidpos]::BIGINT
|
WHERE osm_type = 'N' and osm_id = waynodes[nodeidpos]::BIGINT
|
||||||
and address is not NULL and address ? 'housenumber'
|
and address is not NULL and address ? 'housenumber'
|
||||||
and address->'housenumber' ~ '^[0-9]{1,6}$'
|
|
||||||
and ST_Distance(NEW.linegeo, geometry) < 0.0005
|
and ST_Distance(NEW.linegeo, geometry) < 0.0005
|
||||||
ORDER BY nodeidpos
|
ORDER BY nodeidpos
|
||||||
LOOP
|
LOOP
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ BEGIN
|
|||||||
-- Remove the place from the list of places to be deleted
|
-- Remove the place from the list of places to be deleted
|
||||||
DELETE FROM place_to_be_deleted pdel
|
DELETE FROM place_to_be_deleted pdel
|
||||||
WHERE pdel.osm_type = NEW.osm_type and pdel.osm_id = NEW.osm_id
|
WHERE pdel.osm_type = NEW.osm_type and pdel.osm_id = NEW.osm_id
|
||||||
and pdel.class = NEW.class and pdel.type = NEW.type;
|
and pdel.class = NEW.class;
|
||||||
|
|
||||||
-- Have we already done this place?
|
-- Have we already done this place?
|
||||||
SELECT * INTO existing
|
SELECT * INTO existing
|
||||||
@@ -296,9 +296,7 @@ BEGIN
|
|||||||
extratags = NEW.extratags,
|
extratags = NEW.extratags,
|
||||||
admin_level = NEW.admin_level,
|
admin_level = NEW.admin_level,
|
||||||
indexed_status = 2,
|
indexed_status = 2,
|
||||||
geometry = CASE WHEN existingplacex.rank_address = 0
|
geometry = NEW.geometry
|
||||||
THEN simplify_large_polygons(NEW.geometry)
|
|
||||||
ELSE NEW.geometry END
|
|
||||||
WHERE place_id = existingplacex.place_id;
|
WHERE place_id = existingplacex.place_id;
|
||||||
|
|
||||||
-- Invalidate linked places: they potentially get a new name and addresses.
|
-- Invalidate linked places: they potentially get a new name and addresses.
|
||||||
@@ -365,3 +363,57 @@ BEGIN
|
|||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION flush_deleted_places()
|
||||||
|
RETURNS INTEGER
|
||||||
|
AS $$
|
||||||
|
BEGIN
|
||||||
|
-- deleting large polygons can have a massive effect on the system - require manual intervention to let them through
|
||||||
|
INSERT INTO import_polygon_delete (osm_type, osm_id, class, type)
|
||||||
|
SELECT osm_type, osm_id, class, type FROM place_to_be_deleted WHERE deferred;
|
||||||
|
|
||||||
|
-- delete from place table
|
||||||
|
ALTER TABLE place DISABLE TRIGGER place_before_delete;
|
||||||
|
DELETE FROM place USING place_to_be_deleted
|
||||||
|
WHERE place.osm_type = place_to_be_deleted.osm_type
|
||||||
|
and place.osm_id = place_to_be_deleted.osm_id
|
||||||
|
and place.class = place_to_be_deleted.class
|
||||||
|
and place.type = place_to_be_deleted.type
|
||||||
|
and not deferred;
|
||||||
|
ALTER TABLE place ENABLE TRIGGER place_before_delete;
|
||||||
|
|
||||||
|
-- Mark for delete in the placex table
|
||||||
|
UPDATE placex SET indexed_status = 100 FROM place_to_be_deleted
|
||||||
|
WHERE placex.osm_type = 'N' and place_to_be_deleted.osm_type = 'N'
|
||||||
|
and placex.osm_id = place_to_be_deleted.osm_id
|
||||||
|
and placex.class = place_to_be_deleted.class
|
||||||
|
and placex.type = place_to_be_deleted.type
|
||||||
|
and not deferred;
|
||||||
|
UPDATE placex SET indexed_status = 100 FROM place_to_be_deleted
|
||||||
|
WHERE placex.osm_type = 'W' and place_to_be_deleted.osm_type = 'W'
|
||||||
|
and placex.osm_id = place_to_be_deleted.osm_id
|
||||||
|
and placex.class = place_to_be_deleted.class
|
||||||
|
and placex.type = place_to_be_deleted.type
|
||||||
|
and not deferred;
|
||||||
|
UPDATE placex SET indexed_status = 100 FROM place_to_be_deleted
|
||||||
|
WHERE placex.osm_type = 'R' and place_to_be_deleted.osm_type = 'R'
|
||||||
|
and placex.osm_id = place_to_be_deleted.osm_id
|
||||||
|
and placex.class = place_to_be_deleted.class
|
||||||
|
and placex.type = place_to_be_deleted.type
|
||||||
|
and not deferred;
|
||||||
|
|
||||||
|
-- Mark for delete in interpolations
|
||||||
|
UPDATE location_property_osmline SET indexed_status = 100 FROM place_to_be_deleted
|
||||||
|
WHERE place_to_be_deleted.osm_type = 'W'
|
||||||
|
and place_to_be_deleted.class = 'place'
|
||||||
|
and place_to_be_deleted.type = 'houses'
|
||||||
|
and location_property_osmline.osm_id = place_to_be_deleted.osm_id
|
||||||
|
and not deferred;
|
||||||
|
|
||||||
|
-- Clear todo list.
|
||||||
|
TRUNCATE TABLE place_to_be_deleted;
|
||||||
|
|
||||||
|
RETURN NULL;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
--
|
--
|
||||||
-- This file is part of Nominatim. (https://nominatim.org)
|
-- This file is part of Nominatim. (https://nominatim.org)
|
||||||
--
|
--
|
||||||
-- Copyright (C) 2024 by the Nominatim developer community.
|
-- Copyright (C) 2022 by the Nominatim developer community.
|
||||||
-- For a full list of authors see the git log.
|
-- For a full list of authors see the git log.
|
||||||
|
|
||||||
-- Trigger functions for the placex table.
|
-- Trigger functions for the placex table.
|
||||||
@@ -88,18 +88,12 @@ BEGIN
|
|||||||
-- Add all names from the place nodes that deviate from the name
|
-- Add all names from the place nodes that deviate from the name
|
||||||
-- in the relation with the prefix '_place_'. Deviation means that
|
-- in the relation with the prefix '_place_'. Deviation means that
|
||||||
-- either the value is different or a given key is missing completely
|
-- either the value is different or a given key is missing completely
|
||||||
IF result.name is null THEN
|
SELECT hstore(array_agg('_place_' || key), array_agg(value)) INTO extra_names
|
||||||
SELECT hstore(array_agg('_place_' || key), array_agg(value))
|
FROM each(location.name - result.name);
|
||||||
INTO result.name
|
{% if debug %}RAISE WARNING 'Extra names: %', extra_names;{% endif %}
|
||||||
FROM each(location.name);
|
|
||||||
ELSE
|
|
||||||
SELECT hstore(array_agg('_place_' || key), array_agg(value)) INTO extra_names
|
|
||||||
FROM each(location.name - result.name);
|
|
||||||
{% if debug %}RAISE WARNING 'Extra names: %', extra_names;{% endif %}
|
|
||||||
|
|
||||||
IF extra_names is not null THEN
|
IF extra_names is not null THEN
|
||||||
result.name := result.name || extra_names;
|
result.name := result.name || extra_names;
|
||||||
END IF;
|
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
{% if debug %}RAISE WARNING 'Final names: %', result.name;{% endif %}
|
{% if debug %}RAISE WARNING 'Final names: %', result.name;{% endif %}
|
||||||
@@ -119,14 +113,12 @@ CREATE OR REPLACE FUNCTION find_associated_street(poi_osm_type CHAR(1),
|
|||||||
AS $$
|
AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
location RECORD;
|
location RECORD;
|
||||||
member JSONB;
|
|
||||||
parent RECORD;
|
parent RECORD;
|
||||||
result BIGINT;
|
result BIGINT;
|
||||||
distance FLOAT;
|
distance FLOAT;
|
||||||
new_distance FLOAT;
|
new_distance FLOAT;
|
||||||
waygeom GEOMETRY;
|
waygeom GEOMETRY;
|
||||||
BEGIN
|
BEGIN
|
||||||
{% if db.middle_db_format == '1' %}
|
|
||||||
FOR location IN
|
FOR location IN
|
||||||
SELECT members FROM planet_osm_rels
|
SELECT members FROM planet_osm_rels
|
||||||
WHERE parts @> ARRAY[poi_osm_id]
|
WHERE parts @> ARRAY[poi_osm_id]
|
||||||
@@ -163,40 +155,6 @@ BEGIN
|
|||||||
END LOOP;
|
END LOOP;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
|
|
||||||
{% else %}
|
|
||||||
FOR member IN
|
|
||||||
SELECT value FROM planet_osm_rels r, LATERAL jsonb_array_elements(members)
|
|
||||||
WHERE planet_osm_member_ids(members, poi_osm_type::char(1)) && ARRAY[poi_osm_id]
|
|
||||||
and tags->>'type' = 'associatedStreet'
|
|
||||||
and value->>'role' = 'street'
|
|
||||||
LOOP
|
|
||||||
FOR parent IN
|
|
||||||
SELECT place_id, geometry
|
|
||||||
FROM placex
|
|
||||||
WHERE osm_type = (member->>'type')::char(1)
|
|
||||||
and osm_id = (member->>'ref')::bigint
|
|
||||||
and name is not null
|
|
||||||
and rank_search between 26 and 27
|
|
||||||
LOOP
|
|
||||||
-- Find the closest 'street' member.
|
|
||||||
-- Avoid distance computation for the frequent case where there is
|
|
||||||
-- only one street member.
|
|
||||||
IF waygeom is null THEN
|
|
||||||
result := parent.place_id;
|
|
||||||
waygeom := parent.geometry;
|
|
||||||
ELSE
|
|
||||||
distance := coalesce(distance, ST_Distance(waygeom, bbox));
|
|
||||||
new_distance := ST_Distance(parent.geometry, bbox);
|
|
||||||
IF new_distance < distance THEN
|
|
||||||
distance := new_distance;
|
|
||||||
result := parent.place_id;
|
|
||||||
waygeom := parent.geometry;
|
|
||||||
END IF;
|
|
||||||
END IF;
|
|
||||||
END LOOP;
|
|
||||||
END LOOP;
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
RETURN result;
|
RETURN result;
|
||||||
END;
|
END;
|
||||||
$$
|
$$
|
||||||
@@ -293,11 +251,7 @@ CREATE OR REPLACE FUNCTION find_linked_place(bnd placex)
|
|||||||
RETURNS placex
|
RETURNS placex
|
||||||
AS $$
|
AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
{% if db.middle_db_format == '1' %}
|
|
||||||
relation_members TEXT[];
|
relation_members TEXT[];
|
||||||
{% else %}
|
|
||||||
relation_members JSONB;
|
|
||||||
{% endif %}
|
|
||||||
rel_member RECORD;
|
rel_member RECORD;
|
||||||
linked_placex placex%ROWTYPE;
|
linked_placex placex%ROWTYPE;
|
||||||
bnd_name TEXT;
|
bnd_name TEXT;
|
||||||
@@ -481,20 +435,24 @@ BEGIN
|
|||||||
name_vector := array_merge(name_vector, hnr_vector);
|
name_vector := array_merge(name_vector, hnr_vector);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
IF is_place_addr THEN
|
||||||
|
addr_place_ids := token_addr_place_search_tokens(token_info);
|
||||||
|
IF not addr_place_ids <@ parent_name_vector THEN
|
||||||
|
-- make sure addr:place terms are always searchable
|
||||||
|
nameaddress_vector := array_merge(nameaddress_vector, addr_place_ids);
|
||||||
|
-- If there is a housenumber, also add the place name as a name,
|
||||||
|
-- so we can search it by the usual housenumber+place algorithms.
|
||||||
|
IF hnr_vector is not null THEN
|
||||||
|
name_vector := array_merge(name_vector, addr_place_ids);
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
|
||||||
-- Cheating here by not recomputing all terms but simply using the ones
|
-- Cheating here by not recomputing all terms but simply using the ones
|
||||||
-- from the parent object.
|
-- from the parent object.
|
||||||
nameaddress_vector := array_merge(nameaddress_vector, parent_name_vector);
|
nameaddress_vector := array_merge(nameaddress_vector, parent_name_vector);
|
||||||
nameaddress_vector := array_merge(nameaddress_vector, parent_address_vector);
|
nameaddress_vector := array_merge(nameaddress_vector, parent_address_vector);
|
||||||
|
|
||||||
-- make sure addr:place terms are always searchable
|
|
||||||
IF is_place_addr THEN
|
|
||||||
addr_place_ids := token_addr_place_search_tokens(token_info);
|
|
||||||
IF hnr_vector is not null AND not addr_place_ids <@ parent_name_vector
|
|
||||||
THEN
|
|
||||||
name_vector := array_merge(name_vector, hnr_vector);
|
|
||||||
END IF;
|
|
||||||
nameaddress_vector := array_merge(nameaddress_vector, addr_place_ids);
|
|
||||||
END IF;
|
|
||||||
END;
|
END;
|
||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql;
|
LANGUAGE plpgsql;
|
||||||
@@ -714,12 +672,6 @@ BEGIN
|
|||||||
NEW.country_code := NULL;
|
NEW.country_code := NULL;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- Simplify polygons with a very large memory footprint when they
|
|
||||||
-- do not take part in address computation.
|
|
||||||
IF NEW.rank_address = 0 THEN
|
|
||||||
NEW.geometry := simplify_large_polygons(NEW.geometry);
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
{% if debug %}RAISE WARNING 'placex_insert:END: % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type;{% endif %}
|
{% if debug %}RAISE WARNING 'placex_insert:END: % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type;{% endif %}
|
||||||
@@ -727,12 +679,10 @@ BEGIN
|
|||||||
{% if not disable_diff_updates %}
|
{% if not disable_diff_updates %}
|
||||||
-- The following is not needed until doing diff updates, and slows the main index process down
|
-- The following is not needed until doing diff updates, and slows the main index process down
|
||||||
|
|
||||||
IF NEW.rank_address between 2 and 27 THEN
|
IF NEW.rank_address > 0 THEN
|
||||||
IF (ST_GeometryType(NEW.geometry) in ('ST_Polygon','ST_MultiPolygon') AND ST_IsValid(NEW.geometry)) THEN
|
IF (ST_GeometryType(NEW.geometry) in ('ST_Polygon','ST_MultiPolygon') AND ST_IsValid(NEW.geometry)) THEN
|
||||||
-- Performance: We just can't handle re-indexing for country level changes
|
-- Performance: We just can't handle re-indexing for country level changes
|
||||||
IF (NEW.rank_address < 26 and st_area(NEW.geometry) < 1)
|
IF st_area(NEW.geometry) < 1 THEN
|
||||||
OR (NEW.rank_address >= 26 and st_area(NEW.geometry) < 0.01)
|
|
||||||
THEN
|
|
||||||
-- mark items within the geometry for re-indexing
|
-- mark items within the geometry for re-indexing
|
||||||
-- RAISE WARNING 'placex poly insert: % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type;
|
-- RAISE WARNING 'placex poly insert: % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type;
|
||||||
|
|
||||||
@@ -747,11 +697,9 @@ BEGIN
|
|||||||
or name is not null
|
or name is not null
|
||||||
or (NEW.rank_address >= 16 and address ? 'place'));
|
or (NEW.rank_address >= 16 and address ? 'place'));
|
||||||
END IF;
|
END IF;
|
||||||
ELSEIF ST_GeometryType(NEW.geometry) not in ('ST_LineString', 'ST_MultiLineString')
|
ELSE
|
||||||
OR ST_Length(NEW.geometry) < 0.5
|
|
||||||
THEN
|
|
||||||
-- mark nearby items for re-indexing, where 'nearby' depends on the features rank_search and is a complete guess :(
|
-- mark nearby items for re-indexing, where 'nearby' depends on the features rank_search and is a complete guess :(
|
||||||
diameter := update_place_diameter(NEW.rank_address);
|
diameter := update_place_diameter(NEW.rank_search);
|
||||||
IF diameter > 0 THEN
|
IF diameter > 0 THEN
|
||||||
-- RAISE WARNING 'placex point insert: % % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type,diameter;
|
-- RAISE WARNING 'placex point insert: % % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type,diameter;
|
||||||
IF NEW.rank_search >= 26 THEN
|
IF NEW.rank_search >= 26 THEN
|
||||||
@@ -795,11 +743,7 @@ CREATE OR REPLACE FUNCTION placex_update()
|
|||||||
DECLARE
|
DECLARE
|
||||||
i INTEGER;
|
i INTEGER;
|
||||||
location RECORD;
|
location RECORD;
|
||||||
{% if db.middle_db_format == '1' %}
|
|
||||||
relation_members TEXT[];
|
relation_members TEXT[];
|
||||||
{% else %}
|
|
||||||
relation_member JSONB;
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
geom GEOMETRY;
|
geom GEOMETRY;
|
||||||
parent_address_level SMALLINT;
|
parent_address_level SMALLINT;
|
||||||
@@ -844,9 +788,6 @@ BEGIN
|
|||||||
result := deleteLocationArea(NEW.partition, NEW.place_id, NEW.rank_search);
|
result := deleteLocationArea(NEW.partition, NEW.place_id, NEW.rank_search);
|
||||||
|
|
||||||
NEW.extratags := NEW.extratags - 'linked_place'::TEXT;
|
NEW.extratags := NEW.extratags - 'linked_place'::TEXT;
|
||||||
IF NEW.extratags = ''::hstore THEN
|
|
||||||
NEW.extratags := NULL;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
-- NEW.linked_place_id contains the precomputed linkee. Save this and restore
|
-- NEW.linked_place_id contains the precomputed linkee. Save this and restore
|
||||||
-- the previous link status.
|
-- the previous link status.
|
||||||
@@ -1021,7 +962,6 @@ BEGIN
|
|||||||
|
|
||||||
-- waterway ways are linked when they are part of a relation and have the same class/type
|
-- waterway ways are linked when they are part of a relation and have the same class/type
|
||||||
IF NEW.osm_type = 'R' and NEW.class = 'waterway' THEN
|
IF NEW.osm_type = 'R' and NEW.class = 'waterway' THEN
|
||||||
{% if db.middle_db_format == '1' %}
|
|
||||||
FOR relation_members IN select members from planet_osm_rels r where r.id = NEW.osm_id and r.parts != array[]::bigint[]
|
FOR relation_members IN select members from planet_osm_rels r where r.id = NEW.osm_id and r.parts != array[]::bigint[]
|
||||||
LOOP
|
LOOP
|
||||||
FOR i IN 1..array_upper(relation_members, 1) BY 2 LOOP
|
FOR i IN 1..array_upper(relation_members, 1) BY 2 LOOP
|
||||||
@@ -1040,29 +980,6 @@ BEGIN
|
|||||||
END IF;
|
END IF;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
{% else %}
|
|
||||||
FOR relation_member IN
|
|
||||||
SELECT value FROM planet_osm_rels r, LATERAL jsonb_array_elements(r.members)
|
|
||||||
WHERE r.id = NEW.osm_id
|
|
||||||
LOOP
|
|
||||||
IF relation_member->>'role' IN ('', 'main_stream', 'side_stream')
|
|
||||||
and relation_member->>'type' = 'W'
|
|
||||||
THEN
|
|
||||||
{% if debug %}RAISE WARNING 'waterway parent %, child %', NEW.osm_id, relation_member;{% endif %}
|
|
||||||
FOR linked_node_id IN
|
|
||||||
SELECT place_id FROM placex
|
|
||||||
WHERE osm_type = 'W' and osm_id = (relation_member->>'ref')::bigint
|
|
||||||
and class = NEW.class and type in ('river', 'stream', 'canal', 'drain', 'ditch')
|
|
||||||
and (relation_member->>'role' != 'side_stream' or NEW.name->'name' = name->'name')
|
|
||||||
LOOP
|
|
||||||
UPDATE placex SET linked_place_id = NEW.place_id WHERE place_id = linked_node_id;
|
|
||||||
{% if 'search_name' in db.tables %}
|
|
||||||
DELETE FROM search_name WHERE place_id = linked_node_id;
|
|
||||||
{% endif %}
|
|
||||||
END LOOP;
|
|
||||||
END IF;
|
|
||||||
END LOOP;
|
|
||||||
{% endif %}
|
|
||||||
{% if debug %}RAISE WARNING 'Waterway processed';{% endif %}
|
{% if debug %}RAISE WARNING 'Waterway processed';{% endif %}
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
@@ -1079,7 +996,7 @@ BEGIN
|
|||||||
|
|
||||||
{% if debug %}RAISE WARNING 'finding street for % %', NEW.osm_type, NEW.osm_id;{% endif %}
|
{% if debug %}RAISE WARNING 'finding street for % %', NEW.osm_type, NEW.osm_id;{% endif %}
|
||||||
NEW.parent_place_id := null;
|
NEW.parent_place_id := null;
|
||||||
is_place_address := not token_is_street_address(NEW.token_info);
|
is_place_address := coalesce(not NEW.address ? 'street' and NEW.address ? 'place', FALSE);
|
||||||
|
|
||||||
-- We have to find our parent road.
|
-- We have to find our parent road.
|
||||||
NEW.parent_place_id := find_parent_for_poi(NEW.osm_type, NEW.osm_id,
|
NEW.parent_place_id := find_parent_for_poi(NEW.osm_type, NEW.osm_id,
|
||||||
@@ -1096,7 +1013,7 @@ BEGIN
|
|||||||
SELECT p.country_code, p.postcode, p.name FROM placex p
|
SELECT p.country_code, p.postcode, p.name FROM placex p
|
||||||
WHERE p.place_id = NEW.parent_place_id INTO location;
|
WHERE p.place_id = NEW.parent_place_id INTO location;
|
||||||
|
|
||||||
IF is_place_address and NEW.address ? 'place' THEN
|
IF is_place_address THEN
|
||||||
-- Check if the addr:place tag is part of the parent name
|
-- Check if the addr:place tag is part of the parent name
|
||||||
SELECT count(*) INTO i
|
SELECT count(*) INTO i
|
||||||
FROM svals(location.name) AS pname WHERE pname = NEW.address->'place';
|
FROM svals(location.name) AS pname WHERE pname = NEW.address->'place';
|
||||||
@@ -1265,8 +1182,6 @@ BEGIN
|
|||||||
END IF;
|
END IF;
|
||||||
ELSEIF NEW.rank_address > 25 THEN
|
ELSEIF NEW.rank_address > 25 THEN
|
||||||
max_rank := 25;
|
max_rank := 25;
|
||||||
ELSEIF NEW.class in ('place','boundary') and NEW.type in ('postcode','postal_code') THEN
|
|
||||||
max_rank := NEW.rank_search;
|
|
||||||
ELSE
|
ELSE
|
||||||
max_rank := NEW.rank_address;
|
max_rank := NEW.rank_address;
|
||||||
END IF;
|
END IF;
|
||||||
@@ -1320,9 +1235,7 @@ BEGIN
|
|||||||
OR ST_GeometryType(NEW.geometry) not in ('ST_LineString','ST_MultiLineString')
|
OR ST_GeometryType(NEW.geometry) not in ('ST_LineString','ST_MultiLineString')
|
||||||
OR ST_Length(NEW.geometry) < 0.02)
|
OR ST_Length(NEW.geometry) < 0.02)
|
||||||
THEN
|
THEN
|
||||||
NEW.postcode := get_nearest_postcode(NEW.country_code,
|
NEW.postcode := get_nearest_postcode(NEW.country_code, NEW.geometry);
|
||||||
CASE WHEN NEW.rank_address > 25
|
|
||||||
THEN NEW.centroid ELSE NEW.geometry END);
|
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
{% if debug %}RAISE WARNING 'place update % % finished.', NEW.osm_type, NEW.osm_id;{% endif %}
|
{% if debug %}RAISE WARNING 'place update % % finished.', NEW.osm_type, NEW.osm_id;{% endif %}
|
||||||
@@ -1403,8 +1316,6 @@ BEGIN
|
|||||||
|
|
||||||
{% if debug %}RAISE WARNING 'placex_delete:12 % %',OLD.osm_type,OLD.osm_id;{% endif %}
|
{% if debug %}RAISE WARNING 'placex_delete:12 % %',OLD.osm_type,OLD.osm_id;{% endif %}
|
||||||
|
|
||||||
UPDATE location_postcode SET indexed_status = 2 WHERE parent_place_id = OLD.place_id;
|
|
||||||
|
|
||||||
RETURN OLD;
|
RETURN OLD;
|
||||||
|
|
||||||
END;
|
END;
|
||||||
|
|||||||
@@ -284,24 +284,3 @@ BEGIN
|
|||||||
END;
|
END;
|
||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql IMMUTABLE;
|
LANGUAGE plpgsql IMMUTABLE;
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION weigh_search(search_vector INT[],
|
|
||||||
rankings TEXT,
|
|
||||||
def_weight FLOAT)
|
|
||||||
RETURNS FLOAT
|
|
||||||
AS $$
|
|
||||||
DECLARE
|
|
||||||
rank JSON;
|
|
||||||
BEGIN
|
|
||||||
FOR rank IN
|
|
||||||
SELECT * FROM json_array_elements(rankings::JSON)
|
|
||||||
LOOP
|
|
||||||
IF true = ALL(SELECT x::int = ANY(search_vector) FROM json_array_elements_text(rank->1) as x) THEN
|
|
||||||
RETURN (rank->>0)::float;
|
|
||||||
END IF;
|
|
||||||
END LOOP;
|
|
||||||
RETURN def_weight;
|
|
||||||
END;
|
|
||||||
$$
|
|
||||||
LANGUAGE plpgsql IMMUTABLE;
|
|
||||||
|
|||||||
@@ -73,26 +73,6 @@ END;
|
|||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql IMMUTABLE;
|
LANGUAGE plpgsql IMMUTABLE;
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION get_rel_node_members(members JSONB, memberLabels TEXT[])
|
|
||||||
RETURNS SETOF BIGINT
|
|
||||||
AS $$
|
|
||||||
DECLARE
|
|
||||||
member JSONB;
|
|
||||||
BEGIN
|
|
||||||
FOR member IN SELECT * FROM jsonb_array_elements(members)
|
|
||||||
LOOP
|
|
||||||
IF member->>'type' = 'N' and member->>'role' = ANY(memberLabels) THEN
|
|
||||||
RETURN NEXT (member->>'ref')::bigint;
|
|
||||||
END IF;
|
|
||||||
END LOOP;
|
|
||||||
|
|
||||||
RETURN;
|
|
||||||
END;
|
|
||||||
$$
|
|
||||||
LANGUAGE plpgsql IMMUTABLE;
|
|
||||||
|
|
||||||
|
|
||||||
-- Copy 'name' to or from the default language.
|
-- Copy 'name' to or from the default language.
|
||||||
--
|
--
|
||||||
-- \param country_code Country code of the object being named.
|
-- \param country_code Country code of the object being named.
|
||||||
@@ -164,44 +144,18 @@ CREATE OR REPLACE FUNCTION get_country_code(place geometry)
|
|||||||
DECLARE
|
DECLARE
|
||||||
place_centre GEOMETRY;
|
place_centre GEOMETRY;
|
||||||
nearcountry RECORD;
|
nearcountry RECORD;
|
||||||
countries TEXT[];
|
|
||||||
BEGIN
|
BEGIN
|
||||||
place_centre := ST_PointOnSurface(place);
|
place_centre := ST_PointOnSurface(place);
|
||||||
|
|
||||||
-- RAISE WARNING 'get_country_code, start: %', ST_AsText(place_centre);
|
-- RAISE WARNING 'get_country_code, start: %', ST_AsText(place_centre);
|
||||||
|
|
||||||
-- Try for a OSM polygon
|
-- Try for a OSM polygon
|
||||||
SELECT array_agg(country_code) FROM location_area_country
|
FOR nearcountry IN
|
||||||
WHERE country_code is not null and st_covers(geometry, place_centre)
|
SELECT country_code from location_area_country
|
||||||
INTO countries;
|
WHERE country_code is not null and st_covers(geometry, place_centre) limit 1
|
||||||
|
LOOP
|
||||||
IF array_length(countries, 1) = 1 THEN
|
RETURN nearcountry.country_code;
|
||||||
RETURN countries[1];
|
END LOOP;
|
||||||
END IF;
|
|
||||||
|
|
||||||
IF array_length(countries, 1) > 1 THEN
|
|
||||||
-- more than one country found, confirm against the fallback data what to choose
|
|
||||||
FOR nearcountry IN
|
|
||||||
SELECT country_code FROM country_osm_grid
|
|
||||||
WHERE ST_Covers(geometry, place_centre) AND country_code = ANY(countries)
|
|
||||||
ORDER BY area ASC
|
|
||||||
LOOP
|
|
||||||
RETURN nearcountry.country_code;
|
|
||||||
END LOOP;
|
|
||||||
-- Still nothing? Choose the country code with the smallest partition number.
|
|
||||||
-- And failing that, just go by the alphabet.
|
|
||||||
FOR nearcountry IN
|
|
||||||
SELECT cc,
|
|
||||||
(SELECT partition FROM country_name WHERE country_code = cc) as partition
|
|
||||||
FROM unnest(countries) cc
|
|
||||||
ORDER BY partition, cc
|
|
||||||
LOOP
|
|
||||||
RETURN nearcountry.cc;
|
|
||||||
END LOOP;
|
|
||||||
|
|
||||||
-- Should never be reached.
|
|
||||||
RETURN countries[1];
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
-- RAISE WARNING 'osm fallback: %', ST_AsText(place_centre);
|
-- RAISE WARNING 'osm fallback: %', ST_AsText(place_centre);
|
||||||
|
|
||||||
@@ -319,8 +273,8 @@ BEGIN
|
|||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
RETURN ST_Envelope(ST_Collect(
|
RETURN ST_Envelope(ST_Collect(
|
||||||
ST_Project(geom::geography, radius, 0.785398)::geometry,
|
ST_Project(geom, radius, 0.785398)::geometry,
|
||||||
ST_Project(geom::geography, radius, 3.9269908)::geometry));
|
ST_Project(geom, radius, 3.9269908)::geometry));
|
||||||
END;
|
END;
|
||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql IMMUTABLE;
|
LANGUAGE plpgsql IMMUTABLE;
|
||||||
@@ -462,20 +416,6 @@ END;
|
|||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql IMMUTABLE;
|
LANGUAGE plpgsql IMMUTABLE;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION simplify_large_polygons(geometry GEOMETRY)
|
|
||||||
RETURNS GEOMETRY
|
|
||||||
AS $$
|
|
||||||
BEGIN
|
|
||||||
IF ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon')
|
|
||||||
and ST_MemSize(geometry) > 3000000
|
|
||||||
THEN
|
|
||||||
geometry := ST_SimplifyPreserveTopology(geometry, 0.0001);
|
|
||||||
END IF;
|
|
||||||
RETURN geometry;
|
|
||||||
END;
|
|
||||||
$$
|
|
||||||
LANGUAGE plpgsql IMMUTABLE;
|
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION place_force_delete(placeid BIGINT)
|
CREATE OR REPLACE FUNCTION place_force_delete(placeid BIGINT)
|
||||||
RETURNS BOOLEAN
|
RETURNS BOOLEAN
|
||||||
@@ -547,56 +487,3 @@ BEGIN
|
|||||||
END;
|
END;
|
||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql;
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION flush_deleted_places()
|
|
||||||
RETURNS INTEGER
|
|
||||||
AS $$
|
|
||||||
BEGIN
|
|
||||||
-- deleting large polygons can have a massive effect on the system - require manual intervention to let them through
|
|
||||||
INSERT INTO import_polygon_delete (osm_type, osm_id, class, type)
|
|
||||||
SELECT osm_type, osm_id, class, type FROM place_to_be_deleted WHERE deferred;
|
|
||||||
|
|
||||||
-- delete from place table
|
|
||||||
ALTER TABLE place DISABLE TRIGGER place_before_delete;
|
|
||||||
DELETE FROM place USING place_to_be_deleted
|
|
||||||
WHERE place.osm_type = place_to_be_deleted.osm_type
|
|
||||||
and place.osm_id = place_to_be_deleted.osm_id
|
|
||||||
and place.class = place_to_be_deleted.class
|
|
||||||
and place.type = place_to_be_deleted.type
|
|
||||||
and not deferred;
|
|
||||||
ALTER TABLE place ENABLE TRIGGER place_before_delete;
|
|
||||||
|
|
||||||
-- Mark for delete in the placex table
|
|
||||||
UPDATE placex SET indexed_status = 100 FROM place_to_be_deleted
|
|
||||||
WHERE placex.osm_type = 'N' and place_to_be_deleted.osm_type = 'N'
|
|
||||||
and placex.osm_id = place_to_be_deleted.osm_id
|
|
||||||
and placex.class = place_to_be_deleted.class
|
|
||||||
and placex.type = place_to_be_deleted.type
|
|
||||||
and not deferred;
|
|
||||||
UPDATE placex SET indexed_status = 100 FROM place_to_be_deleted
|
|
||||||
WHERE placex.osm_type = 'W' and place_to_be_deleted.osm_type = 'W'
|
|
||||||
and placex.osm_id = place_to_be_deleted.osm_id
|
|
||||||
and placex.class = place_to_be_deleted.class
|
|
||||||
and placex.type = place_to_be_deleted.type
|
|
||||||
and not deferred;
|
|
||||||
UPDATE placex SET indexed_status = 100 FROM place_to_be_deleted
|
|
||||||
WHERE placex.osm_type = 'R' and place_to_be_deleted.osm_type = 'R'
|
|
||||||
and placex.osm_id = place_to_be_deleted.osm_id
|
|
||||||
and placex.class = place_to_be_deleted.class
|
|
||||||
and placex.type = place_to_be_deleted.type
|
|
||||||
and not deferred;
|
|
||||||
|
|
||||||
-- Mark for delete in interpolations
|
|
||||||
UPDATE location_property_osmline SET indexed_status = 100 FROM place_to_be_deleted
|
|
||||||
WHERE place_to_be_deleted.osm_type = 'W'
|
|
||||||
and place_to_be_deleted.class = 'place'
|
|
||||||
and place_to_be_deleted.type = 'houses'
|
|
||||||
and location_property_osmline.osm_id = place_to_be_deleted.osm_id
|
|
||||||
and not deferred;
|
|
||||||
|
|
||||||
-- Clear todo list.
|
|
||||||
TRUNCATE TABLE place_to_be_deleted;
|
|
||||||
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE plpgsql;
|
|
||||||
|
|||||||
@@ -21,18 +21,8 @@ CREATE INDEX IF NOT EXISTS idx_placex_parent_place_id
|
|||||||
ON placex USING BTREE (parent_place_id) {{db.tablespace.search_index}}
|
ON placex USING BTREE (parent_place_id) {{db.tablespace.search_index}}
|
||||||
WHERE parent_place_id IS NOT NULL;
|
WHERE parent_place_id IS NOT NULL;
|
||||||
---
|
---
|
||||||
-- Used to find postcode areas after a search in location_postcode.
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_placex_postcode_areas
|
|
||||||
ON placex USING BTREE (country_code, postcode) {{db.tablespace.search_index}}
|
|
||||||
WHERE osm_type = 'R' AND class = 'boundary' AND type = 'postal_code';
|
|
||||||
---
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_placex_geometry ON placex
|
CREATE INDEX IF NOT EXISTS idx_placex_geometry ON placex
|
||||||
USING GIST (geometry) {{db.tablespace.search_index}};
|
USING GIST (geometry) {{db.tablespace.search_index}};
|
||||||
-- Index is needed during import but can be dropped as soon as a full
|
|
||||||
-- geometry index is in place. The partial index is almost as big as the full
|
|
||||||
-- index.
|
|
||||||
---
|
|
||||||
DROP INDEX IF EXISTS idx_placex_geometry_lower_rank_ways;
|
|
||||||
---
|
---
|
||||||
CREATE INDEX IF NOT EXISTS idx_placex_geometry_reverse_lookupPolygon
|
CREATE INDEX IF NOT EXISTS idx_placex_geometry_reverse_lookupPolygon
|
||||||
ON placex USING gist (geometry) {{db.tablespace.search_index}}
|
ON placex USING gist (geometry) {{db.tablespace.search_index}}
|
||||||
@@ -40,13 +30,6 @@ CREATE INDEX IF NOT EXISTS idx_placex_geometry_reverse_lookupPolygon
|
|||||||
AND rank_address between 4 and 25 AND type != 'postcode'
|
AND rank_address between 4 and 25 AND type != 'postcode'
|
||||||
AND name is not null AND indexed_status = 0 AND linked_place_id is null;
|
AND name is not null AND indexed_status = 0 AND linked_place_id is null;
|
||||||
---
|
---
|
||||||
-- used in reverse large area lookup
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_placex_geometry_reverse_lookupPlaceNode
|
|
||||||
ON placex USING gist (ST_Buffer(geometry, reverse_place_diameter(rank_search)))
|
|
||||||
{{db.tablespace.search_index}}
|
|
||||||
WHERE rank_address between 4 and 25 AND type != 'postcode'
|
|
||||||
AND name is not null AND linked_place_id is null AND osm_type = 'N';
|
|
||||||
---
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_osmline_parent_place_id
|
CREATE INDEX IF NOT EXISTS idx_osmline_parent_place_id
|
||||||
ON location_property_osmline USING BTREE (parent_place_id) {{db.tablespace.search_index}}
|
ON location_property_osmline USING BTREE (parent_place_id) {{db.tablespace.search_index}}
|
||||||
WHERE parent_place_id is not null;
|
WHERE parent_place_id is not null;
|
||||||
@@ -61,6 +44,7 @@ CREATE INDEX IF NOT EXISTS idx_postcode_postcode
|
|||||||
---
|
---
|
||||||
DROP INDEX IF EXISTS idx_placex_geometry_address_area_candidates;
|
DROP INDEX IF EXISTS idx_placex_geometry_address_area_candidates;
|
||||||
DROP INDEX IF EXISTS idx_placex_geometry_buildings;
|
DROP INDEX IF EXISTS idx_placex_geometry_buildings;
|
||||||
|
DROP INDEX IF EXISTS idx_placex_geometry_lower_rank_ways;
|
||||||
DROP INDEX IF EXISTS idx_placex_wikidata;
|
DROP INDEX IF EXISTS idx_placex_wikidata;
|
||||||
DROP INDEX IF EXISTS idx_placex_rank_address_sector;
|
DROP INDEX IF EXISTS idx_placex_rank_address_sector;
|
||||||
DROP INDEX IF EXISTS idx_placex_rank_boundaries_sector;
|
DROP INDEX IF EXISTS idx_placex_rank_boundaries_sector;
|
||||||
@@ -81,9 +65,6 @@ CREATE INDEX IF NOT EXISTS idx_postcode_postcode
|
|||||||
type TEXT,
|
type TEXT,
|
||||||
deferred BOOLEAN
|
deferred BOOLEAN
|
||||||
);
|
);
|
||||||
---
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_location_postcode_parent_place_id
|
|
||||||
ON location_postcode USING BTREE (parent_place_id) {{db.tablespace.address_index}};
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
-- Indices only needed for search.
|
-- Indices only needed for search.
|
||||||
|
|||||||
@@ -190,6 +190,7 @@ CREATE INDEX idx_placex_geometry_buildings ON placex
|
|||||||
|
|
||||||
-- Usage: - linking of similar named places to boundaries
|
-- Usage: - linking of similar named places to boundaries
|
||||||
-- - linking of place nodes with same type to boundaries
|
-- - linking of place nodes with same type to boundaries
|
||||||
|
-- - lookupPolygon()
|
||||||
CREATE INDEX idx_placex_geometry_placenode ON placex
|
CREATE INDEX idx_placex_geometry_placenode ON placex
|
||||||
USING {{postgres.spgist_geom}} (geometry) {{db.tablespace.address_index}}
|
USING {{postgres.spgist_geom}} (geometry) {{db.tablespace.address_index}}
|
||||||
WHERE osm_type = 'N' and rank_search < 26
|
WHERE osm_type = 'N' and rank_search < 26
|
||||||
@@ -273,27 +274,32 @@ GRANT SELECT ON import_polygon_delete TO "{{config.DATABASE_WEBUSER}}";
|
|||||||
DROP SEQUENCE IF EXISTS file;
|
DROP SEQUENCE IF EXISTS file;
|
||||||
CREATE SEQUENCE file start 1;
|
CREATE SEQUENCE file start 1;
|
||||||
|
|
||||||
{% if 'wikimedia_importance' not in db.tables and 'wikipedia_article' not in db.tables %}
|
-- null table so it won't error
|
||||||
-- create dummy tables here, if nothing was imported
|
-- deliberately no drop - importing the table is expensive and static, if it is already there better to avoid removing it
|
||||||
CREATE TABLE wikimedia_importance (
|
CREATE TABLE IF NOT EXISTS wikipedia_article (
|
||||||
language TEXT NOT NULL,
|
language text NOT NULL,
|
||||||
title TEXT NOT NULL,
|
title text NOT NULL,
|
||||||
importance double precision NOT NULL,
|
langcount integer,
|
||||||
wikidata TEXT
|
othercount integer,
|
||||||
) {{db.tablespace.address_data}};
|
totalcount integer,
|
||||||
{% endif %}
|
lat double precision,
|
||||||
|
lon double precision,
|
||||||
|
importance double precision,
|
||||||
|
osm_type character(1),
|
||||||
|
osm_id bigint,
|
||||||
|
wd_page_title text,
|
||||||
|
instance_of text
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS wikipedia_redirect (
|
||||||
|
language text,
|
||||||
|
from_title text,
|
||||||
|
to_title text
|
||||||
|
);
|
||||||
|
|
||||||
-- osm2pgsql does not create indexes on the middle tables for Nominatim
|
-- osm2pgsql does not create indexes on the middle tables for Nominatim
|
||||||
-- Add one for lookup of associated street relations.
|
-- Add one for lookup of associated street relations.
|
||||||
{% if db.middle_db_format == '1' %}
|
CREATE INDEX planet_osm_rels_parts_associated_idx ON planet_osm_rels USING gin(parts) WHERE tags @> ARRAY['associatedStreet'];
|
||||||
CREATE INDEX planet_osm_rels_parts_associated_idx ON planet_osm_rels USING gin(parts)
|
|
||||||
{{db.tablespace.address_index}}
|
|
||||||
WHERE tags @> ARRAY['associatedStreet'];
|
|
||||||
{% else %}
|
|
||||||
CREATE INDEX planet_osm_rels_relation_members_idx ON planet_osm_rels USING gin(planet_osm_member_ids(members, 'R'::character(1)))
|
|
||||||
WITH (fastupdate=off)
|
|
||||||
{{db.tablespace.address_index}};
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
-- Needed for lookups if a node is part of an interpolation.
|
-- Needed for lookups if a node is part of an interpolation.
|
||||||
CREATE INDEX IF NOT EXISTS idx_place_interpolations
|
CREATE INDEX IF NOT EXISTS idx_place_interpolations
|
||||||
|
|||||||
@@ -41,17 +41,10 @@ AS $$
|
|||||||
$$ LANGUAGE SQL IMMUTABLE STRICT;
|
$$ LANGUAGE SQL IMMUTABLE STRICT;
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION token_is_street_address(info JSONB)
|
|
||||||
RETURNS BOOLEAN
|
|
||||||
AS $$
|
|
||||||
SELECT info->>'street' is not null or info->>'place' is null;
|
|
||||||
$$ LANGUAGE SQL IMMUTABLE;
|
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION token_has_addr_street(info JSONB)
|
CREATE OR REPLACE FUNCTION token_has_addr_street(info JSONB)
|
||||||
RETURNS BOOLEAN
|
RETURNS BOOLEAN
|
||||||
AS $$
|
AS $$
|
||||||
SELECT info->>'street' is not null and info->>'street' != '{}';
|
SELECT info->>'street' is not null;
|
||||||
$$ LANGUAGE SQL IMMUTABLE;
|
$$ LANGUAGE SQL IMMUTABLE;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
40
lib-sql/tokenizer/icu_tokenizer_tables.sql
Normal file
40
lib-sql/tokenizer/icu_tokenizer_tables.sql
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
-- SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
--
|
||||||
|
-- This file is part of Nominatim. (https://nominatim.org)
|
||||||
|
--
|
||||||
|
-- Copyright (C) 2022 by the Nominatim developer community.
|
||||||
|
-- For a full list of authors see the git log.
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS word;
|
||||||
|
CREATE TABLE word (
|
||||||
|
word_id INTEGER,
|
||||||
|
word_token text NOT NULL,
|
||||||
|
type text NOT NULL,
|
||||||
|
word text,
|
||||||
|
info jsonb
|
||||||
|
) {{db.tablespace.search_data}};
|
||||||
|
|
||||||
|
CREATE INDEX idx_word_word_token ON word
|
||||||
|
USING BTREE (word_token) {{db.tablespace.search_index}};
|
||||||
|
-- Used when updating country names from the boundary relation.
|
||||||
|
CREATE INDEX idx_word_country_names ON word
|
||||||
|
USING btree(word) {{db.tablespace.address_index}}
|
||||||
|
WHERE type = 'C';
|
||||||
|
-- Used when inserting new postcodes on updates.
|
||||||
|
CREATE INDEX idx_word_postcodes ON word
|
||||||
|
USING btree(word) {{db.tablespace.address_index}}
|
||||||
|
WHERE type = 'P';
|
||||||
|
-- Used when inserting full words.
|
||||||
|
CREATE INDEX idx_word_full_word ON word
|
||||||
|
USING btree(word) {{db.tablespace.address_index}}
|
||||||
|
WHERE type = 'W';
|
||||||
|
-- Used when inserting analyzed housenumbers (exclude old-style entries).
|
||||||
|
CREATE INDEX idx_word_housenumbers ON word
|
||||||
|
USING btree(word) {{db.tablespace.address_index}}
|
||||||
|
WHERE type = 'H' and word is not null;
|
||||||
|
|
||||||
|
GRANT SELECT ON word TO "{{config.DATABASE_WEBUSER}}";
|
||||||
|
|
||||||
|
DROP SEQUENCE IF EXISTS seq_word;
|
||||||
|
CREATE SEQUENCE seq_word start 1;
|
||||||
|
GRANT SELECT ON seq_word to "{{config.DATABASE_WEBUSER}}";
|
||||||
@@ -41,17 +41,10 @@ AS $$
|
|||||||
$$ LANGUAGE SQL IMMUTABLE STRICT;
|
$$ LANGUAGE SQL IMMUTABLE STRICT;
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION token_is_street_address(info JSONB)
|
|
||||||
RETURNS BOOLEAN
|
|
||||||
AS $$
|
|
||||||
SELECT info->>'street' is not null or info->>'place_search' is null;
|
|
||||||
$$ LANGUAGE SQL IMMUTABLE;
|
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION token_has_addr_street(info JSONB)
|
CREATE OR REPLACE FUNCTION token_has_addr_street(info JSONB)
|
||||||
RETURNS BOOLEAN
|
RETURNS BOOLEAN
|
||||||
AS $$
|
AS $$
|
||||||
SELECT info->>'street' is not null and info->>'street' != '{}';
|
SELECT info->>'street' is not null;
|
||||||
$$ LANGUAGE SQL IMMUTABLE;
|
$$ LANGUAGE SQL IMMUTABLE;
|
||||||
|
|
||||||
|
|
||||||
@@ -347,7 +340,7 @@ BEGIN
|
|||||||
END LOOP;
|
END LOOP;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- consider parts before an opening bracket a full word as well
|
-- consider parts before an opening braket a full word as well
|
||||||
words := regexp_split_to_array(value, E'[(]');
|
words := regexp_split_to_array(value, E'[(]');
|
||||||
IF array_upper(words, 1) > 1 THEN
|
IF array_upper(words, 1) > 1 THEN
|
||||||
s := make_standard_name(words[1]);
|
s := make_standard_name(words[1]);
|
||||||
|
|||||||
15
man/CMakeLists.txt
Normal file
15
man/CMakeLists.txt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Creates and installs manual page
|
||||||
|
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/create-manpage.tmpl create_manpage.py)
|
||||||
|
|
||||||
|
find_program(ARGPARSEMANPAGE argparse-manpage)
|
||||||
|
|
||||||
|
ADD_CUSTOM_TARGET(manpage
|
||||||
|
COMMAND ${ARGPARSEMANPAGE} --pyfile ${CMAKE_CURRENT_BINARY_DIR}/create_manpage.py
|
||||||
|
--function get_parser --project-name Nominatim
|
||||||
|
--url https://nominatim.org > ${CMAKE_CURRENT_SOURCE_DIR}/nominatim.1
|
||||||
|
--author 'the Nominatim developer community'
|
||||||
|
--author-email info@nominatim.org
|
||||||
|
)
|
||||||
|
|
||||||
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/nominatim.1 DESTINATION share/man/man1 )
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import sys
|
|
||||||
import os
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
sys.path.append(str(Path(__file__, '..', '..', 'src').resolve()))
|
|
||||||
|
|
||||||
from nominatim_db.cli import get_set_parser
|
|
||||||
|
|
||||||
def get_parser():
|
|
||||||
parser = get_set_parser()
|
|
||||||
|
|
||||||
return parser.parser
|
|
||||||
12
man/create-manpage.tmpl
Normal file
12
man/create-manpage.tmpl
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
sys.path.append('@PROJECT_SOURCE_DIR@')
|
||||||
|
|
||||||
|
from nominatim.cli import get_set_parser
|
||||||
|
|
||||||
|
def get_parser():
|
||||||
|
parser = get_set_parser(phpcgi_path='@PHPCGI_BIN@')
|
||||||
|
|
||||||
|
return parser.parser
|
||||||
210
man/nominatim.1
210
man/nominatim.1
@@ -3,7 +3,7 @@
|
|||||||
nominatim
|
nominatim
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B nominatim
|
.B nominatim
|
||||||
[-h] [--version] {import,freeze,replication,special-phrases,add-data,index,refresh,admin,export,convert,serve,search,reverse,lookup,details,status} ...
|
[-h] {import,freeze,replication,special-phrases,add-data,index,refresh,admin,export,serve,search,reverse,lookup,details,status} ...
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Command\-line tools for importing, updating, administrating and
|
Command\-line tools for importing, updating, administrating and
|
||||||
.br
|
.br
|
||||||
@@ -12,9 +12,6 @@ nominatim
|
|||||||
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-version\fR
|
|
||||||
Print Nominatim version and exit
|
|
||||||
|
|
||||||
.SS
|
.SS
|
||||||
\fBSub-commands\fR
|
\fBSub-commands\fR
|
||||||
@@ -44,10 +41,7 @@ Print Nominatim version and exit
|
|||||||
Analyse and maintain the database.
|
Analyse and maintain the database.
|
||||||
.TP
|
.TP
|
||||||
\fBnominatim\fR \fI\,export\/\fR
|
\fBnominatim\fR \fI\,export\/\fR
|
||||||
Export places as CSV file from the database.
|
Export addresses as CSV file from the database.
|
||||||
.TP
|
|
||||||
\fBnominatim\fR \fI\,convert\/\fR
|
|
||||||
Convert an existing database into a different format. (EXPERIMENTAL)
|
|
||||||
.TP
|
.TP
|
||||||
\fBnominatim\fR \fI\,serve\/\fR
|
\fBnominatim\fR \fI\,serve\/\fR
|
||||||
Start a simple web server for serving the API.
|
Start a simple web server for serving the API.
|
||||||
@@ -65,15 +59,13 @@ Print Nominatim version and exit
|
|||||||
Execute API details query.
|
Execute API details query.
|
||||||
.TP
|
.TP
|
||||||
\fBnominatim\fR \fI\,status\/\fR
|
\fBnominatim\fR \fI\,status\/\fR
|
||||||
|
Execute API status query.
|
||||||
.SH OPTIONS 'nominatim import'
|
.SH OPTIONS 'nominatim import'
|
||||||
usage: nominatim import [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
usage: nominatim import [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
||||||
[--osm-file FILE]
|
(--osm-file FILE | --continue {load-data,indexing,db-postprocess})
|
||||||
[--continue {import-from-file,load-data,indexing,db-postprocess}]
|
|
||||||
[--osm2pgsql-cache SIZE] [--reverse-only]
|
[--osm2pgsql-cache SIZE] [--reverse-only]
|
||||||
[--no-partitions] [--no-updates] [--offline]
|
[--no-partitions] [--no-updates] [--ignore-errors]
|
||||||
[--ignore-errors] [--index-noanalyse]
|
[--index-noanalyse]
|
||||||
[--prepare-database]
|
|
||||||
|
|
||||||
Create a new Nominatim database from an OSM file.
|
Create a new Nominatim database from an OSM file.
|
||||||
.br
|
.br
|
||||||
@@ -110,7 +102,7 @@ Number of parallel threads to use
|
|||||||
OSM file to be imported (repeat for importing multiple files)
|
OSM file to be imported (repeat for importing multiple files)
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-continue\fR {import\-from\-file,load\-data,indexing,db\-postprocess}
|
\fB\-\-continue\fR {load\-data,indexing,db\-postprocess}
|
||||||
Continue an import that was interrupted
|
Continue an import that was interrupted
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
@@ -129,10 +121,6 @@ Do not partition search indices (speeds up import of single country extracts)
|
|||||||
\fB\-\-no\-updates\fR
|
\fB\-\-no\-updates\fR
|
||||||
Do not keep tables that are only needed for updating the database later
|
Do not keep tables that are only needed for updating the database later
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-offline\fR
|
|
||||||
Do not attempt to load any additional data from the internet
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-ignore\-errors\fR
|
\fB\-\-ignore\-errors\fR
|
||||||
Continue import even when errors in SQL are present
|
Continue import even when errors in SQL are present
|
||||||
@@ -141,10 +129,6 @@ Continue import even when errors in SQL are present
|
|||||||
\fB\-\-index\-noanalyse\fR
|
\fB\-\-index\-noanalyse\fR
|
||||||
Do not perform analyse operations during index (expert only)
|
Do not perform analyse operations during index (expert only)
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-prepare\-database\fR
|
|
||||||
Create the database but do not import any data
|
|
||||||
|
|
||||||
.SH OPTIONS 'nominatim freeze'
|
.SH OPTIONS 'nominatim freeze'
|
||||||
usage: nominatim freeze [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
usage: nominatim freeze [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
||||||
|
|
||||||
@@ -187,8 +171,8 @@ Number of parallel threads to use
|
|||||||
.SH OPTIONS 'nominatim replication'
|
.SH OPTIONS 'nominatim replication'
|
||||||
usage: nominatim replication [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
usage: nominatim replication [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
||||||
[--init] [--no-update-functions]
|
[--init] [--no-update-functions]
|
||||||
[--check-for-updates] [--once] [--catch-up]
|
[--check-for-updates] [--once] [--no-index]
|
||||||
[--no-index] [--osm2pgsql-cache SIZE]
|
[--osm2pgsql-cache SIZE]
|
||||||
[--socket-timeout SOCKET_TIMEOUT]
|
[--socket-timeout SOCKET_TIMEOUT]
|
||||||
|
|
||||||
Update the database using an online replication service.
|
Update the database using an online replication service.
|
||||||
@@ -245,7 +229,7 @@ Initialise the update process
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-no\-update\-functions\fR
|
\fB\-\-no\-update\-functions\fR
|
||||||
Do not update the trigger function to support differential updates (EXPERT)
|
Do not update the trigger function to support differential updates.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-check\-for\-updates\fR
|
\fB\-\-check\-for\-updates\fR
|
||||||
@@ -255,10 +239,6 @@ Check if new updates are available and exit
|
|||||||
\fB\-\-once\fR
|
\fB\-\-once\fR
|
||||||
Download and apply updates only once. When not set, updates are continuously applied
|
Download and apply updates only once. When not set, updates are continuously applied
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-catch\-up\fR
|
|
||||||
Download and apply updates until no new data is available on the server
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-no\-index\fR
|
\fB\-\-no\-index\fR
|
||||||
Do not index the new data. Only usable together with \-\-once
|
Do not index the new data. Only usable together with \-\-once
|
||||||
@@ -310,20 +290,6 @@ usage: nominatim special-phrases [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
|||||||
.br
|
.br
|
||||||
'test/testdb/full_en_phrases_test.csv'.
|
'test/testdb/full_en_phrases_test.csv'.
|
||||||
.br
|
.br
|
||||||
|
|
||||||
.br
|
|
||||||
The import can be further configured to ignore specific key/value pairs.
|
|
||||||
.br
|
|
||||||
This is particularly useful when importing phrases from the wiki. The
|
|
||||||
.br
|
|
||||||
default configuration excludes some very common tags like building=yes.
|
|
||||||
.br
|
|
||||||
The configuration can be customized by putting a file `phrase\-settings.json`
|
|
||||||
.br
|
|
||||||
with custom rules into the project directory or by using the `\-\-config`
|
|
||||||
.br
|
|
||||||
option to point to another configuration file.
|
|
||||||
.br
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -384,7 +350,7 @@ usage: nominatim add-data [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
|||||||
.br
|
.br
|
||||||
data. See the online documentation at
|
data. See the online documentation at
|
||||||
.br
|
.br
|
||||||
https://nominatim.org/release\-docs/latest/customize/Tiger/
|
https://nominatim.org/release\-docs/latest/admin/Import/#installing\-tiger\-housenumber\-data\-for\-the\-us
|
||||||
.br
|
.br
|
||||||
for more information.
|
for more information.
|
||||||
.br
|
.br
|
||||||
@@ -499,11 +465,10 @@ Maximum/finishing rank
|
|||||||
|
|
||||||
.SH OPTIONS 'nominatim refresh'
|
.SH OPTIONS 'nominatim refresh'
|
||||||
usage: nominatim refresh [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
usage: nominatim refresh [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
||||||
[--postcodes] [--word-tokens] [--word-counts]
|
[--postcodes] [--word-counts] [--address-levels]
|
||||||
[--address-levels] [--functions] [--wiki-data]
|
[--functions] [--wiki-data] [--importance]
|
||||||
[--secondary-importance] [--importance] [--website]
|
[--website] [--no-diff-updates]
|
||||||
[--data-object OBJECT] [--data-area OBJECT]
|
[--enable-debug-statements]
|
||||||
[--no-diff-updates] [--enable-debug-statements]
|
|
||||||
|
|
||||||
Recompute auxiliary data used by the indexing process.
|
Recompute auxiliary data used by the indexing process.
|
||||||
.br
|
.br
|
||||||
@@ -547,10 +512,6 @@ Number of parallel threads to use
|
|||||||
\fB\-\-postcodes\fR
|
\fB\-\-postcodes\fR
|
||||||
Update postcode centroid table
|
Update postcode centroid table
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-word\-tokens\fR
|
|
||||||
Clean up search terms
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-word\-counts\fR
|
\fB\-\-word\-counts\fR
|
||||||
Compute frequency of full\-word search terms
|
Compute frequency of full\-word search terms
|
||||||
@@ -567,10 +528,6 @@ Update the PL/pgSQL functions in the database
|
|||||||
\fB\-\-wiki\-data\fR
|
\fB\-\-wiki\-data\fR
|
||||||
Update Wikipedia/data importance numbers
|
Update Wikipedia/data importance numbers
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-secondary\-importance\fR
|
|
||||||
Update secondary importance raster data
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-importance\fR
|
\fB\-\-importance\fR
|
||||||
Recompute place importances (expensive!)
|
Recompute place importances (expensive!)
|
||||||
@@ -579,14 +536,6 @@ Recompute place importances (expensive!)
|
|||||||
\fB\-\-website\fR
|
\fB\-\-website\fR
|
||||||
Refresh the directory that serves the scripts for the web API
|
Refresh the directory that serves the scripts for the web API
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-data\-object\fR OBJECT
|
|
||||||
Mark the given OSM object as requiring an update (format: [NWR]<id>)
|
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-data\-area\fR OBJECT
|
|
||||||
Mark the area around the given OSM object as requiring an update (format: [NWR]<id>)
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-no\-diff\-updates\fR
|
\fB\-\-no\-diff\-updates\fR
|
||||||
Do not enable code for propagating updates
|
Do not enable code for propagating updates
|
||||||
@@ -597,7 +546,7 @@ Enable debug warning statements in functions
|
|||||||
|
|
||||||
.SH OPTIONS 'nominatim admin'
|
.SH OPTIONS 'nominatim admin'
|
||||||
usage: nominatim admin [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
usage: nominatim admin [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
||||||
(--warm | --check-database | --migrate | --analyse-indexing | --collect-os-info | --clean-deleted AGE)
|
(--warm | --check-database | --migrate | --analyse-indexing)
|
||||||
[--search-only] [--reverse-only]
|
[--search-only] [--reverse-only]
|
||||||
[--osm-id OSM_ID | --place-id PLACE_ID]
|
[--osm-id OSM_ID | --place-id PLACE_ID]
|
||||||
|
|
||||||
@@ -639,14 +588,6 @@ Migrate the database to a new software version
|
|||||||
\fB\-\-analyse\-indexing\fR
|
\fB\-\-analyse\-indexing\fR
|
||||||
Print performance analysis of the indexing process
|
Print performance analysis of the indexing process
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-collect\-os\-info\fR
|
|
||||||
Generate a report about the host system information
|
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-clean\-deleted\fR AGE
|
|
||||||
Clean up deleted relations
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-search\-only\fR
|
\fB\-\-search\-only\fR
|
||||||
Only pre\-warm tables for search queries
|
Only pre\-warm tables for search queries
|
||||||
@@ -665,17 +606,14 @@ Analyse indexing of the given Nominatim object
|
|||||||
|
|
||||||
.SH OPTIONS 'nominatim export'
|
.SH OPTIONS 'nominatim export'
|
||||||
usage: nominatim export [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
usage: nominatim export [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
||||||
[--output-type {country,state,county,city,suburb,street,path}]
|
[--output-type {continent,country,state,county,city,suburb,street,path}]
|
||||||
[--output-format OUTPUT_FORMAT] [--language LANGUAGE]
|
[--output-format OUTPUT_FORMAT]
|
||||||
|
[--output-all-postcodes] [--language LANGUAGE]
|
||||||
[--restrict-to-country COUNTRY_CODE]
|
[--restrict-to-country COUNTRY_CODE]
|
||||||
[--restrict-to-osm-node ID] [--restrict-to-osm-way ID]
|
[--restrict-to-osm-node ID] [--restrict-to-osm-way ID]
|
||||||
[--restrict-to-osm-relation ID]
|
[--restrict-to-osm-relation ID]
|
||||||
|
|
||||||
Export places as CSV file from the database.
|
Export addresses as CSV file from the database.
|
||||||
.br
|
|
||||||
|
|
||||||
.br
|
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
|
|
||||||
@@ -698,12 +636,16 @@ Base directory of the Nominatim installation (default:.)
|
|||||||
Number of parallel threads to use
|
Number of parallel threads to use
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-output\-type\fR {country,state,county,city,suburb,street,path}
|
\fB\-\-output\-type\fR {continent,country,state,county,city,suburb,street,path}
|
||||||
Type of places to output (default: street)
|
Type of places to output (default: street)
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-output\-format\fR \fI\,OUTPUT_FORMAT\/\fR
|
\fB\-\-output\-format\fR \fI\,OUTPUT_FORMAT\/\fR
|
||||||
Semicolon\-separated list of address types (see \-\-output\-type). Additionally accepts:placeid,postcode
|
Semicolon\-separated list of address types (see \-\-output\-type). Multiple ranks can be merged into one column by simply using a comma\-separated list.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
\fB\-\-output\-all\-postcodes\fR
|
||||||
|
List all postcodes for address instead of just the most likely one
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-language\fR \fI\,LANGUAGE\/\fR
|
\fB\-\-language\fR \fI\,LANGUAGE\/\fR
|
||||||
@@ -725,85 +667,21 @@ Export only children of this OSM way
|
|||||||
\fB\-\-restrict\-to\-osm\-relation\fR ID
|
\fB\-\-restrict\-to\-osm\-relation\fR ID
|
||||||
Export only children of this OSM relation
|
Export only children of this OSM relation
|
||||||
|
|
||||||
.SH OPTIONS 'nominatim convert'
|
|
||||||
usage: nominatim convert [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
|
||||||
[--format {sqlite}] --output OUTPUT [--with-reverse]
|
|
||||||
[--with-search] [--with-details]
|
|
||||||
|
|
||||||
Convert an existing database into a different format. (EXPERIMENTAL)
|
|
||||||
.br
|
|
||||||
|
|
||||||
.br
|
|
||||||
Dump a read\-only version of the database in a different format.
|
|
||||||
.br
|
|
||||||
At the moment only a SQLite database suitable for reverse lookup
|
|
||||||
.br
|
|
||||||
can be created.
|
|
||||||
.br
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-format\fR {sqlite}
|
|
||||||
Format of the output database (must be sqlite currently)
|
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-output\fR \fI\,OUTPUT\/\fR, \fB\-o\fR \fI\,OUTPUT\/\fR
|
|
||||||
File to write the database to.
|
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-q\fR, \fB\-\-quiet\fR
|
|
||||||
Print only error messages
|
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-v\fR, \fB\-\-verbose\fR
|
|
||||||
Increase verboseness of output
|
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-project\-dir\fR DIR
|
|
||||||
Base directory of the Nominatim installation (default:.)
|
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-j\fR NUM, \fB\-\-threads\fR NUM
|
|
||||||
Number of parallel threads to use
|
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-with\-reverse\fR, \fB\-\-without\-reverse\fR
|
|
||||||
Enable/disable support for reverse and lookup API (default: enabled)
|
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-with\-search\fR, \fB\-\-without\-search\fR
|
|
||||||
Enable/disable support for search API (default: disabled)
|
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-with\-details\fR, \fB\-\-without\-details\fR
|
|
||||||
Enable/disable support for details API (default: enabled)
|
|
||||||
|
|
||||||
.SH OPTIONS 'nominatim serve'
|
.SH OPTIONS 'nominatim serve'
|
||||||
usage: nominatim serve [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
usage: nominatim serve [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
||||||
[--server SERVER] [--engine {php,falcon,starlette}]
|
[--server SERVER]
|
||||||
|
|
||||||
Start a simple web server for serving the API.
|
Start a simple web server for serving the API.
|
||||||
.br
|
.br
|
||||||
|
|
||||||
.br
|
.br
|
||||||
This command starts a built\-in webserver to serve the website
|
This command starts the built\-in PHP webserver to serve the website
|
||||||
.br
|
.br
|
||||||
from the current project directory. This webserver is only suitable
|
from the current project directory. This webserver is only suitable
|
||||||
.br
|
.br
|
||||||
for testing and development. Do not use it in production setups!
|
for testing and development. Do not use it in production setups!
|
||||||
.br
|
.br
|
||||||
|
|
||||||
.br
|
|
||||||
There are different webservers available. The default 'php' engine
|
|
||||||
.br
|
|
||||||
runs the classic PHP frontend. The other engines are Python servers
|
|
||||||
.br
|
|
||||||
which run the new Python frontend code. This is highly experimental
|
|
||||||
.br
|
|
||||||
at the moment and may not include the full API.
|
|
||||||
.br
|
|
||||||
|
|
||||||
.br
|
.br
|
||||||
By the default, the webserver can be accessed at: http://127.0.0.1:8088
|
By the default, the webserver can be accessed at: http://127.0.0.1:8088
|
||||||
.br
|
.br
|
||||||
@@ -831,16 +709,12 @@ Number of parallel threads to use
|
|||||||
\fB\-\-server\fR \fI\,SERVER\/\fR
|
\fB\-\-server\fR \fI\,SERVER\/\fR
|
||||||
The address the server will listen to.
|
The address the server will listen to.
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-engine\fR {php,falcon,starlette}
|
|
||||||
Webserver framework to run. (default: falcon)
|
|
||||||
|
|
||||||
.SH OPTIONS 'nominatim search'
|
.SH OPTIONS 'nominatim search'
|
||||||
usage: nominatim search [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
usage: nominatim search [-h] [-q] [-v] [--project-dir DIR] [-j NUM]
|
||||||
[--query QUERY] [--amenity AMENITY] [--street STREET]
|
[--query QUERY] [--street STREET] [--city CITY]
|
||||||
[--city CITY] [--county COUNTY] [--state STATE]
|
[--county COUNTY] [--state STATE] [--country COUNTRY]
|
||||||
[--country COUNTRY] [--postalcode POSTALCODE]
|
[--postalcode POSTALCODE]
|
||||||
[--format {xml,geojson,geocodejson,json,jsonv2,debug}]
|
[--format {xml,json,jsonv2,geojson,geocodejson}]
|
||||||
[--addressdetails] [--extratags] [--namedetails]
|
[--addressdetails] [--extratags] [--namedetails]
|
||||||
[--lang LANGS]
|
[--lang LANGS]
|
||||||
[--polygon-output {geojson,kml,svg,text}]
|
[--polygon-output {geojson,kml,svg,text}]
|
||||||
@@ -884,10 +758,6 @@ Number of parallel threads to use
|
|||||||
\fB\-\-query\fR \fI\,QUERY\/\fR
|
\fB\-\-query\fR \fI\,QUERY\/\fR
|
||||||
Free\-form query string
|
Free\-form query string
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-amenity\fR \fI\,AMENITY\/\fR
|
|
||||||
Structured query: name and/or type of POI
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-street\fR \fI\,STREET\/\fR
|
\fB\-\-street\fR \fI\,STREET\/\fR
|
||||||
Structured query: housenumber and street
|
Structured query: housenumber and street
|
||||||
@@ -913,7 +783,7 @@ Structured query: country
|
|||||||
Structured query: postcode
|
Structured query: postcode
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-format\fR {xml,geojson,geocodejson,json,jsonv2,debug}
|
\fB\-\-format\fR {xml,json,jsonv2,geojson,geocodejson}
|
||||||
Format of result
|
Format of result
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
@@ -966,8 +836,8 @@ Do not remove duplicates from the result list
|
|||||||
|
|
||||||
.SH OPTIONS 'nominatim reverse'
|
.SH OPTIONS 'nominatim reverse'
|
||||||
usage: nominatim reverse [-h] [-q] [-v] [--project-dir DIR] [-j NUM] --lat LAT
|
usage: nominatim reverse [-h] [-q] [-v] [--project-dir DIR] [-j NUM] --lat LAT
|
||||||
--lon LON [--zoom ZOOM] [--layer LAYER]
|
--lon LON [--zoom ZOOM]
|
||||||
[--format {xml,geojson,geocodejson,json,jsonv2,debug}]
|
[--format {xml,json,jsonv2,geojson,geocodejson}]
|
||||||
[--addressdetails] [--extratags] [--namedetails]
|
[--addressdetails] [--extratags] [--namedetails]
|
||||||
[--lang LANGS]
|
[--lang LANGS]
|
||||||
[--polygon-output {geojson,kml,svg,text}]
|
[--polygon-output {geojson,kml,svg,text}]
|
||||||
@@ -1018,11 +888,7 @@ Longitude of coordinate to look up (in WGS84)
|
|||||||
Level of detail required for the address
|
Level of detail required for the address
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-layer\fR LAYER
|
\fB\-\-format\fR {xml,json,jsonv2,geojson,geocodejson}
|
||||||
OSM id to lookup in format <NRW><id> (may be repeated)
|
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-format\fR {xml,geojson,geocodejson,json,jsonv2,debug}
|
|
||||||
Format of result
|
Format of result
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
@@ -1051,7 +917,7 @@ Simplify output geometry.Parameter is difference tolerance in degrees.
|
|||||||
|
|
||||||
.SH OPTIONS 'nominatim lookup'
|
.SH OPTIONS 'nominatim lookup'
|
||||||
usage: nominatim lookup [-h] [-q] [-v] [--project-dir DIR] [-j NUM] --id OSMID
|
usage: nominatim lookup [-h] [-q] [-v] [--project-dir DIR] [-j NUM] --id OSMID
|
||||||
[--format {xml,geojson,geocodejson,json,jsonv2,debug}]
|
[--format {xml,json,jsonv2,geojson,geocodejson}]
|
||||||
[--addressdetails] [--extratags] [--namedetails]
|
[--addressdetails] [--extratags] [--namedetails]
|
||||||
[--lang LANGS]
|
[--lang LANGS]
|
||||||
[--polygon-output {geojson,kml,svg,text}]
|
[--polygon-output {geojson,kml,svg,text}]
|
||||||
@@ -1094,7 +960,7 @@ Number of parallel threads to use
|
|||||||
OSM id to lookup in format <NRW><id> (may be repeated)
|
OSM id to lookup in format <NRW><id> (may be repeated)
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-format\fR {xml,geojson,geocodejson,json,jsonv2,debug}
|
\fB\-\-format\fR {xml,json,jsonv2,geojson,geocodejson}
|
||||||
Format of result
|
Format of result
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# just use the pgxs makefile
|
# just use the pgxs makefile
|
||||||
|
|
||||||
foreach(suffix ${PostgreSQL_ADDITIONAL_VERSIONS} "16" "15" "14" "13" "12" "11" "10" "9.6")
|
foreach(suffix ${PostgreSQL_ADDITIONAL_VERSIONS} "15" "14" "13" "12" "11" "10" "9.6")
|
||||||
list(APPEND PG_CONFIG_HINTS
|
list(APPEND PG_CONFIG_HINTS
|
||||||
"/usr/pgsql-${suffix}/bin")
|
"/usr/pgsql-${suffix}/bin")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|||||||
@@ -11,11 +11,9 @@
|
|||||||
#include "mb/pg_wchar.h"
|
#include "mb/pg_wchar.h"
|
||||||
#include <utfasciitable.h>
|
#include <utfasciitable.h>
|
||||||
|
|
||||||
#if PG_MAJORVERSION_NUM > 15
|
#ifdef PG_MODULE_MAGIC
|
||||||
#include "varatt.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PG_MODULE_MAGIC;
|
PG_MODULE_MAGIC;
|
||||||
|
#endif
|
||||||
|
|
||||||
Datum transliteration( PG_FUNCTION_ARGS );
|
Datum transliteration( PG_FUNCTION_ARGS );
|
||||||
Datum gettokenstring( PG_FUNCTION_ARGS );
|
Datum gettokenstring( PG_FUNCTION_ARGS );
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# This file is part of Nominatim. (https://nominatim.org)
|
|
||||||
#
|
|
||||||
# Copyright (C) 2024 by the Nominatim developer community.
|
|
||||||
# For a full list of authors see the git log.
|
|
||||||
"""
|
|
||||||
Helper script for development to run nominatim from the source directory.
|
|
||||||
"""
|
|
||||||
from pathlib import Path
|
|
||||||
import sys
|
|
||||||
|
|
||||||
sys.path.insert(1, str((Path(__file__) / '..' / 'src').resolve()))
|
|
||||||
|
|
||||||
from nominatim_db import cli
|
|
||||||
|
|
||||||
exit(cli.nominatim(module_dir=None, osm2pgsql_path=None))
|
|
||||||
@@ -1,28 +1,26 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
#
|
#
|
||||||
# This file is part of Nominatim. (https://nominatim.org)
|
# This file is part of Nominatim. (https://nominatim.org)
|
||||||
#
|
#
|
||||||
# Copyright (C) 2024 by the Nominatim developer community.
|
# Copyright (C) 2022 by the Nominatim developer community.
|
||||||
# For a full list of authors see the git log.
|
# For a full list of authors see the git log.
|
||||||
"""
|
"""
|
||||||
Command-line interface to the Nominatim functions for import, update,
|
Command-line interface to the Nominatim functions for import, update,
|
||||||
database administration and querying.
|
database administration and querying.
|
||||||
"""
|
"""
|
||||||
from typing import Optional, Any
|
from typing import Optional, Any, List, Union
|
||||||
import importlib
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import asyncio
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from .config import Configuration
|
from nominatim.config import Configuration
|
||||||
from .errors import UsageError
|
from nominatim.tools.exec_utils import run_legacy_script, run_php_server
|
||||||
from .tools.exec_utils import run_php_server
|
from nominatim.errors import UsageError
|
||||||
from . import clicmd
|
from nominatim import clicmd
|
||||||
from . import version
|
from nominatim import version
|
||||||
from .clicmd.args import NominatimArgs, Subcommand
|
from nominatim.clicmd.args import NominatimArgs, Subcommand
|
||||||
|
|
||||||
LOG = logging.getLogger()
|
LOG = logging.getLogger()
|
||||||
|
|
||||||
@@ -62,7 +60,7 @@ class CommandlineParser:
|
|||||||
def nominatim_version_text(self) -> str:
|
def nominatim_version_text(self) -> str:
|
||||||
""" Program name and version number as string
|
""" Program name and version number as string
|
||||||
"""
|
"""
|
||||||
text = f'Nominatim version {version.NOMINATIM_VERSION!s}'
|
text = f'Nominatim version {version.version_str()}'
|
||||||
if version.GIT_COMMIT_HASH is not None:
|
if version.GIT_COMMIT_HASH is not None:
|
||||||
text += f' ({version.GIT_COMMIT_HASH})'
|
text += f' ({version.GIT_COMMIT_HASH})'
|
||||||
return text
|
return text
|
||||||
@@ -102,6 +100,9 @@ class CommandlineParser:
|
|||||||
self.parser.print_help()
|
self.parser.print_help()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
for arg in ('module_dir', 'osm2pgsql_path', 'phplib_dir', 'sqllib_dir',
|
||||||
|
'data_dir', 'config_dir', 'phpcgi_path'):
|
||||||
|
setattr(args, arg, Path(kwargs[arg]))
|
||||||
args.project_dir = Path(args.project_dir).resolve()
|
args.project_dir = Path(args.project_dir).resolve()
|
||||||
|
|
||||||
if 'cli_args' not in kwargs:
|
if 'cli_args' not in kwargs:
|
||||||
@@ -110,22 +111,19 @@ class CommandlineParser:
|
|||||||
datefmt='%Y-%m-%d %H:%M:%S',
|
datefmt='%Y-%m-%d %H:%M:%S',
|
||||||
level=max(4 - args.verbose, 1) * 10)
|
level=max(4 - args.verbose, 1) * 10)
|
||||||
|
|
||||||
args.config = Configuration(args.project_dir,
|
args.config = Configuration(args.project_dir, args.config_dir,
|
||||||
environ=kwargs.get('environ', os.environ))
|
environ=kwargs.get('environ', os.environ))
|
||||||
args.config.set_libdirs(module=kwargs['module_dir'],
|
args.config.set_libdirs(module=args.module_dir,
|
||||||
osm2pgsql=kwargs['osm2pgsql_path'])
|
osm2pgsql=args.osm2pgsql_path,
|
||||||
|
php=args.phplib_dir,
|
||||||
|
sql=args.sqllib_dir,
|
||||||
|
data=args.data_dir)
|
||||||
|
|
||||||
log = logging.getLogger()
|
log = logging.getLogger()
|
||||||
log.warning('Using project directory: %s', str(args.project_dir))
|
log.warning('Using project directory: %s', str(args.project_dir))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ret = args.command.run(args)
|
return args.command.run(args)
|
||||||
|
|
||||||
if args.config.TOKENIZER == 'legacy':
|
|
||||||
log.warning('WARNING: the "legacy" tokenizer is deprecated '
|
|
||||||
'and will be removed in Nominatim 5.0.')
|
|
||||||
|
|
||||||
return ret
|
|
||||||
except UsageError as exception:
|
except UsageError as exception:
|
||||||
if log.isEnabledFor(logging.DEBUG):
|
if log.isEnabledFor(logging.DEBUG):
|
||||||
raise # use Python's exception printing
|
raise # use Python's exception printing
|
||||||
@@ -146,19 +144,68 @@ class CommandlineParser:
|
|||||||
#
|
#
|
||||||
# No need to document the functions each time.
|
# No need to document the functions each time.
|
||||||
# pylint: disable=C0111
|
# pylint: disable=C0111
|
||||||
|
class QueryExport:
|
||||||
|
"""\
|
||||||
|
Export addresses as CSV file from the database.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def add_args(self, parser: argparse.ArgumentParser) -> None:
|
||||||
|
group = parser.add_argument_group('Output arguments')
|
||||||
|
group.add_argument('--output-type', default='street',
|
||||||
|
choices=('continent', 'country', 'state', 'county',
|
||||||
|
'city', 'suburb', 'street', 'path'),
|
||||||
|
help='Type of places to output (default: street)')
|
||||||
|
group.add_argument('--output-format',
|
||||||
|
default='street;suburb;city;county;state;country',
|
||||||
|
help=("Semicolon-separated list of address types "
|
||||||
|
"(see --output-type). Multiple ranks can be "
|
||||||
|
"merged into one column by simply using a "
|
||||||
|
"comma-separated list."))
|
||||||
|
group.add_argument('--output-all-postcodes', action='store_true',
|
||||||
|
help=("List all postcodes for address instead of "
|
||||||
|
"just the most likely one"))
|
||||||
|
group.add_argument('--language',
|
||||||
|
help=("Preferred language for output "
|
||||||
|
"(use local name, if omitted)"))
|
||||||
|
group = parser.add_argument_group('Filter arguments')
|
||||||
|
group.add_argument('--restrict-to-country', metavar='COUNTRY_CODE',
|
||||||
|
help='Export only objects within country')
|
||||||
|
group.add_argument('--restrict-to-osm-node', metavar='ID', type=int,
|
||||||
|
help='Export only children of this OSM node')
|
||||||
|
group.add_argument('--restrict-to-osm-way', metavar='ID', type=int,
|
||||||
|
help='Export only children of this OSM way')
|
||||||
|
group.add_argument('--restrict-to-osm-relation', metavar='ID', type=int,
|
||||||
|
help='Export only children of this OSM relation')
|
||||||
|
|
||||||
|
|
||||||
|
def run(self, args: NominatimArgs) -> int:
|
||||||
|
params: List[Union[int, str]] = [
|
||||||
|
'--output-type', args.output_type,
|
||||||
|
'--output-format', args.output_format]
|
||||||
|
if args.output_all_postcodes:
|
||||||
|
params.append('--output-all-postcodes')
|
||||||
|
if args.language:
|
||||||
|
params.extend(('--language', args.language))
|
||||||
|
if args.restrict_to_country:
|
||||||
|
params.extend(('--restrict-to-country', args.restrict_to_country))
|
||||||
|
if args.restrict_to_osm_node:
|
||||||
|
params.extend(('--restrict-to-osm-node', args.restrict_to_osm_node))
|
||||||
|
if args.restrict_to_osm_way:
|
||||||
|
params.extend(('--restrict-to-osm-way', args.restrict_to_osm_way))
|
||||||
|
if args.restrict_to_osm_relation:
|
||||||
|
params.extend(('--restrict-to-osm-relation', args.restrict_to_osm_relation))
|
||||||
|
|
||||||
|
return run_legacy_script('export.php', *params, nominatim_env=args)
|
||||||
|
|
||||||
|
|
||||||
class AdminServe:
|
class AdminServe:
|
||||||
"""\
|
"""\
|
||||||
Start a simple web server for serving the API.
|
Start a simple web server for serving the API.
|
||||||
|
|
||||||
This command starts a built-in webserver to serve the website
|
This command starts the built-in PHP webserver to serve the website
|
||||||
from the current project directory. This webserver is only suitable
|
from the current project directory. This webserver is only suitable
|
||||||
for testing and development. Do not use it in production setups!
|
for testing and development. Do not use it in production setups!
|
||||||
|
|
||||||
There are different webservers available. The default 'php' engine
|
|
||||||
runs the classic PHP frontend. The other engines are Python servers
|
|
||||||
which run the new Python frontend code. This is highly experimental
|
|
||||||
at the moment and may not include the full API.
|
|
||||||
|
|
||||||
By the default, the webserver can be accessed at: http://127.0.0.1:8088
|
By the default, the webserver can be accessed at: http://127.0.0.1:8088
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -166,46 +213,14 @@ class AdminServe:
|
|||||||
group = parser.add_argument_group('Server arguments')
|
group = parser.add_argument_group('Server arguments')
|
||||||
group.add_argument('--server', default='127.0.0.1:8088',
|
group.add_argument('--server', default='127.0.0.1:8088',
|
||||||
help='The address the server will listen to.')
|
help='The address the server will listen to.')
|
||||||
group.add_argument('--engine', default='falcon',
|
|
||||||
choices=('php', 'falcon', 'starlette'),
|
|
||||||
help='Webserver framework to run. (default: falcon)')
|
|
||||||
|
|
||||||
|
|
||||||
def run(self, args: NominatimArgs) -> int:
|
def run(self, args: NominatimArgs) -> int:
|
||||||
if args.engine == 'php':
|
run_php_server(args.server, args.project_dir / 'website')
|
||||||
if args.config.lib_dir.php is None:
|
|
||||||
raise UsageError("PHP frontend not configured.")
|
|
||||||
LOG.warning('\n\nWARNING: the PHP frontend is deprecated '
|
|
||||||
'and will be removed in Nominatim 5.0.\n\n')
|
|
||||||
run_php_server(args.server, args.project_dir / 'website')
|
|
||||||
else:
|
|
||||||
asyncio.run(self.run_uvicorn(args))
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
async def run_uvicorn(self, args: NominatimArgs) -> None:
|
def get_set_parser(**kwargs: Any) -> CommandlineParser:
|
||||||
import uvicorn # pylint: disable=import-outside-toplevel
|
|
||||||
|
|
||||||
server_info = args.server.split(':', 1)
|
|
||||||
host = server_info[0]
|
|
||||||
if len(server_info) > 1:
|
|
||||||
if not server_info[1].isdigit():
|
|
||||||
raise UsageError('Invalid format for --server parameter. Use <host>:<port>')
|
|
||||||
port = int(server_info[1])
|
|
||||||
else:
|
|
||||||
port = 8088
|
|
||||||
|
|
||||||
server_module = importlib.import_module(f'nominatim_api.server.{args.engine}.server')
|
|
||||||
|
|
||||||
app = server_module.get_application(args.project_dir)
|
|
||||||
|
|
||||||
config = uvicorn.Config(app, host=host, port=port)
|
|
||||||
server = uvicorn.Server(config)
|
|
||||||
await server.serve()
|
|
||||||
|
|
||||||
|
|
||||||
def get_set_parser() -> CommandlineParser:
|
|
||||||
"""\
|
"""\
|
||||||
Initializes the parser and adds various subcommands for
|
Initializes the parser and adds various subcommands for
|
||||||
nominatim cli.
|
nominatim cli.
|
||||||
@@ -224,30 +239,17 @@ def get_set_parser() -> CommandlineParser:
|
|||||||
|
|
||||||
parser.add_subcommand('admin', clicmd.AdminFuncs())
|
parser.add_subcommand('admin', clicmd.AdminFuncs())
|
||||||
|
|
||||||
try:
|
parser.add_subcommand('export', QueryExport())
|
||||||
exportcmd = importlib.import_module('nominatim_db.clicmd.export')
|
parser.add_subcommand('serve', AdminServe())
|
||||||
apicmd = importlib.import_module('nominatim_db.clicmd.api')
|
|
||||||
convertcmd = importlib.import_module('nominatim_db.clicmd.convert')
|
|
||||||
|
|
||||||
parser.add_subcommand('export', exportcmd.QueryExport())
|
|
||||||
parser.add_subcommand('convert', convertcmd.ConvertDB())
|
|
||||||
parser.add_subcommand('serve', AdminServe())
|
|
||||||
|
|
||||||
parser.add_subcommand('search', apicmd.APISearch())
|
|
||||||
parser.add_subcommand('reverse', apicmd.APIReverse())
|
|
||||||
parser.add_subcommand('lookup', apicmd.APILookup())
|
|
||||||
parser.add_subcommand('details', apicmd.APIDetails())
|
|
||||||
parser.add_subcommand('status', apicmd.APIStatus())
|
|
||||||
except ModuleNotFoundError as ex:
|
|
||||||
if not ex.name or 'nominatim_api' not in ex.name: # pylint: disable=E1135
|
|
||||||
raise ex
|
|
||||||
|
|
||||||
parser.parser.epilog = \
|
|
||||||
f'\n\nNominatim API package not found (was looking for module: {ex.name}).'\
|
|
||||||
'\nThe following commands are not available:'\
|
|
||||||
'\n export, convert, serve, search, reverse, lookup, details, status'\
|
|
||||||
"\n\nRun 'pip install nominatim-api' to install the package."
|
|
||||||
|
|
||||||
|
if kwargs.get('phpcgi_path'):
|
||||||
|
parser.add_subcommand('search', clicmd.APISearch())
|
||||||
|
parser.add_subcommand('reverse', clicmd.APIReverse())
|
||||||
|
parser.add_subcommand('lookup', clicmd.APILookup())
|
||||||
|
parser.add_subcommand('details', clicmd.APIDetails())
|
||||||
|
parser.add_subcommand('status', clicmd.APIStatus())
|
||||||
|
else:
|
||||||
|
parser.parser.epilog = 'php-cgi not found. Query commands not available.'
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
@@ -257,4 +259,6 @@ def nominatim(**kwargs: Any) -> int:
|
|||||||
Command-line tools for importing, updating, administrating and
|
Command-line tools for importing, updating, administrating and
|
||||||
querying the Nominatim database.
|
querying the Nominatim database.
|
||||||
"""
|
"""
|
||||||
return get_set_parser().run(**kwargs)
|
parser = get_set_parser(**kwargs)
|
||||||
|
|
||||||
|
return parser.run(**kwargs)
|
||||||
26
nominatim/clicmd/__init__.py
Normal file
26
nominatim/clicmd/__init__.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
#
|
||||||
|
# This file is part of Nominatim. (https://nominatim.org)
|
||||||
|
#
|
||||||
|
# Copyright (C) 2022 by the Nominatim developer community.
|
||||||
|
# For a full list of authors see the git log.
|
||||||
|
"""
|
||||||
|
Subcommand definitions for the command-line tool.
|
||||||
|
"""
|
||||||
|
# mypy and pylint disagree about the style of explicit exports,
|
||||||
|
# see https://github.com/PyCQA/pylint/issues/6006.
|
||||||
|
# pylint: disable=useless-import-alias
|
||||||
|
|
||||||
|
from nominatim.clicmd.setup import SetupAll as SetupAll
|
||||||
|
from nominatim.clicmd.replication import UpdateReplication as UpdateReplication
|
||||||
|
from nominatim.clicmd.api import (APISearch as APISearch,
|
||||||
|
APIReverse as APIReverse,
|
||||||
|
APILookup as APILookup,
|
||||||
|
APIDetails as APIDetails,
|
||||||
|
APIStatus as APIStatus)
|
||||||
|
from nominatim.clicmd.index import UpdateIndex as UpdateIndex
|
||||||
|
from nominatim.clicmd.refresh import UpdateRefresh as UpdateRefresh
|
||||||
|
from nominatim.clicmd.add_data import UpdateAddData as UpdateAddData
|
||||||
|
from nominatim.clicmd.admin import AdminFuncs as AdminFuncs
|
||||||
|
from nominatim.clicmd.freeze import SetupFreeze as SetupFreeze
|
||||||
|
from nominatim.clicmd.special_phrases import ImportSpecialPhrases as ImportSpecialPhrases
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
#
|
#
|
||||||
# This file is part of Nominatim. (https://nominatim.org)
|
# This file is part of Nominatim. (https://nominatim.org)
|
||||||
#
|
#
|
||||||
# Copyright (C) 2024 by the Nominatim developer community.
|
# Copyright (C) 2022 by the Nominatim developer community.
|
||||||
# For a full list of authors see the git log.
|
# For a full list of authors see the git log.
|
||||||
"""
|
"""
|
||||||
Implementation of the 'add-data' subcommand.
|
Implementation of the 'add-data' subcommand.
|
||||||
@@ -10,13 +10,10 @@ Implementation of the 'add-data' subcommand.
|
|||||||
from typing import cast
|
from typing import cast
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import asyncio
|
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
|
|
||||||
from .args import NominatimArgs
|
from nominatim.clicmd.args import NominatimArgs
|
||||||
from ..db.connection import connect
|
|
||||||
from ..tools.freeze import is_frozen
|
|
||||||
|
|
||||||
# Do not repeat documentation of subcommand classes.
|
# Do not repeat documentation of subcommand classes.
|
||||||
# pylint: disable=C0111
|
# pylint: disable=C0111
|
||||||
@@ -38,7 +35,7 @@ class UpdateAddData:
|
|||||||
The command can also be used to add external non-OSM data to the
|
The command can also be used to add external non-OSM data to the
|
||||||
database. At the moment the only supported format is TIGER housenumber
|
database. At the moment the only supported format is TIGER housenumber
|
||||||
data. See the online documentation at
|
data. See the online documentation at
|
||||||
https://nominatim.org/release-docs/latest/customize/Tiger/
|
https://nominatim.org/release-docs/latest/admin/Import/#installing-tiger-housenumber-data-for-the-us
|
||||||
for more information.
|
for more information.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -67,15 +64,15 @@ class UpdateAddData:
|
|||||||
|
|
||||||
|
|
||||||
def run(self, args: NominatimArgs) -> int:
|
def run(self, args: NominatimArgs) -> int:
|
||||||
from ..tools import add_osm_data
|
from nominatim.tokenizer import factory as tokenizer_factory
|
||||||
|
from nominatim.tools import tiger_data, add_osm_data
|
||||||
with connect(args.config.get_libpq_dsn()) as conn:
|
|
||||||
if is_frozen(conn):
|
|
||||||
print('Database is marked frozen. New data can\'t be added.')
|
|
||||||
return 1
|
|
||||||
|
|
||||||
if args.tiger_data:
|
if args.tiger_data:
|
||||||
return asyncio.run(self._add_tiger_data(args))
|
tokenizer = tokenizer_factory.get_tokenizer_for_db(args.config)
|
||||||
|
return tiger_data.add_tiger_data(args.tiger_data,
|
||||||
|
args.config,
|
||||||
|
args.threads or psutil.cpu_count() or 1,
|
||||||
|
tokenizer)
|
||||||
|
|
||||||
osm2pgsql_params = args.osm2pgsql_options(default_cache=1000, default_threads=1)
|
osm2pgsql_params = args.osm2pgsql_options(default_cache=1000, default_threads=1)
|
||||||
if args.file or args.diff:
|
if args.file or args.diff:
|
||||||
@@ -102,16 +99,3 @@ class UpdateAddData:
|
|||||||
osm2pgsql_params)
|
osm2pgsql_params)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
async def _add_tiger_data(self, args: NominatimArgs) -> int:
|
|
||||||
from ..tokenizer import factory as tokenizer_factory
|
|
||||||
from ..tools import tiger_data
|
|
||||||
|
|
||||||
assert args.tiger_data
|
|
||||||
|
|
||||||
tokenizer = tokenizer_factory.get_tokenizer_for_db(args.config)
|
|
||||||
return await tiger_data.add_tiger_data(args.tiger_data,
|
|
||||||
args.config,
|
|
||||||
args.threads or psutil.cpu_count() or 1,
|
|
||||||
tokenizer)
|
|
||||||
@@ -1,19 +1,17 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
#
|
#
|
||||||
# This file is part of Nominatim. (https://nominatim.org)
|
# This file is part of Nominatim. (https://nominatim.org)
|
||||||
#
|
#
|
||||||
# Copyright (C) 2024 by the Nominatim developer community.
|
# Copyright (C) 2022 by the Nominatim developer community.
|
||||||
# For a full list of authors see the git log.
|
# For a full list of authors see the git log.
|
||||||
"""
|
"""
|
||||||
Implementation of the 'admin' subcommand.
|
Implementation of the 'admin' subcommand.
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import argparse
|
import argparse
|
||||||
import random
|
|
||||||
|
|
||||||
from ..errors import UsageError
|
from nominatim.tools.exec_utils import run_legacy_script
|
||||||
from ..db.connection import connect, table_exists
|
from nominatim.clicmd.args import NominatimArgs
|
||||||
from .args import NominatimArgs
|
|
||||||
|
|
||||||
# Do not repeat documentation of subcommand classes.
|
# Do not repeat documentation of subcommand classes.
|
||||||
# pylint: disable=C0111
|
# pylint: disable=C0111
|
||||||
@@ -41,8 +39,6 @@ class AdminFuncs:
|
|||||||
help='Print performance analysis of the indexing process')
|
help='Print performance analysis of the indexing process')
|
||||||
objs.add_argument('--collect-os-info', action="store_true",
|
objs.add_argument('--collect-os-info', action="store_true",
|
||||||
help="Generate a report about the host system information")
|
help="Generate a report about the host system information")
|
||||||
objs.add_argument('--clean-deleted', action='store', metavar='AGE',
|
|
||||||
help='Clean up deleted relations')
|
|
||||||
group = parser.add_argument_group('Arguments for cache warming')
|
group = parser.add_argument_group('Arguments for cache warming')
|
||||||
group.add_argument('--search-only', action='store_const', dest='target',
|
group.add_argument('--search-only', action='store_const', dest='target',
|
||||||
const='search',
|
const='search',
|
||||||
@@ -57,9 +53,7 @@ class AdminFuncs:
|
|||||||
mgroup.add_argument('--place-id', type=int,
|
mgroup.add_argument('--place-id', type=int,
|
||||||
help='Analyse indexing of the given Nominatim object')
|
help='Analyse indexing of the given Nominatim object')
|
||||||
|
|
||||||
|
|
||||||
def run(self, args: NominatimArgs) -> int:
|
def run(self, args: NominatimArgs) -> int:
|
||||||
# pylint: disable=too-many-return-statements
|
|
||||||
if args.warm:
|
if args.warm:
|
||||||
return self._warm(args)
|
return self._warm(args)
|
||||||
|
|
||||||
@@ -85,44 +79,13 @@ class AdminFuncs:
|
|||||||
collect_os_info.report_system_information(args.config)
|
collect_os_info.report_system_information(args.config)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if args.clean_deleted:
|
|
||||||
LOG.warning('Cleaning up deleted relations')
|
|
||||||
from ..tools import admin
|
|
||||||
admin.clean_deleted_relations(args.config, age=args.clean_deleted)
|
|
||||||
return 0
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
def _warm(self, args: NominatimArgs) -> int:
|
def _warm(self, args: NominatimArgs) -> int:
|
||||||
try:
|
|
||||||
import nominatim_api as napi
|
|
||||||
except ModuleNotFoundError as exp:
|
|
||||||
raise UsageError("Warming requires nominatim API. "
|
|
||||||
"Install with 'pip install nominatim-api'.") from exp
|
|
||||||
LOG.warning('Warming database caches')
|
LOG.warning('Warming database caches')
|
||||||
|
params = ['warm.php']
|
||||||
api = napi.NominatimAPI(args.project_dir)
|
if args.target == 'reverse':
|
||||||
|
params.append('--reverse-only')
|
||||||
try:
|
if args.target == 'search':
|
||||||
if args.target != 'search':
|
params.append('--search-only')
|
||||||
for _ in range(1000):
|
return run_legacy_script(*params, nominatim_env=args)
|
||||||
api.reverse((random.uniform(-90, 90), random.uniform(-180, 180)),
|
|
||||||
address_details=True)
|
|
||||||
|
|
||||||
if args.target != 'reverse':
|
|
||||||
from ..tokenizer import factory as tokenizer_factory
|
|
||||||
|
|
||||||
tokenizer = tokenizer_factory.get_tokenizer_for_db(args.config)
|
|
||||||
with connect(args.config.get_libpq_dsn()) as conn:
|
|
||||||
if table_exists(conn, 'search_name'):
|
|
||||||
words = tokenizer.most_frequent_words(conn, 1000)
|
|
||||||
else:
|
|
||||||
words = []
|
|
||||||
|
|
||||||
for word in words:
|
|
||||||
api.search(word)
|
|
||||||
finally:
|
|
||||||
api.close()
|
|
||||||
|
|
||||||
return 0
|
|
||||||
283
nominatim/clicmd/api.py
Normal file
283
nominatim/clicmd/api.py
Normal file
@@ -0,0 +1,283 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
#
|
||||||
|
# This file is part of Nominatim. (https://nominatim.org)
|
||||||
|
#
|
||||||
|
# Copyright (C) 2022 by the Nominatim developer community.
|
||||||
|
# For a full list of authors see the git log.
|
||||||
|
"""
|
||||||
|
Subcommand definitions for API calls from the command line.
|
||||||
|
"""
|
||||||
|
from typing import Mapping, Dict
|
||||||
|
import argparse
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from nominatim.tools.exec_utils import run_api_script
|
||||||
|
from nominatim.errors import UsageError
|
||||||
|
from nominatim.clicmd.args import NominatimArgs
|
||||||
|
|
||||||
|
# Do not repeat documentation of subcommand classes.
|
||||||
|
# pylint: disable=C0111
|
||||||
|
|
||||||
|
LOG = logging.getLogger()
|
||||||
|
|
||||||
|
STRUCTURED_QUERY = (
|
||||||
|
('street', 'housenumber and street'),
|
||||||
|
('city', 'city, town or village'),
|
||||||
|
('county', 'county'),
|
||||||
|
('state', 'state'),
|
||||||
|
('country', 'country'),
|
||||||
|
('postalcode', 'postcode')
|
||||||
|
)
|
||||||
|
|
||||||
|
EXTRADATA_PARAMS = (
|
||||||
|
('addressdetails', 'Include a breakdown of the address into elements'),
|
||||||
|
('extratags', ("Include additional information if available "
|
||||||
|
"(e.g. wikipedia link, opening hours)")),
|
||||||
|
('namedetails', 'Include a list of alternative names')
|
||||||
|
)
|
||||||
|
|
||||||
|
DETAILS_SWITCHES = (
|
||||||
|
('addressdetails', 'Include a breakdown of the address into elements'),
|
||||||
|
('keywords', 'Include a list of name keywords and address keywords'),
|
||||||
|
('linkedplaces', 'Include a details of places that are linked with this one'),
|
||||||
|
('hierarchy', 'Include details of places lower in the address hierarchy'),
|
||||||
|
('group_hierarchy', 'Group the places by type'),
|
||||||
|
('polygon_geojson', 'Include geometry of result')
|
||||||
|
)
|
||||||
|
|
||||||
|
def _add_api_output_arguments(parser: argparse.ArgumentParser) -> None:
|
||||||
|
group = parser.add_argument_group('Output arguments')
|
||||||
|
group.add_argument('--format', default='jsonv2',
|
||||||
|
choices=['xml', 'json', 'jsonv2', 'geojson', 'geocodejson'],
|
||||||
|
help='Format of result')
|
||||||
|
for name, desc in EXTRADATA_PARAMS:
|
||||||
|
group.add_argument('--' + name, action='store_true', help=desc)
|
||||||
|
|
||||||
|
group.add_argument('--lang', '--accept-language', metavar='LANGS',
|
||||||
|
help='Preferred language order for presenting search results')
|
||||||
|
group.add_argument('--polygon-output',
|
||||||
|
choices=['geojson', 'kml', 'svg', 'text'],
|
||||||
|
help='Output geometry of results as a GeoJSON, KML, SVG or WKT')
|
||||||
|
group.add_argument('--polygon-threshold', type=float, metavar='TOLERANCE',
|
||||||
|
help=("Simplify output geometry."
|
||||||
|
"Parameter is difference tolerance in degrees."))
|
||||||
|
|
||||||
|
|
||||||
|
def _run_api(endpoint: str, args: NominatimArgs, params: Mapping[str, object]) -> int:
|
||||||
|
script_file = args.project_dir / 'website' / (endpoint + '.php')
|
||||||
|
|
||||||
|
if not script_file.exists():
|
||||||
|
LOG.error("Cannot find API script file.\n\n"
|
||||||
|
"Make sure to run 'nominatim' from the project directory \n"
|
||||||
|
"or use the option --project-dir.")
|
||||||
|
raise UsageError("API script not found.")
|
||||||
|
|
||||||
|
return run_api_script(endpoint, args.project_dir,
|
||||||
|
phpcgi_bin=args.phpcgi_path, params=params)
|
||||||
|
|
||||||
|
class APISearch:
|
||||||
|
"""\
|
||||||
|
Execute a search query.
|
||||||
|
|
||||||
|
This command works exactly the same as if calling the /search endpoint on
|
||||||
|
the web API. See the online documentation for more details on the
|
||||||
|
various parameters:
|
||||||
|
https://nominatim.org/release-docs/latest/api/Search/
|
||||||
|
"""
|
||||||
|
|
||||||
|
def add_args(self, parser: argparse.ArgumentParser) -> None:
|
||||||
|
group = parser.add_argument_group('Query arguments')
|
||||||
|
group.add_argument('--query',
|
||||||
|
help='Free-form query string')
|
||||||
|
for name, desc in STRUCTURED_QUERY:
|
||||||
|
group.add_argument('--' + name, help='Structured query: ' + desc)
|
||||||
|
|
||||||
|
_add_api_output_arguments(parser)
|
||||||
|
|
||||||
|
group = parser.add_argument_group('Result limitation')
|
||||||
|
group.add_argument('--countrycodes', metavar='CC,..',
|
||||||
|
help='Limit search results to one or more countries')
|
||||||
|
group.add_argument('--exclude_place_ids', metavar='ID,..',
|
||||||
|
help='List of search object to be excluded')
|
||||||
|
group.add_argument('--limit', type=int,
|
||||||
|
help='Limit the number of returned results')
|
||||||
|
group.add_argument('--viewbox', metavar='X1,Y1,X2,Y2',
|
||||||
|
help='Preferred area to find search results')
|
||||||
|
group.add_argument('--bounded', action='store_true',
|
||||||
|
help='Strictly restrict results to viewbox area')
|
||||||
|
|
||||||
|
group = parser.add_argument_group('Other arguments')
|
||||||
|
group.add_argument('--no-dedupe', action='store_false', dest='dedupe',
|
||||||
|
help='Do not remove duplicates from the result list')
|
||||||
|
|
||||||
|
|
||||||
|
def run(self, args: NominatimArgs) -> int:
|
||||||
|
params: Dict[str, object]
|
||||||
|
if args.query:
|
||||||
|
params = dict(q=args.query)
|
||||||
|
else:
|
||||||
|
params = {k: getattr(args, k) for k, _ in STRUCTURED_QUERY if getattr(args, k)}
|
||||||
|
|
||||||
|
for param, _ in EXTRADATA_PARAMS:
|
||||||
|
if getattr(args, param):
|
||||||
|
params[param] = '1'
|
||||||
|
for param in ('format', 'countrycodes', 'exclude_place_ids', 'limit', 'viewbox'):
|
||||||
|
if getattr(args, param):
|
||||||
|
params[param] = getattr(args, param)
|
||||||
|
if args.lang:
|
||||||
|
params['accept-language'] = args.lang
|
||||||
|
if args.polygon_output:
|
||||||
|
params['polygon_' + args.polygon_output] = '1'
|
||||||
|
if args.polygon_threshold:
|
||||||
|
params['polygon_threshold'] = args.polygon_threshold
|
||||||
|
if args.bounded:
|
||||||
|
params['bounded'] = '1'
|
||||||
|
if not args.dedupe:
|
||||||
|
params['dedupe'] = '0'
|
||||||
|
|
||||||
|
return _run_api('search', args, params)
|
||||||
|
|
||||||
|
class APIReverse:
|
||||||
|
"""\
|
||||||
|
Execute API reverse query.
|
||||||
|
|
||||||
|
This command works exactly the same as if calling the /reverse endpoint on
|
||||||
|
the web API. See the online documentation for more details on the
|
||||||
|
various parameters:
|
||||||
|
https://nominatim.org/release-docs/latest/api/Reverse/
|
||||||
|
"""
|
||||||
|
|
||||||
|
def add_args(self, parser: argparse.ArgumentParser) -> None:
|
||||||
|
group = parser.add_argument_group('Query arguments')
|
||||||
|
group.add_argument('--lat', type=float, required=True,
|
||||||
|
help='Latitude of coordinate to look up (in WGS84)')
|
||||||
|
group.add_argument('--lon', type=float, required=True,
|
||||||
|
help='Longitude of coordinate to look up (in WGS84)')
|
||||||
|
group.add_argument('--zoom', type=int,
|
||||||
|
help='Level of detail required for the address')
|
||||||
|
|
||||||
|
_add_api_output_arguments(parser)
|
||||||
|
|
||||||
|
|
||||||
|
def run(self, args: NominatimArgs) -> int:
|
||||||
|
params = dict(lat=args.lat, lon=args.lon, format=args.format)
|
||||||
|
if args.zoom is not None:
|
||||||
|
params['zoom'] = args.zoom
|
||||||
|
|
||||||
|
for param, _ in EXTRADATA_PARAMS:
|
||||||
|
if getattr(args, param):
|
||||||
|
params[param] = '1'
|
||||||
|
if args.lang:
|
||||||
|
params['accept-language'] = args.lang
|
||||||
|
if args.polygon_output:
|
||||||
|
params['polygon_' + args.polygon_output] = '1'
|
||||||
|
if args.polygon_threshold:
|
||||||
|
params['polygon_threshold'] = args.polygon_threshold
|
||||||
|
|
||||||
|
return _run_api('reverse', args, params)
|
||||||
|
|
||||||
|
|
||||||
|
class APILookup:
|
||||||
|
"""\
|
||||||
|
Execute API lookup query.
|
||||||
|
|
||||||
|
This command works exactly the same as if calling the /lookup endpoint on
|
||||||
|
the web API. See the online documentation for more details on the
|
||||||
|
various parameters:
|
||||||
|
https://nominatim.org/release-docs/latest/api/Lookup/
|
||||||
|
"""
|
||||||
|
|
||||||
|
def add_args(self, parser: argparse.ArgumentParser) -> None:
|
||||||
|
group = parser.add_argument_group('Query arguments')
|
||||||
|
group.add_argument('--id', metavar='OSMID',
|
||||||
|
action='append', required=True, dest='ids',
|
||||||
|
help='OSM id to lookup in format <NRW><id> (may be repeated)')
|
||||||
|
|
||||||
|
_add_api_output_arguments(parser)
|
||||||
|
|
||||||
|
|
||||||
|
def run(self, args: NominatimArgs) -> int:
|
||||||
|
params: Dict[str, object] = dict(osm_ids=','.join(args.ids), format=args.format)
|
||||||
|
|
||||||
|
for param, _ in EXTRADATA_PARAMS:
|
||||||
|
if getattr(args, param):
|
||||||
|
params[param] = '1'
|
||||||
|
if args.lang:
|
||||||
|
params['accept-language'] = args.lang
|
||||||
|
if args.polygon_output:
|
||||||
|
params['polygon_' + args.polygon_output] = '1'
|
||||||
|
if args.polygon_threshold:
|
||||||
|
params['polygon_threshold'] = args.polygon_threshold
|
||||||
|
|
||||||
|
return _run_api('lookup', args, params)
|
||||||
|
|
||||||
|
|
||||||
|
class APIDetails:
|
||||||
|
"""\
|
||||||
|
Execute API details query.
|
||||||
|
|
||||||
|
This command works exactly the same as if calling the /details endpoint on
|
||||||
|
the web API. See the online documentation for more details on the
|
||||||
|
various parameters:
|
||||||
|
https://nominatim.org/release-docs/latest/api/Details/
|
||||||
|
"""
|
||||||
|
|
||||||
|
def add_args(self, parser: argparse.ArgumentParser) -> None:
|
||||||
|
group = parser.add_argument_group('Query arguments')
|
||||||
|
objs = group.add_mutually_exclusive_group(required=True)
|
||||||
|
objs.add_argument('--node', '-n', type=int,
|
||||||
|
help="Look up the OSM node with the given ID.")
|
||||||
|
objs.add_argument('--way', '-w', type=int,
|
||||||
|
help="Look up the OSM way with the given ID.")
|
||||||
|
objs.add_argument('--relation', '-r', type=int,
|
||||||
|
help="Look up the OSM relation with the given ID.")
|
||||||
|
objs.add_argument('--place_id', '-p', type=int,
|
||||||
|
help='Database internal identifier of the OSM object to look up')
|
||||||
|
group.add_argument('--class', dest='object_class',
|
||||||
|
help=("Class type to disambiguated multiple entries "
|
||||||
|
"of the same object."))
|
||||||
|
|
||||||
|
group = parser.add_argument_group('Output arguments')
|
||||||
|
for name, desc in DETAILS_SWITCHES:
|
||||||
|
group.add_argument('--' + name, action='store_true', help=desc)
|
||||||
|
group.add_argument('--lang', '--accept-language', metavar='LANGS',
|
||||||
|
help='Preferred language order for presenting search results')
|
||||||
|
|
||||||
|
|
||||||
|
def run(self, args: NominatimArgs) -> int:
|
||||||
|
if args.node:
|
||||||
|
params = dict(osmtype='N', osmid=args.node)
|
||||||
|
elif args.way:
|
||||||
|
params = dict(osmtype='W', osmid=args.way)
|
||||||
|
elif args.relation:
|
||||||
|
params = dict(osmtype='R', osmid=args.relation)
|
||||||
|
else:
|
||||||
|
params = dict(place_id=args.place_id)
|
||||||
|
if args.object_class:
|
||||||
|
params['class'] = args.object_class
|
||||||
|
for name, _ in DETAILS_SWITCHES:
|
||||||
|
params[name] = '1' if getattr(args, name) else '0'
|
||||||
|
if args.lang:
|
||||||
|
params['accept-language'] = args.lang
|
||||||
|
|
||||||
|
return _run_api('details', args, params)
|
||||||
|
|
||||||
|
|
||||||
|
class APIStatus:
|
||||||
|
"""\
|
||||||
|
Execute API status query.
|
||||||
|
|
||||||
|
This command works exactly the same as if calling the /status endpoint on
|
||||||
|
the web API. See the online documentation for more details on the
|
||||||
|
various parameters:
|
||||||
|
https://nominatim.org/release-docs/latest/api/Status/
|
||||||
|
"""
|
||||||
|
|
||||||
|
def add_args(self, parser: argparse.ArgumentParser) -> None:
|
||||||
|
group = parser.add_argument_group('API parameters')
|
||||||
|
group.add_argument('--format', default='text', choices=['text', 'json'],
|
||||||
|
help='Format of result')
|
||||||
|
|
||||||
|
|
||||||
|
def run(self, args: NominatimArgs) -> int:
|
||||||
|
return _run_api('status', args, dict(format=args.format))
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
#
|
#
|
||||||
# This file is part of Nominatim. (https://nominatim.org)
|
# This file is part of Nominatim. (https://nominatim.org)
|
||||||
#
|
#
|
||||||
# Copyright (C) 2024 by the Nominatim developer community.
|
# Copyright (C) 2022 by the Nominatim developer community.
|
||||||
# For a full list of authors see the git log.
|
# For a full list of authors see the git log.
|
||||||
"""
|
"""
|
||||||
Provides custom functions over command-line arguments.
|
Provides custom functions over command-line arguments.
|
||||||
@@ -12,9 +12,9 @@ import argparse
|
|||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from ..errors import UsageError
|
from nominatim.errors import UsageError
|
||||||
from ..config import Configuration
|
from nominatim.config import Configuration
|
||||||
from ..typing import Protocol
|
from nominatim.typing import Protocol
|
||||||
|
|
||||||
LOG = logging.getLogger()
|
LOG = logging.getLogger()
|
||||||
|
|
||||||
@@ -42,6 +42,13 @@ class NominatimArgs:
|
|||||||
# Basic environment set by root program.
|
# Basic environment set by root program.
|
||||||
config: Configuration
|
config: Configuration
|
||||||
project_dir: Path
|
project_dir: Path
|
||||||
|
module_dir: Path
|
||||||
|
osm2pgsql_path: Path
|
||||||
|
phplib_dir: Path
|
||||||
|
sqllib_dir: Path
|
||||||
|
data_dir: Path
|
||||||
|
config_dir: Path
|
||||||
|
phpcgi_path: Path
|
||||||
|
|
||||||
# Global switches
|
# Global switches
|
||||||
version: bool
|
version: bool
|
||||||
@@ -70,7 +77,6 @@ class NominatimArgs:
|
|||||||
check_database: bool
|
check_database: bool
|
||||||
migrate: bool
|
migrate: bool
|
||||||
collect_os_info: bool
|
collect_os_info: bool
|
||||||
clean_deleted: str
|
|
||||||
analyse_indexing: bool
|
analyse_indexing: bool
|
||||||
target: Optional[str]
|
target: Optional[str]
|
||||||
osm_id: Optional[str]
|
osm_id: Optional[str]
|
||||||
@@ -85,7 +91,6 @@ class NominatimArgs:
|
|||||||
offline: bool
|
offline: bool
|
||||||
ignore_errors: bool
|
ignore_errors: bool
|
||||||
index_noanalyse: bool
|
index_noanalyse: bool
|
||||||
prepare_database: bool
|
|
||||||
|
|
||||||
# Arguments to 'index'
|
# Arguments to 'index'
|
||||||
boundaries_only: bool
|
boundaries_only: bool
|
||||||
@@ -99,9 +104,9 @@ class NominatimArgs:
|
|||||||
output_all_postcodes: bool
|
output_all_postcodes: bool
|
||||||
language: Optional[str]
|
language: Optional[str]
|
||||||
restrict_to_country: Optional[str]
|
restrict_to_country: Optional[str]
|
||||||
|
restrict_to_osm_node: Optional[int]
|
||||||
# Arguments to 'convert'
|
restrict_to_osm_way: Optional[int]
|
||||||
output: Path
|
restrict_to_osm_relation: Optional[int]
|
||||||
|
|
||||||
# Arguments to 'refresh'
|
# Arguments to 'refresh'
|
||||||
postcodes: bool
|
postcodes: bool
|
||||||
@@ -128,7 +133,6 @@ class NominatimArgs:
|
|||||||
|
|
||||||
# Arguments to 'serve'
|
# Arguments to 'serve'
|
||||||
server: str
|
server: str
|
||||||
engine: str
|
|
||||||
|
|
||||||
# Arguments to 'special-phrases
|
# Arguments to 'special-phrases
|
||||||
import_from_wiki: bool
|
import_from_wiki: bool
|
||||||
@@ -137,7 +141,6 @@ class NominatimArgs:
|
|||||||
|
|
||||||
# Arguments to all query functions
|
# Arguments to all query functions
|
||||||
format: str
|
format: str
|
||||||
list_formats: bool
|
|
||||||
addressdetails: bool
|
addressdetails: bool
|
||||||
extratags: bool
|
extratags: bool
|
||||||
namedetails: bool
|
namedetails: bool
|
||||||
@@ -147,7 +150,6 @@ class NominatimArgs:
|
|||||||
|
|
||||||
# Arguments to 'search'
|
# Arguments to 'search'
|
||||||
query: Optional[str]
|
query: Optional[str]
|
||||||
amenity: Optional[str]
|
|
||||||
street: Optional[str]
|
street: Optional[str]
|
||||||
city: Optional[str]
|
city: Optional[str]
|
||||||
county: Optional[str]
|
county: Optional[str]
|
||||||
@@ -156,7 +158,7 @@ class NominatimArgs:
|
|||||||
postalcode: Optional[str]
|
postalcode: Optional[str]
|
||||||
countrycodes: Optional[str]
|
countrycodes: Optional[str]
|
||||||
exclude_place_ids: Optional[str]
|
exclude_place_ids: Optional[str]
|
||||||
limit: int
|
limit: Optional[int]
|
||||||
viewbox: Optional[str]
|
viewbox: Optional[str]
|
||||||
bounded: bool
|
bounded: bool
|
||||||
dedupe: bool
|
dedupe: bool
|
||||||
@@ -165,18 +167,12 @@ class NominatimArgs:
|
|||||||
lat: float
|
lat: float
|
||||||
lon: float
|
lon: float
|
||||||
zoom: Optional[int]
|
zoom: Optional[int]
|
||||||
layers: Optional[Sequence[str]]
|
|
||||||
|
|
||||||
# Arguments to 'lookup'
|
# Arguments to 'lookup'
|
||||||
ids: Sequence[str]
|
ids: Sequence[str]
|
||||||
|
|
||||||
# Arguments to 'details'
|
# Arguments to 'details'
|
||||||
object_class: Optional[str]
|
object_class: Optional[str]
|
||||||
linkedplaces: bool
|
|
||||||
hierarchy: bool
|
|
||||||
keywords: bool
|
|
||||||
polygon_geojson: bool
|
|
||||||
group_hierarchy: bool
|
|
||||||
|
|
||||||
|
|
||||||
def osm2pgsql_options(self, default_cache: int,
|
def osm2pgsql_options(self, default_cache: int,
|
||||||
@@ -185,12 +181,13 @@ class NominatimArgs:
|
|||||||
from the command line arguments. The resulting dict can be
|
from the command line arguments. The resulting dict can be
|
||||||
further customized and then used in `run_osm2pgsql()`.
|
further customized and then used in `run_osm2pgsql()`.
|
||||||
"""
|
"""
|
||||||
return dict(osm2pgsql=self.config.OSM2PGSQL_BINARY or self.config.lib_dir.osm2pgsql,
|
return dict(osm2pgsql=self.config.OSM2PGSQL_BINARY or self.osm2pgsql_path,
|
||||||
osm2pgsql_cache=self.osm2pgsql_cache or default_cache,
|
osm2pgsql_cache=self.osm2pgsql_cache or default_cache,
|
||||||
osm2pgsql_style=self.config.get_import_style_file(),
|
osm2pgsql_style=self.config.get_import_style_file(),
|
||||||
osm2pgsql_style_path=self.config.config_dir,
|
osm2pgsql_style_path=self.config.config_dir,
|
||||||
threads=self.threads or default_threads,
|
threads=self.threads or default_threads,
|
||||||
dsn=self.config.get_libpq_dsn(),
|
dsn=self.config.get_libpq_dsn(),
|
||||||
|
forward_dependencies=self.config.get_bool('UPDATE_FORWARD_DEPENDENCIES'),
|
||||||
flatnode_file=str(self.config.get_path('FLATNODE_FILE') or ''),
|
flatnode_file=str(self.config.get_path('FLATNODE_FILE') or ''),
|
||||||
tablespaces=dict(slim_data=self.config.TABLESPACE_OSM_DATA,
|
tablespaces=dict(slim_data=self.config.TABLESPACE_OSM_DATA,
|
||||||
slim_index=self.config.TABLESPACE_OSM_INDEX,
|
slim_index=self.config.TABLESPACE_OSM_INDEX,
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
#
|
#
|
||||||
# This file is part of Nominatim. (https://nominatim.org)
|
# This file is part of Nominatim. (https://nominatim.org)
|
||||||
#
|
#
|
||||||
# Copyright (C) 2024 by the Nominatim developer community.
|
# Copyright (C) 2022 by the Nominatim developer community.
|
||||||
# For a full list of authors see the git log.
|
# For a full list of authors see the git log.
|
||||||
"""
|
"""
|
||||||
Implementation of the 'freeze' subcommand.
|
Implementation of the 'freeze' subcommand.
|
||||||
"""
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ..db.connection import connect
|
from nominatim.db.connection import connect
|
||||||
from .args import NominatimArgs
|
from nominatim.clicmd.args import NominatimArgs
|
||||||
|
|
||||||
# Do not repeat documentation of subcommand classes.
|
# Do not repeat documentation of subcommand classes.
|
||||||
# pylint: disable=C0111
|
# pylint: disable=C0111
|
||||||
@@ -1,20 +1,19 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
#
|
#
|
||||||
# This file is part of Nominatim. (https://nominatim.org)
|
# This file is part of Nominatim. (https://nominatim.org)
|
||||||
#
|
#
|
||||||
# Copyright (C) 2024 by the Nominatim developer community.
|
# Copyright (C) 2022 by the Nominatim developer community.
|
||||||
# For a full list of authors see the git log.
|
# For a full list of authors see the git log.
|
||||||
"""
|
"""
|
||||||
Implementation of the 'index' subcommand.
|
Implementation of the 'index' subcommand.
|
||||||
"""
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
import asyncio
|
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
|
|
||||||
from ..db import status
|
from nominatim.db import status
|
||||||
from ..db.connection import connect
|
from nominatim.db.connection import connect
|
||||||
from .args import NominatimArgs
|
from nominatim.clicmd.args import NominatimArgs
|
||||||
|
|
||||||
# Do not repeat documentation of subcommand classes.
|
# Do not repeat documentation of subcommand classes.
|
||||||
# pylint: disable=C0111
|
# pylint: disable=C0111
|
||||||
@@ -45,7 +44,18 @@ class UpdateIndex:
|
|||||||
|
|
||||||
|
|
||||||
def run(self, args: NominatimArgs) -> int:
|
def run(self, args: NominatimArgs) -> int:
|
||||||
asyncio.run(self._do_index(args))
|
from ..indexer.indexer import Indexer
|
||||||
|
from ..tokenizer import factory as tokenizer_factory
|
||||||
|
|
||||||
|
tokenizer = tokenizer_factory.get_tokenizer_for_db(args.config)
|
||||||
|
|
||||||
|
indexer = Indexer(args.config.get_libpq_dsn(), tokenizer,
|
||||||
|
args.threads or psutil.cpu_count() or 1)
|
||||||
|
|
||||||
|
if not args.no_boundaries:
|
||||||
|
indexer.index_boundaries(args.minrank, args.maxrank)
|
||||||
|
if not args.boundaries_only:
|
||||||
|
indexer.index_by_rank(args.minrank, args.maxrank)
|
||||||
|
|
||||||
if not args.no_boundaries and not args.boundaries_only \
|
if not args.no_boundaries and not args.boundaries_only \
|
||||||
and args.minrank == 0 and args.maxrank == 30:
|
and args.minrank == 0 and args.maxrank == 30:
|
||||||
@@ -53,22 +63,3 @@ class UpdateIndex:
|
|||||||
status.set_indexed(conn, True)
|
status.set_indexed(conn, True)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
async def _do_index(self, args: NominatimArgs) -> None:
|
|
||||||
from ..tokenizer import factory as tokenizer_factory
|
|
||||||
|
|
||||||
tokenizer = tokenizer_factory.get_tokenizer_for_db(args.config)
|
|
||||||
from ..indexer.indexer import Indexer
|
|
||||||
|
|
||||||
indexer = Indexer(args.config.get_libpq_dsn(), tokenizer,
|
|
||||||
args.threads or psutil.cpu_count() or 1)
|
|
||||||
|
|
||||||
has_pending = True # run at least once
|
|
||||||
while has_pending:
|
|
||||||
if not args.no_boundaries:
|
|
||||||
await indexer.index_boundaries(args.minrank, args.maxrank)
|
|
||||||
if not args.boundaries_only:
|
|
||||||
await indexer.index_by_rank(args.minrank, args.maxrank)
|
|
||||||
await indexer.index_postcodes()
|
|
||||||
has_pending = indexer.has_pending()
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
#
|
#
|
||||||
# This file is part of Nominatim. (https://nominatim.org)
|
# This file is part of Nominatim. (https://nominatim.org)
|
||||||
#
|
#
|
||||||
# Copyright (C) 2024 by the Nominatim developer community.
|
# Copyright (C) 2022 by the Nominatim developer community.
|
||||||
# For a full list of authors see the git log.
|
# For a full list of authors see the git log.
|
||||||
"""
|
"""
|
||||||
Implementation of 'refresh' subcommand.
|
Implementation of 'refresh' subcommand.
|
||||||
@@ -11,12 +11,11 @@ from typing import Tuple, Optional
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import asyncio
|
|
||||||
|
|
||||||
from ..config import Configuration
|
from nominatim.config import Configuration
|
||||||
from ..db.connection import connect, table_exists
|
from nominatim.db.connection import connect
|
||||||
from ..tokenizer.base import AbstractTokenizer
|
from nominatim.tokenizer.base import AbstractTokenizer
|
||||||
from .args import NominatimArgs
|
from nominatim.clicmd.args import NominatimArgs
|
||||||
|
|
||||||
# Do not repeat documentation of subcommand classes.
|
# Do not repeat documentation of subcommand classes.
|
||||||
# pylint: disable=C0111
|
# pylint: disable=C0111
|
||||||
@@ -90,7 +89,6 @@ class UpdateRefresh:
|
|||||||
from ..tools import refresh, postcodes
|
from ..tools import refresh, postcodes
|
||||||
from ..indexer.indexer import Indexer
|
from ..indexer.indexer import Indexer
|
||||||
|
|
||||||
need_function_refresh = args.functions
|
|
||||||
|
|
||||||
if args.postcodes:
|
if args.postcodes:
|
||||||
if postcodes.can_compute(args.config.get_libpq_dsn()):
|
if postcodes.can_compute(args.config.get_libpq_dsn()):
|
||||||
@@ -100,7 +98,7 @@ class UpdateRefresh:
|
|||||||
args.project_dir, tokenizer)
|
args.project_dir, tokenizer)
|
||||||
indexer = Indexer(args.config.get_libpq_dsn(), tokenizer,
|
indexer = Indexer(args.config.get_libpq_dsn(), tokenizer,
|
||||||
args.threads or 1)
|
args.threads or 1)
|
||||||
asyncio.run(indexer.index_postcodes())
|
indexer.index_postcodes()
|
||||||
else:
|
else:
|
||||||
LOG.error("The place table doesn't exist. "
|
LOG.error("The place table doesn't exist. "
|
||||||
"Postcode updates on a frozen database is not possible.")
|
"Postcode updates on a frozen database is not possible.")
|
||||||
@@ -112,8 +110,7 @@ class UpdateRefresh:
|
|||||||
|
|
||||||
if args.word_counts:
|
if args.word_counts:
|
||||||
LOG.warning('Recompute word statistics')
|
LOG.warning('Recompute word statistics')
|
||||||
self._get_tokenizer(args.config).update_statistics(args.config,
|
self._get_tokenizer(args.config).update_statistics()
|
||||||
threads=args.threads or 1)
|
|
||||||
|
|
||||||
if args.address_levels:
|
if args.address_levels:
|
||||||
LOG.warning('Updating address levels')
|
LOG.warning('Updating address levels')
|
||||||
@@ -125,34 +122,32 @@ class UpdateRefresh:
|
|||||||
with connect(args.config.get_libpq_dsn()) as conn:
|
with connect(args.config.get_libpq_dsn()) as conn:
|
||||||
# If the table did not exist before, then the importance code
|
# If the table did not exist before, then the importance code
|
||||||
# needs to be enabled.
|
# needs to be enabled.
|
||||||
if not table_exists(conn, 'secondary_importance'):
|
if not conn.table_exists('secondary_importance'):
|
||||||
args.functions = True
|
args.functions = True
|
||||||
|
|
||||||
LOG.warning('Import secondary importance raster data from %s', args.project_dir)
|
LOG.warning('Import secondary importance raster data from %s', args.project_dir)
|
||||||
if refresh.import_secondary_importance(args.config.get_libpq_dsn(),
|
if refresh.import_secondary_importance(args.config.get_libpq_dsn(),
|
||||||
args.project_dir) > 0:
|
args.project_dir) > 0:
|
||||||
LOG.fatal('FATAL: Cannot update secondary importance raster data')
|
LOG.fatal('FATAL: Cannot update sendary importance raster data')
|
||||||
return 1
|
return 1
|
||||||
need_function_refresh = True
|
|
||||||
|
|
||||||
if args.wiki_data:
|
if args.functions:
|
||||||
data_path = Path(args.config.WIKIPEDIA_DATA_PATH
|
|
||||||
or args.project_dir)
|
|
||||||
LOG.warning('Import wikipedia article importance from %s', data_path)
|
|
||||||
if refresh.import_wikipedia_articles(args.config.get_libpq_dsn(),
|
|
||||||
data_path) > 0:
|
|
||||||
LOG.fatal('FATAL: Wikipedia importance file not found in %s', data_path)
|
|
||||||
return 1
|
|
||||||
need_function_refresh = True
|
|
||||||
|
|
||||||
if need_function_refresh:
|
|
||||||
LOG.warning('Create functions')
|
LOG.warning('Create functions')
|
||||||
with connect(args.config.get_libpq_dsn()) as conn:
|
with connect(args.config.get_libpq_dsn()) as conn:
|
||||||
refresh.create_functions(conn, args.config,
|
refresh.create_functions(conn, args.config,
|
||||||
args.diffs, args.enable_debug_statements)
|
args.diffs, args.enable_debug_statements)
|
||||||
self._get_tokenizer(args.config).update_sql_functions(args.config)
|
self._get_tokenizer(args.config).update_sql_functions(args.config)
|
||||||
|
|
||||||
# Attention: importance MUST come after wiki data import and after functions.
|
if args.wiki_data:
|
||||||
|
data_path = Path(args.config.WIKIPEDIA_DATA_PATH
|
||||||
|
or args.project_dir)
|
||||||
|
LOG.warning('Import wikipdia article importance from %s', data_path)
|
||||||
|
if refresh.import_wikipedia_articles(args.config.get_libpq_dsn(),
|
||||||
|
data_path) > 0:
|
||||||
|
LOG.fatal('FATAL: Wikipedia importance dump file not found')
|
||||||
|
return 1
|
||||||
|
|
||||||
|
# Attention: importance MUST come after wiki data import.
|
||||||
if args.importance:
|
if args.importance:
|
||||||
LOG.warning('Update importance values for database')
|
LOG.warning('Update importance values for database')
|
||||||
with connect(args.config.get_libpq_dsn()) as conn:
|
with connect(args.config.get_libpq_dsn()) as conn:
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user