1 # SPDX-License-Identifier: GPL-2.0-only
 
   3 # This file is part of Nominatim. (https://nominatim.org)
 
   5 # Copyright (C) 2022 by the Nominatim developer community.
 
   6 # For a full list of authors see the git log.
 
   8 Collection of assertion functions used for the steps.
 
  12     """ Compares a float value with a certain jitter.
 
  14     def __init__(self, value, offset=0.00001):
 
  18     def __eq__(self, other):
 
  19         return abs(other - self.value) < self.offset
 
  22     """ Comparator for bounding boxes.
 
  24     def __init__(self, bbox_string):
 
  25         self.coord = [float(x) for x in bbox_string.split(',')]
 
  27     def __contains__(self, item):
 
  28         if isinstance(item, str):
 
  29             item = item.split(',')
 
  30         item = list(map(float, item))
 
  33             return self.coord[0] <= item[0] <= self.coord[2] \
 
  34                    and self.coord[1] <= item[1] <= self.coord[3]
 
  37             return item[0] >= self.coord[0] and item[1] <= self.coord[1] \
 
  38                    and item[2] >= self.coord[2] and item[3] <= self.coord[3]
 
  40         raise ValueError("Not a coordinate or bbox.")
 
  43         return str(self.coord)