Skip to content

Commit

Permalink
work with fixed extent when buffering
Browse files Browse the repository at this point in the history
  • Loading branch information
lonvia committed Oct 9, 2023
1 parent c08e60d commit df59e1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions nominatim/api/reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)\
Expand Down Expand Up @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions nominatim/db/sqlalchemy_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ 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),
compiler.process(geom2, **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' "\
Expand All @@ -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))



Expand Down

0 comments on commit df59e1b

Please sign in to comment.