]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 19 Sep 2013 21:47:27 +0000 (23:47 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 19 Sep 2013 21:47:27 +0000 (23:47 +0200)
1  2 
sql/functions.sql
utils/update.php

diff --combined sql/functions.sql
index ac64defc34e2a3393937eb0b61b272ba86790c3d,5bbaad5b0d60b704dfab41331d2d8df292dbb6bc..818f6ac12d96e5e6a2e8b600014dcff9f82411d6
@@@ -938,10 -938,6 +938,6 @@@ BEGI
    --DEBUG: RAISE WARNING '% %',NEW.osm_type,NEW.osm_id;
  
    -- just block these
-   IF NEW.class = 'highway' and NEW.type in ('turning_circle','traffic_signals','mini_roundabout','noexit','crossing') THEN
- --    RAISE WARNING 'bad highway %',NEW.osm_id;
-     RETURN null;
-   END IF;
    IF NEW.class in ('landuse','natural') and NEW.name is null THEN
  --    RAISE WARNING 'empty landuse %',NEW.osm_id;
      RETURN null;
@@@ -1357,26 -1353,13 +1353,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
@@@ -2057,9 -2040,6 +2053,6 @@@ BEGI
    END IF;
  
    -- Just block these - lots and pointless
-   IF NEW.class = 'highway' and NEW.type in ('turning_circle','traffic_signals','mini_roundabout','noexit','crossing') THEN
-     RETURN null;
-   END IF;
    IF NEW.class in ('landuse','natural') and NEW.name is null THEN
      RETURN null;
    END IF;
    IF existingplacex.osm_type IS NULL THEN
  
      IF existing.osm_type IS NOT NULL THEN
+       -- pathological case caused by the triggerless copy into place during initial import
+       -- force delete even for large areas, it will be reinserted later
+       UPDATE place set geometry = ST_SetSRID(ST_Point(0,0), 4326) where osm_type = NEW.osm_type and osm_id = NEW.osm_id and class = NEW.class and type = NEW.type;
        DELETE from place where osm_type = NEW.osm_type and osm_id = NEW.osm_id and class = NEW.class and type = NEW.type;
      END IF;
  
        country_code = NEW.country_code,
        parent_place_id = null,
        extratags = NEW.extratags,
-       admin_level = NEW.admin_level,
+       admin_level = CASE WHEN NEW.admin_level > 15 THEN 15 ELSE NEW.admin_level END,
        indexed_status = 2,    
        geometry = NEW.geometry
        where place_id = existingplacex.place_id;
diff --combined utils/update.php
index d3c2bc73c89836bd2b778e1cfe20a9544879bf06,ba0a5c2643ec510ac388b8a678f8c7eea80837aa..270850f93b4cec6197db67f4c326b28d4f9ff3c0
@@@ -47,6 -47,7 +47,6 @@@
                showUsage($aCMDOptions, true, 'Select either import of hourly or daily');
        }
  
 -      if (!isset($aResult['index-instances'])) $aResult['index-instances'] = 1;
        if (!isset($aResult['index-rank'])) $aResult['index-rank'] = 0;
  
  /*
  
        if ($aResult['index'])
        {
 +              if (!isset($aResult['index-instances'])) $aResult['index-instances'] = 1;
                passthru(CONST_BasePath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -t '.$aResult['index-instances'].' -r '.$aResult['index-rank']);
        }
  
        if ($aResult['import-osmosis'] || $aResult['import-osmosis-all'])
        {
+               if (strpos(CONST_Replication_Url, 'download.geofabrik.de') !== false && CONST_Replication_Update_Interval < 86400) {
+                       echo "Error: Update interval too low for download.geofabrik.de.  Please check install documentation (http://wiki.openstreetmap.org/wiki/Nominatim/Installation#Updates)\n";
+                       exit;
+               }
                $sImportFile = CONST_BasePath.'/data/osmosischange.osc';
                $sOsmosisCMD = CONST_Osmosis_Binary;
                $sOsmosisConfigDirectory = CONST_BasePath.'/settings';
                $sCMDDownload = $sOsmosisCMD.' --read-replication-interval workingDirectory='.$sOsmosisConfigDirectory.' --simplify-change --write-xml-change '.$sImportFile;
                $sCMDCheckReplicationLag = $sOsmosisCMD.' -q --read-replication-lag workingDirectory='.$sOsmosisConfigDirectory;
                $sCMDImport = $sOsm2pgsqlCmd.' '.$sImportFile;
 -              $sCMDIndex = $sBasePath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -t '.$aResult['index-instances'];
 +              $sCMDIndex = $sBasePath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'];
                if (!$aResult['no-npi']) {
                        $sCMDIndex .= '-F ';
                }
                        $sBatchEnd = getosmosistimestamp($sOsmosisConfigDirectory);
  
                        // Index file
 -                      $sThisIndexCmd = $sCMDIndex;
 +                      if (!isset($aResult['index-instances']))
 +                      {
 +                              if (getLoadAverage() < 15)
 +                                      $iIndexInstances = 2;
 +                              else
 +                                      $iIndexInstances = 1;
 +                      } else
 +                              $iIndexInstances = $aResult['index-instances'];
 +
 +                      $sThisIndexCmd = $sCMDIndex.' -t '.$iIndexInstances;
  
                        if (!$aResult['no-npi'])
                        {
  
                        if ( CONST_Replication_Update_Interval > 60 )
                        {
-                               $iSleep = round(CONST_Replication_Update_Interval*0.8);
+                               $iSleep = max(0,(strtotime($sBatchEnd)+CONST_Replication_Update_Interval-time()));
                        }
                        else
                        {