Skip to content

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 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.

Configuration class🔗

This class wraps access to the configuration settings for the Nominatim instance in use.

All Nominatim configuration options are prefixed with 'NOMINATIM_' to avoid conflicts with other environment variables. All settings can be accessed as properties of the class under the same name as the setting but with the NOMINATIM_ prefix removed. In addition, there are accessor functions that convert the setting values to types other than string.

get_bool(name: str) -> bool 🔗

Return the given configuration parameter as a boolean.

Parameters:

Name Type Description Default
name str

Name of the configuration parameter with the NOMINATIM_ prefix removed.

required

Returns:

Type Description
bool

True for values of '1', 'yes' and 'true', False otherwise.

get_int(name: str) -> int 🔗

Return the given configuration parameter as an int.

Parameters:

Name Type Description Default
name str

Name of the configuration parameter with the NOMINATIM_ prefix removed.

required

Returns:

Type Description
int

The configuration value converted to int.

Raises:

Type Description
ValueError

when the value is not a number.

get_str_list(name: str) -> Optional[List[str]] 🔗

Return the given configuration parameter as a list of strings. The values are assumed to be given as a comma-sparated list and will be stripped before returning them.

Parameters:

Name Type Description Default
name str

Name of the configuration parameter with the NOMINATIM_ prefix removed.

required

Returns:

Type Description
List[str]

The comma-split parameter as a list. The elements are stripped of leading and final spaces before being returned.

None

The configuration parameter was unset or empty.

get_path(name: str) -> Optional[Path] 🔗

Return the given configuration parameter as a Path.

Parameters:

Name Type Description Default
name str

Name of the configuration parameter with the NOMINATIM_ prefix removed.

required

Returns:

Type Description
Path

A Path object of the parameter value. If a relative path is configured, then the function converts this into an absolute path with the project directory as root path.

None

The configuration parameter was unset or empty.