雅虎按纬度和经度查询天气

时间:2016-02-05 09:22:27

标签: yql yahoo-weather-api

我想使用雅虎查询通过纬度和经度获取一些天气数据。但似乎这个查询现在不可用。查询如下:

select * from weather.forecast where woeid in (SELECT woeid FROM geo.placefinder WHERE text="{lat},{lon}" and gflags="R")

这个查询是改为新的还是什么?或者它不再存在?上次我使用这种格式是大约2个月前,它运作良好。但现在它无法获取任何数据。 YQL控制台的结果如下:

{
 "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."
 }
}

我已经做了一些研究,包括这篇文章:How to get Yahoo's woeid by location?

雅虎是否已经终止此纬度经度查询以获取天气?

2 个答案:

答案 0 :(得分:22)

根据对this answer的最新回复,您应切换到表geo.places并删除gflags="R"部分。 我在YQL控制台中尝试了它,它似乎工作:

select * from weather.forecast where woeid in (SELECT woeid FROM geo.places WHERE text="(latitude,longitude)")

答案 1 :(得分:1)

这对我有用(您应该切换到表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'";

...然后:

query = String.format(query, location.getLatitude(), location.getLongitude());