import yaml from geopy.distance import geodesic import constants with constants.OPTIMIZER_PARAMETERS_PATH.open('r') as f: parameters = yaml.safe_load(f) DETOUR_FACTOR = parameters['detour_factor'] AVERAGE_WALKING_SPEED = parameters['average_walking_speed'] def get_time(p1: tuple[float, float], p2: tuple[float, float]) -> int: """ Calculate the time in minutes to travel from one location to another. Args: p1 (Tuple[float, float]): Coordinates of the starting location. p2 (Tuple[float, float]): Coordinates of the destination. detour (float): Detour factor affecting the distance. speed (float): Walking speed in kilometers per hour. Returns: int: Time to travel from p1 to p2 in minutes. """ # Compute the straight-line distance in km if p1 == p2 : return 0 else: dist = geodesic(p1, p2).kilometers # Consider the detour factor for average cityto deterline walking distance (in km) walk_dist = dist*DETOUR_FACTOR # Time to walk this distance (in minutes) walk_time = walk_dist/AVERAGE_WALKING_SPEED*60 return round(walk_time)