]> git.openstreetmap.org Git - nominatim.git/commitdiff
Reverse geocode include geometry - added bounding box tests
authorMarc Tobias Metten <mtmail@gmx.net>
Wed, 9 Mar 2016 18:43:03 +0000 (19:43 +0100)
committerMarc Tobias Metten <mtmail@gmx.net>
Wed, 9 Mar 2016 18:43:03 +0000 (19:43 +0100)
lib/Geocode.php
lib/template/search-json.php
tests/features/api/reverse.feature
tests/features/api/search_params.feature
tests/steps/api_result.py
website/reverse.php

index cf7dfbe6183e05916eefb4aff62b50ef20b7b1b5..1dbde919d4fda8975763af3e79d300206c6737a0 100644 (file)
                                $oPlaceLookup->setPolygonSimplificationThreshold($this->fPolygonSimplificationThreshold);
 
                                $aOutlineResult = $oPlaceLookup->getOutlines($aResult['place_id'], $aResult['lon'], $aResult['lat'], $fDiameter/2);
                                $oPlaceLookup->setPolygonSimplificationThreshold($this->fPolygonSimplificationThreshold);
 
                                $aOutlineResult = $oPlaceLookup->getOutlines($aResult['place_id'], $aResult['lon'], $aResult['lat'], $fDiameter/2);
-                               foreach($aOutlineResult as $k => $v)
-                               {
-                                       $aResult[$k] = $v;
-                               }
+                               $aResult = array_merge($aResult, $aOutlineResult);
 
                                if ($aResult['extra_place'] == 'city')
                                {
 
                                if ($aResult['extra_place'] == 'city')
                                {
index 068599191b0d01e4a5e5a25842bda2a6783aa731..fc50ee0e09b2554916271e00f11cac6082418ba3 100644 (file)
@@ -18,7 +18,7 @@
 
                if (isset($aPointDetails['aBoundingBox']))
                {
 
                if (isset($aPointDetails['aBoundingBox']))
                {
-                       $aPlace['boundingbox'] = $aPointDetails['aBoundingBox'][0];
+                       $aPlace['boundingbox'] = $aPointDetails['aBoundingBox'];
 
                        if (isset($aPointDetails['aPolyPoints']) && $bShowPolygons)
                        {
 
                        if (isset($aPointDetails['aPolyPoints']) && $bShowPolygons)
                        {
index 4d0c554992e410667521a9a6de3387d676156905..39519177be9be4cd5b9afba5b614eca314d4efec 100644 (file)
@@ -11,6 +11,15 @@ Feature: Reverse geocoding
          | ID | country
          | 0  | Deutschland
 
          | ID | country
          | 0  | Deutschland
 
+
+    Scenario: Boundingbox is returned
+        Given the request parameters
+          | format | zoom
+          | xml    | 4
+        When looking up coordinates 53.9788769,13.0830313
+        And results contain valid boundingboxes
+
+
     @Tiger
     Scenario: TIGER house number
         Given the request parameters
     @Tiger
     Scenario: TIGER house number
         Given the request parameters
index fa0e63b7afe2a70e8dfc25c2628348002ec4af5e..150d6bdcf45479d1255eeca63afc262347de31e3 100644 (file)
@@ -8,6 +8,7 @@ Feature: Search queries
         And result 0 has attributes lat,lon,display_name
         And result 0 has attributes class,type,importance,icon
         And result 0 has not attributes address
         And result 0 has attributes lat,lon,display_name
         And result 0 has attributes class,type,importance,icon
         And result 0 has not attributes address
+        And results contain valid boundingboxes
 
     Scenario: Simple JSON search
         When sending json search query "Vaduz"
 
     Scenario: Simple JSON search
         When sending json search query "Vaduz"
@@ -15,6 +16,7 @@ Feature: Search queries
         And result 0 has attributes osm_type,osm_id,boundingbox
         And result 0 has attributes lat,lon,display_name,importance
         And result 0 has not attributes address
         And result 0 has attributes osm_type,osm_id,boundingbox
         And result 0 has attributes lat,lon,display_name,importance
         And result 0 has not attributes address
+        And results contain valid boundingboxes
 
     Scenario: JSON search with addressdetails
         When sending json search query "Montevideo" with address
 
     Scenario: JSON search with addressdetails
         When sending json search query "Montevideo" with address
index 5e1bcc90e09ee0b8ae82e101939f8a3fcc4c4917..2644d4a20c7489589ab5045d01c4c44fc06a67eb 100644 (file)
@@ -211,6 +211,15 @@ def api_result_contains(step):
                         m = re.match("%s$" % (v,), curres[k])
                         assert_is_not_none(m, msg="field %s does not match: %s$ != %s." % (k, v, curres[k]))
 
                         m = re.match("%s$" % (v,), curres[k])
                         assert_is_not_none(m, msg="field %s does not match: %s$ != %s." % (k, v, curres[k]))
 
+@step(u'results contain valid boundingboxes$')
+def api_result_address_contains(step):
+    step.given('the result is valid')
+    for curres in world.results:
+        bb = curres['boundingbox']
+        if world.response_format == 'json':
+            bb = ','.join(bb)
+        m = re.match('^(-?\d+\.\d+),(-?\d+\.\d+),(-?\d+\.\d+),(-?\d+\.\d+)$', bb)
+        assert_is_not_none(m, msg="invalid boundingbox: %s." % (curres['boundingbox']))
 
 @step(u'result addresses contain$')
 def api_result_address_contains(step):
 
 @step(u'result addresses contain$')
 def api_result_address_contains(step):
index ca823d3cdf60d1be6d1da3cfa4ae4e2dc1e06dfa..d1c554a454352a79914f2f75a4096c182f8fa490 100755 (executable)
                $fRadius = $fDiameter = getResultDiameter($aPlace);
                $aOutlineResult = $oPlaceLookup->getOutlines($aPlace['place_id'],$aPlace['lon'],$aPlace['lat'],$fRadius);
 
                $fRadius = $fDiameter = getResultDiameter($aPlace);
                $aOutlineResult = $oPlaceLookup->getOutlines($aPlace['place_id'],$aPlace['lon'],$aPlace['lat'],$fRadius);
 
-               foreach($aOutlineResult as $k => $v)
-               {
-                       $aPlace[$k] = $v;
-               }
-
+               $aPlace = array_merge($aPlace, $aOutlineResult);
        }
        else
        {
        }
        else
        {