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 * Check if the token can be added to the given search.
36 * Derive new searches by adding this token to an existing search.
38 * @param object $oSearch Partial search description derived so far.
39 * @param object $oPosition Description of the token position within
42 * @return True if the token is compatible with the search configuration
45 public function isExtendable($oSearch, $oPosition)
47 return !$oSearch->hasOperator() && $oPosition->isPhrase('');
51 * Derive new searches by adding this token to an existing search.
53 * @param object $oSearch Partial search description derived so far.
54 * @param object $oPosition Description of the token position within
57 * @return SearchDescription[] List of derived search descriptions.
59 public function extendSearch($oSearch, $oPosition)
63 $iOp = $this->iOperator;
64 if ($iOp == \Nominatim\Operator::NONE) {
65 if ($oSearch->hasName() || $oSearch->getContext()->isBoundedSearch()) {
66 $iOp = \Nominatim\Operator::NAME;
68 $iOp = \Nominatim\Operator::NEAR;
71 } elseif (!$oPosition->isFirstToken() && !$oPosition->isLastToken()) {
74 if ($oSearch->hasHousenumber()) {
78 $oNewSearch = $oSearch->clone($iSearchCost);
79 $oNewSearch->setPoiSearch($iOp, $this->sClass, $this->sType);
81 return array($oNewSearch);
85 public function debugInfo()
89 'Type' => 'special term',
91 'class' => $this->sClass,
92 'type' => $this->sType,
93 'operator' => \Nominatim\Operator::toString($this->iOperator)
98 public function debugCode()