]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/api/v1/format.py
make localisation of results explicit
[nominatim.git] / nominatim / api / v1 / format.py
index b50a2346f58d396d462a52853b81edc7678ea278..7492e48d5c053ed24aaf67e4592c19b06281886c 100644 (file)
@@ -111,16 +111,16 @@ def _format_details_json(result: napi.DetailedResult, options: Mapping[str, Any]
     out.keyval('category', result.category[0])\
          .keyval('type', result.category[1])\
          .keyval('admin_level', result.admin_level)\
-         .keyval('localname', locales.display_name(result.names))\
-         .keyval_not_none('names', result.names or None)\
-         .keyval_not_none('addresstags', result.address or None)\
+         .keyval('localname', result.locale_name or '')\
+         .keyval('names', result.names or {})\
+         .keyval('addresstags', result.address or {})\
          .keyval_not_none('housenumber', result.housenumber)\
          .keyval_not_none('calculated_postcode', result.postcode)\
          .keyval_not_none('country_code', result.country_code)\
          .keyval_not_none('indexed_date', result.indexed_date, lambda v: v.isoformat())\
          .keyval_not_none('importance', result.importance)\
          .keyval('calculated_importance', result.calculated_importance())\
-         .keyval_not_none('extratags', result.extratags or None)\
+         .keyval('extratags', result.extratags or {})\
          .keyval_not_none('calculated_wikipedia', result.wikipedia)\
          .keyval('rank_address', result.rank_address)\
          .keyval('rank_search', result.rank_search)\
@@ -198,33 +198,33 @@ def _format_reverse_jsonv2(results: napi.ReverseResults,
 
 
 @dispatch.format_func(napi.SearchResults, 'xml')
-def _format_reverse_xml(results: napi.SearchResults, options: Mapping[str, Any]) -> str:
+def _format_search_xml(results: napi.SearchResults, options: Mapping[str, Any]) -> str:
     return format_xml.format_base_xml(results,
                                       options, False, 'searchresults',
                                       {'querystring': 'TODO'})
 
 
 @dispatch.format_func(napi.SearchResults, 'geojson')
-def _format_reverse_geojson(results: napi.SearchResults,
+def _format_search_geojson(results: napi.SearchResults,
                             options: Mapping[str, Any]) -> str:
     return format_json.format_base_geojson(results, options, False)
 
 
 @dispatch.format_func(napi.SearchResults, 'geocodejson')
-def _format_reverse_geocodejson(results: napi.SearchResults,
+def _format_search_geocodejson(results: napi.SearchResults,
                                 options: Mapping[str, Any]) -> str:
     return format_json.format_base_geocodejson(results, options, False)
 
 
 @dispatch.format_func(napi.SearchResults, 'json')
-def _format_reverse_json(results: napi.SearchResults,
+def _format_search_json(results: napi.SearchResults,
                          options: Mapping[str, Any]) -> str:
     return format_json.format_base_json(results, options, False,
                                         class_label='class')
 
 
 @dispatch.format_func(napi.SearchResults, 'jsonv2')
-def _format_reverse_jsonv2(results: napi.SearchResults,
+def _format_search_jsonv2(results: napi.SearchResults,
                            options: Mapping[str, Any]) -> str:
     return format_json.format_base_json(results, options, False,
                                         class_label='category')