- // Archive for debug?
- unlink($sImportFile);
-
- $sBatchEnd = getosmosistimestamp($sOsmosisConfigDirectory);
-
- // Index file
- $fCMDStartTime = time();
- $iFileID = $oDB->getOne('select nextval(\'file\')');
- if (PEAR::isError($iFileID))
- {
- echo $oDB->getMessage()."\n";
- exit;
- }
- $sFileDir = CONST_BasePath.'/export/diff/';
- $sFileDir .= str_pad(floor($iFileID/1000000), 3, '0', STR_PAD_LEFT);
- $sFileDir .= '/'.str_pad(floor($iFileID/1000) % 1000, 3, '0', STR_PAD_LEFT);
-
- if (!is_dir($sFileDir)) mkdir($sFileDir, 0777, true);
- $sThisIndexCmd = $sCMDIndex;
- $sThisIndexCmd .= $sFileDir;
- $sThisIndexCmd .= '/'.str_pad($iFileID % 1000, 3, '0', STR_PAD_LEFT);
- $sThisIndexCmd .= ".npi.out";
- echo "$sThisIndexCmd\n";
-
- preg_match('#^([0-9]{4})-([0-9]{2})-([0-9]{2})#', $sBatchEnd, $aBatchMatch);
- $sFileDir = CONST_BasePath.'/export/index/';
- $sFileDir .= $aBatchMatch[1].'/'.$aBatchMatch[2];
+ $iFileSize = filesize($sImportFile);
+ $sBatchEnd = getosmosistimestamp($sOsmosisConfigDirectory);
+
+ // Import the file
+ $fCMDStartTime = time();
+ echo $sCMDImport."\n";
+ exec($sCMDImport, $sJunk, $iErrorLevel);
+ if ($iErrorLevel)
+ {
+ echo "Error: $iErrorLevel\n";
+ exit($iErrorLevel);
+ }
+ $sSQL = "INSERT INTO import_osmosis_log values ('$sBatchEnd',$iFileSize,'".date('Y-m-d H:i:s',$fCMDStartTime)."','".date('Y-m-d H:i:s')."','osm2pgsql')";
+ var_Dump($sSQL);
+ $oDB->query($sSQL);
+ echo date('Y-m-d H:i:s')." Completed osm2pgsql step for $sBatchEnd in ".round((time()-$fCMDStartTime)/60,2)." minutes\n";