]> git.openstreetmap.org Git - nominatim.git/blobdiff - docs/develop/Postcodes.md
Merge pull request #2197 from lonvia/use-jinja-for-sql-preprocessing
[nominatim.git] / docs / develop / Postcodes.md
index 8b532162abe92e2d3c93bb2348697cf6302009ef..343b8de3d6829ec9138d9e30be5606932e53edc1 100644 (file)
@@ -1,18 +1,21 @@
 # Postcodes in Nominatim
 
-The blog post [Nominatim and Postcodes](https://www.openstreetmap.org/user/lonvia/diary/43143)
-describes the new handling in Nominatim 3.1.
+The blog post
+[Nominatim and Postcodes](https://www.openstreetmap.org/user/lonvia/diary/43143)
+describes the handling implemented since Nominatim 3.1.
 
-Postcode centroids (aka 'calculated postcodes') are generated by looking at all postcodes of
-a country, grouping them and calculating the geometric centroid. There is currently no logic
-to deal with extreme outliers (typos or other mistakes in OSM data). There is also no check
-if a postcodes adhere's to a countries format, e.g. if Swiss postcodes are 4 digits.
+Postcode centroids (aka 'calculated postcodes') are generated by looking at all
+postcodes of a country, grouping them and calculating the geometric centroid.
+There is currently no logic to deal with extreme outliers (typos or other
+mistakes in OSM data). There is also no check if a postcodes adheres to a
+country's format, e.g. if Swiss postcodes are 4 digits.
 
 
 ## Regular updating calculated postcodes
 
-The script to rerun the calculation is `build/utils/update.php --calculate-postcodes` and
-runs once per night on nominatim.openstreetmap.org.
+The script to rerun the calculation is
+`nominatim refresh --postcodes`
+and runs once per night on nominatim.openstreetmap.org.
 
 
 ## Finding places that share a specific postcode
@@ -20,10 +23,12 @@ runs once per night on nominatim.openstreetmap.org.
 In the Nominatim database run
 
 ```sql
-  SELECT osm_type, osm_id, class, type, st_x(centroid) as lon, st_y(centroid) at lat
-  FROM placex 
-  WHERE country_code='fr'
-    AND upper(trim (both ' ' from address->'postcode')) = '33210';
+SELECT address->'postcode' as pc,
+       osm_type, osm_id, class, type,
+       st_x(centroid) as lon, st_y(centroid) as lat
+FROM placex
+WHERE country_code='fr'
+  AND upper(trim (both ' ' from address->'postcode')) = '33210';
 ```
 
 Alternatively on [Overpass](https://overpass-turbo.eu/) run the following query