4         require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
 
   5         require_once(CONST_BasePath.'/lib/init-cmd.php');
 
   6         ini_set('memory_limit', '800M');
 
   9                 "Tools to warm nominatim db",
 
  10                 array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
 
  11                 array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
 
  12                 array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
 
  13                 array('reverse-only', '', 0, 1, 0, 0, 'bool', 'Warm reverse only'),
 
  14                 array('search-only', '', 0, 1, 0, 0, 'bool', 'Warm reverse only'),
 
  16         getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true);
 
  18         require_once(CONST_BasePath.'/lib/log.php');
 
  19         require_once(CONST_BasePath.'/lib/Geocode.php');
 
  20         require_once(CONST_BasePath.'/lib/PlaceLookup.php');
 
  21         require_once(CONST_BasePath.'/lib/ReverseGeocode.php');
 
  25         $bVerbose = $aResult['verbose'];
 
  27         if (!$aResult['search-only']) {
 
  29                 $oReverseGeocode = new ReverseGeocode($oDB);
 
  30                 $oReverseGeocode->setZoom(20);
 
  31                 $oPlaceLookup = new PlaceLookup($oDB);
 
  32                 $oPlaceLookup->setIncludeAddressDetails(true);
 
  33                 $oPlaceLookup->setLanguagePreference(array('en'));
 
  35                 echo "Warm reverse: ";
 
  36                 if ($bVerbose) echo "\n";
 
  37                 for($i = 0; $i < 1000; $i++) {
 
  38                         $fLat = rand(-9000, 9000) / 100;
 
  39                         $fLon = rand(-18000, 18000) / 100;
 
  40                         if ($bVerbose) echo "$fLat, $fLon = ";
 
  41                         $aLookup = $oReverseGeocode->lookup($fLat, $fLon);
 
  42                         if ($aLookup && $aLookup['place_id'])
 
  44                                 $aDetails = $oPlaceLookup->lookup((int)$aLookup['place_id'],
 
  45                                                                   $aLookup['type'], $aLookup['fraction']);
 
  46                                 if ($bVerbose) echo $aDetails['langaddress']."\n";
 
  53         if (!$aResult['reverse-only']) {
 
  55                 $oGeocode =& new Geocode($oDB);
 
  58                 if ($bVerbose) echo "\n";
 
  59                 $sSQL = 'select word from word where word is not null order by search_name_count desc limit 1000';
 
  60                 foreach($oDB->getCol($sSQL) as $sWord) {
 
  61                         if ($bVerbose) echo "$sWord = ";
 
  62                         $oGeocode->setLanguagePreference(array('en'));
 
  63                         $oGeocode->setQuery($sWord);
 
  64                         $aSearchResults = $oGeocode->lookup();
 
  65                         if ($bVerbose) echo $aSearchResults[0]['langaddress']."\n";