]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib-sql/functions/placex_triggers.sql
do not assign postcodes to long linear features
[nominatim.git] / lib-sql / functions / placex_triggers.sql
index a8fb9fcc2cf02d3b54541065b280fa6e0d5a7852..295b838eeeb55e6005d34e8be53de5045586446d 100644 (file)
@@ -1230,7 +1230,11 @@ BEGIN
     {% endif %}
   END IF;
 
     {% endif %}
   END IF;
 
-  IF NEW.postcode is null AND NEW.rank_search > 8 THEN
+  IF NEW.postcode is null AND NEW.rank_search > 8
+     AND (NEW.rank_address > 0
+          OR ST_GeometryType(NEW.geometry) not in ('ST_LineString','ST_MultiLineString')
+          OR ST_Length(NEW.geometry) < 0.02)
+  THEN
     NEW.postcode := get_nearest_postcode(NEW.country_code, NEW.geometry);
   END IF;
 
     NEW.postcode := get_nearest_postcode(NEW.country_code, NEW.geometry);
   END IF;