return ($a['foundorder'] < $b['foundorder']?-1:1);
}
- function getPrefferedLangauges()
+ function getPreferredLanguages()
{
// If we have been provided the value in $_GET it overrides browser value
if (isset($_GET['accept-language']) && $_GET['accept-language'])
return false;
/*
- $fTotalFac is a suprisingly good indicator of accuracy
+ $fTotalFac is a surprisingly good indicator of accuracy
$iZoom = 18 + round(log($fTotalFac,32));
$iZoom = max(13,min(18,$iZoom));
*/
-- null record of right type
select * from placex where osm_type = 'N' and osm_id = waynodes[nodeidpos]::INTEGER and type = 'house' limit 1 INTO nextnode;
select ST_SetSRID(ST_Point(lon::float/10000000,lat::float/10000000),4326) from planet_osm_nodes where id = waynodes[nodeidpos] INTO nextnode.geometry;
+ IF nextnode.geometry IS NULL THEN
+ -- we don't have any information about this point, most likely
+ -- because an excerpt was updated and the node never imported
+ -- because the interpolation is outside the region of the excerpt.
+ -- Give up.
+ RETURN newpoints;
+ END IF;
ELSE
select * from placex where place_id = search_place_id INTO nextnode;
END IF;
array('osmosis-init', '', 0, 1, 0, 0, 'bool', 'Generate default osmosis configuration'),
array('osmosis-init-date', '', 0, 1, 1, 1, 'string', 'Generate default osmosis configuration'),
array('index', '', 0, 1, 0, 0, 'bool', 'Index the data'),
- array('index-noanalyse', '', 0, 1, 0, 0, 'bool', 'Do not perform analyse opertions during index (EXPERT)'),
+ array('index-noanalyse', '', 0, 1, 0, 0, 'bool', 'Do not perform analyse operations during index (EXPERT)'),
array('index-output', '', 0, 1, 1, 1, 'string', 'File to dump index information to'),
array('create-search-indices', '', 0, 1, 0, 0, 'bool', 'Create additional indices required for search and update'),
array('create-website', '', 0, 1, 1, 1, 'realpath', 'Create symlinks to setup web directory'),
$bDidSomething = false;
- // This is a pretty hard core defult - the number of processors in the box - 1
+ // This is a pretty hard core default - the number of processors in the box - 1
$iInstances = isset($aCMDResult['threads'])?$aCMDResult['threads']:(getProcessorCount()-1);
if ($iInstances < 1)
{
{
if (!file_exists($sFilename)) fail('unable to find '.$sFilename);
- // Convert database DSN to psql paramaters
+ // Convert database DSN to psql parameters
$aDSNInfo = DB::parseDSN(CONST_Database_DSN);
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432;
$sCMD = 'psql -p '.$aDSNInfo['port'].' -d '.$aDSNInfo['database'].' -f '.$sFilename;
function pgsqlRunScript($sScript)
{
- // Convert database DSN to psql paramaters
+ // Convert database DSN to psql parameters
$aDSNInfo = DB::parseDSN(CONST_Database_DSN);
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432;
$sCMD = 'psql -p '.$aDSNInfo['port'].' -d '.$aDSNInfo['database'];
function pgsqlRunRestoreData($sDumpFile)
{
- // Convert database DSN to psql paramaters
+ // Convert database DSN to psql parameters
$aDSNInfo = DB::parseDSN(CONST_Database_DSN);
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432;
$sCMD = 'pg_restore -p '.$aDSNInfo['port'].' -d '.$aDSNInfo['database'].' -Fc -a '.$sDumpFile;
function pgsqlRunDropAndRestore($sDumpFile)
{
- // Convert database DSN to psql paramaters
+ // Convert database DSN to psql parameters
$aDSNInfo = DB::parseDSN(CONST_Database_DSN);
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432;
$sCMD = 'pg_restore -p '.$aDSNInfo['port'].' -d '.$aDSNInfo['database'].' -Fc --clean '.$sDumpFile;
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('countries', '', 0, 1, 0, 0, 'bool', 'Create import script for coutry codes and names'),
+ array('countries', '', 0, 1, 0, 0, 'bool', 'Create import script for country codes and names'),
array('wiki-import', '', 0, 1, 0, 0, 'bool', 'Create import script for search phrases '),
);
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
$iParentPlaceID = $oDB->getOne('select parent_place_id from location_property_aux where place_id = '.$iPlaceID);
if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
- $aLangPrefOrder = getPrefferedLangauges();
+ $aLangPrefOrder = getPreferredLanguages();
$sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$aLangPrefOrder))."]";
$hLog = logStart($oDB, 'details', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
$bShowAddressDetails = true;
if (isset($_GET['addressdetails'])) $bShowAddressDetails = (bool)$_GET['addressdetails'];
- // Prefered language
- $aLangPrefOrder = getPrefferedLangauges();
+ // Preferred language
+ $aLangPrefOrder = getPreferredLanguages();
$sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$aLangPrefOrder))."]";
$hLog = logStart($oDB, 'reverse', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
$sSQL .= ' ORDER BY ST_distance('.$sPointSQL.', geometry) ASC limit 1';
//var_dump($sSQL);
$aPlace = $oDB->getRow($sSQL);
- $iPlaceID = $aPlace['place_id'];
- $iParentPlaceID = $aPlace['parent_place_id'];
- if (PEAR::IsError($iPlaceID))
+ if (PEAR::IsError($aPlace))
{
failInternalError("Could not determine closest place.", $sSQL, $iPlaceID);
}
+ $iPlaceID = $aPlace['place_id'];
+ $iParentPlaceID = $aPlace['parent_place_id'];
}
// The point we found might be too small - use the address to find what it is a child of
// Show address breakdown
$bShowAddressDetails = isset($_GET['addressdetails']) && $_GET['addressdetails'];
- // Prefered language
- $aLangPrefOrder = getPrefferedLangauges();
+ // Preferred language
+ $aLangPrefOrder = getPreferredLanguages();
if (isset($aLangPrefOrder['name:de'])) $bReverseInPlan = true;
if (isset($aLangPrefOrder['name:ru'])) $bReverseInPlan = true;
if (isset($aLangPrefOrder['name:ja'])) $bReverseInPlan = true;
}
}
- // Only certain ranks of feature
+ // Only certain ranks of feature
if (isset($_GET['featureType']) && !isset($_GET['featuretype'])) $_GET['featuretype'] = $_GET['featureType'];
if (isset($_GET['featuretype']))
{
$sQuery = substr($_SERVER['PATH_INFO'], 1);
- // reverse order of '/' seperated string
+ // reverse order of '/' separated string
$aPhrases = explode('/', $sQuery);
$aPhrases = array_reverse($aPhrases);
$sQuery = join(', ',$aPhrases);
if ($aSearch['sCountryCode'] === false)
{
$aSearch['sCountryCode'] = strtolower($aSearchTerm['country_code']);
- // Country is almost always at the end of the string - increase score for finding it anywhere else (opimisation)
+ // Country is almost always at the end of the string - increase score for finding it anywhere else (optimisation)
if ($iWordset+1 != sizeof($aPhrases[$iPhrase]['wordsets']) || $iPhrase+1 != sizeof($aPhrases)) $aSearch['iSearchRank'] += 5;
if ($aSearch['iSearchRank'] < $iMaxRank) $aNewWordsetSearches[] = $aSearch;
}