]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/api/v1/helpers.py
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / nominatim / api / v1 / helpers.py
index ed66be8cfc5e08a95472a41e26900e1f1402c092..325e5bc629911dc446476c1499499eb641e741dd 100644 (file)
@@ -52,8 +52,8 @@ def feature_type_to_rank(feature_type: Optional[str]) -> Tuple[int, int]:
     return FEATURE_TYPE_TO_RANK.get(feature_type, (0, 30))
 
 
-#pylint: disable=too-many-arguments
-def extend_query_parts(queryparts: dict[str, Any], details: dict[str, Any],
+#pylint: disable=too-many-arguments,too-many-branches
+def extend_query_parts(queryparts: Dict[str, Any], details: Dict[str, Any],
                        feature_type: Optional[str],
                        namedetails: bool, extratags: bool,
                        excluded: Iterable[str]) -> None:
@@ -62,9 +62,14 @@ def extend_query_parts(queryparts: dict[str, Any], details: dict[str, Any],
     """
     parsed = SearchDetails.from_kwargs(details)
     if parsed.geometry_output != GeometryFormat.NONE:
-        for flag in parsed.geometry_output:
-            assert flag.name
-            queryparts[f'polygon_{flag.name.lower()}'] = '1'
+        if GeometryFormat.GEOJSON in parsed.geometry_output:
+            queryparts['polygon_geojson'] = '1'
+        if GeometryFormat.KML in parsed.geometry_output:
+            queryparts['polygon_kml'] = '1'
+        if GeometryFormat.SVG in parsed.geometry_output:
+            queryparts['polygon_svg'] = '1'
+        if GeometryFormat.TEXT in parsed.geometry_output:
+            queryparts['polygon_text'] = '1'
     if parsed.address_details:
         queryparts['addressdetails'] = '1'
     if namedetails:
@@ -78,7 +83,7 @@ def extend_query_parts(queryparts: dict[str, Any], details: dict[str, Any],
     if parsed.countries:
         queryparts['countrycodes'] = ','.join(parsed.countries)
     queryparts['exclude_place_ids'] = \
-        ','.join(chain(excluded, map(str, parsed.excluded)))
+        ','.join(chain(excluded, map(str, (e for e in parsed.excluded if e > 0))))
     if parsed.viewbox:
         queryparts['viewbox'] = ','.join(f"{c:.7g}" for c in parsed.viewbox.coords)
     if parsed.bounded_viewbox: