Question

I'm trying to make sure the result from text search is only UK or Ireland. My places REST request looks like this:

http://where.yahooapis.com/v1/places.q('Belfast')?format=json&appid=MyAppIdGoesHere

Is there another parameter for the URL that I can specify the country or woeid the result must be in?

Was it helpful?

Solution

I don't believe there is a way to add that specificity within the GeoPlanet web service call. There is support for Filters, including the $and filter which lets you combine two filters together, but it doesn't look like a combination exists that would satisfy your request directly.

As an alternative, you could make the API call, then filter the results to keep only those results in the matching country.

For example, the following is part of the results for a search for "Belfast". After retrieving these results, you could keep only those places where country=GB:

<place xmlns="http://where.yahooapis.com/v1/schema.rng"
    xml:lang="en-GB" yahoo:uri="http://where.yahooapis.com/v1/place/44544">
    <woeid>44544</woeid>
    <placeTypeName code="7">Town</placeTypeName>
    <name>Belfast</name>
    <country code="GB" type="Country" woeid="23424975">United Kingdom</country>
    <admin1 code="GB-NIR" type="Country" woeid="20070563">Northern Ireland</admin1>
    <admin2 code="GB-BFS" type="County" woeid="20071112">Belfast</admin2>
    <admin3 code="" type="Local Administrative Area" woeid="20078326">Belfast</admin3>
    <locality1 type="Town" woeid="44544">Belfast</locality1>
</place>
<place xmlns="http://where.yahooapis.com/v1/schema.rng"
    xml:lang="en-GB" yahoo:uri="http://where.yahooapis.com/v1/place/2361609">
    <woeid>2361609</woeid>
    <placeTypeName code="7">Town</placeTypeName>
    <name>Belfast</name>
    <country code="US" type="Country" woeid="23424977">United States</country>
    <admin1 code="US-ME" type="State" woeid="2347578">Maine</admin1>
    <admin2 code="" type="County" woeid="12588673">Waldo</admin2>
    <admin3/>
    <locality1 type="Town" woeid="2361609">Belfast</locality1>
</place>
<place xmlns="http://where.yahooapis.com/v1/schema.rng"
    xml:lang="en-GB" yahoo:uri="http://where.yahooapis.com/v1/place/2348154">
    <woeid>2348154</woeid>
    <placeTypeName code="7">Town</placeTypeName>
    <name>Belfast</name>
    <country code="NZ" type="Country" woeid="23424916">New Zealand</country>
    <admin1 code="NZ-CAN" type="Region" woeid="15021751">Canterbury</admin1>
    <admin2 code="" type="County" woeid="55875854">Christchurch City</admin2>
    <admin3/>
    <locality1 type="Town" woeid="2348154">Belfast</locality1>
</place>
<place xmlns="http://where.yahooapis.com/v1/schema.rng"
    xml:lang="en-GB" yahoo:uri="http://where.yahooapis.com/v1/place/2361600">
    <woeid>2361600</woeid>
    <placeTypeName code="7">Town</placeTypeName>
    <name>Belfast</name>
    <country code="US" type="Country" woeid="23424977">United States</country>
    <admin1 code="US-NY" type="State" woeid="2347591">New York</admin1>
    <admin2 code="" type="County" woeid="12589313">Allegany</admin2>
    <admin3/>
    <locality1 type="Town" woeid="2361600">Belfast</locality1>
</place>

OTHER TIPS

This can be made possible by using the $and operator as your filter. Take note that the $and operator can combine two different filters, which is in your case you want to do the text search within a specified place (UK or Ireland). For that you can use the .woeid and the .q filters like so:

http://where.yahooapis.com/v1/places$and(.woeid(23424975),.q('Belfast'))?format=json&appid=YourAppIdGoesHere

wherein in this example, the numeric value 23424975 is the woeid of UK.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top