4 require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
5 require_once(CONST_BasePath.'/lib/init-cmd.php');
6 ini_set('memory_limit', '800M');
10 'Create and setup nominatim search system',
11 array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
12 array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
13 array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
15 array('parse-tiger', '', 0, 1, 1, 1, 'realpath', 'Convert tiger edge files to nominatim sql import - datafiles from 2011 or later (source: edges directory of tiger data)'),
17 getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
20 if (isset($aCMDResult['parse-tiger'])) {
21 if (!file_exists(CONST_Tiger_Data_Path)) mkdir(CONST_Tiger_Data_Path);
23 $sTempDir = tempnam('/tmp', 'tiger');
27 foreach (glob($aCMDResult['parse-tiger'].'/tl_20??_?????_edges.zip', 0) as $sImportFile) {
29 preg_match('#([0-9]{5})_(.*)#', basename($sImportFile), $aMatch);
30 $sCountyID = $aMatch[1];
32 echo 'Processing '.$sCountyID."...\n";
33 $sUnzipCmd = "unzip -d $sTempDir $sImportFile";
36 $sShapeFilename = $sTempDir.'/'.basename($sImportFile, '.zip').'.shp';
37 $sSqlFilenameTmp = $sTempDir.'/'.$sCountyID.'.sql';
38 $sSqlFilename = CONST_Tiger_Data_Path.'/'.$sCountyID.'.sql';
40 if (!file_exists($sShapeFilename)) {
41 echo "Failed unzip ($sImportFile)\n";
43 $sParseCmd = CONST_BasePath.'/utils/tigerAddressImport.py '.$sShapeFilename.' '.$sSqlFilenameTmp;
45 if (!file_exists($sSqlFilenameTmp)) {
46 echo "Failed parse ($sImportFile)\n";
48 copy($sSqlFilenameTmp, $sSqlFilename);
52 foreach (glob($sTempDir.'/*') as $sTmpFile) {