]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 23 Apr 2017 11:35:12 +0000 (13:35 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sun, 23 Apr 2017 11:35:12 +0000 (13:35 +0200)
1  2 
sql/functions.sql
utils/update.php

diff --combined sql/functions.sql
index 1c39c1fc173cb57bb12ebc34a7eb3039f180f1cb,7b36ac50fec2c44679cc32fcaf616d165079fefc..e6e51a25aac2eea7525c19d75f9e8d274ec623b2
@@@ -1246,7 -1246,8 +1246,8 @@@ BEGI
    END IF;
  
    -- Adding ourselves to the list simplifies address calculations later
-   INSERT INTO place_addressline VALUES (NEW.place_id, NEW.place_id, true, true, 0, NEW.rank_address); 
+   INSERT INTO place_addressline (place_id, address_place_id, fromarea, isaddress, distance, cached_rank_address)
+     VALUES (NEW.place_id, NEW.place_id, true, true, 0, NEW.rank_address); 
  
    -- What level are we searching from
    search_maxrank := NEW.rank_search;
        IF location.rank_search > 4 THEN
            nameaddress_vector := array_merge(nameaddress_vector, location.keywords::integer[]);
        END IF;
-       INSERT INTO place_addressline VALUES (NEW.place_id, location.place_id, true, location_isaddress, location.distance, location.rank_address);
+       INSERT INTO place_addressline (place_id, address_place_id, fromarea, isaddress, distance, cached_rank_address)
+         VALUES (NEW.place_id, location.place_id, true, location_isaddress, location.distance, location.rank_address);
  
        IF location_isaddress THEN
  
  
            IF location.rank_search > 4 THEN
                nameaddress_vector := array_merge(nameaddress_vector, location.keywords::integer[]);
-               INSERT INTO place_addressline VALUES (NEW.place_id, location.place_id, false, NOT address_havelevel[location.rank_address], location.distance, location.rank_address);
+               INSERT INTO place_addressline (place_id, address_place_id, fromarea, isaddress, distance, cached_rank_address)
+                 VALUES (NEW.place_id, location.place_id, false, NOT address_havelevel[location.rank_address], location.distance, location.rank_address);
                address_havelevel[location.rank_address] := true;
  
                IF location.rank_address > parent_place_id_rank THEN
  
          -- Add it to the list of search terms
          nameaddress_vector := array_merge(nameaddress_vector, location.keywords::integer[]);
-         INSERT INTO place_addressline VALUES (NEW.place_id, location.place_id, true, false, location.distance, location.rank_address); 
+         INSERT INTO place_addressline (place_id, address_place_id, fromarea, isaddress, distance, cached_rank_address)
+           VALUES (NEW.place_id, location.place_id, true, false, location.distance, location.rank_address); 
  
        END IF;
  
@@@ -1912,7 -1916,7 +1916,7 @@@ BEGI
    IF st_area(OLD.geometry) > 2 and st_isvalid(OLD.geometry) THEN
      SELECT bool_or(not (rank_address = 0 or rank_address > 26)) as ranked FROM placex WHERE osm_type = OLD.osm_type and osm_id = OLD.osm_id and class = OLD.class and type = OLD.type INTO has_rank;
      IF has_rank THEN
-       insert into import_polygon_delete values (OLD.osm_type,OLD.osm_id,OLD.class,OLD.type);
+       insert into import_polygon_delete (osm_type, osm_id, class, type) values (OLD.osm_type,OLD.osm_id,OLD.class,OLD.type);
        RETURN NULL;
      END IF;
    END IF;
@@@ -1948,9 -1952,8 +1952,8 @@@ BEGI
    --DEBUG: RAISE WARNING 'place_insert: % % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type,st_area(NEW.geometry);
    -- filter wrong tupels
    IF ST_IsEmpty(NEW.geometry) OR NOT ST_IsValid(NEW.geometry) OR ST_X(ST_Centroid(NEW.geometry))::text in ('NaN','Infinity','-Infinity') OR ST_Y(ST_Centroid(NEW.geometry))::text in ('NaN','Infinity','-Infinity') THEN  
-     INSERT INTO import_polygon_error values (NEW.osm_type, NEW.osm_id, NEW.class, NEW.type,
-                                              NEW.name, NEW.address->'country',
-       now(), ST_IsValidReason(NEW.geometry), null, NEW.geometry);
+     INSERT INTO import_polygon_error (osm_type, osm_id, class, type, name, country_code, updated, errormessage, prevgeometry, newgeometry)
+       VALUES (NEW.osm_type, NEW.osm_id, NEW.class, NEW.type, NEW.name, NEW.address->'country', now(), ST_IsValidReason(NEW.geometry), null, NEW.geometry);
  --    RAISE WARNING 'Invalid Geometry: % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type;
      RETURN null;
    END IF;
        AND ST_GeometryType(NEW.geometry) in ('ST_Polygon','ST_MultiPolygon')
        AND st_area(NEW.geometry) < st_area(existing.geometry)*0.5
        THEN
-       INSERT INTO import_polygon_error values (NEW.osm_type, NEW.osm_id, NEW.class, NEW.type, NEW.name, NEW.country_code, now(), 
+       INSERT INTO import_polygon_error (osm_type, osm_id, class, type, name, country_code, updated, errormessage, prevgeometry, newgeometry)
+         VALUES (NEW.osm_type, NEW.osm_id, NEW.class, NEW.type, NEW.name, NEW.country_code, now(), 
          'Area reduced from '||st_area(existing.geometry)||' to '||st_area(NEW.geometry), existing.geometry, NEW.geometry);
        RETURN null;
      END IF;
@@@ -2370,7 -2374,7 +2374,7 @@@ BEGI
        CASE WHEN class = 'place' and type = 'postcode' THEN hstore('name', postcode) ELSE name END as name,
        CASE WHEN extratags ? 'place' THEN 'place' ELSE class END as class,
        CASE WHEN extratags ? 'place' THEN extratags->'place' ELSE type END as type,
 -      admin_level, fromarea, isaddress,
 +      admin_level, fromarea, isaddress and linked_place_id is NULL as 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,country_code,postcode
        from place_addressline join placex on (address_place_id = placex.place_id) 
diff --combined utils/update.php
index 8137584c71cc2540504fa5755eb11608ff8fe6cb,d8ac134add94d52c2894a59a1e59569f2296750f..475e583690e9e71a8585322630181433c9c999ab
@@@ -156,16 -156,25 +156,25 @@@ if ($bHaveDiff) 
  }
  
  if ($aResult['deduplicate']) {
-     //
-     if (getPostgresVersion() < 9.3) {
+     $oDB =& getDB();
+     if (getPostgresVersion($oDB) < 9.3) {
          fail("ERROR: deduplicate is only currently supported in postgresql 9.3");
      }
  
-     $oDB =& getDB();
      $sSQL = 'select partition from country_name order by country_code';
      $aPartitions = chksql($oDB->getCol($sSQL));
      $aPartitions[] = 0;
  
+     // we don't care about empty search_name_* artitions, they can't contain mentions of duplicates
+     foreach ($aPartitions as $i => $sPartition) {
+         $sSQL = "select count(*) from search_name_".$sPartition;
+         $nEntries = chksql($oDB->getOne($sSQL));
+         if ($nEntries == 0) {
+             unset($aPartitions[$i]);
+         }
+     }
      $sSQL = "select word_token,count(*) from word where substr(word_token, 1, 1) = ' '";
      $sSQL .= " and class is null and type is null and country_code is null";
      $sSQL .= " group by word_token having count(*) > 1 order by word_token";
@@@ -298,15 -307,6 +307,15 @@@ if ($aResult['import-osmosis'] || $aRes
  
          // Index file
          $sThisIndexCmd = $sCMDIndex;
 +        if (!isset($aResult['index-instances'])) {
 +            if (getLoadAverage() < 24)
 +                $iIndexInstances = 2;
 +            else
 +                $iIndexInstances = 1;
 +        } else
 +            $iIndexInstances = $aResult['index-instances'];
 +
 +        $sThisIndexCmd = $sCMDIndex.' -t '.$iIndexInstances;
          $fCMDStartTime = time();
  
          if (!$aResult['no-index']) {