Closed krantideep95 closed 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.
If there is a way to check if the city is in Yahoo!'s database, it would be great.
Also, in my tests, Yahoo! can handle
--city Delhi
and --city delhi
both work--city New Delhi
, --city newdelhi
and --city new delhi
.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.
Great. After merging this, I'll see into ipinfo.io's API if they provide region and will be doing the GeoFinder thing.
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.