def display(lat1: float, lon1: float, lat2: float, lon2: float,
            r: str) -> None:
    """
    >>> display(36.12, -86.67, 33.94, -118.4, 'NM')
    From 36.12,-86.67 to 33.94,-118.4 in NM = 1558.53
    """
    r_float = {"NM": NM, "KM": KM, "MI": MI}[r]
    d = haversine(lat1, lon1, lat2, lon2, r_float)
    print(f"From {lat1},{lon1} to {lat2},{lon2} in {r} = {d:.2f}")
 def waypoint(self, next_point: Point) -> Optional[Leg]:
     leg: Optional[Leg]
     if self.last_point is not None:
         leg = Leg(self.last_point, next_point)
         d = haversine(leg.start.lat, leg.start.lon, leg.end.lat,
                       leg.end.lon, self.r)
         leg.distance = round(d)
     else:
         leg = None
     self.last_point = next_point
     return leg
 def waypoint(self, next_point: Point) -> Optional[Leg]:
     leg: Optional[Leg]
     if self.last_point is None:
         # Special case for the first leg
         leg = None
     else:
         leg = Leg(self.last_point, next_point)
         d = haversine(leg.start.lat, leg.start.lon, leg.end.lat,
                       leg.end.lon, self.r)
         leg.distance = round(d)
     self.last_point = next_point
     return leg
Exemplo n.º 4
0
 def distance(self, p1: Point, p2: Point) -> float:
     return haversine(p1.lat, p1.lon, p2.lat, p2.lon, self.r)