wego icon indicating copy to clipboard operation
wego copied to clipboard

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

Open nikil opened this issue 10 years ago • 3 comments

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?

nikil avatar Apr 21 '16 21:04 nikil

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.

schachmat avatar Apr 21 '16 21:04 schachmat

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.

pasky avatar Apr 26 '16 21:04 pasky

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.

schachmat avatar Apr 26 '16 22:04 schachmat