示例#1
0
    def __get_confidence(self, geocode):
        """
            Units are measured in Kilometers
        """
        northeast_geo = (geocode['geometry']['bounds']['northeast']['lat'],
                         geocode['geometry']['bounds']['northeast']['lng'])

        southwest_geo = (geocode['geometry']['bounds']['southwest']['lat'],
                         geocode['geometry']['bounds']['southwest']['lng'])
        if northeast_geo and southwest_geo:
            distance = Distance(northeast_geo, southwest_geo, units='km')
            for score, maximum in [(10, 0.25), (9, 0.5), (8, 1), (7, 5),
                                   (6, 7.5), (5, 10), (4, 15), (3, 20),
                                   (2, 25)]:
                if distance < maximum:
                    logging.debug("Distance: {}".format(distance))
                    logging.debug("Confidence Level: {}".format(score))
                    return score
                if distance >= 25:
                    logging.debug("Distance: {}".format(distance))
                    logging.debug("Confidence Level: {}".format(1))
                    """Cannot determine score"""
                    return 1

        return 0
示例#2
0
def distance(*args, **kwargs):
    """Distance tool measures the distance between two or multiple points.

    :param location: (min 2x locations) Your search location you want geocoded.
    :param units: (default=kilometers) Unit of measurement.
        > kilometers
        > miles
        > feet
        > meters
    """
    return Distance(*args, **kwargs)
示例#3
0
 def confidence(self):
     if self.bbox:
         # Units are measured in Kilometers
         distance = Distance(self.northeast, self.southwest, units='km')
         for score, maximum in [(10, 0.25), (9, 0.5), (8, 1), (7, 5),
                                (6, 7.5), (5, 10), (4, 15), (3, 20),
                                (2, 25)]:
             if distance < maximum:
                 return score
             if distance >= 25:
                 return 1
     # Cannot determine score
     return 0