This started as a request to use airport codes as locations, but then I looked at the output using -owm-debug and realized that the location is just being passed along to the weather API, and not all weather APIs support airport codes as locations (for example, openweathermap does not).
AirportDB offers an API to look up airport information, including their coordinates. API keys allowing up to 5000 requests per month are free.
My original suggestion was going to be to use this API, and have it create a local cache of airport coordinates, so that if somebody runs wego as part of a cron job, each airport's coordinates would only need to be looked up once rather than every time the command runs, since airports' coordinates generally don't change very often. 😁
But then, as I was typing this, I realized that if I'm going to suggest having a local cache of locations and coordinates, it might be nice if users could manually add their own custom locations (or "aliases") to that cache. This could be done either by telling the user to manually edit the cache file (assuming it's stored as JSON, YAML, INI, or some other human-editable format), or by adding command line options.
I'm thinking ...
wego -airport KTPA would ...
- convert the name to lowercase
- if
ktpa is in the cache, get the coordinates from the cache
- if not, use the AirportDB API to look up its coordinates and write them in the cache file
- send the coordinates as part of the weather API request
wego -alias home (or -a home) would ...
- convert the name to lowercase
- if the name is in the cache, get the coordinates from the cache
- if not, throw an error
- send the coordinates as part of the weather API request
wego -alias-add home 27.35,-82.49 would ...
- convert the name to lowercase
- manually add an entry in the cache
wego -alias-list would list the cached entries and their coordinates
wego -alias-remove home would remove an entry from the cache
- this could also be used to remove an airport, since it would just be another alias in the same file
I'm also suggesting that the alias names in the cache file would be lowercased, so it wouldn't matter if somebody enters an alias name (or airport code) as uppercase, lowercase, or mixed.
This started as a request to use airport codes as locations, but then I looked at the output using
-owm-debugand realized that the location is just being passed along to the weather API, and not all weather APIs support airport codes as locations (for example, openweathermap does not).AirportDB offers an API to look up airport information, including their coordinates. API keys allowing up to 5000 requests per month are free.
My original suggestion was going to be to use this API, and have it create a local cache of airport coordinates, so that if somebody runs
wegoas part of a cron job, each airport's coordinates would only need to be looked up once rather than every time the command runs, since airports' coordinates generally don't change very often. 😁But then, as I was typing this, I realized that if I'm going to suggest having a local cache of locations and coordinates, it might be nice if users could manually add their own custom locations (or "aliases") to that cache. This could be done either by telling the user to manually edit the cache file (assuming it's stored as JSON, YAML, INI, or some other human-editable format), or by adding command line options.
I'm thinking ...
wego -airport KTPAwould ...ktpais in the cache, get the coordinates from the cachewego -alias home(or-a home) would ...wego -alias-add home 27.35,-82.49would ...wego -alias-listwould list the cached entries and their coordinateswego -alias-remove homewould remove an entry from the cacheI'm also suggesting that the alias names in the cache file would be lowercased, so it wouldn't matter if somebody enters an alias name (or airport code) as uppercase, lowercase, or mixed.