mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-11-20 12:19:13 +03:00
get bbox of postcode areas into results
This commit is contained in:
parent
83013f819b
commit
5160a1d577
@ -616,6 +616,8 @@ class PostcodeSearch(AbstractSearch):
|
||||
|
||||
for prow in await conn.execute(placex_sql, _details_to_bind_params(details)):
|
||||
result = nres.create_from_placex_row(prow, nres.SearchResult)
|
||||
if result is not None:
|
||||
result.bbox = Bbox.from_wkb(prow.bbox)
|
||||
break
|
||||
else:
|
||||
result = nres.create_from_postcode_row(row, nres.SearchResult)
|
||||
|
@ -59,6 +59,19 @@ def test_postcode_with_country(apiobj, frontend):
|
||||
assert results[0].place_id == 101
|
||||
|
||||
|
||||
def test_postcode_area(apiobj, frontend):
|
||||
apiobj.add_postcode(place_id=100, country_code='ch', postcode='12345')
|
||||
apiobj.add_placex(place_id=200, country_code='ch', postcode='12345',
|
||||
osm_type='R', osm_id=34, class_='boundary', type='postal_code',
|
||||
geometry='POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))')
|
||||
|
||||
results = run_search(apiobj, frontend, 0.3, ['12345'], [0.0])
|
||||
|
||||
assert len(results) == 1
|
||||
assert results[0].place_id == 200
|
||||
assert results[0].bbox.area == 1
|
||||
|
||||
|
||||
class TestPostcodeSearchWithAddress:
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
Loading…
Reference in New Issue
Block a user