3 namespace Nominatim\Token;
5 require_once(CONST_LibDir.'/SpecialSearchOperator.php');
8 * A word token describing a place type.
12 /// Database word id, if applicable.
14 /// Class (or OSM tag key) of the place to look for.
16 /// Type (or OSM tag value) of the place to look for.
18 /// Relationship of the operator to the object (see Operator class).
21 public function __construct($iID, $sClass, $sType, $iOperator)
24 $this->sClass = $sClass;
25 $this->sType = $sType;
26 $this->iOperator = $iOperator;
29 public function getId()
35 * Derive new searches by adding this token to an existing search.
37 * @param object $oSearch Partial search description derived so far.
38 * @param object $oPosition Description of the token position within
41 * @return SearchDescription[] List of derived search descriptions.
43 public function extendSearch($oSearch, $oPosition)
45 if ($oSearch->hasOperator() || !$oPosition->isPhrase('')) {
51 $iOp = $this->iOperator;
52 if ($iOp == \Nominatim\Operator::NONE) {
53 if ($oSearch->hasName() || $oSearch->getContext()->isBoundedSearch()) {
54 $iOp = \Nominatim\Operator::NAME;
56 $iOp = \Nominatim\Operator::NEAR;
59 } elseif (!$oPosition->isFirstToken() && !$oPosition->isLastToken()) {
62 if ($oSearch->hasHousenumber()) {
66 $oNewSearch = $oSearch->clone($iSearchCost);
67 $oNewSearch->setPoiSearch($iOp, $this->sClass, $this->sType);
69 return array($oNewSearch);
73 public function debugInfo()
77 'Type' => 'special term',
79 'class' => $this->sClass,
80 'type' => $this->sType,
81 'operator' => \Nominatim\Operator::toString($this->iOperator)
86 public function debugCode()