]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge branch 'master' of http://github.com/twain47/Nominatim
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 26 Aug 2012 06:02:50 +0000 (08:02 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sun, 26 Aug 2012 06:02:50 +0000 (08:02 +0200)
1  2 
utils/setup.php
website/search.php

diff --combined utils/setup.php
index fb83dd0aa9fbc02aad2ed0c07075917f940395a5,1db725c466f23b8c826069d2a662cc021ea9d5a6..8e3d1cb5fc108c49cd59f2363c49a3bc5c2a23ef
  
        $bDidSomething = false;
  
+       // Check if osm-file is set and points to a valid file if --all or --import-data is given
+       if ($aCMDResult['import-data'] || $aCMDResult['all'])
+       {
+               if (!isset($aCMDResult['osm-file']))
+               {
+                       fail('missing --osm-file for data import');
+               }
+               if (!file_exists($aCMDResult['osm-file']))
+               {
+                       fail('the path supplied to --osm-file does not exist');
+               }
+               if (!is_readable($aCMDResult['osm-file']))
+               {
+                       fail('osm-file "'.$aCMDResult['osm-file'].'" not readable');
+               }
+       }
        // This is a pretty hard core default - the number of processors in the box - 1
        $iInstances = isset($aCMDResult['threads'])?$aCMDResult['threads']:(getProcessorCount()-1);
        if ($iInstances < 1)
                passthru('createdb -E UTF-8 '.$aDSNInfo['database']);
        }
  
-       if ($aCMDResult['create-db'] || $aCMDResult['all'])
+       if ($aCMDResult['setup-db'] || $aCMDResult['all'])
        {
-               echo "Create DB (2)\n";
+               echo "Setup DB\n";
                $bDidSomething = true;
                // TODO: path detection, detection memory, etc.
  
                        echo "Please download and build osm2pgsql.\nIf it is already installed, check the path in your local settings (settings/local.php) file.\n";
                        fail("osm2pgsql not found in '$osm2pgsql'");
                }
 +              $osm2pgsql .= ' --tablespace-slim-index ssd --tablespace-main-index ssd --tablespace-main-data ssd --tablespace-slim-data data';
                $osm2pgsql .= ' -lsc -O gazetteer --hstore';
 -              $osm2pgsql .= ' -C '.$iCacheMemory;
 +              $osm2pgsql .= ' -C 16000';
                $osm2pgsql .= ' -d '.$aDSNInfo['database'].' '.$aCMDResult['osm-file'];
                passthruCheckReturn($osm2pgsql);
  
                        echo '.';
                }
                echo "\n";
 +              pgsqlRunScript('ALTER TABLE place SET TABLESPACE "data"');
                echo "Reanalysing database...\n";
                pgsqlRunScript('ANALYSE');
        }
diff --combined website/search.php
index a337e1ef0e7a6d069d8a99f22ac7ca2ff2ed35ad,60df370d4ea6842e42fea75628c8c9f233aa6310..27d31fa24a62589f307ec63f2bf213150213fc00
                        // Check which tokens we have, get the ID numbers                       
                        $sSQL = 'select word_id,word_token, word, class, type, location, country_code, operator';
                        $sSQL .= ' from word where word_token in ('.join(',',array_map("getDBQuoted",$aTokens)).')';
 -                      $sSQL .= ' and (class is null or class not in (\'highway\'))';
 +                      // HACK WARNING
 +                      // (mis)using search_name_count to exclude words that return too many
 +                      // search results. saerch_name_count is currently set to 1 by hand
 +                      // because there is no fast way to extract this count from a live database. 
 +                      $sSQL .= ' and search_name_count = 0';
 +//                    $sSQL .= ' and (class is null or class not in (\'highway\'))';
  //                    $sSQL .= ' group by word_token, word, class, type, location, country_code';
  
                        if (CONST_Debug) var_Dump($sSQL);
                                                                        $sSQL .= " limit ".$iLimit;
  
                                                                if (CONST_Debug) var_dump($sSQL);
 +                                                              $iStartTime = time();
                                                                $aViewBoxPlaceIDs = $oDB->getAll($sSQL);
                                                                if (PEAR::IsError($aViewBoxPlaceIDs))
                                                                {
                                                                        failInternalError("Could not get places for search terms.", $sSQL, $aViewBoxPlaceIDs);
                                                                }
 +                                                              if (time() - $iStartTime > 60) {
 +                                                                      file_put_contents(CONST_BasePath.'/log/long_queries.log', date('Y-m-d H:i:s', $iStartTime).' '.$sSQL."\n", FILE_APPEND);
 +                                                              }
 +
  //var_dump($aViewBoxPlaceIDs);
                                                                // Did we have an viewbox matches?
                                                                $aPlaceIDs = array();
                {
                        if (stripos($sAddress, $sWord)!==false) $iCountWords++;
                }
-               $aResult['importance'] = $aResult['importance'] + $iCountWords;
+               $aResult['importance'] = $aResult['importance'] + ($iCountWords*0.1); // 0.1 is a completely arbitrary number but something in the range 0.1 to 0.5 would seem right
  
  //if (CONST_Debug) var_dump($aResult['class'].':'.$aResult['type'].':'.$aResult['admin_level']);
  /*