mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
Merge pull request #524 from mtmail/PSR2-function-declarations
fix function declaration errors according to PSR2 coding style guide
This commit is contained in:
@@ -207,12 +207,12 @@ class Geocode
|
|||||||
|
|
||||||
function loadParamArray($oParams)
|
function loadParamArray($oParams)
|
||||||
{
|
{
|
||||||
$this->bIncludeAddressDetails = $oParams->getBool('addressdetails',
|
$this->bIncludeAddressDetails
|
||||||
$this->bIncludeAddressDetails);
|
= $oParams->getBool('addressdetails', $this->bIncludeAddressDetails);
|
||||||
$this->bIncludeExtraTags = $oParams->getBool('extratags',
|
$this->bIncludeExtraTags
|
||||||
$this->bIncludeExtraTags);
|
= $oParams->getBool('extratags', $this->bIncludeExtraTags);
|
||||||
$this->bIncludeNameDetails = $oParams->getBool('namedetails',
|
$this->bIncludeNameDetails
|
||||||
$this->bIncludeNameDetails);
|
= $oParams->getBool('namedetails', $this->bIncludeNameDetails);
|
||||||
|
|
||||||
$this->bBoundedSearch = $oParams->getBool('bounded', $this->bBoundedSearch);
|
$this->bBoundedSearch = $oParams->getBool('bounded', $this->bBoundedSearch);
|
||||||
$this->bDeDupe = $oParams->getBool('dedupe', $this->bDeDupe);
|
$this->bDeDupe = $oParams->getBool('dedupe', $this->bDeDupe);
|
||||||
@@ -279,13 +279,15 @@ class Geocode
|
|||||||
// Search query
|
// Search query
|
||||||
$sQuery = $oParams->getString('q');
|
$sQuery = $oParams->getString('q');
|
||||||
if (!$sQuery) {
|
if (!$sQuery) {
|
||||||
$this->setStructuredQuery($oParams->getString('amenity'),
|
$this->setStructuredQuery(
|
||||||
|
$oParams->getString('amenity'),
|
||||||
$oParams->getString('street'),
|
$oParams->getString('street'),
|
||||||
$oParams->getString('city'),
|
$oParams->getString('city'),
|
||||||
$oParams->getString('county'),
|
$oParams->getString('county'),
|
||||||
$oParams->getString('state'),
|
$oParams->getString('state'),
|
||||||
$oParams->getString('country'),
|
$oParams->getString('country'),
|
||||||
$oParams->getString('postalcode'));
|
$oParams->getString('postalcode')
|
||||||
|
);
|
||||||
$this->setReverseInPlan(false);
|
$this->setReverseInPlan(false);
|
||||||
} else {
|
} else {
|
||||||
$this->setQuery($sQuery);
|
$this->setQuery($sQuery);
|
||||||
@@ -476,8 +478,10 @@ class Geocode
|
|||||||
if (CONST_Debug) {
|
if (CONST_Debug) {
|
||||||
echo "<hr>"; var_dump($sSQL);
|
echo "<hr>"; var_dump($sSQL);
|
||||||
}
|
}
|
||||||
$aSearchResults = chksql($this->oDB->getAll($sSQL),
|
$aSearchResults = chksql(
|
||||||
"Could not get details for place.");
|
$this->oDB->getAll($sSQL),
|
||||||
|
"Could not get details for place."
|
||||||
|
);
|
||||||
|
|
||||||
return $aSearchResults;
|
return $aSearchResults;
|
||||||
}
|
}
|
||||||
@@ -756,12 +760,16 @@ class Geocode
|
|||||||
$bBoundingBoxSearch = $this->bBoundedSearch && $this->sViewboxSmallSQL;
|
$bBoundingBoxSearch = $this->bBoundedSearch && $this->sViewboxSmallSQL;
|
||||||
if ($this->sViewboxCentreSQL) {
|
if ($this->sViewboxCentreSQL) {
|
||||||
// For complex viewboxes (routes) precompute the bounding geometry
|
// For complex viewboxes (routes) precompute the bounding geometry
|
||||||
$sGeom = chksql($this->oDB->getOne("select ".$this->sViewboxSmallSQL),
|
$sGeom = chksql(
|
||||||
"Could not get small viewbox");
|
$this->oDB->getOne("select ".$this->sViewboxSmallSQL),
|
||||||
|
"Could not get small viewbox"
|
||||||
|
);
|
||||||
$this->sViewboxSmallSQL = "'".$sGeom."'::geometry";
|
$this->sViewboxSmallSQL = "'".$sGeom."'::geometry";
|
||||||
|
|
||||||
$sGeom = chksql($this->oDB->getOne("select ".$this->sViewboxLargeSQL),
|
$sGeom = chksql(
|
||||||
"Could not get large viewbox");
|
$this->oDB->getOne("select ".$this->sViewboxLargeSQL),
|
||||||
|
"Could not get large viewbox"
|
||||||
|
);
|
||||||
$this->sViewboxLargeSQL = "'".$sGeom."'::geometry";
|
$this->sViewboxLargeSQL = "'".$sGeom."'::geometry";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -863,8 +871,10 @@ class Geocode
|
|||||||
// Generate a complete list of all
|
// Generate a complete list of all
|
||||||
$aTokens = array();
|
$aTokens = array();
|
||||||
foreach ($aPhrases as $iPhrase => $sPhrase) {
|
foreach ($aPhrases as $iPhrase => $sPhrase) {
|
||||||
$aPhrase = chksql($this->oDB->getRow("select make_standard_name('".pg_escape_string($sPhrase)."') as string"),
|
$aPhrase = chksql(
|
||||||
"Cannot nomralize query string (is it an UTF-8 string?)");
|
$this->oDB->getRow("select make_standard_name('".pg_escape_string($sPhrase)."') as string"),
|
||||||
|
"Cannot nomralize query string (is it an UTF-8 string?)"
|
||||||
|
);
|
||||||
if (trim($aPhrase['string'])) {
|
if (trim($aPhrase['string'])) {
|
||||||
$aPhrases[$iPhrase] = $aPhrase;
|
$aPhrases[$iPhrase] = $aPhrase;
|
||||||
$aPhrases[$iPhrase]['words'] = explode(' ', $aPhrases[$iPhrase]['string']);
|
$aPhrases[$iPhrase]['words'] = explode(' ', $aPhrases[$iPhrase]['string']);
|
||||||
@@ -888,8 +898,10 @@ class Geocode
|
|||||||
|
|
||||||
$aValidTokens = array();
|
$aValidTokens = array();
|
||||||
if (sizeof($aTokens)) {
|
if (sizeof($aTokens)) {
|
||||||
$aDatabaseWords = chksql($this->oDB->getAll($sSQL),
|
$aDatabaseWords = chksql(
|
||||||
"Could not get word tokens.");
|
$this->oDB->getAll($sSQL),
|
||||||
|
"Could not get word tokens."
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$aDatabaseWords = array();
|
$aDatabaseWords = array();
|
||||||
}
|
}
|
||||||
@@ -1136,9 +1148,9 @@ class Geocode
|
|||||||
if (sizeof($aSearch['aNameNonSearch'])) $aTerms[] = "array_cat(name_vector,ARRAY[]::integer[]) @> ARRAY[".join($aSearch['aNameNonSearch'], ",")."]";
|
if (sizeof($aSearch['aNameNonSearch'])) $aTerms[] = "array_cat(name_vector,ARRAY[]::integer[]) @> ARRAY[".join($aSearch['aNameNonSearch'], ",")."]";
|
||||||
if (sizeof($aSearch['aAddress']) && $aSearch['aName'] != $aSearch['aAddress']) {
|
if (sizeof($aSearch['aAddress']) && $aSearch['aName'] != $aSearch['aAddress']) {
|
||||||
// For infrequent name terms disable index usage for address
|
// For infrequent name terms disable index usage for address
|
||||||
if (CONST_Search_NameOnlySearchFrequencyThreshold &&
|
if (CONST_Search_NameOnlySearchFrequencyThreshold
|
||||||
sizeof($aSearch['aName']) == 1 &&
|
&& sizeof($aSearch['aName']) == 1
|
||||||
$aWordFrequencyScores[$aSearch['aName'][reset($aSearch['aName'])]] < CONST_Search_NameOnlySearchFrequencyThreshold
|
&& $aWordFrequencyScores[$aSearch['aName'][reset($aSearch['aName'])]] < CONST_Search_NameOnlySearchFrequencyThreshold
|
||||||
) {
|
) {
|
||||||
$aTerms[] = "array_cat(nameaddress_vector,ARRAY[]::integer[]) @> ARRAY[".join(array_merge($aSearch['aAddress'], $aSearch['aAddressNonSearch']), ",")."]";
|
$aTerms[] = "array_cat(nameaddress_vector,ARRAY[]::integer[]) @> ARRAY[".join(array_merge($aSearch['aAddress'], $aSearch['aAddressNonSearch']), ",")."]";
|
||||||
} else {
|
} else {
|
||||||
@@ -1204,8 +1216,10 @@ class Geocode
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CONST_Debug) var_dump($sSQL);
|
if (CONST_Debug) var_dump($sSQL);
|
||||||
$aViewBoxPlaceIDs = chksql($this->oDB->getAll($sSQL),
|
$aViewBoxPlaceIDs = chksql(
|
||||||
"Could not get places for search terms.");
|
$this->oDB->getAll($sSQL),
|
||||||
|
"Could not get places for search terms."
|
||||||
|
);
|
||||||
//var_dump($aViewBoxPlaceIDs);
|
//var_dump($aViewBoxPlaceIDs);
|
||||||
// Did we have an viewbox matches?
|
// Did we have an viewbox matches?
|
||||||
$aPlaceIDs = array();
|
$aPlaceIDs = array();
|
||||||
@@ -1448,9 +1462,11 @@ class Geocode
|
|||||||
$oReverse = new ReverseGeocode($this->oDB);
|
$oReverse = new ReverseGeocode($this->oDB);
|
||||||
$oReverse->setZoom(18);
|
$oReverse->setZoom(18);
|
||||||
|
|
||||||
$aLookup = $oReverse->lookup((float)$this->aNearPoint[0],
|
$aLookup = $oReverse->lookup(
|
||||||
|
(float)$this->aNearPoint[0],
|
||||||
(float)$this->aNearPoint[1],
|
(float)$this->aNearPoint[1],
|
||||||
false);
|
false
|
||||||
|
);
|
||||||
|
|
||||||
if (CONST_Debug) var_dump("Reverse search", $aLookup);
|
if (CONST_Debug) var_dump("Reverse search", $aLookup);
|
||||||
|
|
||||||
|
|||||||
@@ -155,8 +155,7 @@ class PlaceLookup
|
|||||||
if ($this->bAddressDetails) {
|
if ($this->bAddressDetails) {
|
||||||
// to get addressdetails for tiger data, the housenumber is needed
|
// to get addressdetails for tiger data, the housenumber is needed
|
||||||
$iHousenumber = ($bIsTiger || $bIsInterpolation) ? $aPlace['housenumber'] : -1;
|
$iHousenumber = ($bIsTiger || $bIsInterpolation) ? $aPlace['housenumber'] : -1;
|
||||||
$aPlace['aAddress'] = $this->getAddressNames($aPlace['place_id'],
|
$aPlace['aAddress'] = $this->getAddressNames($aPlace['place_id'], $iHousenumber);
|
||||||
$iHousenumber);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->bExtraTags) {
|
if ($this->bExtraTags) {
|
||||||
@@ -270,8 +269,7 @@ class PlaceLookup
|
|||||||
$sSQL .= $sFrom;
|
$sSQL .= $sFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
$aPointPolygon = chksql($this->oDB->getRow($sSQL),
|
$aPointPolygon = chksql($this->oDB->getRow($sSQL), "Could not get outline");
|
||||||
"Could not get outline");
|
|
||||||
|
|
||||||
if ($aPointPolygon['place_id']) {
|
if ($aPointPolygon['place_id']) {
|
||||||
if ($aPointPolygon['centrelon'] !== null && $aPointPolygon['centrelat'] !== null) {
|
if ($aPointPolygon['centrelon'] !== null && $aPointPolygon['centrelat'] !== null) {
|
||||||
|
|||||||
@@ -78,8 +78,10 @@ class ReverseGeocode
|
|||||||
$sSQL .= ' OR ST_DWithin('.$sPointSQL.', centroid, '.$fSearchDiam.'))';
|
$sSQL .= ' OR ST_DWithin('.$sPointSQL.', centroid, '.$fSearchDiam.'))';
|
||||||
$sSQL .= ' ORDER BY ST_distance('.$sPointSQL.', geometry) ASC limit 1';
|
$sSQL .= ' ORDER BY ST_distance('.$sPointSQL.', geometry) ASC limit 1';
|
||||||
if (CONST_Debug) var_dump($sSQL);
|
if (CONST_Debug) var_dump($sSQL);
|
||||||
$aPlace = chksql($this->oDB->getRow($sSQL),
|
$aPlace = chksql(
|
||||||
"Could not determine closest place.");
|
$this->oDB->getRow($sSQL),
|
||||||
|
"Could not determine closest place."
|
||||||
|
);
|
||||||
$iPlaceID = $aPlace['place_id'];
|
$iPlaceID = $aPlace['place_id'];
|
||||||
$iParentPlaceID = $aPlace['parent_place_id'];
|
$iParentPlaceID = $aPlace['parent_place_id'];
|
||||||
$bIsInUnitedStates = ($aPlace['calculated_country_code'] == 'us');
|
$bIsInUnitedStates = ($aPlace['calculated_country_code'] == 'us');
|
||||||
@@ -102,8 +104,10 @@ class ReverseGeocode
|
|||||||
echo $i['housenumber'] . ' | ' . $i['distance'] * 1000 . ' | ' . $i['lat'] . ' | ' . $i['lon']. ' | '. "<br>\n";
|
echo $i['housenumber'] . ' | ' . $i['distance'] * 1000 . ' | ' . $i['lat'] . ' | ' . $i['lon']. ' | '. "<br>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$aPlaceLine = chksql($this->oDB->getRow($sSQL),
|
$aPlaceLine = chksql(
|
||||||
"Could not determine closest housenumber on an osm interpolation line.");
|
$this->oDB->getRow($sSQL),
|
||||||
|
"Could not determine closest housenumber on an osm interpolation line."
|
||||||
|
);
|
||||||
if ($aPlaceLine) {
|
if ($aPlaceLine) {
|
||||||
if (CONST_Debug) var_dump('found housenumber in interpolation lines table', $aPlaceLine);
|
if (CONST_Debug) var_dump('found housenumber in interpolation lines table', $aPlaceLine);
|
||||||
if ($aPlace['rank_search'] == 30) {
|
if ($aPlace['rank_search'] == 30) {
|
||||||
@@ -111,14 +115,18 @@ class ReverseGeocode
|
|||||||
// if the placex house or the interpolated house are closer to the searched point
|
// if the placex house or the interpolated house are closer to the searched point
|
||||||
// distance between point and placex house
|
// distance between point and placex house
|
||||||
$sSQL = 'SELECT ST_distance('.$sPointSQL.', house.geometry) as distance FROM placex as house WHERE house.place_id='.$iPlaceID;
|
$sSQL = 'SELECT ST_distance('.$sPointSQL.', house.geometry) as distance FROM placex as house WHERE house.place_id='.$iPlaceID;
|
||||||
$aDistancePlacex = chksql($this->oDB->getRow($sSQL),
|
$aDistancePlacex = chksql(
|
||||||
"Could not determine distance between searched point and placex house.");
|
$this->oDB->getRow($sSQL),
|
||||||
|
"Could not determine distance between searched point and placex house."
|
||||||
|
);
|
||||||
$fDistancePlacex = $aDistancePlacex['distance'];
|
$fDistancePlacex = $aDistancePlacex['distance'];
|
||||||
// distance between point and interpolated house (fraction on interpolation line)
|
// distance between point and interpolated house (fraction on interpolation line)
|
||||||
$sSQL = 'SELECT ST_distance('.$sPointSQL.', ST_LineInterpolatePoint(linegeo, '.$aPlaceLine['fraction'].')) as distance';
|
$sSQL = 'SELECT ST_distance('.$sPointSQL.', ST_LineInterpolatePoint(linegeo, '.$aPlaceLine['fraction'].')) as distance';
|
||||||
$sSQL .= ' FROM location_property_osmline WHERE place_id = '.$aPlaceLine['place_id'];
|
$sSQL .= ' FROM location_property_osmline WHERE place_id = '.$aPlaceLine['place_id'];
|
||||||
$aDistanceInterpolation = chksql($this->oDB->getRow($sSQL),
|
$aDistanceInterpolation = chksql(
|
||||||
"Could not determine distance between searched point and interpolated house.");
|
$this->oDB->getRow($sSQL),
|
||||||
|
"Could not determine distance between searched point and interpolated house."
|
||||||
|
);
|
||||||
$fDistanceInterpolation = $aDistanceInterpolation['distance'];
|
$fDistanceInterpolation = $aDistanceInterpolation['distance'];
|
||||||
if ($fDistanceInterpolation < $fDistancePlacex) {
|
if ($fDistanceInterpolation < $fDistancePlacex) {
|
||||||
// interpolation is closer to point than placex house
|
// interpolation is closer to point than placex house
|
||||||
@@ -160,8 +168,10 @@ class ReverseGeocode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$aPlaceTiger = chksql($this->oDB->getRow($sSQL),
|
$aPlaceTiger = chksql(
|
||||||
"Could not determine closest Tiger place.");
|
$this->oDB->getRow($sSQL),
|
||||||
|
"Could not determine closest Tiger place."
|
||||||
|
);
|
||||||
if ($aPlaceTiger) {
|
if ($aPlaceTiger) {
|
||||||
if (CONST_Debug) var_dump('found Tiger housenumber', $aPlaceTiger);
|
if (CONST_Debug) var_dump('found Tiger housenumber', $aPlaceTiger);
|
||||||
$bPlaceIsTiger = true;
|
$bPlaceIsTiger = true;
|
||||||
@@ -183,8 +193,7 @@ class ReverseGeocode
|
|||||||
$sSQL .= " WHERE place_id = $iPlaceID";
|
$sSQL .= " WHERE place_id = $iPlaceID";
|
||||||
$sSQL .= " ORDER BY abs(cached_rank_address - $iMaxRank) asc,cached_rank_address desc,isaddress desc,distance desc";
|
$sSQL .= " ORDER BY abs(cached_rank_address - $iMaxRank) asc,cached_rank_address desc,isaddress desc,distance desc";
|
||||||
$sSQL .= ' LIMIT 1';
|
$sSQL .= ' LIMIT 1';
|
||||||
$iPlaceID = chksql($this->oDB->getOne($sSQL),
|
$iPlaceID = chksql($this->oDB->getOne($sSQL), "Could not get parent for place.");
|
||||||
"Could not get parent for place.");
|
|
||||||
if (!$iPlaceID) {
|
if (!$iPlaceID) {
|
||||||
$iPlaceID = $aPlace['place_id'];
|
$iPlaceID = $aPlace['place_id'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ require_once('DB.php');
|
|||||||
function &getDB($bNew = false, $bPersistent = false)
|
function &getDB($bNew = false, $bPersistent = false)
|
||||||
{
|
{
|
||||||
// Get the database object
|
// Get the database object
|
||||||
$oDB = chksql(DB::connect(CONST_Database_DSN.($bNew?'?new_link=true':''), $bPersistent),
|
$oDB = chksql(
|
||||||
"Failed to establish database connection");
|
DB::connect(CONST_Database_DSN.($bNew?'?new_link=true':''), $bPersistent),
|
||||||
|
"Failed to establish database connection"
|
||||||
|
);
|
||||||
$oDB->setFetchMode(DB_FETCHMODE_ASSOC);
|
$oDB->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||||
$oDB->query("SET DateStyle TO 'sql,european'");
|
$oDB->query("SET DateStyle TO 'sql,european'");
|
||||||
$oDB->query("SET client_encoding TO 'utf-8'");
|
$oDB->query("SET client_encoding TO 'utf-8'");
|
||||||
|
|||||||
11
lib/log.php
11
lib/log.php
@@ -60,9 +60,14 @@ function logEnd(&$oDB, $hLog, $iNumResults)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CONST_Log_File) {
|
if (CONST_Log_File) {
|
||||||
$aOutdata = sprintf("[%s] %.4f %d %s \"%s\"\n",
|
$aOutdata = sprintf(
|
||||||
$hLog[0], $fEndTime-$hLog[5], $iNumResults,
|
"[%s] %.4f %d %s \"%s\"\n",
|
||||||
$hLog[4], $hLog[2]);
|
$hLog[0],
|
||||||
|
$fEndTime-$hLog[5],
|
||||||
|
$iNumResults,
|
||||||
|
$hLog[4],
|
||||||
|
$hLog[2]
|
||||||
|
);
|
||||||
file_put_contents(CONST_Log_File, $aOutdata, FILE_APPEND | LOCK_EX);
|
file_put_contents(CONST_Log_File, $aOutdata, FILE_APPEND | LOCK_EX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,11 +77,6 @@
|
|||||||
INDENTATION, SPACING
|
INDENTATION, SPACING
|
||||||
************************************************************** -->
|
************************************************************** -->
|
||||||
|
|
||||||
<!-- We use tabs -->
|
|
||||||
<rule ref="Generic.WhiteSpace.DisallowTabIndent.TabsUsed">
|
|
||||||
<severity>0</severity>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<!-- We don't need 2 blank lines after function -->
|
<!-- We don't need 2 blank lines after function -->
|
||||||
<rule ref="Squiz.WhiteSpace.FunctionSpacing.After">
|
<rule ref="Squiz.WhiteSpace.FunctionSpacing.After">
|
||||||
<severity>0</severity>
|
<severity>0</severity>
|
||||||
|
|||||||
@@ -32,9 +32,15 @@ if ($aResult['list']) {
|
|||||||
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", "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", "", "", "", "", "", "");
|
||||||
foreach ($aBlocks as $sKey => $aDetails) {
|
foreach ($aBlocks as $sKey => $aDetails) {
|
||||||
printf(" %-40s | %12s | %7s | %13s | %31s | %8s\n", $sKey, $aDetails['totalBlocks'],
|
printf(
|
||||||
(int)$aDetails['currentBucketSize'], $aDetails['currentlyBlocked']?'Y':'N',
|
" %-40s | %12s | %7s | %13s | %31s | %8s\n",
|
||||||
date("r", $aDetails['lastBlockTimestamp']), $aDetails['isSleeping']?'Y':'N');
|
$sKey,
|
||||||
|
$aDetails['totalBlocks'],
|
||||||
|
(int)$aDetails['currentBucketSize'],
|
||||||
|
$aDetails['currentlyBlocked']?'Y':'N',
|
||||||
|
date("r", $aDetails['lastBlockTimestamp']),
|
||||||
|
$aDetails['isSleeping']?'Y':'N'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
|
|||||||
136
utils/setup.php
136
utils/setup.php
@@ -197,18 +197,36 @@ if ($aCMDResult['create-tables'] || $aCMDResult['all']) {
|
|||||||
echo "Tables\n";
|
echo "Tables\n";
|
||||||
$sTemplate = file_get_contents(CONST_BasePath.'/sql/tables.sql');
|
$sTemplate = file_get_contents(CONST_BasePath.'/sql/tables.sql');
|
||||||
$sTemplate = str_replace('{www-user}', CONST_Database_Web_User, $sTemplate);
|
$sTemplate = str_replace('{www-user}', CONST_Database_Web_User, $sTemplate);
|
||||||
$sTemplate = replace_tablespace('{ts:address-data}',
|
$sTemplate = replace_tablespace(
|
||||||
CONST_Tablespace_Address_Data, $sTemplate);
|
'{ts:address-data}',
|
||||||
$sTemplate = replace_tablespace('{ts:address-index}',
|
CONST_Tablespace_Address_Data,
|
||||||
CONST_Tablespace_Address_Index, $sTemplate);
|
$sTemplate
|
||||||
$sTemplate = replace_tablespace('{ts:search-data}',
|
);
|
||||||
CONST_Tablespace_Search_Data, $sTemplate);
|
$sTemplate = replace_tablespace(
|
||||||
$sTemplate = replace_tablespace('{ts:search-index}',
|
'{ts:address-index}',
|
||||||
CONST_Tablespace_Search_Index, $sTemplate);
|
CONST_Tablespace_Address_Index,
|
||||||
$sTemplate = replace_tablespace('{ts:aux-data}',
|
$sTemplate
|
||||||
CONST_Tablespace_Aux_Data, $sTemplate);
|
);
|
||||||
$sTemplate = replace_tablespace('{ts:aux-index}',
|
$sTemplate = replace_tablespace(
|
||||||
CONST_Tablespace_Aux_Index, $sTemplate);
|
'{ts:search-data}',
|
||||||
|
CONST_Tablespace_Search_Data,
|
||||||
|
$sTemplate
|
||||||
|
);
|
||||||
|
$sTemplate = replace_tablespace(
|
||||||
|
'{ts:search-index}',
|
||||||
|
CONST_Tablespace_Search_Index,
|
||||||
|
$sTemplate
|
||||||
|
);
|
||||||
|
$sTemplate = replace_tablespace(
|
||||||
|
'{ts:aux-data}',
|
||||||
|
CONST_Tablespace_Aux_Data,
|
||||||
|
$sTemplate
|
||||||
|
);
|
||||||
|
$sTemplate = replace_tablespace(
|
||||||
|
'{ts:aux-index}',
|
||||||
|
CONST_Tablespace_Aux_Index,
|
||||||
|
$sTemplate
|
||||||
|
);
|
||||||
pgsqlRunScript($sTemplate, false);
|
pgsqlRunScript($sTemplate, false);
|
||||||
|
|
||||||
// re-run the functions
|
// re-run the functions
|
||||||
@@ -221,18 +239,36 @@ if ($aCMDResult['create-partition-tables'] || $aCMDResult['all']) {
|
|||||||
$bDidSomething = true;
|
$bDidSomething = true;
|
||||||
|
|
||||||
$sTemplate = file_get_contents(CONST_BasePath.'/sql/partition-tables.src.sql');
|
$sTemplate = file_get_contents(CONST_BasePath.'/sql/partition-tables.src.sql');
|
||||||
$sTemplate = replace_tablespace('{ts:address-data}',
|
$sTemplate = replace_tablespace(
|
||||||
CONST_Tablespace_Address_Data, $sTemplate);
|
'{ts:address-data}',
|
||||||
$sTemplate = replace_tablespace('{ts:address-index}',
|
CONST_Tablespace_Address_Data,
|
||||||
CONST_Tablespace_Address_Index, $sTemplate);
|
$sTemplate
|
||||||
$sTemplate = replace_tablespace('{ts:search-data}',
|
);
|
||||||
CONST_Tablespace_Search_Data, $sTemplate);
|
$sTemplate = replace_tablespace(
|
||||||
$sTemplate = replace_tablespace('{ts:search-index}',
|
'{ts:address-index}',
|
||||||
CONST_Tablespace_Search_Index, $sTemplate);
|
CONST_Tablespace_Address_Index,
|
||||||
$sTemplate = replace_tablespace('{ts:aux-data}',
|
$sTemplate
|
||||||
CONST_Tablespace_Aux_Data, $sTemplate);
|
);
|
||||||
$sTemplate = replace_tablespace('{ts:aux-index}',
|
$sTemplate = replace_tablespace(
|
||||||
CONST_Tablespace_Aux_Index, $sTemplate);
|
'{ts:search-data}',
|
||||||
|
CONST_Tablespace_Search_Data,
|
||||||
|
$sTemplate
|
||||||
|
);
|
||||||
|
$sTemplate = replace_tablespace(
|
||||||
|
'{ts:search-index}',
|
||||||
|
CONST_Tablespace_Search_Index,
|
||||||
|
$sTemplate
|
||||||
|
);
|
||||||
|
$sTemplate = replace_tablespace(
|
||||||
|
'{ts:aux-data}',
|
||||||
|
CONST_Tablespace_Aux_Data,
|
||||||
|
$sTemplate
|
||||||
|
);
|
||||||
|
$sTemplate = replace_tablespace(
|
||||||
|
'{ts:aux-index}',
|
||||||
|
CONST_Tablespace_Aux_Index,
|
||||||
|
$sTemplate
|
||||||
|
);
|
||||||
|
|
||||||
pgsqlRunPartitionScript($sTemplate);
|
pgsqlRunPartitionScript($sTemplate);
|
||||||
}
|
}
|
||||||
@@ -351,10 +387,16 @@ if ($aCMDResult['import-tiger-data']) {
|
|||||||
|
|
||||||
$sTemplate = file_get_contents(CONST_BasePath.'/sql/tiger_import_start.sql');
|
$sTemplate = file_get_contents(CONST_BasePath.'/sql/tiger_import_start.sql');
|
||||||
$sTemplate = str_replace('{www-user}', CONST_Database_Web_User, $sTemplate);
|
$sTemplate = str_replace('{www-user}', CONST_Database_Web_User, $sTemplate);
|
||||||
$sTemplate = replace_tablespace('{ts:aux-data}',
|
$sTemplate = replace_tablespace(
|
||||||
CONST_Tablespace_Aux_Data, $sTemplate);
|
'{ts:aux-data}',
|
||||||
$sTemplate = replace_tablespace('{ts:aux-index}',
|
CONST_Tablespace_Aux_Data,
|
||||||
CONST_Tablespace_Aux_Index, $sTemplate);
|
$sTemplate
|
||||||
|
);
|
||||||
|
$sTemplate = replace_tablespace(
|
||||||
|
'{ts:aux-index}',
|
||||||
|
CONST_Tablespace_Aux_Index,
|
||||||
|
$sTemplate
|
||||||
|
);
|
||||||
pgsqlRunScript($sTemplate, false);
|
pgsqlRunScript($sTemplate, false);
|
||||||
|
|
||||||
$aDBInstances = array();
|
$aDBInstances = array();
|
||||||
@@ -401,10 +443,16 @@ if ($aCMDResult['import-tiger-data']) {
|
|||||||
echo "Creating indexes\n";
|
echo "Creating indexes\n";
|
||||||
$sTemplate = file_get_contents(CONST_BasePath.'/sql/tiger_import_finish.sql');
|
$sTemplate = file_get_contents(CONST_BasePath.'/sql/tiger_import_finish.sql');
|
||||||
$sTemplate = str_replace('{www-user}', CONST_Database_Web_User, $sTemplate);
|
$sTemplate = str_replace('{www-user}', CONST_Database_Web_User, $sTemplate);
|
||||||
$sTemplate = replace_tablespace('{ts:aux-data}',
|
$sTemplate = replace_tablespace(
|
||||||
CONST_Tablespace_Aux_Data, $sTemplate);
|
'{ts:aux-data}',
|
||||||
$sTemplate = replace_tablespace('{ts:aux-index}',
|
CONST_Tablespace_Aux_Data,
|
||||||
CONST_Tablespace_Aux_Index, $sTemplate);
|
$sTemplate
|
||||||
|
);
|
||||||
|
$sTemplate = replace_tablespace(
|
||||||
|
'{ts:aux-index}',
|
||||||
|
CONST_Tablespace_Aux_Index,
|
||||||
|
$sTemplate
|
||||||
|
);
|
||||||
pgsqlRunScript($sTemplate, false);
|
pgsqlRunScript($sTemplate, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -522,12 +570,21 @@ if ($aCMDResult['create-search-indices'] || $aCMDResult['all']) {
|
|||||||
$bDidSomething = true;
|
$bDidSomething = true;
|
||||||
|
|
||||||
$sTemplate = file_get_contents(CONST_BasePath.'/sql/indices.src.sql');
|
$sTemplate = file_get_contents(CONST_BasePath.'/sql/indices.src.sql');
|
||||||
$sTemplate = replace_tablespace('{ts:address-index}',
|
$sTemplate = replace_tablespace(
|
||||||
CONST_Tablespace_Address_Index, $sTemplate);
|
'{ts:address-index}',
|
||||||
$sTemplate = replace_tablespace('{ts:search-index}',
|
CONST_Tablespace_Address_Index,
|
||||||
CONST_Tablespace_Search_Index, $sTemplate);
|
$sTemplate
|
||||||
$sTemplate = replace_tablespace('{ts:aux-index}',
|
);
|
||||||
CONST_Tablespace_Aux_Index, $sTemplate);
|
$sTemplate = replace_tablespace(
|
||||||
|
'{ts:search-index}',
|
||||||
|
CONST_Tablespace_Search_Index,
|
||||||
|
$sTemplate
|
||||||
|
);
|
||||||
|
$sTemplate = replace_tablespace(
|
||||||
|
'{ts:aux-index}',
|
||||||
|
CONST_Tablespace_Aux_Index,
|
||||||
|
$sTemplate
|
||||||
|
);
|
||||||
|
|
||||||
pgsqlRunScript($sTemplate);
|
pgsqlRunScript($sTemplate);
|
||||||
}
|
}
|
||||||
@@ -759,8 +816,7 @@ function passthruCheckReturn($cmd)
|
|||||||
function replace_tablespace($sTemplate, $sTablespace, $sSql)
|
function replace_tablespace($sTemplate, $sTablespace, $sSql)
|
||||||
{
|
{
|
||||||
if ($sTablespace) {
|
if ($sTablespace) {
|
||||||
$sSql = str_replace($sTemplate, 'TABLESPACE "'.$sTablespace.'"',
|
$sSql = str_replace($sTemplate, 'TABLESPACE "'.$sTablespace.'"', $sSql);
|
||||||
$sSql);
|
|
||||||
} else {
|
} else {
|
||||||
$sSql = str_replace($sTemplate, '', $sSql);
|
$sSql = str_replace($sTemplate, '', $sSql);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,8 +46,9 @@ if ($aCMDResult['wiki-import']) {
|
|||||||
# quotes into the wiki
|
# quotes into the wiki
|
||||||
$sType = preg_replace('/"/', '', $sType);
|
$sType = preg_replace('/"/', '', $sType);
|
||||||
# sanity check, in case somebody added garbage in the wiki
|
# sanity check, in case somebody added garbage in the wiki
|
||||||
if (preg_match('/^\\w+$/', $sClass) < 1 ||
|
if (preg_match('/^\\w+$/', $sClass) < 1
|
||||||
preg_match('/^\\w+$/', $sType) < 1) {
|
|| preg_match('/^\\w+$/', $sType) < 1
|
||||||
|
) {
|
||||||
trigger_error("Bad class/type for language $sLanguage: $sClass=$sType");
|
trigger_error("Bad class/type for language $sLanguage: $sClass=$sType");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,11 @@ if (!$aResult['search-only']) {
|
|||||||
if ($bVerbose) echo "$fLat, $fLon = ";
|
if ($bVerbose) echo "$fLat, $fLon = ";
|
||||||
$aLookup = $oReverseGeocode->lookup($fLat, $fLon);
|
$aLookup = $oReverseGeocode->lookup($fLat, $fLon);
|
||||||
if ($aLookup && $aLookup['place_id']) {
|
if ($aLookup && $aLookup['place_id']) {
|
||||||
$aDetails = $oPlaceLookup->lookup((int)$aLookup['place_id'],
|
$aDetails = $oPlaceLookup->lookup(
|
||||||
$aLookup['type'], $aLookup['fraction']);
|
(int)$aLookup['place_id'],
|
||||||
|
$aLookup['type'],
|
||||||
|
$aLookup['fraction']
|
||||||
|
);
|
||||||
if ($bVerbose) echo $aDetails['langaddress']."\n";
|
if ($bVerbose) echo $aDetails['langaddress']."\n";
|
||||||
} else {
|
} else {
|
||||||
echo ".";
|
echo ".";
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
python-numpy php-phpunit-PHPUnit
|
python-numpy php-phpunit-PHPUnit
|
||||||
pip install --user --upgrade pip setuptools lettuce==0.2.18 six==1.9 \
|
pip install --user --upgrade pip setuptools lettuce==0.2.18 six==1.9 \
|
||||||
haversine Shapely pytidylib
|
haversine Shapely pytidylib
|
||||||
|
sudo pear install PHP_CodeSniffer
|
||||||
|
|
||||||
#
|
#
|
||||||
# System Configuration
|
# System Configuration
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ sudo apt-get install -y -qq python-Levenshtein python-shapely \
|
|||||||
python-numpy phpunit
|
python-numpy phpunit
|
||||||
|
|
||||||
sudo -H pip install --quiet 'setuptools>=23.0.0' lettuce==0.2.18 'six>=1.9' haversine
|
sudo -H pip install --quiet 'setuptools>=23.0.0' lettuce==0.2.18 'six>=1.9' haversine
|
||||||
|
sudo pear install PHP_CodeSniffer
|
||||||
|
|
||||||
sudo service postgresql restart
|
sudo service postgresql restart
|
||||||
sudo -u postgres createuser -S www-data
|
sudo -u postgres createuser -S www-data
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export DEBIAN_FRONTEND=noninteractive #DOCS:
|
|||||||
python-numpy phpunit
|
python-numpy phpunit
|
||||||
|
|
||||||
pip install --user lettuce==0.2.18 six==1.7 haversine
|
pip install --user lettuce==0.2.18 six==1.7 haversine
|
||||||
|
sudo pear install PHP_CodeSniffer
|
||||||
|
|
||||||
#
|
#
|
||||||
# System Configuration
|
# System Configuration
|
||||||
|
|||||||
@@ -10,8 +10,7 @@
|
|||||||
$oDB =& getDB();
|
$oDB =& getDB();
|
||||||
|
|
||||||
$sSQL = "select placex.place_id, calculated_country_code as country_code, name->'name' as name, i.* from placex, import_polygon_delete i where placex.osm_id = i.osm_id and placex.osm_type = i.osm_type and placex.class = i.class and placex.type = i.type";
|
$sSQL = "select placex.place_id, calculated_country_code as country_code, name->'name' as name, i.* from placex, import_polygon_delete i where placex.osm_id = i.osm_id and placex.osm_type = i.osm_type and placex.class = i.class and placex.type = i.type";
|
||||||
$aPolygons = chksql($oDB->getAll($sSQL),
|
$aPolygons = chksql($oDB->getAll($sSQL), "Could not get list of deleted OSM elements.");
|
||||||
"Could not get list of deleted OSM elements.");
|
|
||||||
|
|
||||||
if (CONST_DEBUG) {
|
if (CONST_DEBUG) {
|
||||||
var_dump($aPolygons);
|
var_dump($aPolygons);
|
||||||
|
|||||||
@@ -66,8 +66,7 @@ $sSQL .= " ST_y(centroid) as lat, ST_x(centroid) as lon,";
|
|||||||
$sSQL .= " case when importance = 0 OR importance IS NULL then 0.75-(rank_search::float/40) else importance end as calculated_importance, ";
|
$sSQL .= " case when importance = 0 OR importance IS NULL then 0.75-(rank_search::float/40) else importance end as calculated_importance, ";
|
||||||
$sSQL .= " ST_AsText(CASE WHEN ST_NPoints(geometry) > 5000 THEN ST_SimplifyPreserveTopology(geometry, 0.0001) ELSE geometry END) as outlinestring";
|
$sSQL .= " ST_AsText(CASE WHEN ST_NPoints(geometry) > 5000 THEN ST_SimplifyPreserveTopology(geometry, 0.0001) ELSE geometry END) as outlinestring";
|
||||||
$sSQL .= " from placex where place_id = $iPlaceID";
|
$sSQL .= " from placex where place_id = $iPlaceID";
|
||||||
$aPointDetails = chksql($oDB->getRow($sSQL),
|
$aPointDetails = chksql($oDB->getRow($sSQL), "Could not get details of place object.");
|
||||||
"Could not get details of place object.");
|
|
||||||
$aPointDetails['localname'] = $aPointDetails['localname']?$aPointDetails['localname']:$aPointDetails['housenumber'];
|
$aPointDetails['localname'] = $aPointDetails['localname']?$aPointDetails['localname']:$aPointDetails['housenumber'];
|
||||||
|
|
||||||
$aClassType = getClassTypesWithImportance();
|
$aClassType = getClassTypesWithImportance();
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ $bAsGeoJSON = $oParams->getBool('polygon_geojson');
|
|||||||
$bAsKML = $oParams->getBool('polygon_kml');
|
$bAsKML = $oParams->getBool('polygon_kml');
|
||||||
$bAsSVG = $oParams->getBool('polygon_svg');
|
$bAsSVG = $oParams->getBool('polygon_svg');
|
||||||
$bAsText = $oParams->getBool('polygon_text');
|
$bAsText = $oParams->getBool('polygon_text');
|
||||||
if ((($bAsGeoJSON?1:0) + ($bAsKML?1:0) + ($bAsSVG?1:0)
|
|
||||||
+ ($bAsText?1:0)) > CONST_PolygonOutput_MaximumTypes
|
$iWantedTypes = ($bAsGeoJSON?1:0) + ($bAsKML?1:0) + ($bAsSVG?1:0) + ($bAsText?1:0);
|
||||||
) {
|
if ($iWantedTypes > CONST_PolygonOutput_MaximumTypes) {
|
||||||
if (CONST_PolygonOutput_MaximumTypes) {
|
if (CONST_PolygonOutput_MaximumTypes) {
|
||||||
userError("Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option");
|
userError("Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option");
|
||||||
} else {
|
} else {
|
||||||
@@ -58,8 +58,11 @@ if ($sOsmType && $iOsmId > 0) {
|
|||||||
$aLookup = $oReverseGeocode->lookup($fLat, $fLon);
|
$aLookup = $oReverseGeocode->lookup($fLat, $fLon);
|
||||||
if (CONST_Debug) var_dump($aLookup);
|
if (CONST_Debug) var_dump($aLookup);
|
||||||
|
|
||||||
$aPlace = $oPlaceLookup->lookup((int)$aLookup['place_id'],
|
$aPlace = $oPlaceLookup->lookup(
|
||||||
$aLookup['type'], $aLookup['fraction']);
|
(int)$aLookup['place_id'],
|
||||||
|
$aLookup['type'],
|
||||||
|
$aLookup['fraction']
|
||||||
|
);
|
||||||
} elseif ($sOutputFormat != 'html') {
|
} elseif ($sOutputFormat != 'html') {
|
||||||
userError("Need coordinates or OSM object to lookup.");
|
userError("Need coordinates or OSM object to lookup.");
|
||||||
}
|
}
|
||||||
@@ -73,9 +76,12 @@ if ($aPlace) {
|
|||||||
$oPlaceLookup->setPolygonSimplificationThreshold($fThreshold);
|
$oPlaceLookup->setPolygonSimplificationThreshold($fThreshold);
|
||||||
|
|
||||||
$fRadius = $fDiameter = getResultDiameter($aPlace);
|
$fRadius = $fDiameter = getResultDiameter($aPlace);
|
||||||
$aOutlineResult = $oPlaceLookup->getOutlines($aPlace['place_id'],
|
$aOutlineResult = $oPlaceLookup->getOutlines(
|
||||||
$aPlace['lon'], $aPlace['lat'],
|
$aPlace['place_id'],
|
||||||
$fRadius);
|
$aPlace['lon'],
|
||||||
|
$aPlace['lat'],
|
||||||
|
$fRadius
|
||||||
|
);
|
||||||
|
|
||||||
if ($aOutlineResult) {
|
if ($aOutlineResult) {
|
||||||
$aPlace = array_merge($aPlace, $aOutlineResult);
|
$aPlace = array_merge($aPlace, $aOutlineResult);
|
||||||
|
|||||||
@@ -38,13 +38,8 @@ if ($sOutputFormat == 'html') {
|
|||||||
$bAsKML = $oParams->getBool('polygon_kml');
|
$bAsKML = $oParams->getBool('polygon_kml');
|
||||||
$bAsSVG = $oParams->getBool('polygon_svg');
|
$bAsSVG = $oParams->getBool('polygon_svg');
|
||||||
$bAsText = $oParams->getBool('polygon_text');
|
$bAsText = $oParams->getBool('polygon_text');
|
||||||
if (( ($bAsGeoJSON?1:0)
|
$iWantedTypes = ($bAsGeoJSON?1:0) + ($bAsKML?1:0) + ($bAsSVG?1:0) + ($bAsText?1:0) + ($bAsPoints?1:0);
|
||||||
+ ($bAsKML?1:0)
|
if ($iWantedTypes > CONST_PolygonOutput_MaximumTypes) {
|
||||||
+ ($bAsSVG?1:0)
|
|
||||||
+ ($bAsText?1:0)
|
|
||||||
+ ($bAsPoints?1:0)
|
|
||||||
) > CONST_PolygonOutput_MaximumTypes
|
|
||||||
) {
|
|
||||||
if (CONST_PolygonOutput_MaximumTypes) {
|
if (CONST_PolygonOutput_MaximumTypes) {
|
||||||
userError("Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option");
|
userError("Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option");
|
||||||
} else {
|
} else {
|
||||||
@@ -82,7 +77,9 @@ if (CONST_Search_BatchMode && isset($_GET['batch'])) {
|
|||||||
$oGeocode->setQueryFromParams($oParams);
|
$oGeocode->setQueryFromParams($oParams);
|
||||||
|
|
||||||
if (!$oGeocode->getQueryString()
|
if (!$oGeocode->getQueryString()
|
||||||
&& isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'][0] == '/') {
|
&& isset($_SERVER['PATH_INFO'])
|
||||||
|
&& $_SERVER['PATH_INFO'][0] == '/'
|
||||||
|
) {
|
||||||
$sQuery = substr(rawurldecode($_SERVER['PATH_INFO']), 1);
|
$sQuery = substr(rawurldecode($_SERVER['PATH_INFO']), 1);
|
||||||
|
|
||||||
// reverse order of '/' separated string
|
// reverse order of '/' separated string
|
||||||
|
|||||||
Reference in New Issue
Block a user