X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/d42e2e391f1e0ac252f8251561d984a72bd3b1ff..8adeaa2c7efc1087bacf6a6212e81c06d7097cc1:/nominatim/api/reverse.py diff --git a/nominatim/api/reverse.py b/nominatim/api/reverse.py index 6a76becd..4a5f9c03 100644 --- a/nominatim/api/reverse.py +++ b/nominatim/api/reverse.py @@ -7,7 +7,7 @@ """ Implementation of reverse geocoding. """ -from typing import Optional, List, Callable, Type, Tuple, Dict, Any, cast +from typing import Optional, List, Callable, Type, Tuple, Dict, Any, cast, Union import functools import sqlalchemy as sa @@ -195,16 +195,17 @@ class ReverseGeocoder: if self.has_geometries(): sql = self._add_geometry_columns(sql, t.c.geometry) - restrict: List[SaColumn] = [] + restrict: List[Union[SaColumn, Callable[[], SaColumn]]] = [] if self.layer_enabled(DataLayer.ADDRESS): - restrict.append(no_index(t.c.rank_address).between(26, min(29, self.max_rank))) + max_rank = min(29, self.max_rank) + restrict.append(lambda: no_index(t.c.rank_address).between(26, max_rank)) if self.max_rank == 30: - restrict.append(_is_address_point(t)) + restrict.append(lambda: _is_address_point(t)) if self.layer_enabled(DataLayer.POI) and self.max_rank == 30: - restrict.append(sa.and_(no_index(t.c.rank_search) == 30, - t.c.class_.not_in(('place', 'building')), - sa.not_(t.c.geometry.is_line_like()))) + restrict.append(lambda: sa.and_(no_index(t.c.rank_search) == 30, + t.c.class_.not_in(('place', 'building')), + sa.not_(t.c.geometry.is_line_like()))) if self.has_feature_layers(): restrict.append(sa.and_(no_index(t.c.rank_search).between(26, MAX_RANK_PARAM), no_index(t.c.rank_address) == 0,