/// Index of phrase currently processed.
private $iNamePhrase = -1;
-
/**
* Create an empty search description.
*
//now search for housenumber, if housenumber provided
if ($this->sHouseNumber && !empty($aResults)) {
$aNamedPlaceIDs = $aResults;
- $aResults = $this->queryHouseNumber($oDB, $aNamedPlaceIDs, $iLimit);
+ $aResults = $this->queryHouseNumber($oDB, $aNamedPlaceIDs);
if (empty($aResults) && $this->looksLikeFullAddress()) {
$aResults = $aNamedPlaceIDs;
}
}
- if (CONST_Debug) {
- echo '<br><b>Place IDs:</b> ';
- var_dump(array_keys($aResults));
- }
+ Debug::printDebugTable('Place IDs', $aResults);
if (!empty($aResults) && $this->sPostcode) {
$sPlaceIds = Result::joinIdsByTable($aResults, Result::TABLE_PLACEX);
$sSQL = 'SELECT place_id FROM placex';
$sSQL .= ' WHERE place_id in ('.$sPlaceIds.')';
$sSQL .= " AND postcode = '".$this->sPostcode."'";
- if (CONST_Debug) var_dump($sSQL);
+ Debug::printSQL($sSQL);
$aFilteredPlaceIDs = chksql($oDB->getCol($sSQL));
if ($aFilteredPlaceIDs) {
$aNewResults = array();
$aNewResults[$iPlaceId] = $aResults[$iPlaceId];
}
$aResults = $aNewResults;
- if (CONST_Debug) {
- echo '<br><b>Place IDs after postcode filtering:</b> ';
- var_dump(array_keys($aResults));
- }
+ Debug::printVar('Place IDs after postcode filtering', $aResults);
}
}
}
}
$sSQL .= ' ORDER BY st_area(geometry) DESC LIMIT 1';
- if (CONST_Debug) var_dump($sSQL);
+ Debug::printSQL($sSQL);
$aResults = array();
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
$sSQL .= ' ORDER BY '.$this->oContext->distanceSQL('ct.centroid').' ASC';
}
$sSQL .= " limit $iLimit";
- if (CONST_Debug) var_dump($sSQL);
+ Debug::printSQL($sSQL);
$aDBResults = chksql($oDB->getCol($sSQL));
}
}
$sSQL .= ' ORDER BY '.$this->oContext->distanceSQL('centroid').' ASC';
$sSQL .= " LIMIT $iLimit";
- if (CONST_Debug) var_dump($sSQL);
+ Debug::printSQL($sSQL);
$aDBResults = chksql($oDB->getCol($sSQL));
}
$sSQL .= $this->oContext->excludeSQL(' AND p.place_id');
$sSQL .= " LIMIT $iLimit";
- if (CONST_Debug) var_dump($sSQL);
+ Debug::printSQL($sSQL);
$aResults = array();
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
$sSQL .= ' ORDER BY '.join(', ', $aOrder);
$sSQL .= ' LIMIT '.$iLimit;
- if (CONST_Debug) var_dump($sSQL);
+ Debug::printSQL($sSQL);
$aDBResults = chksql(
$oDB->getAll($sSQL),
return $aResults;
}
- private function queryHouseNumber(&$oDB, $aRoadPlaceIDs, $iLimit)
+ private function queryHouseNumber(&$oDB, $aRoadPlaceIDs)
{
$aResults = array();
$sPlaceIDs = Result::joinIdsByTable($aRoadPlaceIDs, Result::TABLE_PLACEX);
$sSQL .= 'WHERE parent_place_id in ('.$sPlaceIDs.')';
$sSQL .= " AND transliteration(housenumber) ~* E'".$sHouseNumberRegex."'";
$sSQL .= $this->oContext->excludeSQL(' AND place_id');
- $sSQL .= " LIMIT $iLimit";
- if (CONST_Debug) var_dump($sSQL);
+ Debug::printSQL($sSQL);
// XXX should inherit the exactMatches from its parent
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
$sSQL .= $iHousenumber.'>=startnumber and ';
$sSQL .= $iHousenumber.'<=endnumber';
$sSQL .= $this->oContext->excludeSQL(' AND place_id');
- $sSQL .= " limit $iLimit";
- if (CONST_Debug) var_dump($sSQL);
+ Debug::printSQL($sSQL);
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
$oResult = new Result($iPlaceId, Result::TABLE_OSMLINE);
$sSQL .= ' WHERE parent_place_id in ('.$sPlaceIDs.')';
$sSQL .= " AND housenumber = '".$this->sHouseNumber."'";
$sSQL .= $this->oContext->excludeSQL(' AND place_id');
- $sSQL .= " limit $iLimit";
- if (CONST_Debug) var_dump($sSQL);
+ Debug::printSQL($sSQL);
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
$aResults[$iPlaceId] = new Result($iPlaceId, Result::TABLE_AUX);
$sSQL .= $iHousenumber.'>=startnumber and ';
$sSQL .= $iHousenumber.'<=endnumber';
$sSQL .= $this->oContext->excludeSQL(' AND place_id');
- $sSQL .= " limit $iLimit";
- if (CONST_Debug) var_dump($sSQL);
+ Debug::printSQL($sSQL);
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
$oResult = new Result($iPlaceId, Result::TABLE_TIGER);
$sSQL .= ' ORDER BY rank_search ASC ';
$sSQL .= " LIMIT $iLimit";
- if (CONST_Debug) var_dump($sSQL);
+ Debug::printSQL($sSQL);
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
$aResults[$iPlaceId] = new Result($iPlaceId);
$bCacheTable = (bool) chksql($oDB->getOne($sSQL));
$sSQL = "SELECT min(rank_search) FROM placex WHERE place_id in ($sPlaceIDs)";
- if (CONST_Debug) var_dump($sSQL);
+ Debug::printSQL($sSQL);
$iMaxRank = (int)chksql($oDB->getOne($sSQL));
// For state / country level searches the normal radius search doesn't work very well
$sSQL .= " AND ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon')";
$sSQL .= ' ORDER BY rank_search ASC ';
$sSQL .= ' LIMIT 1';
- if (CONST_Debug) var_dump($sSQL);
+ Debug::printSQL($sSQL);
$sPlaceGeom = chksql($oDB->getOne($sSQL));
}
$iMaxRank += 5;
$sSQL = 'SELECT place_id FROM placex';
$sSQL .= " WHERE place_id in ($sPlaceIDs) and rank_search < $iMaxRank";
- if (CONST_Debug) var_dump($sSQL);
+ Debug::printSQL($sSQL);
$aPlaceIDs = chksql($oDB->getCol($sSQL));
$sPlaceIDs = join(',', $aPlaceIDs);
}
}
$sSQL .= " limit $iLimit";
- if (CONST_Debug) var_dump($sSQL);
+ Debug::printSQL($sSQL);
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
$aResults[$iPlaceId] = new Result($iPlaceId);
}
$sSQL .= " limit $iLimit";
- if (CONST_Debug) var_dump($sSQL);
+ Debug::printSQL($sSQL);
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
$aResults[$iPlaceId] = new Result($iPlaceId);
//////////// Debugging functions
+ public function debugInfo()
+ {
+ return array(
+ 'Search rank' => $this->iSearchRank,
+ 'Country code' => $this->sCountryCode,
+ 'Name terms' => $this->aName,
+ 'Name terms (stop words)' => $this->aNameNonSearch,
+ 'Address terms' => $this->aAddress,
+ 'Address terms (stop words)' => $this->aAddressNonSearch,
+ 'Address terms (full words)' => $this->aFullNameAddress,
+ 'Special search' => $this->iOperator,
+ 'Class' => $this->sClass,
+ 'Type' => $this->sType,
+ 'House number' => $this->sHouseNumber,
+ 'Postcode' => $this->sPostcode
+ );
+ }
+
public function dumpAsHtmlTableRow(&$aWordIDs)
{
$kf = function ($k) use (&$aWordIDs) {