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;
29 /// Address rank of the result.
32 public function debugInfo()
35 'Table' => $this->iTable,
37 'House number' => $this->iHouseNumber,
38 'Exact Matches' => $this->iExactMatches,
39 'Result rank' => $this->iResultRank
44 public function __construct($sId, $iTable = Result::TABLE_PLACEX)
46 $this->iTable = $iTable;
47 $this->iId = (int) $sId;
50 public static function joinIdsByTable($aResults, $iTable)
52 return join(',', array_keys(array_filter(
54 function ($aValue) use ($iTable) {
55 return $aValue->iTable == $iTable;
59 public static function sqlHouseNumberTable($aResults, $iTable)
63 foreach ($aResults as $oResult) {
64 if ($oResult->iTable == $iTable) {
65 $sHousenumbers .= $sSep.'('.$oResult->iId.',';
66 $sHousenumbers .= $oResult->iHouseNumber.')';
71 return $sHousenumbers;
75 * Split a result array into highest ranked result and the rest
77 * @param object[] $aResults List of results to split.
81 public static function splitResults($aResults)
87 foreach ($aResults as $oRes) {
88 if ($oRes->iResultRank < $iMinRank) {
90 $aHead = array($oRes->iId => $oRes);
91 $iMinRank = $oRes->iResultRank;
92 } elseif ($oRes->iResultRank == $iMinRank) {
93 $aHead[$oRes->iId] = $oRes;
95 $aTail[$oRes->iId] = $oRes;
99 return array('head' => $aHead, 'tail' => $aTail);