]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/DebugHtml.php
add unknown addr:place to address output
[nominatim.git] / lib / DebugHtml.php
index ce2b8361c3fa5bf211846bfe5cc347c9eea1e2bb..98da8794055c644e23fbb90ffdbbc6d3d5b45f8e 100644 (file)
@@ -39,33 +39,48 @@ class Debug
     public static function printDebugTable($sHeading, $aVar)
     {
         echo '<b>'.$sHeading.":</b>\n";
     public static function printDebugTable($sHeading, $aVar)
     {
         echo '<b>'.$sHeading.":</b>\n";
-        echo '<table border="1">';
+        echo "<table border='1'>\n";
         if (!empty($aVar)) {
         if (!empty($aVar)) {
-            echo '<tr>';
+            echo "  <tr>\n";
             $aKeys = array();
             $aInfo = reset($aVar);
             if (!is_array($aInfo)) {
                 $aInfo = $aInfo->debugInfo();
             }
             foreach ($aInfo as $sKey => $mVal) {
             $aKeys = array();
             $aInfo = reset($aVar);
             if (!is_array($aInfo)) {
                 $aInfo = $aInfo->debugInfo();
             }
             foreach ($aInfo as $sKey => $mVal) {
-                echo '<th><small>'.$sKey.'</small></th>';
+                echo '    <th><small>'.$sKey.'</small></th>'."\n";
                 $aKeys[] = $sKey;
             }
                 $aKeys[] = $sKey;
             }
-            echo '</tr>';
+            echo "  </tr>\n";
             foreach ($aVar as $oRow) {
                 $aInfo = $oRow;
                 if (!is_array($oRow)) {
                     $aInfo = $oRow->debugInfo();
                 }
             foreach ($aVar as $oRow) {
                 $aInfo = $oRow;
                 if (!is_array($oRow)) {
                     $aInfo = $oRow->debugInfo();
                 }
-                echo '<tr>';
+                echo "  <tr>\n";
                 foreach ($aKeys as $sKey) {
                 foreach ($aKeys as $sKey) {
-                    echo '<td><pre>';
+                    echo '    <td><pre>';
                     if (isset($aInfo[$sKey])) {
                         Debug::outputVar($aInfo[$sKey], '');
                     }
                     if (isset($aInfo[$sKey])) {
                         Debug::outputVar($aInfo[$sKey], '');
                     }
-                    echo '</pre></td>';
+                    echo '</pre></td>'."\n";
                 }
                 }
-                echo '<tr>';
+                echo "  </tr>\n";
+            }
+        }
+        echo "</table>\n";
+    }
+
+    public static function printGroupedSearch($aSearches, $aWordsIDs)
+    {
+        echo '<table border="1">';
+        echo '<tr><th>rank</th><th>Name Tokens</th><th>Name Not</th>';
+        echo '<th>Address Tokens</th><th>Address Not</th>';
+        echo '<th>country</th><th>operator</th>';
+        echo '<th>class</th><th>type</th><th>postcode</th><th>housenumber</th></tr>';
+        foreach ($aSearches as $iRank => $aRankedSet) {
+            foreach ($aRankedSet as $aRow) {
+                $aRow->dumpAsHtmlTableRow($aWordsIDs);
             }
         }
         echo '</table>';
             }
         }
         echo '</table>';
@@ -74,38 +89,40 @@ class Debug
     public static function printGroupTable($sHeading, $aVar)
     {
         echo '<b>'.$sHeading.":</b>\n";
     public static function printGroupTable($sHeading, $aVar)
     {
         echo '<b>'.$sHeading.":</b>\n";
-        echo '<table border="1">';
+        echo "<table border='1'>\n";
         if (!empty($aVar)) {
         if (!empty($aVar)) {
-            echo '<tr><th><small>Group</small></th>';
+            echo "  <tr>\n";
+            echo '    <th><small>Group</small></th>'."\n";
             $aKeys = array();
             $aKeys = array();
-            $aInfo = reset(reset($aVar));
+            $aInfo = reset($aVar)[0];
             if (!is_array($aInfo)) {
                 $aInfo = $aInfo->debugInfo();
             }
             foreach ($aInfo as $sKey => $mVal) {
             if (!is_array($aInfo)) {
                 $aInfo = $aInfo->debugInfo();
             }
             foreach ($aInfo as $sKey => $mVal) {
-                echo '<th><small>'.$sKey.'</small></th>';
+                echo '    <th><small>'.$sKey.'</small></th>'."\n";
                 $aKeys[] = $sKey;
             }
                 $aKeys[] = $sKey;
             }
-            echo '</tr>';
+            echo "  </tr>\n";
             foreach ($aVar as $sGrpKey => $aGroup) {
                 foreach ($aGroup as $oRow) {
                     $aInfo = $oRow;
                     if (!is_array($oRow)) {
                         $aInfo = $oRow->debugInfo();
                     }
             foreach ($aVar as $sGrpKey => $aGroup) {
                 foreach ($aGroup as $oRow) {
                     $aInfo = $oRow;
                     if (!is_array($oRow)) {
                         $aInfo = $oRow->debugInfo();
                     }
-                    echo '<tr><td><pre>'.$sGrpKey.'</pre></td>';
+                    echo "  <tr>\n";
+                    echo '    <td><pre>'.$sGrpKey.'</pre></td>'."\n";
                     foreach ($aKeys as $sKey) {
                     foreach ($aKeys as $sKey) {
-                        echo '<td><pre>';
+                        echo '    <td><pre>';
                         if (!empty($aInfo[$sKey])) {
                             Debug::outputVar($aInfo[$sKey], '');
                         }
                         if (!empty($aInfo[$sKey])) {
                             Debug::outputVar($aInfo[$sKey], '');
                         }
-                        echo '</pre></td>';
+                        echo '</pre></td>'."\n";
                     }
                     }
-                    echo '<tr>';
+                    echo "  </tr>\n";
                 }
             }
         }
                 }
             }
         }
-        echo '</table>';
+        echo "</table>\n";
     }
 
     public static function printSQL($sSQL)
     }
 
     public static function printSQL($sSQL)
@@ -128,14 +145,18 @@ class Debug
                 $sPre = "\n".$sPreNL;
             }
         } elseif (is_array($mVar) && isset($mVar['__debug_format'])) {
                 $sPre = "\n".$sPreNL;
             }
         } elseif (is_array($mVar) && isset($mVar['__debug_format'])) {
-            if (!empty($mVar[data])) {
+            if (!empty($mVar['data'])) {
                 $sPre = '';
                 $sPre = '';
-                foreach ($mVar[data] as $mValue) {
+                foreach ($mVar['data'] as $mValue) {
                     echo $sPre;
                     Debug::outputSimpleVar($mValue);
                     $sPre = ', ';
                 }
             }
                     echo $sPre;
                     Debug::outputSimpleVar($mValue);
                     $sPre = ', ';
                 }
             }
+        } elseif (is_object($mVar) && method_exists($mVar, 'debugInfo')) {
+            Debug::outputVar($mVar->debugInfo(), $sPreNL);
+        } elseif (is_a($mVar, 'stdClass')) {
+            Debug::outputVar(json_decode(json_encode($mVar), true), $sPreNL);
         } else {
             Debug::outputSimpleVar($mVar);
         }
         } else {
             Debug::outputSimpleVar($mVar);
         }