Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/nominatim_api/reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ async def _find_closest_street_or_pois(self, distance: float,
sa.func.first_value(sa.case((sa.or_(inner.c.rank_search <= 27,
inner.c.osm_type == 'N'), None),
else_=inner.c._geometry))
.over(order_by=inner.c.distance)
.over(order_by=[inner.c.distance,
sa.func.ST_Area(inner.c._geometry)])
.label('_best_geometry')) \
.subquery()

Expand Down Expand Up @@ -354,7 +355,8 @@ async def lookup_street_poi(self) -> Tuple[Optional[SaRow], RowFunc]:
# a POI nearby and return that with preference.
elif result.osm_type != 'N' and result.rank_search > 27 \
and result.distance == 0 \
and row.best_inside:
and row.best_inside \
and (result.housenumber is None or result.housenumber == row.housenumber):
log().var_dump('POI near closest result area', row)
result = row
break # it can't get better than that, everything else is farther away
Expand Down
18 changes: 17 additions & 1 deletion test/bdd/features/db/query/reverse.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Feature: Reverse searches
| W1 | aeroway | terminal | (1,2,3,4,1) |
| N9 | amenity | restaurant | 9 |
When importing
And reverse geocoding 1.0001,1.0001
And reverse geocoding 1.0002,1.0001
Then the result contains
| object |
| N9 |
Expand All @@ -21,6 +21,22 @@ Feature: Reverse searches
| W1 |


Scenario: POI in POI area with different housenumbers
Given the 0.0001 grid with origin 1,1
| 1 | | | | | | | | 2 |
| | 9 | | | | | | | |
| 4 | | | | | | | | 3 |
And the places
| osm | class | type | housenr | geometry |
| W1 | aeroway | terminal | 11 | (1,2,3,4,1) |
| N9 | amenity | restaurant | 13 | 9 |
When importing
And reverse geocoding 1.0002,1.0001
Then the result contains
| object |
| W1 |


Scenario: Find closest housenumber for street matches
Given the 0.0001 grid with origin 1,1
| | 1 | | |
Expand Down
Loading