schachmat / wego

weather app for the terminal
ISC License
7.82k stars 476 forks source link

Convert location text to latitude/longitude for forecast.io backend #87

Open nikil opened 8 years ago

nikil commented 8 years ago

Since forecast.io only supports latitude/longitude style locations, it would be nice to have an interface where we could specify a normal location (e.g., "Los Angeles") and have the backend convert automatically to lat/long. When displaying the weather, you could also convert from the lat/long used in the forecast.io lookup back to a canonical location string.

It appears that there's a Go library for just such this purpose: https://github.com/jasonwinn/geocoder

Any chance this could be integrated into wego?

schachmat commented 8 years ago

Yep, it's definitely a feature I'm looking into. This was a regression from the worldweatheronline API, which allowed locations specified as city names or even postal codes. A few other possible backends also only support lat,lon-pairs, so it will definitely be added.

I don't like the solution you found, since it has to do another RTT of network traffic before requesting the weather data. A local database would be more fitting.

pasky commented 8 years ago

How big would such a database be, though? I could ask wego Plavy before, which refers to a village in Czech Republic, and get a sensible reply. Maybe it'd be better to use geocoder, but cache resolved locations in .wegorc.

schachmat commented 8 years ago

Caching would be a solution, but it should be done by the geocoder lib, so other projects using that lib can also benefit from the cache. I opened an issue for that.