X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/760807c5e04c427d8df616991b18c78f72a10b04..a8a700e16d286971c43c013b322a1fd4a339de4d:/lib/SearchDescription.php?ds=sidebyside
diff --git a/lib/SearchDescription.php b/lib/SearchDescription.php
index e9495852..bf45dada 100644
--- a/lib/SearchDescription.php
+++ b/lib/SearchDescription.php
@@ -240,14 +240,17 @@ class SearchDescription
$oSearch->sHouseNumber = trim($aSearchTerm['word_token']);
// sanity check: if the housenumber is not mainly made
// up of numbers, add a penalty
- if (preg_match_all("/[^0-9]/", $oSearch->sHouseNumber, $aMatches) > 2) {
+ if (preg_match_all('/[^0-9]/', $oSearch->sHouseNumber, $aMatches) > 2) {
$oSearch->iSearchRank++;
}
if (!isset($aSearchTerm['word_id'])) {
$oSearch->iSearchRank++;
}
// also must not appear in the middle of the address
- if (sizeof($this->aAddress) || sizeof($this->aAddressNonSearch)) {
+ if (sizeof($this->aAddress)
+ || sizeof($this->aAddressNonSearch)
+ || $this->sPostcode
+ ) {
$oSearch->iSearchRank++;
}
$aNewSearches[] = $oSearch;
@@ -447,7 +450,7 @@ class SearchDescription
}
if (CONST_Debug) {
- echo "
Place IDs: ";
+ echo '
Place IDs: ';
var_dump(array_keys($aResults));
}
@@ -462,11 +465,11 @@ class SearchDescription
if ($aFilteredPlaceIDs) {
$aNewResults = array();
foreach ($aFilteredPlaceIDs as $iPlaceId) {
- $aNewResults[$iPlaceId] = $aResults[$iPLaceId];
+ $aNewResults[$iPlaceId] = $aResults[$iPlaceId];
}
$aResults = $aNewResults;
if (CONST_Debug) {
- echo "
Place IDs after postcode filtering: ";
+ echo '
Place IDs after postcode filtering: ';
var_dump(array_keys($aResults));
}
}
@@ -485,7 +488,7 @@ class SearchDescription
if ($this->oContext->bViewboxBounded) {
$sSQL .= ' AND ST_Intersects('.$this->oContext->sqlViewboxSmall.', geometry)';
}
- $sSQL .= " ORDER BY st_area(geometry) DESC LIMIT 1";
+ $sSQL .= ' ORDER BY st_area(geometry) DESC LIMIT 1';
if (CONST_Debug) var_dump($sSQL);
@@ -540,7 +543,7 @@ class SearchDescription
if ($this->oContext->sqlCountryList) {
$sSQL .= ' AND country_code in '.$this->oContext->sqlCountryList;
}
- $sSQL .= ' ORDER BY '.$this->oContext->distanceSQL('centroid')." ASC";
+ $sSQL .= ' ORDER BY '.$this->oContext->distanceSQL('centroid').' ASC';
$sSQL .= " LIMIT $iLimit";
if (CONST_Debug) var_dump($sSQL);
$aDBResults = chksql($oDB->getCol($sSQL));
@@ -635,13 +638,13 @@ class SearchDescription
}
if ($this->sHouseNumber) {
- $aTerms[] = "address_rank between 16 and 27";
+ $aTerms[] = 'address_rank between 16 and 27';
} elseif (!$this->sClass || $this->iOperator == Operator::NAME) {
if ($iMinAddressRank > 0) {
- $aTerms[] = "address_rank >= ".$iMinAddressRank;
+ $aTerms[] = 'address_rank >= '.$iMinAddressRank;
}
if ($iMaxAddressRank < 30) {
- $aTerms[] = "address_rank <= ".$iMaxAddressRank;
+ $aTerms[] = 'address_rank <= '.$iMaxAddressRank;
}
}
@@ -707,7 +710,7 @@ class SearchDescription
$aDBResults = chksql(
$oDB->getAll($sSQL),
- "Could not get places for search terms."
+ 'Could not get places for search terms.'
);
foreach ($aDBResults as $aResult) {
@@ -759,8 +762,8 @@ class SearchDescription
$sSQL .= "interpolationtype='odd'";
}
$sSQL .= " or interpolationtype='all') and ";
- $sSQL .= $iHousenumber.">=startnumber and ";
- $sSQL .= $iHousenumber."<=endnumber";
+ $sSQL .= $iHousenumber.'>=startnumber and ';
+ $sSQL .= $iHousenumber.'<=endnumber';
$sSQL .= $this->oContext->excludeSQL(' AND place_id');
$sSQL .= " limit $iLimit";
@@ -798,8 +801,8 @@ class SearchDescription
$sSQL .= "interpolationtype='odd'";
}
$sSQL .= " or interpolationtype='all') and ";
- $sSQL .= $iHousenumber.">=startnumber and ";
- $sSQL .= $iHousenumber."<=endnumber";
+ $sSQL .= $iHousenumber.'>=startnumber and ';
+ $sSQL .= $iHousenumber.'<=endnumber';
$sSQL .= $this->oContext->excludeSQL(' AND place_id');
$sSQL .= " limit $iLimit";
@@ -832,9 +835,9 @@ class SearchDescription
$sSQL .= " WHERE place_id in ($sPlaceIDs)";
$sSQL .= " AND class='".$this->sClass."' ";
$sSQL .= " AND type='".$this->sType."'";
- $sSQL .= " AND linked_place_id is null";
+ $sSQL .= ' AND linked_place_id is null';
$sSQL .= $this->oContext->excludeSQL(' AND place_id');
- $sSQL .= " ORDER BY rank_search ASC ";
+ $sSQL .= ' ORDER BY rank_search ASC ';
$sSQL .= " LIMIT $iLimit";
if (CONST_Debug) var_dump($sSQL);
@@ -862,8 +865,8 @@ class SearchDescription
$sSQL .= " WHERE place_id in ($sPlaceIDs)";
$sSQL .= " AND rank_search < $iMaxRank + 5";
$sSQL .= " AND ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon')";
- $sSQL .= " ORDER BY rank_search ASC ";
- $sSQL .= " LIMIT 1";
+ $sSQL .= ' ORDER BY rank_search ASC ';
+ $sSQL .= ' LIMIT 1';
if (CONST_Debug) var_dump($sSQL);
$sPlaceGeom = chksql($oDB->getOne($sSQL));
}
@@ -889,7 +892,7 @@ class SearchDescription
if ($this->oContext->hasNearPoint()) {
$sOrderBySQL = $this->oContext->distanceSQL('l.centroid');
} elseif ($sPlaceIDs) {
- $sOrderBySQL = "ST_Distance(l.centroid, f.geometry)";
+ $sOrderBySQL = 'ST_Distance(l.centroid, f.geometry)';
} elseif ($sPlaceGeom) {
$sOrderBySQL = "ST_Distance(st_centroid('".$sPlaceGeom."'), l.centroid)";
}
@@ -905,7 +908,7 @@ class SearchDescription
$sSQL .= ' from '.$sClassTable.' as l';
if ($sPlaceIDs) {
- $sSQL .= ",placex as f WHERE ";
+ $sSQL .= ',placex as f WHERE ';
$sSQL .= "f.place_id in ($sPlaceIDs) ";
$sSQL .= " AND ST_DWithin(l.centroid, f.centroid, $fRange)";
} elseif ($sPlaceGeom) {
@@ -933,7 +936,7 @@ class SearchDescription
if ($this->oContext->hasNearPoint()) {
$sOrderBySQL = $this->oContext->distanceSQL('l.geometry');
} else {
- $sOrderBySQL = "ST_Distance(l.geometry, f.geometry)";
+ $sOrderBySQL = 'ST_Distance(l.geometry, f.geometry)';
}
$sSQL = 'SELECT distinct l.place_id';
@@ -947,7 +950,7 @@ class SearchDescription
$sSQL .= " AND l.type='".$this->sType."'";
$sSQL .= $this->oContext->excludeSQL(' AND l.place_id');
if ($sOrderBySQL) {
- $sSQL .= "ORDER BY orderterm ASC";
+ $sSQL .= 'ORDER BY orderterm ASC';
}
$sSQL .= " limit $iLimit";
@@ -1002,19 +1005,19 @@ class SearchDescription
return $aWordIDs[$k];
};
- echo "