Reorganise handling of country names imported from OSM #2614
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Country names are special for Nominatim because they are their own kind of token. A basic set of country names comes from the static [data/country_name.sql] file. Additional names are imported from
boundary=administrative
relations withadmin_level=4
. The problem here is that the OSM names are only added to the word token table but never deleted. It's usually fine because these names rarely change. But when they are changed to something bogus, the wrong name stays in the database forever.This PR introduces a clear separation between internal and imported names.
country_name
gets an extra field to save the names from OSM. Both name sets are then mixed on the fly when formatting output. The internal names are also marked in the word token table. Whenever changes to the OSM boundaries come in, only the tokens not marked are updated. This allows to delete the ones that are no longer in the OSM relation.As an additional precaution against editing mistakes, only the largest relation of a certain country can contribute country names.
Fixes #2611.