- IF location.type in ('postcode', 'postal_code') THEN
- postcode_isaddress := false;
- IF location.osm_type != 'R' THEN
- location.isaddress := FALSE;
+ IF location.type in ('postcode', 'postal_code')
+ AND searchpostcode is not null
+ THEN
+ -- If the place had a postcode assigned, take this one only
+ -- into consideration when it is an area and the place does not have
+ -- a postcode itself.
+ IF location.fromarea AND not postcode_isexact AND location.isaddress THEN
+ searchpostcode := null; -- remove the less exact postcode
+ ELSE
+ location.isaddress := false;