]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/api/v1/format_json.py
add server fronting for search endpoint
[nominatim.git] / nominatim / api / v1 / format_json.py
index c82681e91f7078fc7446644fa800a08a97c28637..0907c95526b25d4d9b47238dad008d2ad1bc54fa 100644 (file)
@@ -68,8 +68,6 @@ def format_base_json(results: Union[napi.ReverseResults, napi.SearchResults],
                      class_label: str) -> str:
     """ Return the result list as a simple json string in custom Nominatim format.
     """
                      class_label: str) -> str:
     """ Return the result list as a simple json string in custom Nominatim format.
     """
-    locales = options.get('locales', napi.Locales())
-
     out = JsonWriter()
 
     if simple:
     out = JsonWriter()
 
     if simple:
@@ -79,8 +77,6 @@ def format_base_json(results: Union[napi.ReverseResults, napi.SearchResults],
         out.start_array()
 
     for result in results:
         out.start_array()
 
     for result in results:
-        label_parts = result.address_rows.localize(locales) if result.address_rows else []
-
         out.start_object()\
              .keyval_not_none('place_id', result.place_id)\
              .keyval('licence', cl.OSM_ATTRIBUTION)\
         out.start_object()\
              .keyval_not_none('place_id', result.place_id)\
              .keyval('licence', cl.OSM_ATTRIBUTION)\
@@ -96,8 +92,8 @@ def format_base_json(results: Union[napi.ReverseResults, napi.SearchResults],
              .keyval('addresstype', cl.get_label_tag(result.category, result.extratags,
                                                      result.rank_address,
                                                      result.country_code))\
              .keyval('addresstype', cl.get_label_tag(result.category, result.extratags,
                                                      result.rank_address,
                                                      result.country_code))\
-             .keyval('name', locales.display_name(result.names))\
-             .keyval('display_name', ', '.join(label_parts))
+             .keyval('name', result.locale_name or '')\
+             .keyval('display_name', result.display_name or '')
 
 
         if options.get('icon_base_url', None):
 
 
         if options.get('icon_base_url', None):
@@ -151,8 +147,6 @@ def format_base_geojson(results: Union[napi.ReverseResults, napi.SearchResults],
     if not results and simple:
         return '{"error":"Unable to geocode"}'
 
     if not results and simple:
         return '{"error":"Unable to geocode"}'
 
-    locales = options.get('locales', napi.Locales())
-
     out = JsonWriter()
 
     out.start_object()\
     out = JsonWriter()
 
     out.start_object()\
@@ -161,11 +155,6 @@ def format_base_geojson(results: Union[napi.ReverseResults, napi.SearchResults],
          .key('features').start_array()
 
     for result in results:
          .key('features').start_array()
 
     for result in results:
-        if result.address_rows:
-            label_parts = result.address_rows.localize(locales)
-        else:
-            label_parts = []
-
         out.start_object()\
              .keyval('type', 'Feature')\
              .key('properties').start_object()
         out.start_object()\
              .keyval('type', 'Feature')\
              .key('properties').start_object()
@@ -181,8 +170,8 @@ def format_base_geojson(results: Union[napi.ReverseResults, napi.SearchResults],
            .keyval('addresstype', cl.get_label_tag(result.category, result.extratags,
                                                    result.rank_address,
                                                    result.country_code))\
            .keyval('addresstype', cl.get_label_tag(result.category, result.extratags,
                                                    result.rank_address,
                                                    result.country_code))\
-           .keyval('name', locales.display_name(result.names))\
-           .keyval('display_name', ', '.join(label_parts))
+           .keyval('name', result.locale_name or '')\
+           .keyval('display_name', result.display_name or '')
 
         if options.get('addressdetails', False):
             out.key('address').start_object()
 
         if options.get('addressdetails', False):
             out.key('address').start_object()
@@ -219,8 +208,6 @@ def format_base_geocodejson(results: Union[napi.ReverseResults, napi.SearchResul
     if not results and simple:
         return '{"error":"Unable to geocode"}'
 
     if not results and simple:
         return '{"error":"Unable to geocode"}'
 
-    locales = options.get('locales', napi.Locales())
-
     out = JsonWriter()
 
     out.start_object()\
     out = JsonWriter()
 
     out.start_object()\
@@ -234,11 +221,6 @@ def format_base_geocodejson(results: Union[napi.ReverseResults, napi.SearchResul
          .key('features').start_array()
 
     for result in results:
          .key('features').start_array()
 
     for result in results:
-        if result.address_rows:
-            label_parts = result.address_rows.localize(locales)
-        else:
-            label_parts = []
-
         out.start_object()\
              .keyval('type', 'Feature')\
              .key('properties').start_object()\
         out.start_object()\
              .keyval('type', 'Feature')\
              .key('properties').start_object()\
@@ -252,8 +234,8 @@ def format_base_geocodejson(results: Union[napi.ReverseResults, napi.SearchResul
            .keyval('osm_value', result.category[1])\
            .keyval('type', GEOCODEJSON_RANKS[max(3, min(28, result.rank_address))])\
            .keyval_not_none('accuracy', getattr(result, 'distance', None), transform=int)\
            .keyval('osm_value', result.category[1])\
            .keyval('type', GEOCODEJSON_RANKS[max(3, min(28, result.rank_address))])\
            .keyval_not_none('accuracy', getattr(result, 'distance', None), transform=int)\
-           .keyval('label', ', '.join(label_parts))\
-           .keyval_not_none('name', result.names, transform=locales.display_name)\
+           .keyval('label', result.display_name or '')\
+           .keyval_not_none('name', result.locale_name or None)\
 
         if options.get('addressdetails', False):
             _write_geocodejson_address(out, result.address_rows, result.place_id,
 
         if options.get('addressdetails', False):
             _write_geocodejson_address(out, result.address_rows, result.place_id,