mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
replace double-quoting with single quotes where applicable
This commit is contained in:
@@ -7,7 +7,7 @@ ini_set('memory_limit', '800M');
|
||||
|
||||
$aCMDOptions
|
||||
= array(
|
||||
"Manage service blocks / restrictions",
|
||||
'Manage service blocks / restrictions',
|
||||
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'),
|
||||
@@ -29,8 +29,8 @@ if ($aResult['list']) {
|
||||
|
||||
$aBlocks = getBucketBlocks();
|
||||
echo "\n";
|
||||
printf(" %-40s | %12s | %7s | %13s | %31s | %8s\n", "Key", "Total Blocks", "Current", "Still Blocked", "Last Block Time", "Sleeping");
|
||||
printf(" %'--40s-|-%'-12s-|-%'-7s-|-%'-13s-|-%'-31s-|-%'-8s\n", "", "", "", "", "", "");
|
||||
printf(" %-40s | %12s | %7s | %13s | %31s | %8s\n", 'Key', 'Total Blocks', 'Current', 'Still Blocked', 'Last Block Time', 'Sleeping');
|
||||
printf(" %'--40s-|-%'-12s-|-%'-7s-|-%'-13s-|-%'-31s-|-%'-8s\n", '', '', '', '', '', '');
|
||||
foreach ($aBlocks as $sKey => $aDetails) {
|
||||
printf(
|
||||
" %-40s | %12s | %7s | %13s | %31s | %8s\n",
|
||||
@@ -38,7 +38,7 @@ if ($aResult['list']) {
|
||||
$aDetails['totalBlocks'],
|
||||
(int)$aDetails['currentBucketSize'],
|
||||
$aDetails['currentlyBlocked']?'Y':'N',
|
||||
date("r", $aDetails['lastBlockTimestamp']),
|
||||
date('r', $aDetails['lastBlockTimestamp']),
|
||||
$aDetails['isSleeping']?'Y':'N'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ ini_set('display_errors', 'stderr');
|
||||
|
||||
$aCMDOptions
|
||||
= array(
|
||||
"Import country language data from osm wiki",
|
||||
'Import country language data from osm wiki',
|
||||
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'),
|
||||
|
||||
@@ -7,7 +7,7 @@ ini_set('memory_limit', '800M');
|
||||
|
||||
$aCMDOptions
|
||||
= array(
|
||||
"Create and setup nominatim search system",
|
||||
'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'),
|
||||
@@ -379,7 +379,7 @@ if (isset($aCMDResult['link'])) {
|
||||
|
||||
$sURL = $sNominatimBaseURL.'?format=xml&accept-language=en';
|
||||
|
||||
echo "\n-- ".$aRecord['name'].", ".$aRecord['infobox_type']."\n";
|
||||
echo "\n-- ".$aRecord['name'].', '.$aRecord['infobox_type']."\n";
|
||||
$fMaxDist = 0.0000001;
|
||||
$bUnknown = false;
|
||||
switch (strtolower($aRecord['infobox_type'])) {
|
||||
@@ -387,15 +387,15 @@ if (isset($aCMDResult['link'])) {
|
||||
continue 2;
|
||||
case 'sea':
|
||||
$fMaxDist = 60; // effectively turn it off
|
||||
$sURL .= "&viewbox=".($aRecord['lon']-$fMaxDist).",".($aRecord['lat']+$fMaxDist).",".($aRecord['lon']+$fMaxDist).",".($aRecord['lat']-$fMaxDist);
|
||||
$sURL .= '&viewbox='.($aRecord['lon']-$fMaxDist).','.($aRecord['lat']+$fMaxDist).','.($aRecord['lon']+$fMaxDist).','.($aRecord['lat']-$fMaxDist);
|
||||
break;
|
||||
case 'country':
|
||||
case 'island':
|
||||
case 'islands':
|
||||
case 'continent':
|
||||
$fMaxDist = 60; // effectively turn it off
|
||||
$sURL .= "&featuretype=country";
|
||||
$sURL .= "&viewbox=".($aRecord['lon']-$fMaxDist).",".($aRecord['lat']+$fMaxDist).",".($aRecord['lon']+$fMaxDist).",".($aRecord['lat']-$fMaxDist);
|
||||
$sURL .= '&featuretype=country';
|
||||
$sURL .= '&viewbox='.($aRecord['lon']-$fMaxDist).','.($aRecord['lat']+$fMaxDist).','.($aRecord['lon']+$fMaxDist).','.($aRecord['lat']-$fMaxDist);
|
||||
break;
|
||||
case 'prefecture japan':
|
||||
$aRecord['name'] = trim(str_replace(' Prefecture', ' ', $aRecord['name']));
|
||||
@@ -415,14 +415,14 @@ if (isset($aCMDResult['link'])) {
|
||||
case '#australia state or territory':
|
||||
case 'russian federal subject':
|
||||
$fMaxDist = 4;
|
||||
$sURL .= "&featuretype=state";
|
||||
$sURL .= "&viewbox=".($aRecord['lon']-$fMaxDist).",".($aRecord['lat']+$fMaxDist).",".($aRecord['lon']+$fMaxDist).",".($aRecord['lat']-$fMaxDist);
|
||||
$sURL .= '&featuretype=state';
|
||||
$sURL .= '&viewbox='.($aRecord['lon']-$fMaxDist).','.($aRecord['lat']+$fMaxDist).','.($aRecord['lon']+$fMaxDist).','.($aRecord['lat']-$fMaxDist);
|
||||
break;
|
||||
case 'protected area':
|
||||
$fMaxDist = 1;
|
||||
$sURL .= "&nearlat=".$aRecord['lat'];
|
||||
$sURL .= "&nearlon=".$aRecord['lon'];
|
||||
$sURL .= "&viewbox=".($aRecord['lon']-$fMaxDist).",".($aRecord['lat']+$fMaxDist).",".($aRecord['lon']+$fMaxDist).",".($aRecord['lat']-$fMaxDist);
|
||||
$sURL .= '&nearlat='.$aRecord['lat'];
|
||||
$sURL .= '&nearlon='.$aRecord['lon'];
|
||||
$sURL .= '&viewbox='.($aRecord['lon']-$fMaxDist).','.($aRecord['lat']+$fMaxDist).','.($aRecord['lon']+$fMaxDist).','.($aRecord['lat']-$fMaxDist);
|
||||
break;
|
||||
case 'settlement':
|
||||
$bUnknown = true;
|
||||
@@ -444,8 +444,8 @@ if (isset($aCMDResult['link'])) {
|
||||
case 'russian city':
|
||||
case 'city':
|
||||
$fMaxDist = 0.2;
|
||||
$sURL .= "&featuretype=settlement";
|
||||
$sURL .= "&viewbox=".($aRecord['lon']-0.5).",".($aRecord['lat']+0.5).",".($aRecord['lon']+0.5).",".($aRecord['lat']-0.5);
|
||||
$sURL .= '&featuretype=settlement';
|
||||
$sURL .= '&viewbox='.($aRecord['lon']-0.5).','.($aRecord['lat']+0.5).','.($aRecord['lon']+0.5).','.($aRecord['lat']-0.5);
|
||||
break;
|
||||
case 'mountain':
|
||||
case 'mountain pass':
|
||||
@@ -453,33 +453,33 @@ if (isset($aCMDResult['link'])) {
|
||||
case 'lake':
|
||||
case 'airport':
|
||||
$fMaxDist = 0.2;
|
||||
$sURL .= "&viewbox=".($aRecord['lon']-0.5).",".($aRecord['lat']+0.5).",".($aRecord['lon']+0.5).",".($aRecord['lat']-0.5);
|
||||
$sURL .= '&viewbox='.($aRecord['lon']-0.5).','.($aRecord['lat']+0.5).','.($aRecord['lon']+0.5).','.($aRecord['lat']-0.5);
|
||||
break;
|
||||
case 'ship begin':
|
||||
$fMaxDist = 0.1;
|
||||
$aTypes = array('wreck');
|
||||
$sURL .= "&viewbox=".($aRecord['lon']-0.01).",".($aRecord['lat']+0.01).",".($aRecord['lon']+0.01).",".($aRecord['lat']-0.01);
|
||||
$sURL .= "&nearlat=".$aRecord['lat'];
|
||||
$sURL .= "&nearlon=".$aRecord['lon'];
|
||||
$sURL .= '&viewbox='.($aRecord['lon']-0.01).','.($aRecord['lat']+0.01).','.($aRecord['lon']+0.01).','.($aRecord['lat']-0.01);
|
||||
$sURL .= '&nearlat='.$aRecord['lat'];
|
||||
$sURL .= '&nearlon='.$aRecord['lon'];
|
||||
break;
|
||||
case 'road':
|
||||
case 'university':
|
||||
case 'company':
|
||||
case 'department':
|
||||
$fMaxDist = 0.005;
|
||||
$sURL .= "&viewbox=".($aRecord['lon']-0.01).",".($aRecord['lat']+0.01).",".($aRecord['lon']+0.01).",".($aRecord['lat']-0.01);
|
||||
$sURL .= "&bounded=1";
|
||||
$sURL .= "&nearlat=".$aRecord['lat'];
|
||||
$sURL .= "&nearlon=".$aRecord['lon'];
|
||||
$sURL .= '&viewbox='.($aRecord['lon']-0.01).','.($aRecord['lat']+0.01).','.($aRecord['lon']+0.01).','.($aRecord['lat']-0.01);
|
||||
$sURL .= '&bounded=1';
|
||||
$sURL .= '&nearlat='.$aRecord['lat'];
|
||||
$sURL .= '&nearlon='.$aRecord['lon'];
|
||||
break;
|
||||
default:
|
||||
$bUnknown = true;
|
||||
$fMaxDist = 0.005;
|
||||
$sURL .= "&viewbox=".($aRecord['lon']-0.01).",".($aRecord['lat']+0.01).",".($aRecord['lon']+0.01).",".($aRecord['lat']-0.01);
|
||||
$sURL .= '&viewbox='.($aRecord['lon']-0.01).','.($aRecord['lat']+0.01).','.($aRecord['lon']+0.01).','.($aRecord['lat']-0.01);
|
||||
// $sURL .= "&bounded=1";
|
||||
$sURL .= "&nearlat=".$aRecord['lat'];
|
||||
$sURL .= "&nearlon=".$aRecord['lon'];
|
||||
echo "-- Unknown: ".$aRecord['infobox_type']."\n";
|
||||
$sURL .= '&nearlat='.$aRecord['lat'];
|
||||
$sURL .= '&nearlon='.$aRecord['lon'];
|
||||
echo '-- Unknown: '.$aRecord['infobox_type']."\n";
|
||||
break;
|
||||
}
|
||||
$sNameURL = $sURL.'&q='.urlencode($aRecord['name']);
|
||||
@@ -526,14 +526,14 @@ if (isset($aCMDResult['link'])) {
|
||||
elseif ($iRank <= 26) $fMaxDist = 0.001;
|
||||
else $fMaxDist = 0.001;
|
||||
}
|
||||
echo "-- FOUND \"".substr($aNominatRecords[$i]['DISPLAY_NAME'], 0, 50);
|
||||
echo "\", ".$aNominatRecords[$i]['CLASS'].", ".$aNominatRecords[$i]['TYPE'];
|
||||
echo ", ".$aNominatRecords[$i]['PLACE_RANK'].", ".$aNominatRecords[$i]['OSM_TYPE'];
|
||||
echo '-- FOUND "'.substr($aNominatRecords[$i]['DISPLAY_NAME'], 0, 50);
|
||||
echo '", '.$aNominatRecords[$i]['CLASS'].', '.$aNominatRecords[$i]['TYPE'];
|
||||
echo ', '.$aNominatRecords[$i]['PLACE_RANK'].', '.$aNominatRecords[$i]['OSM_TYPE'];
|
||||
echo " (dist:$fDiff, max:$fMaxDist)\n";
|
||||
if ($fDiff > $fMaxDist) {
|
||||
echo "-- Diff too big $fDiff (max: $fMaxDist)".$aRecord['lat'].','.$aNominatRecords[$i]['LAT'].' & '.$aRecord['lon'].','.$aNominatRecords[$i]['LON']." \n";
|
||||
} else {
|
||||
$sSQL = "update wikipedia_article set osm_type=";
|
||||
$sSQL = 'update wikipedia_article set osm_type=';
|
||||
switch ($aNominatRecords[$i]['OSM_TYPE']) {
|
||||
case 'relation':
|
||||
$sSQL .= "'R'";
|
||||
@@ -545,7 +545,7 @@ if (isset($aCMDResult['link'])) {
|
||||
$sSQL .= "'N'";
|
||||
break;
|
||||
}
|
||||
$sSQL .= ", osm_id=".$aNominatRecords[$i]['OSM_ID']." where language = '".pg_escape_string($aRecord['language'])."' and title = '".pg_escape_string($aRecord['title'])."'";
|
||||
$sSQL .= ', osm_id='.$aNominatRecords[$i]['OSM_ID']." where language = '".pg_escape_string($aRecord['language'])."' and title = '".pg_escape_string($aRecord['title'])."'";
|
||||
$oDB->query($sSQL);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ ini_set('memory_limit', '800M');
|
||||
|
||||
$aCMDOptions
|
||||
= array(
|
||||
"Create and setup nominatim search system",
|
||||
'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'),
|
||||
@@ -29,7 +29,7 @@ if (isset($aCMDResult['parse-tiger'])) {
|
||||
preg_match('#([0-9]{5})_(.*)#', basename($sImportFile), $aMatch);
|
||||
$sCountyID = $aMatch[1];
|
||||
|
||||
echo "Processing ".$sCountyID."...\n";
|
||||
echo 'Processing '.$sCountyID."...\n";
|
||||
$sUnzipCmd = "unzip -d $sTempDir $sImportFile";
|
||||
exec($sUnzipCmd);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ ini_set('memory_limit', '800M');
|
||||
|
||||
$aCMDOptions
|
||||
= array(
|
||||
"Query database from command line. Returns search result as JSON.",
|
||||
'Query database from command line. Returns search result as JSON.',
|
||||
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'),
|
||||
@@ -41,7 +41,7 @@ if ($oParams->getBool('search')) {
|
||||
|
||||
$aSearchResults = $oGeocode->lookup();
|
||||
|
||||
if (version_compare(phpversion(), "5.4.0", '<')) {
|
||||
if (version_compare(phpversion(), '5.4.0', '<')) {
|
||||
echo json_encode($aSearchResults);
|
||||
} else {
|
||||
echo json_encode($aSearchResults, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)."\n";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/php -Cq
|
||||
<?php
|
||||
|
||||
$sFile = "sample.log.txt"; // Apache log file
|
||||
$sFile = 'sample.log.txt'; // Apache log file
|
||||
$sHost1 = 'http://mq-open-search-lm02.ihost.aol.com:8000/nominatim/v1';
|
||||
$sHost2 = 'http://mq-open-search-lm03.ihost.aol.com:8000/nominatim/v1';
|
||||
|
||||
@@ -11,7 +11,7 @@ $sHost2Escaped = str_replace('/', '\\/', $sHost2);
|
||||
|
||||
$aToDo = array(251, 293, 328, 399.1, 455.1, 479, 496, 499, 574, 609, 702, 790, 846, 865, 878, 894, 902, 961, 980);
|
||||
|
||||
$hFile = @fopen($sFile, "r");
|
||||
$hFile = @fopen($sFile, 'r');
|
||||
if (!$hFile) {
|
||||
echo "Unable to open file: $sFile\n";
|
||||
exit;
|
||||
|
||||
@@ -7,7 +7,7 @@ ini_set('memory_limit', '800M');
|
||||
|
||||
$aCMDOptions
|
||||
= array(
|
||||
"Create and setup nominatim search system",
|
||||
'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'),
|
||||
@@ -28,7 +28,7 @@ $aCMDOptions
|
||||
array('create-tables', '', 0, 1, 0, 0, 'bool', 'Create main tables'),
|
||||
array('create-partition-tables', '', 0, 1, 0, 0, 'bool', 'Create required partition tables'),
|
||||
array('create-partition-functions', '', 0, 1, 0, 0, 'bool', 'Create required partition triggers'),
|
||||
array('no-partitions', '', 0, 1, 0, 0, 'bool', "Do not partition search indices (speeds up import of single country extracts)"),
|
||||
array('no-partitions', '', 0, 1, 0, 0, 'bool', 'Do not partition search indices (speeds up import of single country extracts)'),
|
||||
array('import-wikipedia-articles', '', 0, 1, 0, 0, 'bool', 'Import wikipedia article dump'),
|
||||
array('load-data', '', 0, 1, 0, 0, 'bool', 'Copy data to live tables from import table'),
|
||||
array('disable-token-precalc', '', 0, 1, 0, 0, 'bool', 'Disable name precalculation (EXPERT)'),
|
||||
@@ -83,7 +83,7 @@ $aDSNInfo = DB::parseDSN(CONST_Database_DSN);
|
||||
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432;
|
||||
|
||||
if ($aCMDResult['create-db'] || $aCMDResult['all']) {
|
||||
info("Create DB");
|
||||
info('Create DB');
|
||||
$bDidSomething = true;
|
||||
$oDB = DB::connect(CONST_Database_DSN, false);
|
||||
if (!PEAR::isError($oDB)) {
|
||||
@@ -93,7 +93,7 @@ if ($aCMDResult['create-db'] || $aCMDResult['all']) {
|
||||
}
|
||||
|
||||
if ($aCMDResult['setup-db'] || $aCMDResult['all']) {
|
||||
info("Setup DB");
|
||||
info('Setup DB');
|
||||
$bDidSomething = true;
|
||||
|
||||
$oDB =& getDB();
|
||||
@@ -102,7 +102,7 @@ if ($aCMDResult['setup-db'] || $aCMDResult['all']) {
|
||||
echo 'Postgres version found: '.$fPostgresVersion."\n";
|
||||
|
||||
if ($fPostgresVersion < 9.1) {
|
||||
fail("Minimum supported version of Postgresql is 9.1.");
|
||||
fail('Minimum supported version of Postgresql is 9.1.');
|
||||
}
|
||||
|
||||
pgsqlRunScript('CREATE EXTENSION IF NOT EXISTS hstore');
|
||||
@@ -151,7 +151,7 @@ if ($aCMDResult['setup-db'] || $aCMDResult['all']) {
|
||||
}
|
||||
|
||||
if (!file_exists(CONST_ExtraDataPath.'/country_osm_grid.sql.gz')) {
|
||||
echo "Error: you need to download the country_osm_grid first:";
|
||||
echo 'Error: you need to download the country_osm_grid first:';
|
||||
echo "\n wget -O ".CONST_ExtraDataPath."/country_osm_grid.sql.gz http://www.nominatim.org/data/country_grid.sql.gz\n";
|
||||
exit(1);
|
||||
}
|
||||
@@ -219,7 +219,7 @@ if ($aCMDResult['create-functions'] || $aCMDResult['all']) {
|
||||
info('Create Functions');
|
||||
$bDidSomething = true;
|
||||
if (!file_exists(CONST_InstallPath.'/module/nominatim.so')) {
|
||||
fail("nominatim module not built");
|
||||
fail('nominatim module not built');
|
||||
}
|
||||
create_sql_functions($aCMDResult);
|
||||
}
|
||||
@@ -393,7 +393,7 @@ if ($aCMDResult['load-data'] || $aCMDResult['all']) {
|
||||
$sSQL = "INSERT INTO placex ($sColumns) SELECT $sColumns FROM place WHERE osm_id % $iLoadThreads = $i";
|
||||
$sSQL .= " and not (class='place' and type='houses' and osm_type='W'";
|
||||
$sSQL .= " and ST_GeometryType(geometry) = 'ST_LineString')";
|
||||
$sSQL .= " and ST_IsValid(geometry)";
|
||||
$sSQL .= ' and ST_IsValid(geometry)';
|
||||
if ($aCMDResult['verbose']) echo "$sSQL\n";
|
||||
if (!pg_send_query($aDBInstances[$i]->connection, $sSQL)) {
|
||||
fail(pg_last_error($aDBInstances[$i]->connection));
|
||||
@@ -459,7 +459,7 @@ if ($aCMDResult['import-tiger-data']) {
|
||||
|
||||
foreach (glob(CONST_Tiger_Data_Path.'/*.sql') as $sFile) {
|
||||
echo $sFile.': ';
|
||||
$hFile = fopen($sFile, "r");
|
||||
$hFile = fopen($sFile, 'r');
|
||||
$sSQL = fgets($hFile, 100000);
|
||||
$iLines = 0;
|
||||
|
||||
@@ -472,7 +472,7 @@ if ($aCMDResult['import-tiger-data']) {
|
||||
if (!pg_send_query($aDBInstances[$i]->connection, $sSQL)) fail(pg_last_error($oDB->connection));
|
||||
$iLines++;
|
||||
if ($iLines == 1000) {
|
||||
echo ".";
|
||||
echo '.';
|
||||
$iLines = 0;
|
||||
}
|
||||
}
|
||||
@@ -517,15 +517,15 @@ if ($aCMDResult['calculate-postcodes'] || $aCMDResult['all']) {
|
||||
fail(pg_last_error($oDB->connection));
|
||||
}
|
||||
|
||||
$sSQL = "INSERT INTO location_postcode";
|
||||
$sSQL .= " (place_id, indexed_status, country_code, postcode, geometry) ";
|
||||
$sSQL = 'INSERT INTO location_postcode';
|
||||
$sSQL .= ' (place_id, indexed_status, country_code, postcode, geometry) ';
|
||||
$sSQL .= "SELECT nextval('seq_place'), 1, country_code,";
|
||||
$sSQL .= " upper(trim (both ' ' from address->'postcode')) as pc,";
|
||||
$sSQL .= " ST_Centroid(ST_Collect(ST_Centroid(geometry)))";
|
||||
$sSQL .= " FROM placex";
|
||||
$sSQL .= ' ST_Centroid(ST_Collect(ST_Centroid(geometry)))';
|
||||
$sSQL .= ' FROM placex';
|
||||
$sSQL .= " WHERE address ? 'postcode' AND address->'postcode' NOT SIMILAR TO '%(,|;)%'";
|
||||
$sSQL .= " AND geometry IS NOT null";
|
||||
$sSQL .= " GROUP BY country_code, pc";
|
||||
$sSQL .= ' AND geometry IS NOT null';
|
||||
$sSQL .= ' GROUP BY country_code, pc';
|
||||
|
||||
if (!pg_query($oDB->connection, $sSQL)) {
|
||||
fail(pg_last_error($oDB->connection));
|
||||
@@ -533,36 +533,36 @@ if ($aCMDResult['calculate-postcodes'] || $aCMDResult['all']) {
|
||||
|
||||
if (CONST_Use_Extra_US_Postcodes) {
|
||||
// only add postcodes that are not yet available in OSM
|
||||
$sSQL = "INSERT INTO location_postcode";
|
||||
$sSQL .= " (place_id, indexed_status, country_code, postcode, geometry) ";
|
||||
$sSQL = 'INSERT INTO location_postcode';
|
||||
$sSQL .= ' (place_id, indexed_status, country_code, postcode, geometry) ';
|
||||
$sSQL .= "SELECT nextval('seq_place'), 1, 'us', postcode,";
|
||||
$sSQL .= " ST_SetSRID(ST_Point(x,y),4326)";
|
||||
$sSQL .= " FROM us_postcode WHERE postcode NOT IN";
|
||||
$sSQL .= " (SELECT postcode FROM location_postcode";
|
||||
$sSQL .= ' ST_SetSRID(ST_Point(x,y),4326)';
|
||||
$sSQL .= ' FROM us_postcode WHERE postcode NOT IN';
|
||||
$sSQL .= ' (SELECT postcode FROM location_postcode';
|
||||
$sSQL .= " WHERE country_code = 'us')";
|
||||
} else {
|
||||
$sSQL .= "TRUNCATE TABLE us_postcode";
|
||||
$sSQL .= 'TRUNCATE TABLE us_postcode';
|
||||
}
|
||||
if (!pg_query($oDB->connection, $sSQL)) fail(pg_last_error($oDB->connection));
|
||||
|
||||
// add missing postcodes for GB (if available)
|
||||
$sSQL = "INSERT INTO location_postcode";
|
||||
$sSQL .= " (place_id, indexed_status, country_code, postcode, geometry) ";
|
||||
$sSQL = 'INSERT INTO location_postcode';
|
||||
$sSQL .= ' (place_id, indexed_status, country_code, postcode, geometry) ';
|
||||
$sSQL .= "SELECT nextval('seq_place'), 1, 'gb', postcode, geometry";
|
||||
$sSQL .= " FROM gb_postcode WHERE postcode NOT IN";
|
||||
$sSQL .= " (SELECT postcode FROM location_postcode";
|
||||
$sSQL .= ' FROM gb_postcode WHERE postcode NOT IN';
|
||||
$sSQL .= ' (SELECT postcode FROM location_postcode';
|
||||
$sSQL .= " WHERE country_code = 'gb')";
|
||||
if (!pg_query($oDB->connection, $sSQL)) fail(pg_last_error($oDB->connection));
|
||||
|
||||
if (!$aCMDResult['all']) {
|
||||
$sSQL = "DELETE FROM word WHERE class='place' and type='postcode'";
|
||||
$sSQL .= "and word NOT IN (SELECT postcode FROM location_postcode)";
|
||||
$sSQL .= 'and word NOT IN (SELECT postcode FROM location_postcode)';
|
||||
if (!pg_query($oDB->connection, $sSQL)) {
|
||||
fail(pg_last_error($oDB->connection));
|
||||
}
|
||||
}
|
||||
$sSQL = "SELECT count(getorcreate_postcode_id(v)) FROM ";
|
||||
$sSQL .= "(SELECT distinct(postcode) as v FROM location_postcode) p";
|
||||
$sSQL = 'SELECT count(getorcreate_postcode_id(v)) FROM ';
|
||||
$sSQL .= '(SELECT distinct(postcode) as v FROM location_postcode) p';
|
||||
|
||||
if (!pg_query($oDB->connection, $sSQL)) {
|
||||
fail(pg_last_error($oDB->connection));
|
||||
@@ -623,7 +623,7 @@ if ($aCMDResult['create-country-names'] || $aCMDResult['all']) {
|
||||
|
||||
pgsqlRunScript("select getorcreate_country(make_standard_name('uk'), 'gb')");
|
||||
pgsqlRunScript("select getorcreate_country(make_standard_name('united states'), 'us')");
|
||||
pgsqlRunScript("select count(*) from (select getorcreate_country(make_standard_name(country_code), country_code) from country_name where country_code is not null) as x");
|
||||
pgsqlRunScript('select count(*) from (select getorcreate_country(make_standard_name(country_code), country_code) from country_name where country_code is not null) as x');
|
||||
pgsqlRunScript("select count(*) from (select getorcreate_country(make_standard_name(name->'name'), country_code) from country_name where name ? 'name') as x");
|
||||
|
||||
$sSQL = 'select count(*) from (select getorcreate_country(make_standard_name(v), country_code) from (select country_code, skeys(name) as k, svals(name) as v from country_name) x where k ';
|
||||
@@ -653,21 +653,21 @@ if ($aCMDResult['drop']) {
|
||||
|
||||
// tables we want to keep. everything else goes.
|
||||
$aKeepTables = array(
|
||||
"*columns",
|
||||
"import_polygon_*",
|
||||
"import_status",
|
||||
"place_addressline",
|
||||
"location_property*",
|
||||
"placex",
|
||||
"search_name",
|
||||
"seq_*",
|
||||
"word",
|
||||
"query_log",
|
||||
"new_query_log",
|
||||
"gb_postcode",
|
||||
"spatial_ref_sys",
|
||||
"country_name",
|
||||
"place_classtype_*"
|
||||
'*columns',
|
||||
'import_polygon_*',
|
||||
'import_status',
|
||||
'place_addressline',
|
||||
'location_property*',
|
||||
'placex',
|
||||
'search_name',
|
||||
'seq_*',
|
||||
'word',
|
||||
'query_log',
|
||||
'new_query_log',
|
||||
'gb_postcode',
|
||||
'spatial_ref_sys',
|
||||
'country_name',
|
||||
'place_classtype_*'
|
||||
);
|
||||
|
||||
$oDB =& getDB();
|
||||
@@ -693,7 +693,7 @@ if ($aCMDResult['drop']) {
|
||||
}
|
||||
|
||||
if (!is_null(CONST_Osm2pgsql_Flatnode_File)) {
|
||||
if ($aCMDResult['verbose']) echo "deleting ".CONST_Osm2pgsql_Flatnode_File."\n";
|
||||
if ($aCMDResult['verbose']) echo 'deleting '.CONST_Osm2pgsql_Flatnode_File."\n";
|
||||
unlink(CONST_Osm2pgsql_Flatnode_File);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ ini_set('display_errors', 'stderr');
|
||||
|
||||
$aCMDOptions
|
||||
= array(
|
||||
"Import and export special phrases",
|
||||
'Import and export special phrases',
|
||||
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'),
|
||||
@@ -76,30 +76,30 @@ if ($aCMDResult['wiki-import']) {
|
||||
}
|
||||
}
|
||||
|
||||
echo "create index idx_placex_classtype on placex (class, type);";
|
||||
echo 'create index idx_placex_classtype on placex (class, type);';
|
||||
|
||||
foreach ($aPairs as $aPair) {
|
||||
echo "create table place_classtype_".pg_escape_string($aPair[0])."_".pg_escape_string($aPair[1]);
|
||||
echo 'create table place_classtype_'.pg_escape_string($aPair[0]).'_'.pg_escape_string($aPair[1]);
|
||||
if (CONST_Tablespace_Aux_Data)
|
||||
echo " tablespace ".CONST_Tablespace_Aux_Data;
|
||||
echo " as select place_id as place_id,st_centroid(geometry) as centroid from placex where ";
|
||||
echo ' tablespace '.CONST_Tablespace_Aux_Data;
|
||||
echo ' as select place_id as place_id,st_centroid(geometry) as centroid from placex where ';
|
||||
echo "class = '".pg_escape_string($aPair[0])."' and type = '".pg_escape_string($aPair[1])."'";
|
||||
echo ";\n";
|
||||
|
||||
echo "CREATE INDEX idx_place_classtype_".pg_escape_string($aPair[0])."_".pg_escape_string($aPair[1])."_centroid ";
|
||||
echo "ON place_classtype_".pg_escape_string($aPair[0])."_".pg_escape_string($aPair[1])." USING GIST (centroid)";
|
||||
echo 'CREATE INDEX idx_place_classtype_'.pg_escape_string($aPair[0]).'_'.pg_escape_string($aPair[1]).'_centroid ';
|
||||
echo 'ON place_classtype_'.pg_escape_string($aPair[0]).'_'.pg_escape_string($aPair[1]).' USING GIST (centroid)';
|
||||
if (CONST_Tablespace_Aux_Index)
|
||||
echo " tablespace ".CONST_Tablespace_Aux_Index;
|
||||
echo ' tablespace '.CONST_Tablespace_Aux_Index;
|
||||
echo ";\n";
|
||||
|
||||
echo "CREATE INDEX idx_place_classtype_".pg_escape_string($aPair[0])."_".pg_escape_string($aPair[1])."_place_id ";
|
||||
echo "ON place_classtype_".pg_escape_string($aPair[0])."_".pg_escape_string($aPair[1])." USING btree(place_id)";
|
||||
echo 'CREATE INDEX idx_place_classtype_'.pg_escape_string($aPair[0]).'_'.pg_escape_string($aPair[1]).'_place_id ';
|
||||
echo 'ON place_classtype_'.pg_escape_string($aPair[0]).'_'.pg_escape_string($aPair[1]).' USING btree(place_id)';
|
||||
if (CONST_Tablespace_Aux_Index)
|
||||
echo " tablespace ".CONST_Tablespace_Aux_Index;
|
||||
echo ' tablespace '.CONST_Tablespace_Aux_Index;
|
||||
echo ";\n";
|
||||
|
||||
echo "GRANT SELECT ON place_classtype_".pg_escape_string($aPair[0])."_".pg_escape_string($aPair[1]).' TO "'.CONST_Database_Web_User."\";\n";
|
||||
echo 'GRANT SELECT ON place_classtype_'.pg_escape_string($aPair[0]).'_'.pg_escape_string($aPair[1]).' TO "'.CONST_Database_Web_User."\";\n";
|
||||
}
|
||||
|
||||
echo "drop index idx_placex_classtype;";
|
||||
echo 'drop index idx_placex_classtype;';
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ ini_set('memory_limit', '800M');
|
||||
|
||||
$aCMDOptions
|
||||
= array(
|
||||
"Import / update / index osm data",
|
||||
'Import / update / index osm data',
|
||||
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'),
|
||||
@@ -64,7 +64,7 @@ if ($aResult['init-updates']) {
|
||||
if ($sBaseState === false) {
|
||||
echo "\nCannot find state.txt file at the configured replication URL.\n";
|
||||
echo "Does the URL point to a directory containing OSM update data?\n\n";
|
||||
fail("replication URL not reachable.");
|
||||
fail('replication URL not reachable.');
|
||||
}
|
||||
$sSetup = CONST_InstallPath.'/utils/setup.php';
|
||||
$iRet = -1;
|
||||
@@ -75,7 +75,7 @@ if ($aResult['init-updates']) {
|
||||
|
||||
$sDatabaseDate = getDatabaseDate($oDB);
|
||||
if ($sDatabaseDate === false) {
|
||||
fail("Cannot determine date of database.");
|
||||
fail('Cannot determine date of database.');
|
||||
}
|
||||
$sWindBack = strftime('%Y-%m-%dT%H:%M:%SZ', strtotime($sDatabaseDate) - (3*60*60));
|
||||
|
||||
@@ -89,9 +89,9 @@ if ($aResult['init-updates']) {
|
||||
|
||||
pg_query($oDB->connection, 'TRUNCATE import_status');
|
||||
$sSQL = "INSERT INTO import_status (lastimportdate, sequence_id, indexed) VALUES('";
|
||||
$sSQL .= $sDatabaseDate."',".$aOutput[0].", true)";
|
||||
$sSQL .= $sDatabaseDate."',".$aOutput[0].', true)';
|
||||
if (!pg_query($oDB->connection, $sSQL)) {
|
||||
fail("Could not enter sequence into database.");
|
||||
fail('Could not enter sequence into database.');
|
||||
}
|
||||
|
||||
echo "Done. Database updates will start at sequence $aOutput[0] ($sWindBack)\n";
|
||||
@@ -118,7 +118,7 @@ if (isset($aResult['import-diff']) || isset($aResult['import-file'])) {
|
||||
}
|
||||
|
||||
if ($aResult['calculate-postcodes']) {
|
||||
info("Update postcodes centroids");
|
||||
info('Update postcodes centroids');
|
||||
$sTemplate = file_get_contents(CONST_BasePath.'/sql/update-postcodes.sql');
|
||||
runSQLScript($sTemplate, true, true);
|
||||
}
|
||||
@@ -170,7 +170,7 @@ if ($aResult['deduplicate']) {
|
||||
$oDB =& getDB();
|
||||
|
||||
if (getPostgresVersion($oDB) < 9.3) {
|
||||
fail("ERROR: deduplicate is only currently supported in postgresql 9.3");
|
||||
fail('ERROR: deduplicate is only currently supported in postgresql 9.3');
|
||||
}
|
||||
|
||||
$sSQL = 'select partition from country_name order by country_code';
|
||||
@@ -179,7 +179,7 @@ if ($aResult['deduplicate']) {
|
||||
|
||||
// we don't care about empty search_name_* partitions, they can't contain mentions of duplicates
|
||||
foreach ($aPartitions as $i => $sPartition) {
|
||||
$sSQL = "select count(*) from search_name_".$sPartition;
|
||||
$sSQL = 'select count(*) from search_name_'.$sPartition;
|
||||
$nEntries = chksql($oDB->getOne($sSQL));
|
||||
if ($nEntries == 0) {
|
||||
unset($aPartitions[$i]);
|
||||
@@ -187,14 +187,14 @@ if ($aResult['deduplicate']) {
|
||||
}
|
||||
|
||||
$sSQL = "select word_token,count(*) from word where substr(word_token, 1, 1) = ' '";
|
||||
$sSQL .= " and class is null and type is null and country_code is null";
|
||||
$sSQL .= " group by word_token having count(*) > 1 order by word_token";
|
||||
$sSQL .= ' and class is null and type is null and country_code is null';
|
||||
$sSQL .= ' group by word_token having count(*) > 1 order by word_token';
|
||||
$aDuplicateTokens = chksql($oDB->getAll($sSQL));
|
||||
foreach ($aDuplicateTokens as $aToken) {
|
||||
if (trim($aToken['word_token']) == '' || trim($aToken['word_token']) == '-') continue;
|
||||
echo "Deduping ".$aToken['word_token']."\n";
|
||||
$sSQL = "select word_id,";
|
||||
$sSQL .= " (select count(*) from search_name where nameaddress_vector @> ARRAY[word_id]) as num";
|
||||
echo 'Deduping '.$aToken['word_token']."\n";
|
||||
$sSQL = 'select word_id,';
|
||||
$sSQL .= ' (select count(*) from search_name where nameaddress_vector @> ARRAY[word_id]) as num';
|
||||
$sSQL .= " from word where word_token = '".$aToken['word_token'];
|
||||
$sSQL .= "' and class is null and type is null and country_code is null order by num desc";
|
||||
$aTokenSet = chksql($oDB->getAll($sSQL));
|
||||
@@ -203,35 +203,35 @@ if ($aResult['deduplicate']) {
|
||||
$iKeepID = $aKeep['word_id'];
|
||||
|
||||
foreach ($aTokenSet as $aRemove) {
|
||||
$sSQL = "update search_name set";
|
||||
$sSQL .= " name_vector = array_replace(name_vector,".$aRemove['word_id'].",".$iKeepID."),";
|
||||
$sSQL .= " nameaddress_vector = array_replace(nameaddress_vector,".$aRemove['word_id'].",".$iKeepID.")";
|
||||
$sSQL .= " where name_vector @> ARRAY[".$aRemove['word_id']."]";
|
||||
$sSQL = 'update search_name set';
|
||||
$sSQL .= ' name_vector = array_replace(name_vector,'.$aRemove['word_id'].','.$iKeepID.'),';
|
||||
$sSQL .= ' nameaddress_vector = array_replace(nameaddress_vector,'.$aRemove['word_id'].','.$iKeepID.')';
|
||||
$sSQL .= ' where name_vector @> ARRAY['.$aRemove['word_id'].']';
|
||||
chksql($oDB->query($sSQL));
|
||||
|
||||
$sSQL = "update search_name set";
|
||||
$sSQL .= " nameaddress_vector = array_replace(nameaddress_vector,".$aRemove['word_id'].",".$iKeepID.")";
|
||||
$sSQL .= " where nameaddress_vector @> ARRAY[".$aRemove['word_id']."]";
|
||||
$sSQL = 'update search_name set';
|
||||
$sSQL .= ' nameaddress_vector = array_replace(nameaddress_vector,'.$aRemove['word_id'].','.$iKeepID.')';
|
||||
$sSQL .= ' where nameaddress_vector @> ARRAY['.$aRemove['word_id'].']';
|
||||
chksql($oDB->query($sSQL));
|
||||
|
||||
$sSQL = "update location_area_country set";
|
||||
$sSQL .= " keywords = array_replace(keywords,".$aRemove['word_id'].",".$iKeepID.")";
|
||||
$sSQL .= " where keywords @> ARRAY[".$aRemove['word_id']."]";
|
||||
$sSQL = 'update location_area_country set';
|
||||
$sSQL .= ' keywords = array_replace(keywords,'.$aRemove['word_id'].','.$iKeepID.')';
|
||||
$sSQL .= ' where keywords @> ARRAY['.$aRemove['word_id'].']';
|
||||
chksql($oDB->query($sSQL));
|
||||
|
||||
foreach ($aPartitions as $sPartition) {
|
||||
$sSQL = "update search_name_".$sPartition." set";
|
||||
$sSQL .= " name_vector = array_replace(name_vector,".$aRemove['word_id'].",".$iKeepID.")";
|
||||
$sSQL .= " where name_vector @> ARRAY[".$aRemove['word_id']."]";
|
||||
$sSQL = 'update search_name_'.$sPartition.' set';
|
||||
$sSQL .= ' name_vector = array_replace(name_vector,'.$aRemove['word_id'].','.$iKeepID.')';
|
||||
$sSQL .= ' where name_vector @> ARRAY['.$aRemove['word_id'].']';
|
||||
chksql($oDB->query($sSQL));
|
||||
|
||||
$sSQL = "update location_area_country set";
|
||||
$sSQL .= " keywords = array_replace(keywords,".$aRemove['word_id'].",".$iKeepID.")";
|
||||
$sSQL .= " where keywords @> ARRAY[".$aRemove['word_id']."]";
|
||||
$sSQL = 'update location_area_country set';
|
||||
$sSQL .= ' keywords = array_replace(keywords,'.$aRemove['word_id'].','.$iKeepID.')';
|
||||
$sSQL .= ' where keywords @> ARRAY['.$aRemove['word_id'].']';
|
||||
chksql($oDB->query($sSQL));
|
||||
}
|
||||
|
||||
$sSQL = "delete from word where word_id = ".$aRemove['word_id'];
|
||||
$sSQL = 'delete from word where word_id = '.$aRemove['word_id'];
|
||||
chksql($oDB->query($sSQL));
|
||||
}
|
||||
}
|
||||
@@ -360,7 +360,7 @@ if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) {
|
||||
$oDB->query($sSQL);
|
||||
echo date('Y-m-d H:i:s')." Completed index step for $sBatchEnd in ".round((time()-$fCMDStartTime)/60, 2)." minutes\n";
|
||||
|
||||
$sSQL = "update import_status set indexed = true";
|
||||
$sSQL = 'update import_status set indexed = true';
|
||||
$oDB->query($sSQL);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ require_once(CONST_BasePath.'/lib/init-cmd.php');
|
||||
ini_set('memory_limit', '800M');
|
||||
|
||||
$aCMDOptions = array(
|
||||
"Tools to warm nominatim db",
|
||||
'Tools to warm nominatim db',
|
||||
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'),
|
||||
@@ -31,7 +31,7 @@ if (!$aResult['search-only']) {
|
||||
$oPlaceLookup->setIncludeAddressDetails(true);
|
||||
$oPlaceLookup->setLanguagePreference(array('en'));
|
||||
|
||||
echo "Warm reverse: ";
|
||||
echo 'Warm reverse: ';
|
||||
if ($bVerbose) echo "\n";
|
||||
for ($i = 0; $i < 1000; $i++) {
|
||||
$fLat = rand(-9000, 9000) / 100;
|
||||
@@ -46,7 +46,7 @@ if (!$aResult['search-only']) {
|
||||
);
|
||||
if ($bVerbose) echo $aDetails['langaddress']."\n";
|
||||
} else {
|
||||
echo ".";
|
||||
echo '.';
|
||||
}
|
||||
}
|
||||
echo "\n";
|
||||
@@ -55,7 +55,7 @@ if (!$aResult['search-only']) {
|
||||
if (!$aResult['reverse-only']) {
|
||||
$oGeocode = new Nominatim\Geocode($oDB);
|
||||
|
||||
echo "Warm search: ";
|
||||
echo 'Warm search: ';
|
||||
if ($bVerbose) echo "\n";
|
||||
$sSQL = 'select word from word where word is not null order by search_name_count desc limit 1000';
|
||||
foreach ($oDB->getCol($sSQL) as $sWord) {
|
||||
@@ -64,6 +64,6 @@ if (!$aResult['reverse-only']) {
|
||||
$oGeocode->setQuery($sWord);
|
||||
$aSearchResults = $oGeocode->lookup();
|
||||
if ($bVerbose) echo $aSearchResults[0]['langaddress']."\n";
|
||||
else echo ".";
|
||||
else echo '.';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user