- $searchedHousenumber = -1;
-
- if (CONST_Debug) echo "<hr><b>Search Loop, group $iGroupLoop, loop $iQueryLoop</b>";
- if (CONST_Debug) _debugDumpGroupedSearches(array($iGroupedRank => array($oSearch)), $aValidTokens);
-
- $aPlaceIDs = array();
- if ($oSearch->isCountrySearch()) {
- // Just looking for a country - look it up
- if (4 >= $this->iMinAddressRank && 4 <= $this->iMaxAddressRank) {
- $aPlaceIDs = $oSearch->queryCountry(
- $this->oDB,
- $bBoundingBoxSearch ? $this->sViewboxSmallSQL : ''
- );
- }
- } elseif (!$oSearch->isNamedSearch()) {
- // looking for a POI in a geographic area
- if (!$bBoundingBoxSearch && !$oSearch->isNearSearch()) {
- continue;
- }
-
- $aPlaceIDs = $oSearch->queryNearbyPoi(
- $this->oDB,
- $sCountryCodesSQL,
- $bBoundingBoxSearch ? $this->sViewboxSmallSQL : '',
- $this->sViewboxCentreSQL,
- $this->aExcludePlaceIDs ? join(',', $this->aExcludePlaceIDs) : '',
- $this->iLimit
- );
- } elseif ($oSearch->isOperator(Operator::POSTCODE)) {
- $aPlaceIDs = $oSearch->queryPostcode(
- $oDB,
- $sCountryCodesSQL,
- $this->iLimit
- );
- } else {
- // Ordinary search:
- // First search for places according to name and address.
- $aNamedPlaceIDs = $oSearch->queryNamedPlace(
- $this->oDB,
- $aWordFrequencyScores,
- $sCountryCodesSQL,
- $this->iMinAddressRank,
- $this->iMaxAddressRank,
- $this->aExcludePlaceIDs ? join(',', $this->aExcludePlaceIDs) : '',
- $bBoundingBoxSearch ? $this->sViewboxSmallSQL : '',
- $bBoundingBoxSearch ? $this->sViewboxLargeSQL : '',
- $this->iLimit
- );
-
- if (sizeof($aNamedPlaceIDs)) {
- foreach ($aNamedPlaceIDs as $aRow) {
- $aPlaceIDs[] = $aRow['place_id'];
- $this->exactMatchCache[$aRow['place_id']] = $aRow['exactmatch'];
- }
- }
-
- //now search for housenumber, if housenumber provided
- if ($oSearch->hasHouseNumber() && sizeof($aPlaceIDs)) {
- $aResult = $oSearch->queryHouseNumber(
- $this->oDB,
- $aPlaceIDs,
- $this->aExcludePlaceIDs ? join(',', $this->aExcludePlaceIDs) : '',
- $this->iLimit
- );
-
- if (sizeof($aResult)) {
- $searchedHousenumber = $aResult['iHouseNumber'];
- $aPlaceIDs = $aResult['aPlaceIDs'];
- } elseif (!$oSearch->looksLikeFullAddress()) {
- $aPlaceIDs = array();
- }
- }
-
- // finally get POIs if requested
- if ($oSearch->isPoiSearch() && sizeof($aPlaceIDs)) {
- $aPlaceIDs = $oSearch->queryPoiByOperator(
- $this->oDB,
- $aPlaceIDs,
- $this->aExcludePlaceIDs ? join(',', $this->aExcludePlaceIDs) : '',
- $this->iLimit
- );
- }
- }