6 * A single result of a search operation or a reverse lookup.
8 * This object only contains the id of the result. It does not yet
9 * have any details needed to format the output document.
13 const TABLE_PLACEX = 0;
14 const TABLE_POSTCODE = 1;
15 const TABLE_OSMLINE = 2;
17 const TABLE_TIGER = 4;
19 /// Database table that contains the result.
23 /// House number (only for interpolation results).
24 public $iHouseNumber = -1;
25 /// Number of exact matches in address (address searches only).
26 public $iExactMatches = 0;
27 /// Subranking within the results (the higher the worse).
28 public $iResultRank = 0;
30 public function debugInfo()
33 'Table' => $this->iTable,
35 'House number' => $this->iHouseNumber,
36 'Exact Matches' => $this->iExactMatches,
37 'Result rank' => $this->iResultRank
42 public function __construct($sId, $iTable = Result::TABLE_PLACEX)
44 $this->iTable = $iTable;
45 $this->iId = (int) $sId;
48 public static function joinIdsByTable($aResults, $iTable)
50 return join(',', array_keys(array_filter(
52 function ($aValue) use ($iTable) {
53 return $aValue->iTable == $iTable;
57 public static function sqlHouseNumberTable($aResults, $iTable)
61 foreach ($aResults as $oResult) {
62 if ($oResult->iTable == $iTable) {
63 $sHousenumbers .= $sSep.'('.$oResult->iId.',';
64 $sHousenumbers .= $oResult->iHouseNumber.')';
69 return $sHousenumbers;
73 * Split a result array into highest ranked result and the rest
75 * @param object[] $aResults List of results to split.
79 public static function splitResults($aResults)
85 foreach ($aResults as $oRes) {
86 if ($oRes->iResultRank < $iMinRank) {
87 $aTail = array_merge($aTail, $aHead);
88 $aHead = array($oRes->iId => $oRes);
89 $iMinRank = $oRes->iResultRank;
90 } elseif ($oRes->iResultRank == $iMinRank) {
91 $aHead[$oRes->iId] = $oRes;
93 $aTail[$oRes->iId] = $oRes;
97 return array('head' => $aHead, 'tail' => $aTail);