mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-12 05:44:06 +00:00
split SearchResult type
Use adapted types for the different result types. This makes it easier to have adapted output formatting and means there are only result fields that are filled.
This commit is contained in:
@@ -92,8 +92,8 @@ def _add_parent_rows_grouped(writer: JsonWriter, rows: napi.AddressLines,
|
||||
writer.end_object().next()
|
||||
|
||||
|
||||
@dispatch.format_func(napi.SearchResult, 'details-json')
|
||||
def _format_search_json(result: napi.SearchResult, options: Mapping[str, Any]) -> str:
|
||||
@dispatch.format_func(napi.DetailedResult, 'json')
|
||||
def _format_search_json(result: napi.DetailedResult, options: Mapping[str, Any]) -> str:
|
||||
locales = options.get('locales', napi.Locales())
|
||||
geom = result.geometry.get('geojson')
|
||||
centroid = result.centroid.to_geojson()
|
||||
|
||||
@@ -210,8 +210,7 @@ async def details_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) ->
|
||||
raise params.error('No place with that OSM ID found.', status=404)
|
||||
|
||||
output = formatting.format_result(
|
||||
result,
|
||||
'details-json',
|
||||
result, 'json',
|
||||
{'locales': locales,
|
||||
'group_hierarchy': params.get_bool('group_hierarchy', False),
|
||||
'icon_base_url': params.config().MAPICON_URL})
|
||||
|
||||
Reference in New Issue
Block a user