6 * Operators describing special searches.
8 abstract final class Operator
10 /// No operator selected.
12 /// Search for POI of the given type.
14 /// Search for POIs near the given place.
16 /// Search for POIS in the given place.
18 /// Search for POIS named as given.
20 /// Search for postcodes.
25 * Description of a single interpretation of a search query.
27 class SearchDescription
29 /// Ranking how well the description fits the query.
30 private $iSearchRank = 0;
31 /// Country code of country the result must belong to.
32 private $sCountryCode = '';
33 /// List of word ids making up the name of the object.
34 private $aName = array();
35 /// List of word ids making up the address of the object.
36 private $aAddress = array();
37 /// Subset of word ids of full words making up the address.
38 private $aFullNameAddress = array();
39 /// List of word ids that appear in the name but should be ignored.
40 private $aNameNonSearch = array();
41 /// List of word ids that appear in the address but should be ignored.
42 private $aAddressNonSearch = array();
43 /// Kind of search for special searches, see Nominatim::Operator.
44 private $iOperator = Operator::NONE;
45 /// Class of special feature to search for.
47 /// Type of special feature to search for.
49 /// Housenumber of the object.
50 private $sHouseNumber = '';
51 /// Postcode for the object.
52 private $sPostcode = '';
53 /// Geographic search area.
54 private $oNearPoint = false;
56 // Temporary values used while creating the search description.
58 /// Index of phrase currently processed
59 private $iNamePhrase = -1;
63 return $this->iSearchRank;
67 * Set the geographic search radius.
69 public setNear(&$oNearPoint)
71 $this->oNearPoint = $oNearPoint;
74 public setPoiSearch($iOperator, $sClass, $sType)
76 $this->iOperator = $iOperator;
77 $this->sClass = $sClass;
78 $this->sType = $sType;
83 return $this->iOperator != Operator::NONE;
87 * Extract special terms from the query, amend the search
88 * and return the shortended query.
90 * Only the first special term found will be used but all will
91 * be removed from the query.
93 public extractKeyValuePairs(&$oDB, $sQuery)
95 // Search for terms of kind [<key>=<value>].
97 '/\\[([\\w_]*)=([\\w_]*)\\]/',
103 foreach ($aSpecialTermsRaw as $aTerm) {
104 $sQuery = str_replace($aTerm[0], ' ', $sQuery);
105 if (!$this->hasOperator()) {
106 $this->setPoiSearch(Operator::TYPE, $aTerm[1], $aTerm[2]);