Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul osm2pgsql style #3615

Merged
merged 17 commits into from
Dec 16, 2024
Merged

Conversation

lonvia
Copy link
Member

@lonvia lonvia commented Dec 16, 2024

This started out as a simple task to make the Nominatim osm2pgsql import style compatible with osm2pgsql-themepark and ended up to be a complete refresh of the style implementation.

The philosophy of the configuration script stays largely the same but there are some significant changes in the implementation:

  • The actual tag configuration, which was previously directly in the style files, has been moved to preset snippets. The style files just apply the appropriate presets. This removes a lot of configuration duplication and makes it easier for you to reuse parts of the default configuration in your own scripts.
  • The functions for setting the various tag types now have companion functions to modify an already existing configuration. This was necessary to make the preset snippets work but also means that you can now base your own style on an existing one and just modify the bits you don't like. You don't need to manual keep your configuration up to date with the default one anymore.
  • The prefilter settings (delete tags or move them to extratags) have been merged with the main tag setting. These two settings have always been mutually exclusive. In fact, prefiltering was implicitly used to exclude some values for a certain key. The new delete and extra main tag settings, make the exclusion more explicit.
  • The main tag types now translate to functions which do the final formatting/filtering of an entry before it is added to the database. That is about 20% faster than the nested if conditions we had before. It also has the added bonus that it is now possible to further customize at this point and do much more complex checks and transformations.

The changes are mostly backwards compatible, i.e. your custom styles should still work as before. The only exception is customization of the process_tags() function. This function is no longer considered public and neither are the helper functions used in it. They currently still work but will be removed at some point.

Finally, the actual goal, running under themepark, is now possible as well. Nominatim will export the appropriate variables to ensure that the theme is found. Using themepark it becomes easy to run Nominatim alongside other projects like openstreetmap-carto in the same database. I will update the cookbook after the next release.

This change also includes some improvements to the style which are now possible because of the new structure:

  • exclude highway=footway when they are sidewalks and crossings
  • use information=* for the class/type for tourism=information objects, when available
  • use water=* for the class/type for natural=water when available and exclude water areas for rivers, streams and the like where there is already a waterway
  • support for lock_name (closes Support for key "lock_name" #3365)
  • do not import names when falling back to importing the address only (closes Unexpected objects in search results for a building address #3603)
  • exclude unnamed swimming pools (most of those are private)

This already allows to run Nominatim under themepark, currently
as a topic-less theme.
Defining a tag as deleteable/extratag and main tag is mutually exclusive
and deleting certain key/value combinations to exclude them from being
used as a main tag is confusing. By merging the handling, such
excludes can now be made explicit in the main list.

By using the same lookup table, it is now also possible to have a
short-cut for uninteresting objects.
Now implemented as a simple filter function which can also be
customized by the user.
Introduces presets which avoid much of the previous configuration
duplication. The original import files are now thin wrappers around
the themepark themes.
These footways are part of a street that is usually already named.
If an object doesn't have a useable main tag, then the names should
always be ignored, independently of the presence of housenumbers.
We have to assume that the name belongs to a feature that was
intentionally filtered out.
Publicly accessible ones are usually mapped as the bigger area
with the water park.
@lonvia lonvia merged commit 9058dab into osm-search:master Dec 16, 2024
6 of 8 checks passed
@lonvia lonvia deleted the overhaul-osm2pgsql-style branch December 16, 2024 18:13
@lonvia
Copy link
Member Author

lonvia commented Dec 16, 2024

CI failures are due to OSM outage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected objects in search results for a building address Support for key "lock_name"
1 participant