mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-11 05:14:07 +00:00
revert accidental change in json output format
This commit is contained in:
@@ -84,8 +84,9 @@ def format_base_json(results: Union[ReverseResults, SearchResults],
|
|||||||
|
|
||||||
_write_osm_id(out, result.osm_object)
|
_write_osm_id(out, result.osm_object)
|
||||||
|
|
||||||
out.key('lat').float(result.centroid.lat, 7).next()\
|
# lat and lon must be string values
|
||||||
.key('lon').float(result.centroid.lon, 7).next()\
|
out.keyval('lat', f"{result.centroid.lat:0.7f}")\
|
||||||
|
.keyval('lon', f"{result.centroid.lon:0.7f}")\
|
||||||
.keyval(class_label, result.category[0])\
|
.keyval(class_label, result.category[0])\
|
||||||
.keyval('type', result.category[1])\
|
.keyval('type', result.category[1])\
|
||||||
.keyval('place_rank', result.rank_search)\
|
.keyval('place_rank', result.rank_search)\
|
||||||
@@ -112,12 +113,13 @@ def format_base_json(results: Union[ReverseResults, SearchResults],
|
|||||||
if options.get('namedetails', False):
|
if options.get('namedetails', False):
|
||||||
out.keyval('namedetails', result.names)
|
out.keyval('namedetails', result.names)
|
||||||
|
|
||||||
|
# must be string values
|
||||||
bbox = cl.bbox_from_result(result)
|
bbox = cl.bbox_from_result(result)
|
||||||
out.key('boundingbox').start_array()\
|
out.key('boundingbox').start_array()\
|
||||||
.float(bbox.minlat, 7).next()\
|
.value(f"{bbox.minlat:0.7f}").next()\
|
||||||
.float(bbox.maxlat, 7).next()\
|
.value(f"{bbox.maxlat:0.7f}").next()\
|
||||||
.float(bbox.minlon, 7).next()\
|
.value(f"{bbox.minlon:0.7f}").next()\
|
||||||
.float(bbox.maxlon, 7).next()\
|
.value(f"{bbox.maxlon:0.7f}").next()\
|
||||||
.end_array().next()
|
.end_array().next()
|
||||||
|
|
||||||
if result.geometry:
|
if result.geometry:
|
||||||
|
|||||||
@@ -150,6 +150,10 @@ def reverse_geocode_via_api(test_config_env, pytestconfig, datatable, lat, lon):
|
|||||||
result = APIResult('json', 'reverse', api_response.body)
|
result = APIResult('json', 'reverse', api_response.body)
|
||||||
assert result.is_simple()
|
assert result.is_simple()
|
||||||
|
|
||||||
|
assert isinstance(result.result['lat'], str)
|
||||||
|
assert isinstance(result.result['lon'], str)
|
||||||
|
result.result['centroid'] = f"POINT({result.result['lon']} {result.result['lat']})"
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@@ -159,20 +163,8 @@ def reverse_geocode_via_api_and_grid(test_config_env, pytestconfig, node_grid, d
|
|||||||
coords = node_grid.get(node)
|
coords = node_grid.get(node)
|
||||||
if coords is None:
|
if coords is None:
|
||||||
raise ValueError('Unknown node id')
|
raise ValueError('Unknown node id')
|
||||||
runner = APIRunner(test_config_env, pytestconfig.option.NOMINATIM_API_ENGINE)
|
|
||||||
api_response = runner.run_step('reverse',
|
|
||||||
{'lat': coords[1], 'lon': coords[0]},
|
|
||||||
datatable, 'jsonv2', {})
|
|
||||||
|
|
||||||
assert api_response.status == 200
|
return reverse_geocode_via_api(test_config_env, pytestconfig, datatable, coords[1], coords[0])
|
||||||
assert api_response.headers['content-type'] == 'application/json; charset=utf-8'
|
|
||||||
|
|
||||||
result = APIResult('json', 'reverse', api_response.body)
|
|
||||||
assert result.is_simple()
|
|
||||||
|
|
||||||
result.result['centroid'] = f"POINT({result.result['lon']:.7f} {result.result['lat']:.7f})"
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
@when(step_parse(r'geocoding(?: "(?P<query>.*)")?'),
|
@when(step_parse(r'geocoding(?: "(?P<query>.*)")?'),
|
||||||
@@ -193,7 +185,9 @@ def forward_geocode_via_api(test_config_env, pytestconfig, datatable, query):
|
|||||||
assert not result.is_simple()
|
assert not result.is_simple()
|
||||||
|
|
||||||
for res in result.result:
|
for res in result.result:
|
||||||
res['centroid'] = f"POINT({res['lon']:.7f} {res['lat']:.7f})"
|
assert isinstance(res['lat'], str)
|
||||||
|
assert isinstance(res['lon'], str)
|
||||||
|
res['centroid'] = f"POINT({res['lon']} {res['lat']})"
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user