diff --git a/nominatim/api/reverse.py b/nominatim/api/reverse.py index 7b1c6431f8..bf81378cd8 100644 --- a/nominatim/api/reverse.py +++ b/nominatim/api/reverse.py @@ -403,7 +403,7 @@ def _place_inside_area_query() -> SaSelect: .where(t.c.indexed_status == 0)\ .where(snfn.select_index_placex_geometry_reverse_lookupplacenode('placex'))\ .where(snfn.IntersectsReverseDistance(t.c.geometry, t.c.rank_search, - WKT_PARAM))\ + WKT_PARAM, address_rank))\ .order_by(sa.desc(t.c.rank_search))\ .limit(50)\ .subquery('places') @@ -440,7 +440,7 @@ async def _lookup_area_others(self) -> Optional[SaRow]: .where(t.c.linked_place_id == None)\ .where(self._filter_by_layer(t))\ .where(snfn.IntersectsReverseDistance(t.c.geometry, t.c.rank_search, - WKT_PARAM))\ + WKT_PARAM, 25))\ .order_by(sa.desc(t.c.rank_search))\ .order_by('distance')\ .limit(50)\ @@ -514,7 +514,7 @@ def _base_query() -> SaSelect: .where(t.c.indexed_status == 0)\ .where(t.c.country_code.in_(ccodes))\ .where(snfn.select_index_placex_geometry_reverse_lookupplacenode('placex'))\ - .where(snfn.IntersectsReverseDistance(t.c.geometry, t.c.rank_search, WKT_PARAM))\ + .where(snfn.IntersectsReverseDistance(t.c.geometry, t.c.rank_search, WKT_PARAM, 25))\ .order_by(sa.desc(t.c.rank_search))\ .limit(50)\ .subquery('area') diff --git a/nominatim/db/sqlalchemy_functions.py b/nominatim/db/sqlalchemy_functions.py index 037cbcb156..8d2b47c0be 100644 --- a/nominatim/db/sqlalchemy_functions.py +++ b/nominatim/db/sqlalchemy_functions.py @@ -42,7 +42,7 @@ class IntersectsReverseDistance(sa.sql.functions.GenericFunction): @compiles(IntersectsReverseDistance) def default_reverse_place_diameter(element, compiler, **kw): - geom1, rank, geom2 = list(element.clauses) + geom1, rank, geom2, _ = list(element.clauses) return "ST_Buffer(%s, reverse_place_diameter(%s)) && %s" % ( compiler.process(geom1, **kw), compiler.process(rank, **kw), @@ -50,7 +50,7 @@ def default_reverse_place_diameter(element, compiler, **kw): @compiles(IntersectsReverseDistance, 'sqlite') def sqlite_reverse_place_diameter(element, compiler, **kw): - geom1, rank, geom2 = list(element.clauses) + geom1, rank, geom2, max_rank = list(element.clauses) return "MbrIntersects(%s, ST_Expand(%s, 14.0 * exp(-0.2 * %s) - 0.03)) "\ "AND %s.ROWID IN (SELECT ROWID FROM SpatialIndex AS si "\ "WHERE si.f_table_name = '%s' and si.f_geometry_column = '%s' "\ @@ -60,7 +60,7 @@ def sqlite_reverse_place_diameter(element, compiler, **kw): compiler.process(rank, **kw), geom1.table.name, geom1.table.name, geom1.name, compiler.process(geom2, **kw), - compiler.process(rank, **kw)) + compiler.process(max_rank, **kw))