forked from hans/Nominatim
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)
|
||||
|
||||
out.key('lat').float(result.centroid.lat, 7).next()\
|
||||
.key('lon').float(result.centroid.lon, 7).next()\
|
||||
# lat and lon must be string values
|
||||
out.keyval('lat', f"{result.centroid.lat:0.7f}")\
|
||||
.keyval('lon', f"{result.centroid.lon:0.7f}")\
|
||||
.keyval(class_label, result.category[0])\
|
||||
.keyval('type', result.category[1])\
|
||||
.keyval('place_rank', result.rank_search)\
|
||||
@@ -112,12 +113,13 @@ def format_base_json(results: Union[ReverseResults, SearchResults],
|
||||
if options.get('namedetails', False):
|
||||
out.keyval('namedetails', result.names)
|
||||
|
||||
# must be string values
|
||||
bbox = cl.bbox_from_result(result)
|
||||
out.key('boundingbox').start_array()\
|
||||
.float(bbox.minlat, 7).next()\
|
||||
.float(bbox.maxlat, 7).next()\
|
||||
.float(bbox.minlon, 7).next()\
|
||||
.float(bbox.maxlon, 7).next()\
|
||||
.value(f"{bbox.minlat:0.7f}").next()\
|
||||
.value(f"{bbox.maxlat:0.7f}").next()\
|
||||
.value(f"{bbox.minlon:0.7f}").next()\
|
||||
.value(f"{bbox.maxlon:0.7f}").next()\
|
||||
.end_array().next()
|
||||
|
||||
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)
|
||||
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
|
||||
|
||||
|
||||
@@ -159,20 +163,8 @@ def reverse_geocode_via_api_and_grid(test_config_env, pytestconfig, node_grid, d
|
||||
coords = node_grid.get(node)
|
||||
if coords is None:
|
||||
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
|
||||
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
|
||||
return reverse_geocode_via_api(test_config_env, pytestconfig, datatable, coords[1], coords[0])
|
||||
|
||||
|
||||
@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()
|
||||
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user