10

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?

Community
  • 1
  • 1
squall leonhart
  • 301
  • 1
  • 5
  • 16

2 Answers2

22

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)")
rotten_flesh
  • 69
  • 2
  • 13
greg
  • 433
  • 5
  • 12
  • hi. thank you for reply. but seems your answer still produce the same result. i really think that this query is not valid anymore. – squall leonhart Mar 03 '16 at 10:37
  • It doesn't produce the same results. I don't know how you tried it, but I just tried and everything works fine. [take a look here and just press the test button](https://developer.yahoo.com/yql/console/#h=select+*+from+weather.forecast+where+woeid+in+(SELECT+woeid+FROM+geo.places+WHERE+text%3D%22%7Blat%7D%2C%7Blon%7D%22)) – greg Mar 03 '16 at 11:14
  • may i know, what the exact location you put, i mean the latitude and longitude that you are using for this query? yes i already try your test and it works. but it seems you only put 'lat' and 'lon' in the query. – squall leonhart Mar 07 '16 at 05:54
  • 9
    Try this one, is New York: `select * from weather.forecast where woeid in (SELECT woeid FROM geo.places WHERE text="(40.7141667,-74.0063889)")` – greg Mar 07 '16 at 10:43
  • If this answer has been useful, could you please vote this? I suppose it's you that gave the answer a negative vote... – greg Mar 11 '16 at 12:44
1

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());
Vladyslav Ulianytskyi
  • 1,401
  • 22
  • 22