示例#1
0
def __get_observation_at_geocoords(
        api: OWM, location: dict) -> Tuple[Observation, UVIndex]:
    """
    Gets the observation at a set of coordinates
    """
    weather_manager = api.weather_manager()
    obs_weather: Observation = weather_manager.weather_at_coords(
        lat=location["latitude"], lon=location["longitude"])
    if obs_weather is None:
        return LOC_NOT_FOUND_MSG

    uvindex_manager = api.uvindex_manager()
    obs_uv: UVIndex = uvindex_manager.uvindex_around_coords(
        obs_weather.location.lat, obs_weather.location.lon)

    return (obs_weather, obs_uv)
示例#2
0
def __get_observation_at_place_id(
        api: OWM, location: dict) -> Tuple[Observation, UVIndex]:
    """
    Gets an observation at a specific place id
    """

    weather_manager = api.weather_manager()
    obs_weather: Observation = weather_manager.weather_at_id(
        location["place_id"])
    if obs_weather is None:
        return LOC_NOT_FOUND_MSG

    uvindex_manager = api.uvindex_manager()
    obs_uv: UVIndex = uvindex_manager.uvindex_around_coords(
        obs_weather.location.lat, obs_weather.location.lon)

    return (obs_weather, obs_uv)