bharadwaj-raju / WeatherDesk

MOVED: https://gitlab.com/bharadwaj-raju/WeatherDesk
https://gitlab.com/bharadwaj-raju/WeatherDesk
GNU General Public License v3.0
217 stars 31 forks source link

[Fix] city arg sent may not match with the one Yahoo returns #19

Closed krantideep95 closed 8 years ago

krantideep95 commented 8 years ago

City argument for Yahoo weather api may not match with the location data it sends back. This may not be a issue when you determine location using IP address , but when user inputs city himself using --city and it doesn't match with Yahoo database, it may be difficult to pinpoint the error. This commit enables it to print location returned by Yahoo Weather API, instead of city mentioned earlier.

bharadwaj-raju commented 8 years ago

But if the city provided by --city is invalid, even the Yahoo! database query will not complete.

Also, if the city is valid (accepted by Yahoo!), what benefit will this provide? Yahoo's database accepts it.

bharadwaj-raju commented 8 years ago

If there is a way to check if the city is in Yahoo!'s database, it would be great.

bharadwaj-raju commented 8 years ago

Also, in my tests, Yahoo! can handle

krantideep95 commented 8 years ago

The issue occurs when the specified city is relatively small / unkown. Try running it with --city mesra and then --city mesra india / --city mesra ranchi . Both show results for Mesra, but one is in Algeria while other one is in Ranchi Jharkhand. So, print(city) prints "mesra" no matter what the Yahoo! output is.

If there is a way to check if the city is in Yahoo!'s database, it would be great.

This requires Yahoo GeoFinder API : https://query.yahooapis.com/v1/public/yql?q=select%20%2A%20from%20geo.places(5)%20where%20text%3D"mesra"&format=json

Actually,if user inputs his own location, you can compare woeid of district for all the results given by this API and compare it with woeid district of city obtained by ipinfo.io. The one which matches will be most acurate. :D

For Example, for --city mesra woeid obtained first is for algeria and second one is for Mesra, Ranchi . Using ipinfo.io ,location obtained is Ranchi. So, by comparing woeid of district of all these places with district woeid of ip geoloc (ip geolocation and user's own location must be in same district), we can find one which is common. This way , weather info will be more accurate.

bharadwaj-raju commented 8 years ago

Great. After merging this, I'll see into ipinfo.io's API if they provide region and will be doing the GeoFinder thing.