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;
16 const TABLE_TIGER = 3;
18 /// Database table that contains the result.
22 /// House number (only for interpolation results).
23 public $iHouseNumber = -1;
24 /// Number of exact matches in address (address searches only).
25 public $iExactMatches = 0;
26 /// Subranking within the results (the higher the worse).
27 public $iResultRank = 0;
28 /// Address rank of the result.
31 public function debugInfo()
34 'Table' => $this->iTable,
36 'House number' => $this->iHouseNumber,
37 'Exact Matches' => $this->iExactMatches,
38 'Result rank' => $this->iResultRank
43 public function __construct($sId, $iTable = Result::TABLE_PLACEX)
45 $this->iTable = $iTable;
46 $this->iId = (int) $sId;
49 public static function joinIdsByTable($aResults, $iTable)
51 return join(',', array_keys(array_filter(
53 function ($aValue) use ($iTable) {
54 return $aValue->iTable == $iTable;
58 public static function sqlHouseNumberTable($aResults, $iTable)
62 foreach ($aResults as $oResult) {
63 if ($oResult->iTable == $iTable) {
64 $sHousenumbers .= $sSep.'('.$oResult->iId.',';
65 $sHousenumbers .= $oResult->iHouseNumber.')';
70 return $sHousenumbers;
74 * Split a result array into highest ranked result and the rest
76 * @param object[] $aResults List of results to split.
80 public static function splitResults($aResults)
86 foreach ($aResults as $oRes) {
87 if ($oRes->iResultRank < $iMinRank) {
89 $aHead = array($oRes->iId => $oRes);
90 $iMinRank = $oRes->iResultRank;
91 } elseif ($oRes->iResultRank == $iMinRank) {
92 $aHead[$oRes->iId] = $oRes;
94 $aTail[$oRes->iId] = $oRes;
98 return array('head' => $aHead, 'tail' => $aTail);