]> git.openstreetmap.org Git - nominatim.git/blob - lib-php/SpecialSearchOperator.php
extend word statistics to address index
[nominatim.git] / lib-php / SpecialSearchOperator.php
1 <?php
2 /**
3  * SPDX-License-Identifier: GPL-2.0-only
4  *
5  * This file is part of Nominatim. (https://nominatim.org)
6  *
7  * Copyright (C) 2022 by the Nominatim developer community.
8  * For a full list of authors see the git log.
9  */
10
11 namespace Nominatim;
12
13 /**
14  * Operators describing special searches.
15  */
16 abstract class Operator
17 {
18     /// No operator selected.
19     const NONE = 0;
20     /// Search for POI of the given type.
21     const TYPE = 1;
22     /// Search for POIs near the given place.
23     const NEAR = 2;
24     /// Search for POIS in the given place.
25     const IN = 3;
26     /// Search for POIS named as given.
27     const NAME = 4;
28     /// Search for postcodes.
29     const POSTCODE = 5;
30
31     private static $aConstantNames = null;
32
33
34     public static function toString($iOperator)
35     {
36         if ($iOperator == Operator::NONE) {
37             return '';
38         }
39
40         if (Operator::$aConstantNames === null) {
41             $oReflector = new \ReflectionClass('Nominatim\Operator');
42             $aConstants = $oReflector->getConstants();
43
44             Operator::$aConstantNames = array();
45             foreach ($aConstants as $sName => $iValue) {
46                 Operator::$aConstantNames[$iValue] = $sName;
47             }
48         }
49
50         return Operator::$aConstantNames[$iOperator];
51     }
52 }