Receive a WOEID by Lat, Long with Yahoos API

后端 未结 11 1899
北荒
北荒 2020-12-07 17:57

i searched a while but found nothing, thats simular to my problem.

i\'m trying to use the YAHOO Weather API, for example: http://weather.yahooapis.com/forecastrss?w=

相关标签:
11条回答
  • 2020-12-07 18:28

    First get city name from lat/long using this code.

    CLGeocoder *geocoder = [[CLGeocoder alloc] init] ;
    [geocoder reverseGeocodeLocation:location
                   completionHandler:^(NSArray *placemarks, NSError *error) {
                       if (error){
                           NSLog(@"Geocode failed with error: %@", error);
                           return;
                       }
                       CLPlacemark *placemark = [placemarks objectAtIndex:0];
                       NSLog(@"cityname - %@",placemark.locality);
                   }];
    

    Then use that cityname in below url

    https://search.yahoo.com/sugg/gossip/gossip-gl-location/?appid=weather&output=sd1&p2=pt&command=YOURCITYNAME

    Example - https://search.yahoo.com/sugg/gossip/gossip-gl-location/?appid=weather&output=sd1&p2=pt&command=sydney

    This will return json and you find get WOEID in this...

    { "l" : { "gprid" : "eIL89mltSzSfgDWdP7uyBA" },
      "q" : "sydney",
      "r" : [ { "d" : "pt:iso=AU&woeid=1105779&lon=151.021&lat=-33.8563&s=New South Wales&c=Australia&sc=NSW&n=Sydney, Australia",
            "k" : "Sydney"
          } ]
    }
    
    0 讨论(0)
  • 2020-12-07 18:32

    Instead using lng & lat, you can use the current online IP Address to get the City Name then use Yahoo GeoPlanet web service to get the WOEID. Follow this tutorial to get the detail: http://4rapiddev.com/php/get-woeid-of-a-city-name-from-ip-address-with-php/

    0 讨论(0)
  • 2020-12-07 18:36

    This is not using Yahoo's API but I found this blog post: http://geomojo.org/?p=38

    Mentioning this service: http://www.geomojo.org/cgi-bin/reversegeocoder.cgi?long=-117.699444&lat=35.4775

    Perhaps you can use that? It solved my problem, I hope it helps in solving yours.

    0 讨论(0)
  • 2020-12-07 18:38

    Yahoo api uses weather.com actually, so go to weather.com and search for your local weather. I'm in Chicago so I entered 'Chicago, IL' and here's the link in my browser bar showing my weather:

    http://www.weather.com/weather/today/Chicago+IL+USIL0225?lswe=chicago,%20il&from=searchbox_localwx

    In the link is the woeid - which is USIL0225

    You can get yours the same way.

    0 讨论(0)
  • 2020-12-07 18:40

    It is somewhat ridiculous that Yahoo doesn't provide a lookup method for WOEIDs via lat/lon--it's been on their todo list since 2008--but that's the state of things.

    I would caution you against using the suggested workaround implemented at Geomojo. If it works for your data, great, but the Yahoo service that Geomojo relies on is unpredictable. Geomojo uses Yahoo's PlaceMaker, which extracts location information from unstructured text to get a WOEID. It does this by creating a microformat containing your lat/lon pair and submitting it to PlaceMaker. However, since PlaceMaker returns WOEIDs for zip codes there's a loss of resolution and you will sometimes not be able to identify even the town for submitted coordinates. I have a number of example points on the east coast of the U.S. where the PlaceMaker WOEIDs do not correspond to the submitted lat/lon pairs.

    Strangely, as HD writes, only Flickr's API provides a simple way to lookup a WOEID from lat/lon. Flickr's findByLatLon method has great resolution. It will usually return a neighborhood (one level below town) for a pair of coordinates.

    0 讨论(0)
  • 2020-12-07 18:44

    There is a topic about this issue at the YDN forums http://developer.yahoo.net/forum/index.php?showtopic=69

    Looks like it's buried in the to-do list, from 2008 "The ability to map a set of longitude and latitude coordinates to a WOEID, from which information such as ZIP and State may be derived, has already been identified as a valuable feature and it is on our enhancement request list."

    Other quotes;

    "Flickr has a method: flickr.places.findByLatLon which returns a WOEID, but they truncate coordinates to three decimal places."

    In this topic a Yahoo dev also suggests using the advice at http://geomojo.org/?p=38 as an interim solution.

    0 讨论(0)
提交回复
热议问题