- $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);
- }
- } elseif (!$oSearch->isNamedSearch()) {
- // looking for a POI in a geographic area
- if (!$oCtx->isBoundedSearch()) {
- continue;
- }
- $aPlaceIDs = $oSearch->queryNearbyPoi($this->oDB, $this->iLimit);
- } elseif ($oSearch->isOperator(Operator::POSTCODE)) {
- // looking for postcode
- $aPlaceIDs = $oSearch->queryPostcode($this->oDB, $this->iLimit);
- } else {
- // Ordinary search:
- // First search for places according to name and address.
- $aNamedPlaceIDs = $oSearch->queryNamedPlace(
- $this->oDB,
- $aWordFrequencyScores,
- $this->iMinAddressRank,
- $this->iMaxAddressRank,
- $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->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->iLimit
- );
- }
- }