Skip to content

Commit fe0ade8

Browse files
committed
docs: improve contents listing
1 parent f52212a commit fe0ade8

File tree

5 files changed

+50
-14
lines changed

5 files changed

+50
-14
lines changed

docs/api/Overview.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
### Nominatim API
2-
31
!!! Attention
42
The current version of Nominatim implements two different search frontends:
53
the old PHP frontend and the new Python frontend. They have a very similar

docs/library/Configuration.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Configuration
22

33
When using Nominatim through the library, it can be configured in exactly
4-
the same way as when running as a service. This means that you should have
5-
created a [project directory](../admin/Import.md#creating-the-project-directory)
6-
which contains all files belonging to the Nominatim instance. It can also contain
7-
an `.env` file with configuration options. Setting configuration parameters
8-
via environment variables works as well.
4+
the same way as when running as a service. You may instantiate the library
5+
against the [project directory](../admin/Import.md#creating-the-project-directory)
6+
of your Nominatim installation. It contains all files belonging to the
7+
Nominatim instance. This may include an `.env` file with configuration options.
8+
Setting configuration parameters via environment variables works as well.
9+
Alternatively to using the operating system's environment, a set of
10+
configuration parameters may also be passed to the Nomiantim API object.
911

1012
Configuration options are resolved in the following order:
1113

docs/library/Getting-Started.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ To install the package from the source tree directly, run:
3434

3535
Usually you would want to run this in a virtual environment.
3636

37-
### A simple search example
37+
## A simple search example
3838

3939
To query the Nominatim database you need to first set up a connection. This
4040
is done by creating an Nominatim API object. This object exposes all the
@@ -88,7 +88,7 @@ implementations. The documentation itself will usually refer only to
8888
available only for the synchronous or asynchronous version, this will be
8989
explicitly mentioned.
9090

91-
### Defining which database to use
91+
## Defining which database to use
9292

9393
The [Configuration](../admin/Import.md#configuration-setup-in-env)
9494
section explains how Nominatim is configured using the
@@ -103,7 +103,41 @@ have normally created a [project directory](../admin/Import.md#creating-the-proj
103103
which stores the various configuration and customization files that Nominatim
104104
needs. You may pass the location of the project directory to your
105105
'Nominatim API class' constructor and it will read the .env file in the
106-
directory and set the configuration accordingly.
106+
directory and set the configuration accordingly. Here is the simple search
107+
example, using the configuration from a pre-defined project directory in
108+
`/srv/nominatim-project`:
109+
110+
!!! example
111+
=== "NominatimAPIAsync"
112+
``` python
113+
import asyncio
114+
115+
import nominatim_api as napi
116+
117+
async def search(query):
118+
async with napi.NominatimAPIAsync('/srv/nominatim-project') as api:
119+
return await api.search(query)
120+
121+
results = asyncio.run(search('Brugge'))
122+
if not results:
123+
print('Cannot find Brugge')
124+
else:
125+
print(f'Found a place at {results[0].centroid.x},{results[0].centroid.y}')
126+
```
127+
128+
=== "NominatimAPI"
129+
``` python
130+
import nominatim_api as napi
131+
132+
with napi.NominatimAPI('/srv/nominatim-project') as api:
133+
results = api.search('Brugge')
134+
135+
if not results:
136+
print('Cannot find Brugge')
137+
else:
138+
print(f'Found a place at {results[0].centroid.x},{results[0].centroid.y}')
139+
```
140+
107141

108142
You may also configure Nominatim by setting environment variables.
109143
Normally Nominatim will check the operating system environment. Lets
@@ -148,9 +182,10 @@ like this:
148182
```
149183

150184
When the `environ` parameter is given, then only configuration variables
151-
from this dictionary will be used.
185+
from this dictionary will be used. The operating system's environment
186+
variables will be ignored.
152187

153-
### Presenting results to humans
188+
## Presenting results to humans
154189

155190
All search functions return full result objects from the database. Such a
156191
result object contains lots of details: names, address information, OSM tags etc.

docs/library/Low-Level-DB-Access.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ the placex table:
2424

2525
```
2626
import asyncio
27-
from pathlib import Path
2827
import sqlalchemy as sa
2928
from nominatim_api import NominatimAPIAsync
3029
3130
async def print_table_size():
32-
api = NominatimAPIAsync(Path('.'))
31+
api = NominatimAPIAsync()
3332
3433
async with api.begin() as conn:
3534
cnt = await conn.scalar(sa.select(sa.func.count()).select_from(conn.t.placex))

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ theme:
44
name: material
55
features:
66
- navigation.tabs
7+
- toc.integrate
78
plugins:
89
- privacy
910
copyright: Copyright © Nominatim developer community
@@ -71,6 +72,7 @@ markdown_extensions:
7172
alternate_style: true
7273
- def_list
7374
- toc:
75+
toc_depth: 4
7476
permalink: 🔗
7577
extra_css: [extra.css, styles.css]
7678
exclude_docs: |

0 commit comments

Comments
 (0)