mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
make sure PHP and Python reverse code does the same
The only allowable difference is precision of coordinates. Python uses a precision of 7 digits where possible, which corresponds to the precision of OSM data. Also fixes some smaller bugs found by the BDD tests.
This commit is contained in:
@@ -47,15 +47,16 @@ class Field:
|
||||
""" Generic comparator for fields, which looks at the type of the
|
||||
value compared.
|
||||
"""
|
||||
def __init__(self, value):
|
||||
def __init__(self, value, **extra_args):
|
||||
self.value = value
|
||||
self.extra_args = extra_args
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(self.value, float):
|
||||
return math.isclose(self.value, float(other))
|
||||
return math.isclose(self.value, float(other), **self.extra_args)
|
||||
|
||||
if self.value.startswith('^'):
|
||||
return re.fullmatch(self.value, other)
|
||||
return re.fullmatch(self.value, str(other))
|
||||
|
||||
if isinstance(other, dict):
|
||||
return other == eval('{' + self.value + '}')
|
||||
|
||||
Reference in New Issue
Block a user