more tiger import code

This commit is contained in:
Brian Quinion
2010-11-16 13:24:52 +00:00
parent d4625e7741
commit 1663dd49a4
2 changed files with 47 additions and 4 deletions

43
utils/imports.php Executable file
View File

@@ -0,0 +1,43 @@
#!/usr/bin/php -Cq
<?php
require_once(dirname(dirname(__FILE__)).'/lib/init-cmd.php');
ini_set('memory_limit', '800M');
$aCMDOptions = array(
"Create and setup nominatim search system",
array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
array('parse-tiger', '', 0, 1, 1, 1, 'realpath', 'Convert tigger edge files to nominatim sql import'),
);
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
$bDidSomething = false;
if (isset($aCMDResult['parse-tiger']))
{
$sTempDir = tempnam('/tmp', 'tiger');
unlink($sTempDir);
mkdir($sTempDir);
foreach(glob($aCMDResult['parse-tiger'].'/??_*', GLOB_ONLYDIR) as $sStateFolder)
{
foreach(glob($sStateFolder.'/?????_*', GLOB_ONLYDIR) as $sCountyFolder)
{
preg_match('#([0-9]{5})_(.*)#',basename($sCountyFolder), $aMatch);
$sCountyID = $aMatch[1];
$sCountyName = str_replace('_', ' ', $aMatch[2]);
$sImportFile = $sCountyFolder.'/tl_2009_'.$sCountyID.'_edges.zip';
if (!file_exists($sImportFile))
{
echo "Missing: $sImportFile\n";
}
$sUnzipCmd = "unzip -d $sTempDir $sImportFile";
var_dump($sUnzipCmd);
exit;
// exec($sUnzipCmd);
}
}
}

View File

@@ -996,7 +996,7 @@ county_fips = {
'19135' : 'Monroe, IA' , '19135' : 'Monroe, IA' ,
'19137' : 'Montgomery, IA' , '19137' : 'Montgomery, IA' ,
'19139' : 'Muscatine, IA' , '19139' : 'Muscatine, IA' ,
'19141' : 'O'Brien, IA' , '19141' : 'O\'Brien, IA' ,
'19143' : 'Osceola, IA' , '19143' : 'Osceola, IA' ,
'19145' : 'Page, IA' , '19145' : 'Page, IA' ,
'19147' : 'Palo Alto, IA' , '19147' : 'Palo Alto, IA' ,
@@ -1350,9 +1350,9 @@ county_fips = {
'24027' : 'Howard, MD' , '24027' : 'Howard, MD' ,
'24029' : 'Kent, MD' , '24029' : 'Kent, MD' ,
'24031' : 'Montgomery, MD' , '24031' : 'Montgomery, MD' ,
'24033' : 'Prince George's, MD' , '24033' : 'Prince George\'s, MD' ,
'24035' : 'Queen Anne's, MD' , '24035' : 'Queen Anne\'s, MD' ,
'24037' : 'St. Mary's, MD' , '24037' : 'St. Mary\'s, MD' ,
'24039' : 'Somerset, MD' , '24039' : 'Somerset, MD' ,
'24041' : 'Talbot, MD' , '24041' : 'Talbot, MD' ,
'24043' : 'Washington, MD' , '24043' : 'Washington, MD' ,