问题
I want to fetch some weather data via latitude and longitude using yahoo query. but it seems this query is not available now. the query is below:
select * from weather.forecast where woeid in (SELECT woeid FROM geo.placefinder WHERE text="{lat},{lon}" and gflags="R")
is this query is changed to new one or something? or it didn't exist anymore? last time I use this format was about 2 months ago and it worked well. but now it can't fetch any data. result from YQL console is as below:
{
"error": {
"lang": "en-US",
"description": "Tenant 'query_yahooapis_com' access to 'Resource [tenantName=query_yahooapis_com, type=TABLE, name=geo.placefinder, locatorType=FILE, url=/home/y/share/manhattan/application/tenantBundles/yql_query_yahooapis_com_manhattan_v2/YQL-INF/restdefs/geo.placefinder.xml, useUrl=false]' is denied."
}
}
I already make some research, including this post: How to get Yahoo's woeid by location?
Is that true that yahoo already terminate this latitude longitude query for fetching weather?
回答1:
According to the latest reply to this answer, you should switch to the table geo.places
and remove the gflags="R"
part.
I tried it in the YQL console and it seems to work:
select * from weather.forecast where woeid in (SELECT woeid FROM geo.places WHERE text="(latitude,longitude)")
回答2:
This works for me(you should switch to the table geo.places(1)):
...
query = "SELECT * FROM weather.forecast " +
"WHERE woeid in (" +
"SELECT woeid " +
"FROM geo.places(1) " +
"WHERE text=\"(%1$s, %2$s)\") " +
"AND u='c'";
... and then:
query = String.format(query, location.getLatitude(), location.getLongitude());
来源:https://stackoverflow.com/questions/35220361/yahoo-weather-query-by-latitude-and-longitude