Skip to content

Conversation

@lonvia
Copy link
Member

@lonvia lonvia commented Dec 30, 2025

This PR completely overhauls the handling of postcodes:

  • Postcode areas and postcode fallbacks are now saved in a separate table place_postcode instead of the place table. This allows to get rid of a lot of special handling in the update triggers.
  • The location_postcodes table now collects precise postcode areas (from relations) as well as guessed postcodes from postcode attributes. The placex table no longer contains any postcode areas at all. This allows to remove even more special casing during indexing.
  • Guessed postcodes now have an area that extends as a rectangle around the centroid. The extent of this rectangle can be set on a per-country base in the country settings. The default is 5km. Finding good per-country settings is left for a later PR. Maybe it will be possible to do some statistics over existing postcodes.
  • Postcode recomputation now uses postcode areas as exclusion zones when it comes to computing guessed postcodes: all postcodes for which an area exists are ignored for guessing as well as all postcodes that are inside a postcode area. This hopefully removes a few false positives at the price of computation being a bit more expensive.
  • Updating the postcode table will now cause invalidation of effected entries in the placex table. It remains to be seen how expensive these updates are going to be.

Migration for this change is rather complex. The new postcode table is now called location_postcodes to make it easier to migrate from the old location_postcode without any downtime. Nonetheless it is recommended to put the server offline when doing the migration.

Closes #3882.

@lonvia lonvia merged commit df4abfd into osm-search:master Dec 30, 2025
8 checks passed
@lonvia lonvia deleted the rework-postcode-handling branch December 30, 2025 14:54
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.

German postcode 98704 still in database but no OSM data contains it anymore

1 participant