A text-based weather service that provides weather details based on location or local file data. Uses Nominatim for geolocation and National Weather Service for obtaining weather data.
This program reads input from standard input. All input must be provided in the exact order and format described below.
The first line of input specifies the target location and must be in one of the following formats:
TARGET NOMINATIM location
locationis any non-empty string describing the location to analyze.- The program will use the Nominatim API to determine latitude and longitude.
OR
TARGET FILE path
pathis the path to a local file containing the result of a previous Nominatim API call.- The file must exist and be in the same format returned by Nominatim.
The second line of input specifies the source of weather data and must be in one of the following formats:
WEATHER NWS
- Uses the National Weather Service API to obtain hourly weather forecasts.
OR
WEATHER FILE path
pathis the path to a local file containing the result of a previous NWS hourly forecast API call.- The file must exist and be in the same format returned by the NWS API.
The third line of input must be a weather query. Subsequent lines may contain additional weather queries.
- At least one weather query will be provided.
- There is no limit to the number of queries.
- Queries may appear in any order and may be duplicated.
Each weather query must be in one of the following formats:
TEMPERATURE AIR scale length limit
TEMPERATURE FEELS scale length limit
scale:F(Fahrenheit) orC(Celsius)length: positive integer indicating hours into the futurelimit:MAXorMIN
HUMIDITY length limit
- Reported as a percentage.
WIND length limit
- Reported in miles per hour.
PRECIPITATION length limit
- Reported as an hourly percentage chance.
After all weather queries have been entered, include the following line:
NO MORE QUERIES
The final line of input specifies how to determine the nearest weather station location and must be in one of the following formats:
REVERSE NOMINATIM
- Uses the Nominatim API for reverse geocoding.
OR
REVERSE FILE path
pathis the path to a local file containing the result of a previous Nominatim reverse geocoding API call.- The file must exist and be in the same format returned by Nominatim.
TARGET NOMINATIM Bren Hall, Irvine, CA
WEATHER NWS
TEMPERATURE AIR F 24 MAX
HUMIDITY 24 MIN
WIND 12 MAX
NO MORE QUERIES
REVERSE NOMINATIM