mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
fix poscode update computation: use distance
This commit is contained in:
@@ -119,7 +119,7 @@ class _PostcodeCollector:
|
|||||||
pcobj = self.collected.pop(postcode, None)
|
pcobj = self.collected.pop(postcode, None)
|
||||||
if pcobj:
|
if pcobj:
|
||||||
newx, newy = pcobj.centroid()
|
newx, newy = pcobj.centroid()
|
||||||
if (x - newx) > 0.0000001 or (y - newy) > 0.0000001:
|
if abs(x - newx) > 0.0000001 or abs(y - newy) > 0.0000001:
|
||||||
to_update.append((newx, newy, postcode))
|
to_update.append((newx, newy, postcode))
|
||||||
else:
|
else:
|
||||||
to_delete.append(postcode)
|
to_delete.append(postcode)
|
||||||
|
|||||||
@@ -100,10 +100,12 @@ def test_postcodes_add_new(dsn, postcode_table, insert_implicit_postcode, tokeni
|
|||||||
assert postcode_table.row_set == {('xx', '9486', 10, 12), }
|
assert postcode_table.row_set == {('xx', '9486', 10, 12), }
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('coords', [(99, 34), (10, 34), (99, 12),
|
||||||
|
(9, 34), (9, 11), (23, 11)])
|
||||||
def test_postcodes_replace_coordinates(dsn, postcode_table, tmp_path,
|
def test_postcodes_replace_coordinates(dsn, postcode_table, tmp_path,
|
||||||
insert_implicit_postcode, tokenizer):
|
insert_implicit_postcode, tokenizer, coords):
|
||||||
insert_implicit_postcode(1, 'xx', 'POINT(10 12)', dict(postcode='AB 4511'))
|
insert_implicit_postcode(1, 'xx', 'POINT(10 12)', dict(postcode='AB 4511'))
|
||||||
postcode_table.add('xx', 'AB 4511', 99, 34)
|
postcode_table.add('xx', 'AB 4511', *coords)
|
||||||
|
|
||||||
postcodes.update_postcodes(dsn, tmp_path, tokenizer)
|
postcodes.update_postcodes(dsn, tmp_path, tokenizer)
|
||||||
|
|
||||||
@@ -113,11 +115,11 @@ def test_postcodes_replace_coordinates(dsn, postcode_table, tmp_path,
|
|||||||
def test_postcodes_replace_coordinates_close(dsn, postcode_table,
|
def test_postcodes_replace_coordinates_close(dsn, postcode_table,
|
||||||
insert_implicit_postcode, tokenizer):
|
insert_implicit_postcode, tokenizer):
|
||||||
insert_implicit_postcode(1, 'xx', 'POINT(10 12)', dict(postcode='AB 4511'))
|
insert_implicit_postcode(1, 'xx', 'POINT(10 12)', dict(postcode='AB 4511'))
|
||||||
postcode_table.add('xx', 'AB 4511', 10, 11.99999)
|
postcode_table.add('xx', 'AB 4511', 10, 11.99999999)
|
||||||
|
|
||||||
postcodes.update_postcodes(dsn, None, tokenizer)
|
postcodes.update_postcodes(dsn, None, tokenizer)
|
||||||
|
|
||||||
assert postcode_table.row_set == {('xx', 'AB 4511', 10, 11.99999)}
|
assert postcode_table.row_set == {('xx', 'AB 4511', 10, 11.99999999)}
|
||||||
|
|
||||||
|
|
||||||
def test_postcodes_remove(dsn, postcode_table,
|
def test_postcodes_remove(dsn, postcode_table,
|
||||||
|
|||||||
Reference in New Issue
Block a user