mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-11 05:14:07 +00:00
fix CodeSniffer violations
This commit is contained in:
@@ -368,7 +368,7 @@ class Geocode
|
|||||||
$this->aAddressRankList = array();
|
$this->aAddressRankList = array();
|
||||||
|
|
||||||
$this->aStructuredQuery = array();
|
$this->aStructuredQuery = array();
|
||||||
$this->sAllowedTypesSQLList = False;
|
$this->sAllowedTypesSQLList = false;
|
||||||
|
|
||||||
$this->loadStructuredAddressElement($sAmenity, 'amenity', 26, 30, false);
|
$this->loadStructuredAddressElement($sAmenity, 'amenity', 26, 30, false);
|
||||||
$this->loadStructuredAddressElement($sStreet, 'street', 26, 30, false);
|
$this->loadStructuredAddressElement($sStreet, 'street', 26, 30, false);
|
||||||
@@ -413,8 +413,7 @@ class Geocode
|
|||||||
if (sizeof($aPlaceIDs) == 0) return array();
|
if (sizeof($aPlaceIDs) == 0) return array();
|
||||||
|
|
||||||
$sLanguagePrefArraySQL = getArraySQL(
|
$sLanguagePrefArraySQL = getArraySQL(
|
||||||
array_map("getDBQuoted",
|
array_map("getDBQuoted", $this->aLangPrefOrder)
|
||||||
$this->aLangPrefOrder)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get the details for display (is this a redundant extra step?)
|
// Get the details for display (is this a redundant extra step?)
|
||||||
@@ -789,7 +788,6 @@ class Geocode
|
|||||||
$aNewWordsetSearches[] = $oSearch;
|
$aNewWordsetSearches[] = $oSearch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -892,8 +890,7 @@ class Geocode
|
|||||||
|
|
||||||
$sNormQuery = $this->normTerm($this->sQuery);
|
$sNormQuery = $this->normTerm($this->sQuery);
|
||||||
$sLanguagePrefArraySQL = getArraySQL(
|
$sLanguagePrefArraySQL = getArraySQL(
|
||||||
array_map("getDBQuoted",
|
array_map("getDBQuoted", $this->aLangPrefOrder)
|
||||||
$this->aLangPrefOrder)
|
|
||||||
);
|
);
|
||||||
$sCountryCodesSQL = false;
|
$sCountryCodesSQL = false;
|
||||||
if ($this->aCountryCodes) {
|
if ($this->aCountryCodes) {
|
||||||
|
|||||||
@@ -1,47 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once(CONST_BasePath.'/lib/SpecialSearchOperator.php');
|
||||||
|
|
||||||
namespace Nominatim;
|
namespace Nominatim;
|
||||||
|
|
||||||
/**
|
|
||||||
* Operators describing special searches.
|
|
||||||
*/
|
|
||||||
abstract class Operator
|
|
||||||
{
|
|
||||||
/// No operator selected.
|
|
||||||
const NONE = 0;
|
|
||||||
/// Search for POI of the given type.
|
|
||||||
const TYPE = 1;
|
|
||||||
/// Search for POIs near the given place.
|
|
||||||
const NEAR = 2;
|
|
||||||
/// Search for POIS in the given place.
|
|
||||||
const IN = 3;
|
|
||||||
/// Search for POIS named as given.
|
|
||||||
const NAME = 4;
|
|
||||||
/// Search for postcodes.
|
|
||||||
const POSTCODE = 5;
|
|
||||||
|
|
||||||
private static $aConstantNames = null;
|
|
||||||
|
|
||||||
public static function toString($iOperator)
|
|
||||||
{
|
|
||||||
if ($iOperator == Operator::NONE) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Operator::$aConstantNames === null) {
|
|
||||||
$oReflector = new \ReflectionClass ('Nominatim\Operator');
|
|
||||||
$aConstants = $oReflector->getConstants();
|
|
||||||
|
|
||||||
Operator::$aConstantNames = array();
|
|
||||||
foreach ($aConstants as $sName => $iValue) {
|
|
||||||
Operator::$aConstantNames[$iValue] = $sName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Operator::$aConstantNames[$iOperator];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of a single interpretation of a search query.
|
* Description of a single interpretation of a search query.
|
||||||
*/
|
*/
|
||||||
@@ -79,6 +41,7 @@ class SearchDescription
|
|||||||
/// Index of phrase currently processed
|
/// Index of phrase currently processed
|
||||||
private $iNamePhrase = -1;
|
private $iNamePhrase = -1;
|
||||||
|
|
||||||
|
|
||||||
public function getRank()
|
public function getRank()
|
||||||
{
|
{
|
||||||
return $this->iSearchRank;
|
return $this->iSearchRank;
|
||||||
@@ -95,9 +58,6 @@ class SearchDescription
|
|||||||
return $this->sPostcode;
|
return $this->sPostcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the geographic search radius.
|
|
||||||
*/
|
|
||||||
public function setNear(&$oNearPoint)
|
public function setNear(&$oNearPoint)
|
||||||
{
|
{
|
||||||
$this->oNearPoint = $oNearPoint;
|
$this->oNearPoint = $oNearPoint;
|
||||||
@@ -110,26 +70,17 @@ class SearchDescription
|
|||||||
$this->sType = $sType;
|
$this->sType = $sType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if name or address for the search are specified.
|
|
||||||
*/
|
|
||||||
public function isNamedSearch()
|
public function isNamedSearch()
|
||||||
{
|
{
|
||||||
return sizeof($this->aName) > 0 || sizeof($this->aAddress) > 0;
|
return sizeof($this->aName) > 0 || sizeof($this->aAddress) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if only a country is requested.
|
|
||||||
*/
|
|
||||||
public function isCountrySearch()
|
public function isCountrySearch()
|
||||||
{
|
{
|
||||||
return $this->sCountryCode && sizeof($this->aName) == 0
|
return $this->sCountryCode && sizeof($this->aName) == 0
|
||||||
&& !$this->iOperator && !$this->oNearPoint;
|
&& !$this->iOperator && !$this->oNearPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a search near a geographic location is requested.
|
|
||||||
*/
|
|
||||||
public function isNearSearch()
|
public function isNearSearch()
|
||||||
{
|
{
|
||||||
return (bool) $this->oNearPoint;
|
return (bool) $this->oNearPoint;
|
||||||
@@ -179,13 +130,6 @@ class SearchDescription
|
|||||||
return $this->iOperator != Operator::NONE;
|
return $this->iOperator != Operator::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Extract special terms from the query, amend the search
|
|
||||||
* and return the shortended query.
|
|
||||||
*
|
|
||||||
* Only the first special term found will be used but all will
|
|
||||||
* be removed from the query.
|
|
||||||
*/
|
|
||||||
public function extractKeyValuePairs($sQuery)
|
public function extractKeyValuePairs($sQuery)
|
||||||
{
|
{
|
||||||
// Search for terms of kind [<key>=<value>].
|
// Search for terms of kind [<key>=<value>].
|
||||||
@@ -225,6 +169,7 @@ class SearchDescription
|
|||||||
|
|
||||||
/////////// Search building functions
|
/////////// Search building functions
|
||||||
|
|
||||||
|
|
||||||
public function extendWithFullTerm($aSearchTerm, $bWordInQuery, $bHasPartial, $sPhraseType, $bFirstToken, $bFirstPhrase, $bLastToken, &$iGlobalRank)
|
public function extendWithFullTerm($aSearchTerm, $bWordInQuery, $bHasPartial, $sPhraseType, $bFirstToken, $bFirstPhrase, $bLastToken, &$iGlobalRank)
|
||||||
{
|
{
|
||||||
$aNewSearches = array();
|
$aNewSearches = array();
|
||||||
@@ -335,8 +280,7 @@ class SearchDescription
|
|||||||
$oSearch->iSearchRank++;
|
$oSearch->iSearchRank++;
|
||||||
$oSearch->aAddress[$iWordID] = $iWordID;
|
$oSearch->aAddress[$iWordID] = $iWordID;
|
||||||
$aNewSearches[] = $oSearch;
|
$aNewSearches[] = $oSearch;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$this->aFullNameAddress[$iWordID] = $iWordID;
|
$this->aFullNameAddress[$iWordID] = $iWordID;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -421,6 +365,7 @@ class SearchDescription
|
|||||||
|
|
||||||
/////////// Query functions
|
/////////// Query functions
|
||||||
|
|
||||||
|
|
||||||
public function queryCountry(&$oDB, $sViewboxSQL)
|
public function queryCountry(&$oDB, $sViewboxSQL)
|
||||||
{
|
{
|
||||||
$sSQL = 'SELECT place_id FROM placex ';
|
$sSQL = 'SELECT place_id FROM placex ';
|
||||||
@@ -490,7 +435,7 @@ class SearchDescription
|
|||||||
|
|
||||||
public function queryPostcode(&$oDB, $sCountryList, $iLimit)
|
public function queryPostcode(&$oDB, $sCountryList, $iLimit)
|
||||||
{
|
{
|
||||||
$sSQL = 'SELECT p.place_id FROM location_postcode p ';
|
$sSQL = 'SELECT p.place_id FROM location_postcode p ';
|
||||||
|
|
||||||
if (sizeof($this->aAddress)) {
|
if (sizeof($this->aAddress)) {
|
||||||
$sSQL .= ', search_name s ';
|
$sSQL .= ', search_name s ';
|
||||||
@@ -592,7 +537,7 @@ class SearchDescription
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($sViewboxSmall) {
|
if ($sViewboxSmall) {
|
||||||
$aTerms[] = 'centroid && '.$sViewboxSmall;
|
$aTerms[] = 'centroid && '.$sViewboxSmall;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->oNearPoint) {
|
if ($this->oNearPoint) {
|
||||||
@@ -895,7 +840,8 @@ class SearchDescription
|
|||||||
|
|
||||||
/////////// Sort functions
|
/////////// Sort functions
|
||||||
|
|
||||||
static function bySearchRank($a, $b)
|
|
||||||
|
public static function bySearchRank($a, $b)
|
||||||
{
|
{
|
||||||
if ($a->iSearchRank == $b->iSearchRank) {
|
if ($a->iSearchRank == $b->iSearchRank) {
|
||||||
return $a->iOperator + strlen($a->sHouseNumber)
|
return $a->iOperator + strlen($a->sHouseNumber)
|
||||||
@@ -907,9 +853,12 @@ class SearchDescription
|
|||||||
|
|
||||||
//////////// Debugging functions
|
//////////// Debugging functions
|
||||||
|
|
||||||
function dumpAsHtmlTableRow(&$aWordIDs)
|
|
||||||
|
public function dumpAsHtmlTableRow(&$aWordIDs)
|
||||||
{
|
{
|
||||||
$kf = function($k) use (&$aWordIDs) { return $aWordIDs[$k]; };
|
$kf = function ($k) use (&$aWordIDs) {
|
||||||
|
return $aWordIDs[$k];
|
||||||
|
};
|
||||||
|
|
||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
echo "<td>$this->iSearchRank</td>";
|
echo "<td>$this->iSearchRank</td>";
|
||||||
@@ -934,4 +883,4 @@ class SearchDescription
|
|||||||
|
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
<rule ref="Generic.Files.LineLength">
|
<rule ref="Generic.Files.LineLength">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="lineLimit" value="199"/>
|
<property name="lineLimit" value="194"/>
|
||||||
<property name="absoluteLineLimit" value="199"/>
|
<property name="absoluteLineLimit" value="194"/>
|
||||||
</properties>
|
</properties>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
|
|||||||
@@ -540,7 +540,6 @@ if ($aCMDResult['calculate-postcodes'] || $aCMDResult['all']) {
|
|||||||
$sSQL .= " FROM us_postcode WHERE postcode NOT IN";
|
$sSQL .= " FROM us_postcode WHERE postcode NOT IN";
|
||||||
$sSQL .= " (SELECT postcode FROM location_postcode";
|
$sSQL .= " (SELECT postcode FROM location_postcode";
|
||||||
$sSQL .= " WHERE country_code = 'us')";
|
$sSQL .= " WHERE country_code = 'us')";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$sSQL .= "TRUNCATE TABLE us_postcode";
|
$sSQL .= "TRUNCATE TABLE us_postcode";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,8 +77,7 @@ if ($aResult['init-updates']) {
|
|||||||
if ($sDatabaseDate === false) {
|
if ($sDatabaseDate === false) {
|
||||||
fail("Cannot determine date of database.");
|
fail("Cannot determine date of database.");
|
||||||
}
|
}
|
||||||
$sWindBack = strftime('%Y-%m-%dT%H:%M:%SZ',
|
$sWindBack = strftime('%Y-%m-%dT%H:%M:%SZ', strtotime($sDatabaseDate) - (3*60*60));
|
||||||
strtotime($sDatabaseDate) - (3*60*60));
|
|
||||||
|
|
||||||
// get the appropriate state id
|
// get the appropriate state id
|
||||||
$aOutput = 0;
|
$aOutput = 0;
|
||||||
@@ -288,7 +287,7 @@ if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) {
|
|||||||
if ($iResult == 3) {
|
if ($iResult == 3) {
|
||||||
echo 'No new updates. Sleeping for '.CONST_Replication_Recheck_Interval." sec.\n";
|
echo 'No new updates. Sleeping for '.CONST_Replication_Recheck_Interval." sec.\n";
|
||||||
sleep(CONST_Replication_Recheck_Interval);
|
sleep(CONST_Replication_Recheck_Interval);
|
||||||
} else if ($iResult != 0) {
|
} elseif ($iResult != 0) {
|
||||||
echo 'ERROR: updates failed.';
|
echo 'ERROR: updates failed.';
|
||||||
exit($iResult);
|
exit($iResult);
|
||||||
} else {
|
} else {
|
||||||
@@ -325,7 +324,11 @@ if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) {
|
|||||||
|
|
||||||
// write the update logs
|
// write the update logs
|
||||||
$iFileSize = filesize($sImportFile);
|
$iFileSize = filesize($sImportFile);
|
||||||
$sSQL = "INSERT INTO import_osmosis_log (batchend, batchseq, batchsize, starttime, endtime, event) values ('$sBatchEnd',$iEndSequence,$iFileSize,'".date('Y-m-d H:i:s', $fCMDStartTime)."','".date('Y-m-d H:i:s')."','import')";
|
$sSQL = 'INSERT INTO import_osmosis_log';
|
||||||
|
$sSQL .= '(batchend, batchseq, batchsize, starttime, endtime, event)';
|
||||||
|
$sSQL .= " values ('$sBatchEnd',$iEndSequence,$iFileSize,'";
|
||||||
|
$sSQL .= date('Y-m-d H:i:s', $fCMDStartTime)."','";
|
||||||
|
$sSQL .= date('Y-m-d H:i:s')."','import')";
|
||||||
var_Dump($sSQL);
|
var_Dump($sSQL);
|
||||||
chksql($oDB->query($sSQL));
|
chksql($oDB->query($sSQL));
|
||||||
|
|
||||||
@@ -348,7 +351,11 @@ if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) {
|
|||||||
exit($iErrorLevel);
|
exit($iErrorLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sSQL = "INSERT INTO import_osmosis_log (batchend, batchseq, batchsize, starttime, endtime, event) values ('$sBatchEnd',$iEndSequence,$iFileSize,'".date('Y-m-d H:i:s', $fCMDStartTime)."','".date('Y-m-d H:i:s')."','index')";
|
$sSQL = 'INSERT INTO import_osmosis_log';
|
||||||
|
$sSQL .= '(batchend, batchseq, batchsize, starttime, endtime, event)';
|
||||||
|
$sSQL .= " values ('$sBatchEnd',$iEndSequence,$iFileSize,'";
|
||||||
|
$sSQL .= date('Y-m-d H:i:s', $fCMDStartTime)."','";
|
||||||
|
$sSQL .= date('Y-m-d H:i:s')."','index')";
|
||||||
var_Dump($sSQL);
|
var_Dump($sSQL);
|
||||||
$oDB->query($sSQL);
|
$oDB->query($sSQL);
|
||||||
echo date('Y-m-d H:i:s')." Completed index step for $sBatchEnd in ".round((time()-$fCMDStartTime)/60, 2)." minutes\n";
|
echo date('Y-m-d H:i:s')." Completed index step for $sBatchEnd in ".round((time()-$fCMDStartTime)/60, 2)." minutes\n";
|
||||||
@@ -362,4 +369,3 @@ if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) {
|
|||||||
if (!$aResult['import-osmosis-all']) exit(0);
|
if (!$aResult['import-osmosis-all']) exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user