def score_by_geo_distance(helper, result): if not helper.lat or not helper.lon: return km = haversine_distance((float(result.lat), float(result.lon)), (helper.lat, helper.lon)) result.distance = km * 1000 result.add_score('geo_distance', km_to_score(km), ceiling=0.1)
def score_by_geo_distance(helper, result): if helper.lat is None or helper.lon is None: return km = haversine_distance((float(result.lat), float(result.lon)), (helper.lat, helper.lon)) result.distance = km * 1000 result.add_score('geo_distance', km_to_score(km) * config.GEO_DISTANCE_WEIGHT, ceiling=config.GEO_DISTANCE_WEIGHT)
def sort(h): return haversine_distance((float(h[1]), float(h[2])), (helper.lat, helper.lon))