mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-09-11 11:15:26 +03:00
replace PHP sizeof() with either count() or empty()
This commit is contained in:
parent
d79a2bb17e
commit
27bc8d4f7b
@ -303,7 +303,7 @@ class Geocode
|
|||||||
$this->loadStructuredAddressElement($sPostalCode, 'postalcode', 5, 11, array(5, 11));
|
$this->loadStructuredAddressElement($sPostalCode, 'postalcode', 5, 11, array(5, 11));
|
||||||
$this->loadStructuredAddressElement($sCountry, 'country', 4, 4, false);
|
$this->loadStructuredAddressElement($sCountry, 'country', 4, 4, false);
|
||||||
|
|
||||||
if (sizeof($this->aStructuredQuery) > 0) {
|
if (!empty($this->aStructuredQuery)) {
|
||||||
$this->sQuery = join(', ', $this->aStructuredQuery);
|
$this->sQuery = join(', ', $this->aStructuredQuery);
|
||||||
if ($this->iMaxAddressRank < 30) {
|
if ($this->iMaxAddressRank < 30) {
|
||||||
$this->sAllowedTypesSQLList = '(\'place\',\'boundary\')';
|
$this->sAllowedTypesSQLList = '(\'place\',\'boundary\')';
|
||||||
@ -317,7 +317,7 @@ class Geocode
|
|||||||
|
|
||||||
$aParams = $this->aStructuredQuery;
|
$aParams = $this->aStructuredQuery;
|
||||||
|
|
||||||
if (sizeof($aParams) == 1) return false;
|
if (count($aParams) == 1) return false;
|
||||||
|
|
||||||
$aOrderToFallback = array('postalcode', 'street', 'city', 'county', 'state');
|
$aOrderToFallback = array('postalcode', 'street', 'city', 'county', 'state');
|
||||||
|
|
||||||
@ -375,8 +375,8 @@ class Geocode
|
|||||||
$sPhraseType,
|
$sPhraseType,
|
||||||
$iToken == 0 && $iPhrase == 0,
|
$iToken == 0 && $iPhrase == 0,
|
||||||
$iPhrase == 0,
|
$iPhrase == 0,
|
||||||
$iToken + 1 == sizeof($aWordset)
|
$iToken + 1 == count($aWordset)
|
||||||
&& $iPhrase + 1 == sizeof($aPhrases)
|
&& $iPhrase + 1 == count($aPhrases)
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($aNewSearches as $oSearch) {
|
foreach ($aNewSearches as $oSearch) {
|
||||||
@ -411,7 +411,7 @@ class Geocode
|
|||||||
usort($aNewWordsetSearches, array('Nominatim\SearchDescription', 'bySearchRank'));
|
usort($aNewWordsetSearches, array('Nominatim\SearchDescription', 'bySearchRank'));
|
||||||
$aWordsetSearches = array_slice($aNewWordsetSearches, 0, 50);
|
$aWordsetSearches = array_slice($aNewWordsetSearches, 0, 50);
|
||||||
}
|
}
|
||||||
//var_Dump('<hr>',sizeof($aWordsetSearches)); exit;
|
//var_Dump('<hr>',count($aWordsetSearches)); exit;
|
||||||
|
|
||||||
$aNewPhraseSearches = array_merge($aNewPhraseSearches, $aNewWordsetSearches);
|
$aNewPhraseSearches = array_merge($aNewPhraseSearches, $aNewWordsetSearches);
|
||||||
usort($aNewPhraseSearches, array('Nominatim\SearchDescription', 'bySearchRank'));
|
usort($aNewPhraseSearches, array('Nominatim\SearchDescription', 'bySearchRank'));
|
||||||
@ -442,7 +442,7 @@ class Geocode
|
|||||||
$iSearchCount = 0;
|
$iSearchCount = 0;
|
||||||
$aSearches = array();
|
$aSearches = array();
|
||||||
foreach ($aGroupedSearches as $iScore => $aNewSearches) {
|
foreach ($aGroupedSearches as $iScore => $aNewSearches) {
|
||||||
$iSearchCount += sizeof($aNewSearches);
|
$iSearchCount += count($aNewSearches);
|
||||||
$aSearches = array_merge($aSearches, $aNewSearches);
|
$aSearches = array_merge($aSearches, $aNewSearches);
|
||||||
if ($iSearchCount > 50) break;
|
if ($iSearchCount > 50) break;
|
||||||
}
|
}
|
||||||
@ -627,7 +627,7 @@ class Geocode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sizeof($aTokens)) {
|
if (!empty($aTokens)) {
|
||||||
// Check which tokens we have, get the ID numbers
|
// Check which tokens we have, get the ID numbers
|
||||||
$sSQL = 'SELECT word_id, word_token, word, class, type, country_code, operator, search_name_count';
|
$sSQL = 'SELECT word_id, word_token, word, class, type, country_code, operator, search_name_count';
|
||||||
$sSQL .= ' FROM word ';
|
$sSQL .= ' FROM word ';
|
||||||
@ -702,8 +702,8 @@ class Geocode
|
|||||||
// because order in the address doesn't matter.
|
// because order in the address doesn't matter.
|
||||||
$aPhrases = array_reverse($aPhrases);
|
$aPhrases = array_reverse($aPhrases);
|
||||||
$aPhrases[0]->invertWordSets();
|
$aPhrases[0]->invertWordSets();
|
||||||
if (sizeof($aPhrases) > 1) {
|
if (count($aPhrases) > 1) {
|
||||||
$aPhrases[sizeof($aPhrases)-1]->invertWordSets();
|
$aPhrases[count($aPhrases)-1]->invertWordSets();
|
||||||
}
|
}
|
||||||
$aReverseGroupedSearches = $this->getGroupedSearches($aSearches, $aPhrases, $aValidTokens, false);
|
$aReverseGroupedSearches = $this->getGroupedSearches($aSearches, $aPhrases, $aValidTokens, false);
|
||||||
|
|
||||||
@ -738,7 +738,7 @@ class Geocode
|
|||||||
$sHash = serialize($aSearch);
|
$sHash = serialize($aSearch);
|
||||||
if (isset($aSearchHash[$sHash])) {
|
if (isset($aSearchHash[$sHash])) {
|
||||||
unset($aGroupedSearches[$iGroup][$iSearch]);
|
unset($aGroupedSearches[$iGroup][$iSearch]);
|
||||||
if (sizeof($aGroupedSearches[$iGroup]) == 0) unset($aGroupedSearches[$iGroup]);
|
if (empty($aGroupedSearches[$iGroup])) unset($aGroupedSearches[$iGroup]);
|
||||||
} else {
|
} else {
|
||||||
$aSearchHash[$sHash] = 1;
|
$aSearchHash[$sHash] = 1;
|
||||||
}
|
}
|
||||||
@ -771,7 +771,7 @@ class Geocode
|
|||||||
if ($iQueryLoop > 20) break;
|
if ($iQueryLoop > 20) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sizeof($aResults) && ($this->iMinAddressRank != 0 || $this->iMaxAddressRank != 30)) {
|
if (!empty($aResults) && ($this->iMinAddressRank != 0 || $this->iMaxAddressRank != 30)) {
|
||||||
// Need to verify passes rank limits before dropping out of the loop (yuk!)
|
// Need to verify passes rank limits before dropping out of the loop (yuk!)
|
||||||
// reduces the number of place ids, like a filter
|
// reduces the number of place ids, like a filter
|
||||||
// rank_address is 30 for interpolated housenumbers
|
// rank_address is 30 for interpolated housenumbers
|
||||||
@ -824,7 +824,7 @@ class Geocode
|
|||||||
$aResults = $tempIDs;
|
$aResults = $tempIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sizeof($aResults)) break;
|
if (!empty($aResults)) break;
|
||||||
if ($iGroupLoop > 4) break;
|
if ($iGroupLoop > 4) break;
|
||||||
if ($iQueryLoop > 30) break;
|
if ($iQueryLoop > 30) break;
|
||||||
}
|
}
|
||||||
@ -843,7 +843,7 @@ class Geocode
|
|||||||
}
|
}
|
||||||
|
|
||||||
// No results? Done
|
// No results? Done
|
||||||
if (!sizeof($aResults)) {
|
if (empty($aResults)) {
|
||||||
if ($this->bFallback) {
|
if ($this->bFallback) {
|
||||||
if ($this->fallbackStructuredQuery()) {
|
if ($this->fallbackStructuredQuery()) {
|
||||||
return $this->lookup();
|
return $this->lookup();
|
||||||
@ -982,7 +982,7 @@ class Geocode
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Absolute limit on number of results
|
// Absolute limit on number of results
|
||||||
if (sizeof($aSearchResults) >= $this->iFinalLimit) break;
|
if (count($aSearchResults) >= $this->iFinalLimit) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CONST_Debug) var_dump($aSearchResults);
|
if (CONST_Debug) var_dump($aSearchResults);
|
||||||
|
@ -99,7 +99,7 @@ class ParameterParser
|
|||||||
arsort($aLanguages);
|
arsort($aLanguages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!sizeof($aLanguages) && CONST_Default_Language) {
|
if (empty($aLanguages) && CONST_Default_Language) {
|
||||||
$aLanguages[CONST_Default_Language] = 1;
|
$aLanguages[CONST_Default_Language] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class Phrase
|
|||||||
$aResult = array(array(join(' ', $aWords)));
|
$aResult = array(array(join(' ', $aWords)));
|
||||||
$sFirstToken = '';
|
$sFirstToken = '';
|
||||||
if ($iDepth < Phrase::MAX_DEPTH) {
|
if ($iDepth < Phrase::MAX_DEPTH) {
|
||||||
while (sizeof($aWords) > 1) {
|
while (count($aWords) > 1) {
|
||||||
$sWord = array_shift($aWords);
|
$sWord = array_shift($aWords);
|
||||||
$sFirstToken .= ($sFirstToken?' ':'').$sWord;
|
$sFirstToken .= ($sFirstToken?' ':'').$sWord;
|
||||||
$aRest = $this->createWordSets($aWords, $iDepth + 1);
|
$aRest = $this->createWordSets($aWords, $iDepth + 1);
|
||||||
@ -101,7 +101,7 @@ class Phrase
|
|||||||
$aResult = array(array(join(' ', $aWords)));
|
$aResult = array(array(join(' ', $aWords)));
|
||||||
$sFirstToken = '';
|
$sFirstToken = '';
|
||||||
if ($iDepth < Phrase::MAX_DEPTH) {
|
if ($iDepth < Phrase::MAX_DEPTH) {
|
||||||
while (sizeof($aWords) > 1) {
|
while (count($aWords) > 1) {
|
||||||
$sWord = array_pop($aWords);
|
$sWord = array_pop($aWords);
|
||||||
$sFirstToken = $sWord.($sFirstToken?' ':'').$sFirstToken;
|
$sFirstToken = $sWord.($sFirstToken?' ':'').$sFirstToken;
|
||||||
$aRest = $this->createInverseWordSets($aWords, $iDepth + 1);
|
$aRest = $this->createInverseWordSets($aWords, $iDepth + 1);
|
||||||
|
@ -164,12 +164,12 @@ class PlaceLookup
|
|||||||
|
|
||||||
$aResults = $this->lookup(array($iPlaceID => new Result($iPlaceID)));
|
$aResults = $this->lookup(array($iPlaceID => new Result($iPlaceID)));
|
||||||
|
|
||||||
return sizeof($aResults) ? reset($aResults) : null;
|
return empty($aResults) ? null : reset($aResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function lookup($aResults, $iMinRank = 0, $iMaxRank = 30)
|
public function lookup($aResults, $iMinRank = 0, $iMaxRank = 30)
|
||||||
{
|
{
|
||||||
if (!sizeof($aResults)) {
|
if (empty($aResults)) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
$aSubSelects = array();
|
$aSubSelects = array();
|
||||||
@ -408,7 +408,7 @@ class PlaceLookup
|
|||||||
|
|
||||||
if (CONST_Debug) var_dump($aSubSelects);
|
if (CONST_Debug) var_dump($aSubSelects);
|
||||||
|
|
||||||
if (!sizeof($aSubSelects)) {
|
if (empty($aSubSelects)) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,8 +94,8 @@ class SearchDescription
|
|||||||
*/
|
*/
|
||||||
public function looksLikeFullAddress()
|
public function looksLikeFullAddress()
|
||||||
{
|
{
|
||||||
return sizeof($this->aName)
|
return (!empty($this->aName))
|
||||||
&& (sizeof($this->aAddress || $this->sCountryCode))
|
&& (!empty($this->aAddress) || $this->sCountryCode)
|
||||||
&& preg_match('/[0-9]+/', $this->sHouseNumber);
|
&& preg_match('/[0-9]+/', $this->sHouseNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ class SearchDescription
|
|||||||
*/
|
*/
|
||||||
public function isValidSearch()
|
public function isValidSearch()
|
||||||
{
|
{
|
||||||
if (!sizeof($this->aName)) {
|
if (empty($this->aName)) {
|
||||||
if ($this->sHouseNumber) {
|
if ($this->sHouseNumber) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -223,7 +223,7 @@ class SearchDescription
|
|||||||
// If we have a structured search or this is not the first term,
|
// If we have a structured search or this is not the first term,
|
||||||
// add the postcode as an addendum.
|
// add the postcode as an addendum.
|
||||||
if ($this->iOperator != Operator::POSTCODE
|
if ($this->iOperator != Operator::POSTCODE
|
||||||
&& ($sPhraseType == 'postalcode' || sizeof($this->aName))
|
&& ($sPhraseType == 'postalcode' || !empty($this->aName))
|
||||||
) {
|
) {
|
||||||
$oSearch = clone $this;
|
$oSearch = clone $this;
|
||||||
$oSearch->iSearchRank++;
|
$oSearch->iSearchRank++;
|
||||||
@ -247,8 +247,8 @@ class SearchDescription
|
|||||||
$oSearch->iSearchRank++;
|
$oSearch->iSearchRank++;
|
||||||
}
|
}
|
||||||
// also must not appear in the middle of the address
|
// also must not appear in the middle of the address
|
||||||
if (sizeof($this->aAddress)
|
if (!empty($this->aAddress)
|
||||||
|| sizeof($this->aAddressNonSearch)
|
|| (!empty($this->aAddressNonSearch))
|
||||||
|| $this->sPostcode
|
|| $this->sPostcode
|
||||||
) {
|
) {
|
||||||
$oSearch->iSearchRank++;
|
$oSearch->iSearchRank++;
|
||||||
@ -262,7 +262,7 @@ class SearchDescription
|
|||||||
|
|
||||||
$iOp = Operator::NEAR; // near == in for the moment
|
$iOp = Operator::NEAR; // near == in for the moment
|
||||||
if ($aSearchTerm['operator'] == '') {
|
if ($aSearchTerm['operator'] == '') {
|
||||||
if (sizeof($this->aName) || $this->oContext->isBoundedSearch()) {
|
if (!empty($this->aName) || $this->oContext->isBoundedSearch()) {
|
||||||
$iOp = Operator::NAME;
|
$iOp = Operator::NAME;
|
||||||
}
|
}
|
||||||
$oSearch->iSearchRank += 2;
|
$oSearch->iSearchRank += 2;
|
||||||
@ -280,7 +280,7 @@ class SearchDescription
|
|||||||
// of the phrase. In structured search the name must forcably in
|
// of the phrase. In structured search the name must forcably in
|
||||||
// the first phrase. In unstructured search it may be in a later
|
// the first phrase. In unstructured search it may be in a later
|
||||||
// phrase when the first phrase is a house number.
|
// phrase when the first phrase is a house number.
|
||||||
if (sizeof($this->aName) || !($bFirstPhrase || $sPhraseType == '')) {
|
if (!empty($this->aName) || !($bFirstPhrase || $sPhraseType == '')) {
|
||||||
if (($sPhraseType == '' || !$bFirstPhrase) && !$bHasPartial) {
|
if (($sPhraseType == '' || !$bFirstPhrase) && !$bHasPartial) {
|
||||||
$oSearch = clone $this;
|
$oSearch = clone $this;
|
||||||
$oSearch->iSearchRank++;
|
$oSearch->iSearchRank++;
|
||||||
@ -322,7 +322,7 @@ class SearchDescription
|
|||||||
$iWordID = $aSearchTerm['word_id'];
|
$iWordID = $aSearchTerm['word_id'];
|
||||||
|
|
||||||
if ((!$bStructuredPhrases || $iPhrase > 0)
|
if ((!$bStructuredPhrases || $iPhrase > 0)
|
||||||
&& sizeof($this->aName)
|
&& (!empty($this->aName))
|
||||||
&& strpos($aSearchTerm['word_token'], ' ') === false
|
&& strpos($aSearchTerm['word_token'], ' ') === false
|
||||||
) {
|
) {
|
||||||
if ($aSearchTerm['search_name_count'] + 1 < CONST_Max_Word_Frequency) {
|
if ($aSearchTerm['search_name_count'] + 1 < CONST_Max_Word_Frequency) {
|
||||||
@ -337,7 +337,7 @@ class SearchDescription
|
|||||||
if (preg_match('#^[0-9]+$#', $aSearchTerm['word_token'])) {
|
if (preg_match('#^[0-9]+$#', $aSearchTerm['word_token'])) {
|
||||||
$oSearch->iSearchRank += 2;
|
$oSearch->iSearchRank += 2;
|
||||||
}
|
}
|
||||||
if (sizeof($aFullTokens)) {
|
if (!empty($aFullTokens)) {
|
||||||
$oSearch->iSearchRank++;
|
$oSearch->iSearchRank++;
|
||||||
}
|
}
|
||||||
$aNewSearches[] = $oSearch;
|
$aNewSearches[] = $oSearch;
|
||||||
@ -358,11 +358,11 @@ class SearchDescription
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((!$this->sPostcode && !$this->aAddress && !$this->aAddressNonSearch)
|
if ((!$this->sPostcode && !$this->aAddress && !$this->aAddressNonSearch)
|
||||||
&& (!sizeof($this->aName) || $this->iNamePhrase == $iPhrase)
|
&& (empty($this->aName) || $this->iNamePhrase == $iPhrase)
|
||||||
) {
|
) {
|
||||||
$oSearch = clone $this;
|
$oSearch = clone $this;
|
||||||
$oSearch->iSearchRank += 2;
|
$oSearch->iSearchRank += 2;
|
||||||
if (!sizeof($this->aName)) {
|
if (empty($this->aName)) {
|
||||||
$oSearch->iSearchRank += 1;
|
$oSearch->iSearchRank += 1;
|
||||||
}
|
}
|
||||||
if (preg_match('#^[0-9]+$#', $aSearchTerm['word_token'])) {
|
if (preg_match('#^[0-9]+$#', $aSearchTerm['word_token'])) {
|
||||||
@ -405,7 +405,7 @@ class SearchDescription
|
|||||||
$iHousenumber = -1;
|
$iHousenumber = -1;
|
||||||
|
|
||||||
if ($this->sCountryCode
|
if ($this->sCountryCode
|
||||||
&& !sizeof($this->aName)
|
&& empty($this->aName)
|
||||||
&& !$this->iOperator
|
&& !$this->iOperator
|
||||||
&& !$this->sClass
|
&& !$this->sClass
|
||||||
&& !$this->oContext->hasNearPoint()
|
&& !$this->oContext->hasNearPoint()
|
||||||
@ -414,7 +414,7 @@ class SearchDescription
|
|||||||
if (4 >= $iMinRank && 4 <= $iMaxRank) {
|
if (4 >= $iMinRank && 4 <= $iMaxRank) {
|
||||||
$aResults = $this->queryCountry($oDB);
|
$aResults = $this->queryCountry($oDB);
|
||||||
}
|
}
|
||||||
} elseif (!sizeof($this->aName) && !sizeof($this->aAddress)) {
|
} elseif (empty($this->aName) && empty($this->aAddress)) {
|
||||||
// Neither name nor address? Then we must be
|
// Neither name nor address? Then we must be
|
||||||
// looking for a POI in a geographic area.
|
// looking for a POI in a geographic area.
|
||||||
if ($this->oContext->isBoundedSearch()) {
|
if ($this->oContext->isBoundedSearch()) {
|
||||||
@ -435,17 +435,17 @@ class SearchDescription
|
|||||||
);
|
);
|
||||||
|
|
||||||
//now search for housenumber, if housenumber provided
|
//now search for housenumber, if housenumber provided
|
||||||
if ($this->sHouseNumber && sizeof($aResults)) {
|
if ($this->sHouseNumber && !empty($aResults)) {
|
||||||
$aNamedPlaceIDs = $aResults;
|
$aNamedPlaceIDs = $aResults;
|
||||||
$aResults = $this->queryHouseNumber($oDB, $aNamedPlaceIDs, $iLimit);
|
$aResults = $this->queryHouseNumber($oDB, $aNamedPlaceIDs, $iLimit);
|
||||||
|
|
||||||
if (!sizeof($aResults) && $this->looksLikeFullAddress()) {
|
if (empty($aResults) && $this->looksLikeFullAddress()) {
|
||||||
$aResults = $aNamedPlaceIDs;
|
$aResults = $aNamedPlaceIDs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally get POIs if requested
|
// finally get POIs if requested
|
||||||
if ($this->sClass && sizeof($aResults)) {
|
if ($this->sClass && !empty($aResults)) {
|
||||||
$aResults = $this->queryPoiByOperator($oDB, $aResults, $iLimit);
|
$aResults = $this->queryPoiByOperator($oDB, $aResults, $iLimit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -455,7 +455,7 @@ class SearchDescription
|
|||||||
var_dump(array_keys($aResults));
|
var_dump(array_keys($aResults));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sizeof($aResults) && $this->sPostcode) {
|
if (!empty($aResults) && $this->sPostcode) {
|
||||||
$sPlaceIds = Result::joinIdsByTable($aResults, Result::TABLE_PLACEX);
|
$sPlaceIds = Result::joinIdsByTable($aResults, Result::TABLE_PLACEX);
|
||||||
if ($sPlaceIds) {
|
if ($sPlaceIds) {
|
||||||
$sSQL = 'SELECT place_id FROM placex';
|
$sSQL = 'SELECT place_id FROM placex';
|
||||||
@ -562,7 +562,7 @@ class SearchDescription
|
|||||||
{
|
{
|
||||||
$sSQL = 'SELECT p.place_id FROM location_postcode p ';
|
$sSQL = 'SELECT p.place_id FROM location_postcode p ';
|
||||||
|
|
||||||
if (sizeof($this->aAddress)) {
|
if (!empty($this->aAddress)) {
|
||||||
$sSQL .= ', search_name s ';
|
$sSQL .= ', search_name s ';
|
||||||
$sSQL .= 'WHERE s.place_id = p.parent_place_id ';
|
$sSQL .= 'WHERE s.place_id = p.parent_place_id ';
|
||||||
$sSQL .= 'AND array_cat(s.nameaddress_vector, s.name_vector)';
|
$sSQL .= 'AND array_cat(s.nameaddress_vector, s.name_vector)';
|
||||||
@ -591,7 +591,7 @@ class SearchDescription
|
|||||||
$aTerms = array();
|
$aTerms = array();
|
||||||
$aOrder = array();
|
$aOrder = array();
|
||||||
|
|
||||||
if ($this->sHouseNumber && sizeof($this->aAddress)) {
|
if ($this->sHouseNumber && !empty($this->aAddress)) {
|
||||||
$sHouseNumberRegex = '\\\\m'.$this->sHouseNumber.'\\\\M';
|
$sHouseNumberRegex = '\\\\m'.$this->sHouseNumber.'\\\\M';
|
||||||
$aOrder[] = ' (';
|
$aOrder[] = ' (';
|
||||||
$aOrder[0] .= 'EXISTS(';
|
$aOrder[0] .= 'EXISTS(';
|
||||||
@ -617,13 +617,13 @@ class SearchDescription
|
|||||||
$aOrder[0] .= ') DESC';
|
$aOrder[0] .= ') DESC';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sizeof($this->aName)) {
|
if (!empty($this->aName)) {
|
||||||
$aTerms[] = 'name_vector @> '.getArraySQL($this->aName);
|
$aTerms[] = 'name_vector @> '.getArraySQL($this->aName);
|
||||||
}
|
}
|
||||||
if (sizeof($this->aAddress)) {
|
if (!empty($this->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($this->aName) == 1
|
&& count($this->aName) == 1
|
||||||
&& $aWordFrequencyScores[$this->aName[reset($this->aName)]]
|
&& $aWordFrequencyScores[$this->aName[reset($this->aName)]]
|
||||||
< CONST_Search_NameOnlySearchFrequencyThreshold
|
< CONST_Search_NameOnlySearchFrequencyThreshold
|
||||||
) {
|
) {
|
||||||
@ -653,7 +653,7 @@ class SearchDescription
|
|||||||
$aTerms[] = $this->oContext->withinSQL('centroid');
|
$aTerms[] = $this->oContext->withinSQL('centroid');
|
||||||
$aOrder[] = $this->oContext->distanceSQL('centroid');
|
$aOrder[] = $this->oContext->distanceSQL('centroid');
|
||||||
} elseif ($this->sPostcode) {
|
} elseif ($this->sPostcode) {
|
||||||
if (!sizeof($this->aAddress)) {
|
if (empty($this->aAddress)) {
|
||||||
$aTerms[] = "EXISTS(SELECT place_id FROM location_postcode p WHERE p.postcode = '".$this->sPostcode."' AND ST_DWithin(search_name.centroid, p.geometry, 0.1))";
|
$aTerms[] = "EXISTS(SELECT place_id FROM location_postcode p WHERE p.postcode = '".$this->sPostcode."' AND ST_DWithin(search_name.centroid, p.geometry, 0.1))";
|
||||||
} else {
|
} else {
|
||||||
$aOrder[] = "(SELECT min(ST_Distance(search_name.centroid, p.geometry)) FROM location_postcode p WHERE p.postcode = '".$this->sPostcode."')";
|
$aOrder[] = "(SELECT min(ST_Distance(search_name.centroid, p.geometry)) FROM location_postcode p WHERE p.postcode = '".$this->sPostcode."')";
|
||||||
@ -681,7 +681,7 @@ class SearchDescription
|
|||||||
$sImportanceSQL .= $this->oContext->viewboxImportanceSQL('centroid');
|
$sImportanceSQL .= $this->oContext->viewboxImportanceSQL('centroid');
|
||||||
$aOrder[] = "$sImportanceSQL DESC";
|
$aOrder[] = "$sImportanceSQL DESC";
|
||||||
|
|
||||||
if (sizeof($this->aFullNameAddress)) {
|
if (!empty($this->aFullNameAddress)) {
|
||||||
$sExactMatchSQL = ' ( ';
|
$sExactMatchSQL = ' ( ';
|
||||||
$sExactMatchSQL .= ' SELECT count(*) FROM ( ';
|
$sExactMatchSQL .= ' SELECT count(*) FROM ( ';
|
||||||
$sExactMatchSQL .= ' SELECT unnest('.getArraySQL($this->aFullNameAddress).')';
|
$sExactMatchSQL .= ' SELECT unnest('.getArraySQL($this->aFullNameAddress).')';
|
||||||
@ -700,7 +700,7 @@ class SearchDescription
|
|||||||
|
|
||||||
$aResults = array();
|
$aResults = array();
|
||||||
|
|
||||||
if (sizeof($aTerms)) {
|
if (!empty($aTerms)) {
|
||||||
$sSQL = 'SELECT place_id,'.$sExactMatchSQL;
|
$sSQL = 'SELECT place_id,'.$sExactMatchSQL;
|
||||||
$sSQL .= ' FROM search_name';
|
$sSQL .= ' FROM search_name';
|
||||||
$sSQL .= ' WHERE '.join(' and ', $aTerms);
|
$sSQL .= ' WHERE '.join(' and ', $aTerms);
|
||||||
@ -749,7 +749,7 @@ class SearchDescription
|
|||||||
|
|
||||||
$bIsIntHouseNumber= (bool) preg_match('/[0-9]+/', $this->sHouseNumber);
|
$bIsIntHouseNumber= (bool) preg_match('/[0-9]+/', $this->sHouseNumber);
|
||||||
$iHousenumber = intval($this->sHouseNumber);
|
$iHousenumber = intval($this->sHouseNumber);
|
||||||
if ($bIsIntHouseNumber && !sizeof($aResults)) {
|
if ($bIsIntHouseNumber && empty($aResults)) {
|
||||||
// if nothing found, search in the interpolation line table
|
// if nothing found, search in the interpolation line table
|
||||||
$sSQL = 'SELECT distinct place_id FROM location_property_osmline';
|
$sSQL = 'SELECT distinct place_id FROM location_property_osmline';
|
||||||
$sSQL .= ' WHERE startnumber is not NULL';
|
$sSQL .= ' WHERE startnumber is not NULL';
|
||||||
@ -778,7 +778,7 @@ class SearchDescription
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If nothing found try the aux fallback table
|
// If nothing found try the aux fallback table
|
||||||
if (CONST_Use_Aux_Location_data && !sizeof($aResults)) {
|
if (CONST_Use_Aux_Location_data && empty($aResults)) {
|
||||||
$sSQL = 'SELECT place_id FROM location_property_aux';
|
$sSQL = 'SELECT place_id FROM location_property_aux';
|
||||||
$sSQL .= ' WHERE parent_place_id in ('.$sPlaceIDs.')';
|
$sSQL .= ' WHERE parent_place_id in ('.$sPlaceIDs.')';
|
||||||
$sSQL .= " AND housenumber = '".$this->sHouseNumber."'";
|
$sSQL .= " AND housenumber = '".$this->sHouseNumber."'";
|
||||||
@ -793,7 +793,7 @@ class SearchDescription
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If nothing found then search in Tiger data (location_property_tiger)
|
// If nothing found then search in Tiger data (location_property_tiger)
|
||||||
if (CONST_Use_US_Tiger_Data && $bIsIntHouseNumber && !sizeof($aResults)) {
|
if (CONST_Use_US_Tiger_Data && $bIsIntHouseNumber && empty($aResults)) {
|
||||||
$sSQL = 'SELECT place_id FROM location_property_tiger';
|
$sSQL = 'SELECT place_id FROM location_property_tiger';
|
||||||
$sSQL .= ' WHERE parent_place_id in ('.$sPlaceIDs.') and (';
|
$sSQL .= ' WHERE parent_place_id in ('.$sPlaceIDs.') and (';
|
||||||
if ($iHousenumber % 2 == 0) {
|
if ($iHousenumber % 2 == 0) {
|
||||||
|
@ -16,7 +16,7 @@ function getCmdOpt($aArg, $aSpec, &$aResult, $bExitOnError = false, $bExitOnUnkn
|
|||||||
|
|
||||||
$aResult = array();
|
$aResult = array();
|
||||||
$bUnknown = false;
|
$bUnknown = false;
|
||||||
$iSize = sizeof($aArg);
|
$iSize = count($aArg);
|
||||||
for ($i = 1; $i < $iSize; $i++) {
|
for ($i = 1; $i < $iSize; $i++) {
|
||||||
if (isset($aQuick[$aArg[$i]])) {
|
if (isset($aQuick[$aArg[$i]])) {
|
||||||
$aLine = $aQuick[$aArg[$i]];
|
$aLine = $aQuick[$aArg[$i]];
|
||||||
|
@ -14,7 +14,7 @@ function getProcessorCount()
|
|||||||
{
|
{
|
||||||
$sCPU = file_get_contents('/proc/cpuinfo');
|
$sCPU = file_get_contents('/proc/cpuinfo');
|
||||||
preg_match_all('#processor\s+: [0-9]+#', $sCPU, $aMatches);
|
preg_match_all('#processor\s+: [0-9]+#', $sCPU, $aMatches);
|
||||||
return sizeof($aMatches[0]);
|
return count($aMatches[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
$aFilteredPlaces = array();
|
$aFilteredPlaces = array();
|
||||||
|
|
||||||
if (!sizeof($aPlace)) {
|
if (empty($aPlace)) {
|
||||||
if (isset($sError))
|
if (isset($sError))
|
||||||
$aFilteredPlaces['error'] = $sError;
|
$aFilteredPlaces['error'] = $sError;
|
||||||
else $aFilteredPlaces['error'] = 'Unable to geocode';
|
else $aFilteredPlaces['error'] = 'Unable to geocode';
|
||||||
|
@ -11,7 +11,7 @@ echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.ope
|
|||||||
echo " querystring='".htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES)."'";
|
echo " querystring='".htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES)."'";
|
||||||
echo ">\n";
|
echo ">\n";
|
||||||
|
|
||||||
if (!sizeof($aPlace)) {
|
if (empty($aPlace)) {
|
||||||
if (isset($sError))
|
if (isset($sError))
|
||||||
echo "<error>$sError</error>";
|
echo "<error>$sError</error>";
|
||||||
else echo '<error>Unable to geocode</error>';
|
else echo '<error>Unable to geocode</error>';
|
||||||
|
@ -199,7 +199,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sizeof($aParentOfLines))
|
if (!empty($aParentOfLines))
|
||||||
{
|
{
|
||||||
headline('Parent Of');
|
headline('Parent Of');
|
||||||
|
|
||||||
@ -223,7 +223,7 @@
|
|||||||
_one_row($aAddressLine);
|
_one_row($aAddressLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sizeof($aParentOfLines) >= 500) {
|
if (count($aParentOfLines) >= 500) {
|
||||||
echo '<p>There are more child objects which are not shown.</p>';
|
echo '<p>There are more child objects which are not shown.</p>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ foreach ($aBatchResults as $aSearchResults) {
|
|||||||
$aPlace['icon'] = $aPointDetails['icon'];
|
$aPlace['icon'] = $aPointDetails['icon'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])>0) {
|
if (isset($aPointDetails['address']) && !empty($aPointDetails['address'])) {
|
||||||
$aPlace['address'] = $aPointDetails['address'];
|
$aPlace['address'] = $aPointDetails['address'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
echo '</div>';
|
echo '</div>';
|
||||||
$i = $i+1;
|
$i = $i+1;
|
||||||
}
|
}
|
||||||
if (sizeof($aSearchResults) && $sMoreURL)
|
if (!empty($aSearchResults) && $sMoreURL)
|
||||||
{
|
{
|
||||||
echo '<div class="more"><a class="btn btn-primary" href="'.htmlentities($sMoreURL).'">Search for more results</a></div>';
|
echo '<div class="more"><a class="btn btn-primary" href="'.htmlentities($sMoreURL).'">Search for more results</a></div>';
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ foreach ($aSearchResults as $iResNum => $aPointDetails) {
|
|||||||
$aPlace['icon'] = $aPointDetails['icon'];
|
$aPlace['icon'] = $aPointDetails['icon'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])) {
|
if (isset($aPointDetails['address']) && !empty($aPointDetails['address'])) {
|
||||||
$aPlace['address'] = $aPointDetails['address'];
|
$aPlace['address'] = $aPointDetails['address'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- eval, system, etc -->
|
||||||
|
<rule ref="Generic.PHP.ForbiddenFunctions">
|
||||||
|
<properties>
|
||||||
|
<property name="forbiddenFunctions" type="array" value="sizeof=>count,delete=>unset,print=>echo,create_function=>null,eval=>null"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
<!-- **************************************************************
|
<!-- **************************************************************
|
||||||
DOCUMENTATION
|
DOCUMENTATION
|
||||||
************************************************************** -->
|
************************************************************** -->
|
||||||
|
@ -241,7 +241,7 @@ function _templatesToProperties($aTemplates)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Assume the first template with lots of params is the type (fallback for infobox)
|
// Assume the first template with lots of params is the type (fallback for infobox)
|
||||||
if (!isset($aPageProperties['sPossibleInfoboxType']) && sizeof($aParams) > 10) {
|
if (!isset($aPageProperties['sPossibleInfoboxType']) && count($aParams) > 10) {
|
||||||
$aPageProperties['sPossibleInfoboxType'] = trim($aTemplate[0]);
|
$aPageProperties['sPossibleInfoboxType'] = trim($aTemplate[0]);
|
||||||
// $aPageProperties['aInfoboxParams'] = $aParams;
|
// $aPageProperties['aInfoboxParams'] = $aParams;
|
||||||
}
|
}
|
||||||
@ -495,7 +495,7 @@ if (isset($aCMDResult['link'])) {
|
|||||||
|
|
||||||
if (!isset($aNominatRecords[0])) {
|
if (!isset($aNominatRecords[0])) {
|
||||||
$aNameParts = preg_split('#[(,]#', $aRecord['name']);
|
$aNameParts = preg_split('#[(,]#', $aRecord['name']);
|
||||||
if (sizeof($aNameParts) > 1) {
|
if (count($aNameParts) > 1) {
|
||||||
$sNameURL = $sURL.'&q='.urlencode(trim($aNameParts[0]));
|
$sNameURL = $sURL.'&q='.urlencode(trim($aNameParts[0]));
|
||||||
var_Dump($sNameURL);
|
var_Dump($sNameURL);
|
||||||
$sXML = file_get_contents($sNameURL);
|
$sXML = file_get_contents($sNameURL);
|
||||||
@ -509,7 +509,7 @@ if (isset($aCMDResult['link'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// assume first is best/right
|
// assume first is best/right
|
||||||
for ($i = 0; $i < sizeof($aNominatRecords); $i++) {
|
for ($i = 0; $i < count($aNominatRecords); $i++) {
|
||||||
$fDiff = ($aRecord['lat']-$aNominatRecords[$i]['LAT']) * ($aRecord['lat']-$aNominatRecords[$i]['LAT']);
|
$fDiff = ($aRecord['lat']-$aNominatRecords[$i]['LAT']) * ($aRecord['lat']-$aNominatRecords[$i]['LAT']);
|
||||||
$fDiff += ($aRecord['lon']-$aNominatRecords[$i]['LON']) * ($aRecord['lon']-$aNominatRecords[$i]['LON']);
|
$fDiff += ($aRecord['lon']-$aNominatRecords[$i]['LON']) * ($aRecord['lon']-$aNominatRecords[$i]['LON']);
|
||||||
$fDiff = sqrt($fDiff);
|
$fDiff = sqrt($fDiff);
|
||||||
|
@ -62,7 +62,7 @@ $oPlaceLookup->setIncludeAddressDetails(true);
|
|||||||
|
|
||||||
$aPlaceAddress = array_reverse($oPlaceLookup->getAddressDetails($iPlaceID));
|
$aPlaceAddress = array_reverse($oPlaceLookup->getAddressDetails($iPlaceID));
|
||||||
|
|
||||||
if (!sizeof($aPlaceAddress)) userError('Unknown place id.');
|
if (empty($aPlaceAddress)) userError('Unknown place id.');
|
||||||
|
|
||||||
$aBreadcrums = array();
|
$aBreadcrums = array();
|
||||||
foreach ($aPlaceAddress as $i => $aPlace) {
|
foreach ($aPlaceAddress as $i => $aPlace) {
|
||||||
@ -100,7 +100,7 @@ $sSQL .= ' where parent_place_id in ('.join(',', $aRelatedPlaceIDs).') and name
|
|||||||
$sSQL .= ' order by rank_address asc,rank_search asc,localname,class, type,housenumber';
|
$sSQL .= ' order by rank_address asc,rank_search asc,localname,class, type,housenumber';
|
||||||
$aParentOfLines = chksql($oDB->getAll($sSQL));
|
$aParentOfLines = chksql($oDB->getAll($sSQL));
|
||||||
|
|
||||||
if (sizeof($aParentOfLines)) {
|
if (!empty($aParentOfLines)) {
|
||||||
echo '<h2>Parent Of:</h2>';
|
echo '<h2>Parent Of:</h2>';
|
||||||
$aClassType = getClassTypesWithImportance();
|
$aClassType = getClassTypesWithImportance();
|
||||||
$aGroupedAddressLines = array();
|
$aGroupedAddressLines = array();
|
||||||
@ -136,7 +136,7 @@ if (sizeof($aParentOfLines)) {
|
|||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sizeof($aParentOfLines) >= 500) {
|
if (count($aParentOfLines) >= 500) {
|
||||||
echo '<p>There are more child objects which are not shown.</p>';
|
echo '<p>There are more child objects which are not shown.</p>';
|
||||||
}
|
}
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
@ -18,7 +18,7 @@ $oDB =& getDB();
|
|||||||
$iTotalBroken = (int) chksql($oDB->getOne('select count(*) from import_polygon_error'));
|
$iTotalBroken = (int) chksql($oDB->getOne('select count(*) from import_polygon_error'));
|
||||||
|
|
||||||
$aPolygons = array();
|
$aPolygons = array();
|
||||||
while ($iTotalBroken && !sizeof($aPolygons)) {
|
while ($iTotalBroken && empty($aPolygons)) {
|
||||||
$sSQL = 'select osm_type as "type",osm_id as "id",class as "key",type as "value",name->\'name\' as "name",';
|
$sSQL = 'select osm_type as "type",osm_id as "id",class as "key",type as "value",name->\'name\' as "name",';
|
||||||
$sSQL .= 'country_code as "country",errormessage as "error message",updated';
|
$sSQL .= 'country_code as "country",errormessage as "error message",updated';
|
||||||
$sSQL .= ' from import_polygon_error';
|
$sSQL .= ' from import_polygon_error';
|
||||||
@ -32,7 +32,7 @@ while ($iTotalBroken && !sizeof($aPolygons)) {
|
|||||||
if ($bReduced) $aWhere[] = "errormessage like 'Area reduced%'";
|
if ($bReduced) $aWhere[] = "errormessage like 'Area reduced%'";
|
||||||
if ($sClass) $sWhere[] = "class = '".pg_escape_string($sClass)."'";
|
if ($sClass) $sWhere[] = "class = '".pg_escape_string($sClass)."'";
|
||||||
|
|
||||||
if (sizeof($aWhere)) {
|
if (!empty($aWhere)) {
|
||||||
$sSQL .= ' where '.join(' and ', $aWhere);
|
$sSQL .= ' where '.join(' and ', $aWhere);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ if ($sOsmType && $iOsmId > 0) {
|
|||||||
|
|
||||||
if ($oLookup) {
|
if ($oLookup) {
|
||||||
$aPlaces = $oPlaceLookup->lookup(array($oLookup->iId => $oLookup));
|
$aPlaces = $oPlaceLookup->lookup(array($oLookup->iId => $oLookup));
|
||||||
if (sizeof($aPlaces)) {
|
if (!empty($aPlaces)) {
|
||||||
$aPlace = reset($aPlaces);
|
$aPlace = reset($aPlaces);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ $aSearchResults = $oGeocode->lookup();
|
|||||||
if ($sOutputFormat=='html') {
|
if ($sOutputFormat=='html') {
|
||||||
$sDataDate = chksql($oDB->getOne("select TO_CHAR(lastimportdate,'YYYY/MM/DD HH24:MI')||' GMT' from import_status limit 1"));
|
$sDataDate = chksql($oDB->getOne("select TO_CHAR(lastimportdate,'YYYY/MM/DD HH24:MI')||' GMT' from import_status limit 1"));
|
||||||
}
|
}
|
||||||
logEnd($oDB, $hLog, sizeof($aSearchResults));
|
logEnd($oDB, $hLog, count($aSearchResults));
|
||||||
|
|
||||||
$sQuery = $oGeocode->getQueryString();
|
$sQuery = $oGeocode->getQueryString();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user