mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
more strict parameter checking for reverse
This commit is contained in:
@@ -50,3 +50,48 @@ Feature: Simple Reverse Tests
|
|||||||
Then the result is valid json
|
Then the result is valid json
|
||||||
When looking up jsonv2 coordinates 36.791966,127.171726
|
When looking up jsonv2 coordinates 36.791966,127.171726
|
||||||
Then the result is valid json
|
Then the result is valid json
|
||||||
|
|
||||||
|
Scenario: Missing lon parameter
|
||||||
|
Given the request parameters
|
||||||
|
| lat
|
||||||
|
| 51.51
|
||||||
|
When sending an API call reverse
|
||||||
|
Then exactly 0 results are returned
|
||||||
|
|
||||||
|
Scenario: Missing lat parameter
|
||||||
|
Given the request parameters
|
||||||
|
| lon
|
||||||
|
| -79.39114
|
||||||
|
When sending an API call reverse
|
||||||
|
Then exactly 0 results are returned
|
||||||
|
|
||||||
|
Scenario: Missing osm_id parameter
|
||||||
|
Given the request parameters
|
||||||
|
| osm_type
|
||||||
|
| N
|
||||||
|
When sending an API call reverse
|
||||||
|
Then exactly 0 results are returned
|
||||||
|
|
||||||
|
Scenario: Missing osm_type parameter
|
||||||
|
Given the request parameters
|
||||||
|
| osm_id
|
||||||
|
| 3498564
|
||||||
|
When sending an API call reverse
|
||||||
|
Then exactly 0 results are returned
|
||||||
|
|
||||||
|
Scenario Outline: Bad format for lat or lon
|
||||||
|
Given the request parameters
|
||||||
|
| lat | lon |
|
||||||
|
| <lat> | <lon> |
|
||||||
|
When sending an API call reverse
|
||||||
|
Then exactly 0 results are returned
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| lat | lon
|
||||||
|
| 48.9660 | 8,4482
|
||||||
|
| 48,9660 | 8.4482
|
||||||
|
| 48,9660 | 8,4482
|
||||||
|
| 48.966.0 | 8.4482
|
||||||
|
| 48.966 | 8.448.2
|
||||||
|
| Nan | 8.448
|
||||||
|
| 48.966 | Nan
|
||||||
|
|||||||
@@ -122,3 +122,7 @@ def api_setup_details(step, obj):
|
|||||||
else:
|
else:
|
||||||
world.params['place_id'] = obj
|
world.params['place_id'] = obj
|
||||||
api_call('details')
|
api_call('details')
|
||||||
|
|
||||||
|
@step(u'sending an API call (\w+)')
|
||||||
|
def api_general_call(step, call):
|
||||||
|
api_call(call)
|
||||||
|
|||||||
@@ -45,10 +45,8 @@
|
|||||||
$oPlaceLookup->setOSMID($_GET['osm_type'], $_GET['osm_id']);
|
$oPlaceLookup->setOSMID($_GET['osm_type'], $_GET['osm_id']);
|
||||||
|
|
||||||
$aPlace = $oPlaceLookup->lookup();
|
$aPlace = $oPlaceLookup->lookup();
|
||||||
|
|
||||||
//if (!$iPlaceID) $sError = 'OSM ID Not Found';
|
|
||||||
}
|
}
|
||||||
else
|
else if (isset($_GET['lat']) && isset($_GET['lon']) && preg_match('/^[+-]?[0-9]*\.?[0-9]+$/', $_GET['lat']) && preg_match('/^[+-]?[0-9]*\.?[0-9]+$/', $_GET['lon']))
|
||||||
{
|
{
|
||||||
$oReverseGeocode = new ReverseGeocode($oDB);
|
$oReverseGeocode = new ReverseGeocode($oDB);
|
||||||
$oReverseGeocode->setLanguagePreference($aLangPrefOrder);
|
$oReverseGeocode->setLanguagePreference($aLangPrefOrder);
|
||||||
@@ -59,6 +57,10 @@
|
|||||||
|
|
||||||
$aPlace = $oReverseGeocode->lookup();
|
$aPlace = $oReverseGeocode->lookup();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$aPlace = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (CONST_Debug) exit;
|
if (CONST_Debug) exit;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user