]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 15 Dec 2013 23:06:58 +0000 (00:06 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Sun, 15 Dec 2013 23:06:58 +0000 (00:06 +0100)
1  2 
sql/functions.sql

diff --combined sql/functions.sql
index fcd895646c3ffcefc9404e0937d60f3fdab4a220,1883d99867f08008c103a48c92793bfccd24ef6c..acaa6d838e411858314d1bf4bdcbd3ba3478eea5
@@@ -937,11 -937,6 +937,11 @@@ DECLAR
  BEGIN
    --DEBUG: RAISE WARNING '% %',NEW.osm_type,NEW.osm_id;
  
 +  -- remove operator tag for most places, messes too much with search_name indexes
 +  IF NEW.class not in ('amenity', 'shop') THEN
 +    NEW.name := delete(NEW.name, 'operator');
 +  END IF;
 +
    -- just block these
    IF NEW.class in ('landuse','natural') and NEW.name is null THEN
  --    RAISE WARNING 'empty landuse %',NEW.osm_id;
@@@ -1362,26 -1357,13 +1362,26 @@@ BEGI
      NEW.centroid := null;
  
      -- reclaculate country and partition
 -    IF NEW.rank_search >= 4 THEN
 -      --NEW.calculated_country_code := lower(get_country_code(NEW.geometry, NEW.country_code));
 -      NEW.calculated_country_code := lower(get_country_code(place_centroid));
 +    IF NEW.rank_search = 4 THEN
 +      -- for countries, believe the mapped country code,
 +      -- so that we remain in the right partition if the boundaries
 +      -- suddenly expand.
 +      NEW.partition := get_partition(place_centroid, lower(NEW.country_code));
 +      IF NEW.partition = 0 THEN
 +        NEW.calculated_country_code := lower(get_country_code(place_centroid));
 +        NEW.partition := get_partition(place_centroid, NEW.calculated_country_code);
 +      ELSE
 +        NEW.calculated_country_code := lower(NEW.country_code);
 +      END IF;
      ELSE
 -      NEW.calculated_country_code := NULL;
 +      IF NEW.rank_search > 4 THEN
 +        --NEW.calculated_country_code := lower(get_country_code(NEW.geometry, NEW.country_code));
 +        NEW.calculated_country_code := lower(get_country_code(place_centroid));
 +      ELSE
 +        NEW.calculated_country_code := NULL;
 +      END IF;
 +      NEW.partition := get_partition(place_centroid, NEW.calculated_country_code);
      END IF;
 -    NEW.partition := get_partition(place_centroid, NEW.calculated_country_code);
      NEW.geometry_sector := geometry_sector(NEW.partition, place_centroid);
  
      -- Adding ourselves to the list simplifies address calculations later
@@@ -2061,11 -2043,6 +2061,11 @@@ BEGI
      --DEBUG: RAISE WARNING '%', existingplacex;
    END IF;
  
 +  -- remove operator tag for most places, messes too much with search_name indexes
 +  IF NEW.class not in ('amenity', 'shop') THEN
 +    NEW.name := delete(NEW.name, 'operator');
 +  END IF;
 +
    -- Just block these - lots and pointless
    IF NEW.class in ('landuse','natural') and NEW.name is null THEN
      RETURN null;
  
    END IF;
  
 +  -- refuse to update multiplpoygons with too many objects, too much of a performance hit
 +  IF ST_NumGeometries(NEW.geometry) > 2000 THEN
 +    RAISE WARNING 'Dropping update of % % because of geometry complexity.', NEW.osm_type, NEW.osm_id;
 +    RETURN NULL;
 +  END IF;
 +
    IF coalesce(existing.name::text, '') != coalesce(NEW.name::text, '')
       OR coalesce(existing.extratags::text, '') != coalesce(NEW.extratags::text, '')
       OR coalesce(existing.housenumber, '') != coalesce(NEW.housenumber, '')
@@@ -2510,7 -2481,7 +2510,7 @@@ BEGI
        CASE WHEN class = 'place' and type = 'postcode' THEN hstore('name', postcode) ELSE name END as name,
        class, type, admin_level, fromarea, isaddress,
        CASE WHEN address_place_id = for_place_id AND rank_address = 0 THEN 100 WHEN rank_address = 11 THEN 5 ELSE rank_address END as rank_address,
-       distance,calculated_country_code
+       distance,calculated_country_code,postcode
        from place_addressline join placex on (address_place_id = placex.place_id) 
        where place_addressline.place_id = for_place_id 
        and (cached_rank_address > 0 AND cached_rank_address < searchrankaddress)
      IF searchpostcode IS NOT NULL and location.type = 'postcode' THEN
        location.isaddress := FALSE;
      END IF;
+     IF searchpostcode IS NULL and location.isaddress and location.type != 'postcode' and location.postcode IS NOT NULL THEN
+       searchpostcode := location.postcode;
+     END IF;
      IF location.rank_address = 4 AND location.isaddress THEN
        hadcountry := true;
      END IF;