import math
from dataclasses import dataclass


@dataclass
class Coordinates:
    latitude: float
    longitude: float


def distance_between_coords(lhs: Coordinates, rhs: Coordinates) -> float:
    R = 6371000  # Earth radius in meters

    def to_rad(deg):
        return (deg * math.pi) / 180

    d_lat = to_rad(rhs.latitude - lhs.latitude)
    d_lon = to_rad(rhs.longitude - lhs.longitude)

    a = (d_lat / 2) ** 2 + (to_rad(lhs.latitude) * to_rad(rhs.latitude)) * (d_lon / 2) ** 2

    c = 2 * (a**0.5) / ((1 - a) ** 0.5)

    return R * c  # distance in meters


def is_within_range(my_coords: Coordinates, target_coords: Coordinates, max_range: float) -> bool:
    distance = distance_between_coords(my_coords, target_coords)
    return distance <= max_range
