4 require_once(dirname(dirname(__FILE__)).'/lib/init-cmd.php');
5 ini_set('memory_limit', '800M');
8 "Create and setup nominatim search system",
9 array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
10 array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
11 array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
13 array('parse-tiger', '', 0, 1, 1, 1, 'realpath', 'Convert tigger edge files to nominatim sql import'),
15 getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
17 $bDidSomething = false;
19 if (isset($aCMDResult['parse-tiger']))
21 $sTempDir = tempnam('/tmp', 'tiger');
25 foreach(glob($aCMDResult['parse-tiger'].'/??_*', GLOB_ONLYDIR) as $sStateFolder)
27 foreach(glob($sStateFolder.'/?????_*', GLOB_ONLYDIR) as $sCountyFolder)
29 preg_match('#([0-9]{5})_(.*)#',basename($sCountyFolder), $aMatch);
30 $sCountyID = $aMatch[1];
31 $sCountyName = str_replace('_', ' ', $aMatch[2]);
32 $sImportFile = $sCountyFolder.'/tl_2009_'.$sCountyID.'_edges.zip';
33 if (!file_exists($sImportFile))
35 echo "Missing: $sImportFile\n";
37 $sUnzipCmd = "unzip -d $sTempDir $sImportFile";