]> git.openstreetmap.org Git - nominatim.git/commitdiff
add missing include
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 8 Oct 2017 15:13:41 +0000 (17:13 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sun, 8 Oct 2017 15:13:41 +0000 (17:13 +0200)
lib/SearchDescription.php
lib/SpecialSearchOperator.php [new file with mode: 0644]

index d84c8bf80c7e8a643fc6ebae066c01b720a1bf6e..533c0ab46983e51600bdffe443bd860cbabc59fb 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 
-require_once(CONST_BasePath.'/lib/SpecialSearchOperator.php');
-
 namespace Nominatim;
 
+require_once(CONST_BasePath.'/lib/SpecialSearchOperator.php');
+
 /**
  * Description of a single interpretation of a search query.
  */
diff --git a/lib/SpecialSearchOperator.php b/lib/SpecialSearchOperator.php
new file mode 100644 (file)
index 0000000..a0ec23e
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+namespace Nominatim;
+
+/**
+ * Operators describing special searches.
+ */
+abstract class Operator
+{
+    /// No operator selected.
+    const NONE = 0;
+    /// Search for POI of the given type.
+    const TYPE = 1;
+    /// Search for POIs near the given place.
+    const NEAR = 2;
+    /// Search for POIS in the given place.
+    const IN = 3;
+    /// Search for POIS named as given.
+    const NAME = 4;
+    /// Search for postcodes.
+    const POSTCODE = 5;
+
+    private static $aConstantNames = null;
+
+
+    public static function toString($iOperator)
+    {
+        if ($iOperator == Operator::NONE) {
+            return '';
+        }
+
+        if (Operator::$aConstantNames === null) {
+            $oReflector = new \ReflectionClass('Nominatim\Operator');
+            $aConstants = $oReflector->getConstants();
+
+            Operator::$aConstantNames = array();
+            foreach ($aConstants as $sName => $iValue) {
+                Operator::$aConstantNames[$iValue] = $sName;
+            }
+        }
+
+        return Operator::$aConstantNames[$iOperator];
+    }
+}