]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/SearchDescription.php
fix more syntax issues
[nominatim.git] / lib / SearchDescription.php
index d18e7eab35790b3208a6c1cde94508875afbc011..b7b4498d378e272fbc9b35611dc7e3fff32dc65f 100644 (file)
@@ -19,6 +19,27 @@ abstract class Operator
     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];
+    }
 }
 
 /**
@@ -301,7 +322,7 @@ class SearchDescription
                 }
 
                 $oSearch->setPoiSearch($iOp, $aSearchTerm['class'], $aSearchTerm['type']);
-                $aNewWordsetSearches[] = $oSearch;
+                $aNewSearches[] = $oSearch;
             }
         } elseif (isset($aSearchTerm['word_id']) && $aSearchTerm['word_id']) {
             $iWordID = $aSearchTerm['word_id'];
@@ -480,10 +501,10 @@ class SearchDescription
             $sSQL .= 'WHERE ';
         }
 
-        $sSQL .= "p.postcode = '".pg_escape_string(reset($this->$aName))."'";
+        $sSQL .= "p.postcode = '".pg_escape_string(reset($this->aName))."'";
         $sCountryTerm = $this->countryCodeSQL('p.country_code', $sCountryList);
         if ($sCountryTerm) {
-            $sSQL .= ' AND '.$sCountyTerm;
+            $sSQL .= ' AND '.$sCountryTerm;
         }
         $sSQL .= " LIMIT $iLimit";
 
@@ -884,4 +905,33 @@ class SearchDescription
         return $a->iSearchRank < $b->iSearchRank ? -1 : 1;
     }
 
+    //////////// Debugging functions
+
+    function dumpAsHtmlTableRow(&$aWordIDs)
+    {
+        $kf = function($k) use (&$aWordIDs) { return $aWordIDs[$k]; };
+
+        echo "<tr>";
+        echo "<td>$this->iSearchRank</td>";
+        echo "<td>".join(', ', array_map($kf, $this->aName))."</td>";
+        echo "<td>".join(', ', array_map($kf, $this->aNameNonSearch))."</td>";
+        echo "<td>".join(', ', array_map($kf, $this->aAddress))."</td>";
+        echo "<td>".join(', ', array_map($kf, $this->aAddressNonSearch))."</td>";
+        echo "<td>".$this->sCountryCode."</td>";
+        echo "<td>".Operator::toString($this->iOperator)."</td>";
+        echo "<td>".$this->sClass."</td>";
+        echo "<td>".$this->sType."</td>";
+        echo "<td>".$this->sPostcode."</td>";
+        echo "<td>".$this->sHouseNumber."</td>";
+
+        if ($this->oNearPoint) {
+            echo "<td>".$this->oNearPoint->lat()."</td>";
+            echo "<td>".$this->oNearPoint->lon()."</td>";
+            echo "<td>".$this->oNearPoint->radius()."</td>";
+        } else {
+            echo "<td></td><td></td><td></td>";
+        }
+
+        echo "</tr>";
+    }
 };