]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge pull request #1151 from mtmail/documentation-for-details-endpoint
authorSarah Hoffmann <lonvia@denofr.de>
Wed, 22 Aug 2018 20:38:32 +0000 (22:38 +0200)
committerGitHub <noreply@github.com>
Wed, 22 Aug 2018 20:38:32 +0000 (22:38 +0200)
documentation for /details endpoint

lib/template/details-html.php
lib/template/details-json.php
test/bdd/api/details/params.feature

index 4d5ccb87c60c23c1b35e1f22b27e869e14219ac8..01583e5f789499a27a28dbdb4d9e3048c72b761e 100644 (file)
@@ -46,8 +46,7 @@
     function hash_to_subtable($aAssociatedList)
     {
         $sHTML = '';
-        foreach($aAssociatedList as $sKey => $sValue)
-        {
+        foreach ($aAssociatedList as $sKey => $sValue) {
             $sHTML = $sHTML.' <div class="line"><span class="name">'.$sValue.'</span> ('.$sKey.')</div>'."\n";
         }
         return $sHTML;
                 <tbody>
 
                 <?php
-
-                    foreach($aAddressLines as $aAddressLine)
-                    {   
+                    foreach ($aAddressLines as $aAddressLine) {
                         _one_row($aAddressLine);
                     }
                 ?>
-    
 
 
 <?php
     if ($aLinkedLines)
     {
         headline('Linked Places');
-        foreach($aLinkedLines as $aAddressLine)
-        {   
+        foreach ($aLinkedLines as $aAddressLine) {
             _one_row($aAddressLine);
         }
     }
 
-
-
     if ($bIncludeKeywords)
     {
         headline('Name Keywords');
-        foreach($aPlaceSearchNameKeywords as $aRow)
-        {
-            _one_keyword_row($aRow['word_token'], $aRow['word_id']);
+        if ($aPlaceSearchNameKeywords) {
+            foreach ($aPlaceSearchNameKeywords as $aRow) {
+                _one_keyword_row($aRow['word_token'], $aRow['word_id']);
+            }
         }
 
         headline('Address Keywords');
-        foreach($aPlaceSearchAddressKeywords as $aRow)
-        {
-            _one_keyword_row($aRow['word_token'], $aRow['word_id']);
+        if ($aPlaceSearchAddressKeywords) {
+            foreach ($aPlaceSearchAddressKeywords as $aRow) {
+                _one_keyword_row($aRow['word_token'], $aRow['word_id']);
+            }
         }
     }
-    
+
     if (!empty($aHierarchyLines))
     {
         headline('Parent Of');
 
         $aGroupedAddressLines = array();
-        foreach($aHierarchyLines as $aAddressLine)
-        {
+        foreach ($aHierarchyLines as $aAddressLine) {
             if ($aAddressLine['type'] == 'yes') $sType = $aAddressLine['class'];
             else $sType = $aAddressLine['type'];
 
                 $aGroupedAddressLines[$sType] = array();
             $aGroupedAddressLines[$sType][] = $aAddressLine;
         }
-        foreach($aGroupedAddressLines as $sGroupHeading => $aHierarchyLines)
-        {
+        foreach ($aGroupedAddressLines as $sGroupHeading => $aHierarchyLines) {
             $sGroupHeading = ucwords($sGroupHeading);
             headline3($sGroupHeading);
 
-            foreach($aHierarchyLines as $aAddressLine)
-            {
+            foreach ($aHierarchyLines as $aAddressLine) {
                 _one_row($aAddressLine);
             }
         }
                 'lon' => $aPointDetails['lon'],
                 'lat' => $aPointDetails['lat'],
         );
-        echo 'var nominatim_result = ' . json_encode($aPlace, JSON_PRETTY_PRINT) . ';'; 
+        echo 'var nominatim_result = ' . json_encode($aPlace, JSON_PRETTY_PRINT) . ';';
 
 
     ?>
index 9b4237c70720331a82b20160f2570c1b7bc3c0df..06554aba68f2143c6a24b46ce9cdb39e9cfc3362 100644 (file)
@@ -26,7 +26,9 @@ $aPlaceDetails['calculated_importance'] = (float) $aPointDetails['calculated_imp
 
 $aPlaceDetails['extratags'] = $aPointDetails['aExtraTags'];
 $aPlaceDetails['calculated_wikipedia'] = $aPointDetails['wikipedia'];
-$aPlaceDetails['icon'] = CONST_Website_BaseURL.'images/mapicons/'.$aPointDetails['icon'].'.n.32.png';
+if ($aPointDetails['icon']) {
+    $aPlaceDetails['icon'] = CONST_Website_BaseURL.'images/mapicons/'.$aPointDetails['icon'].'.n.32.png';
+}
 
 $aPlaceDetails['rank_address'] = (int) $aPointDetails['rank_address'];
 $aPlaceDetails['rank_search'] = (int) $aPointDetails['rank_search'];
index a0b990ebc14cd90123fc111f13211f0f326d56f0..3c9286ed285acedc3c2c847a04db89a0662889bf 100644 (file)
@@ -41,3 +41,16 @@ Feature: Object details
             | linkedplaces |
             | 1 |
         Then the result is valid json
+
+    Scenario Outline: HTML Details with keywords
+        When sending html details query for <osmid>
+            | keywords |
+            | 1 |
+        Then the result is valid html
+
+    Examples:
+            | osmid |
+            | W78099902 |
+            | N3121929846 |
+
+