0

Restrict results to those under a specified WOEID e.g. A country

As discussed in this forum thread I misinterpreted the documentation by thinking that the focus parameter sent to the places.q() service restricted results to the specified ISO country or those under the specified WOEID, rather than the actual functionality which is to promote places from that focus in the results.

It would be great if the places.q() service could accept a 'parent' or 'under' parameter which would restrict results to those under the supplied WOEID. This would allow users to search through a particular branch of the hierarchy. And would be awesome.

by
4 Replies
  • QUOTE (neil.crookes @ Apr 13 2010, 12:03 AM) <{POST_SNAPBACK}>
    As discussed in this forum thread I misinterpreted the documentation by thinking that the focus parameter sent to the places.q() service restricted results to the specified ISO country or those under the specified WOEID, rather than the actual functionality which is to promote places from that focus in the results.

    It would be great if the places.q() service could accept a 'parent' or 'under' parameter which would restrict results to those under the supplied WOEID. This would allow users to search through a particular branch of the hierarchy. And would be awesome.


    Thanks for the suggestion. We will consider this for a future release of GeoPlanet. The concept of parent is very specific in GeoPlanet; it is the next-largest administrative area that contains a place. The concept of belongto is more general; it is any place that "contains" a place (including the parent place). It seems to me that you would like to be able to provide a belongto filter (e.g. .belongto(woeid)) when using the places collection.

    Eddie Babcock
    Yahoo! Geo Technologies
    0
  • I have a different situation that needs a similar approach.

    I'm trying to find partial matches to a particular place name, restricted to a particular country (in my case, Australia). For example, I'd like to be able to query for towns in Australia beginning with "Mel" and get (for example) Melbourne as a match. Using something like places$and(.q('Mel%2A','au'),.type(7)) does not work as Neil discovered, as results from outside Australia are still returned. The other reasonable approach, places$and(.q('Mel%2A,au'),.type(7)), seems apparently to be misinterpreted and returns no results.

    Being able to filter out results belonging to a particular country or WOEID would be very useful in this case, and I can't imagine it's much more difficult (if at all) in a technical sense than simply promoting them.
    0
  • QUOTE (mac.coombe @ Jan 17 2011, 07:40 PM) <{POST_SNAPBACK}>
    I have a different situation that needs a similar approach.

    I'm trying to find partial matches to a particular place name, restricted to a particular country (in my case, Australia). For example, I'd like to be able to query for towns in Australia beginning with "Mel" and get (for example) Melbourne as a match. Using something like places$and(.q('Mel%2A','au'),.type(7)) does not work as Neil discovered, as results from outside Australia are still returned. The other reasonable approach, places$and(.q('Mel%2A,au'),.type(7)), seems apparently to be misinterpreted and returns no results.

    Being able to filter out results belonging to a particular country or WOEID would be very useful in this case, and I can't imagine it's much more difficult (if at all) in a technical sense than simply promoting them.


    The startswith feature (appending "*" to the query string) only works if the "*" is at the end of the query string, and not in the middle as in your example.

    Now that GeoPlanet is supported by YQL (visit http://developer.yahoo.com/yql for more information), it is possible to use YQL to return only results in the desired country. For example, the following YQL query string returns all the towns in Australia that start with the text "mel":

    CODE
    select name,woeid from geo.places where text="mel*" and country.code="AU"


    This query string would be embedded into a YQL web service request like http://query.yahooapis.com/v1/public/yql?q...&appid=test. Note that the response format for YQL is slightly different from the response format for GeoPlanet.

    Eddie Babcock
    Yahoo! Geo Technologies
    0
  • QUOTE (Eddie B @ Jan 18 2011, 02:03 PM) <{POST_SNAPBACK}>
    The startswith feature (appending "*" to the query string) only works if the "*" is at the end of the query string, and not in the middle as in your example.

    Now that GeoPlanet is supported by YQL (visit http://developer.yahoo.com/yql for more information), it is possible to use YQL to return only results in the desired country. For example, the following YQL query string returns all the towns in Australia that start with the text "mel":

    CODE
    select name,woeid from geo.places where text="mel*" and country.code="AU"


    This query string would be embedded into a YQL web service request like http://query.yahooapis.com/v1/public/yql?q...&appid=test. Note that the response format for YQL is slightly different from the response format for GeoPlanet.

    Eddie Babcock
    Yahoo! Geo Technologies


    Thanks for your swift reply Eddie.

    I figured that the asterisk not being at the end of the string might be the issue, but thanks for confirming that. I'll definitely be looking into YQL - thanks also for that tip.

    Cheers,
    Mac
    0
This forum is locked.

Recent Posts

in GeoPlanet Enhancement Requests