Re: Sample code for using Yahoo's geocoding to emulate near in the search API

2009-02-19 Thread SteveR

Hi,

I have used Google Maps to do something similar (with my Tweet search
app - www.tweedar.com).

Basically the Geocode function in Google Maps allows you to look up a
name and it will return you a set or GPS coords. In Tweedar I have
used this within a Flex application so the code is in ActionScript,
but I did a map application for Facebook as well and I used a call
from PHP to do the same thing (this was taken from example code I
found on the net). You can then call this function from PHP (or as a
HTTP call) and get the c0ords back from a location name ( i.e. San
Francisco, USA)  - you will need  a key for Google Maps as well.

/**
 * Look up a set of GPS coords(lat lon) from a text location/address
 *
 * @param string $location:  the text address(comma delimited)
 * @param string $key:  a valid map key on Google MAPS
 *
 * @return an array of the result [http status, detail, lat, lon]
 */
function getGpsCoordsFromGoogle($location, $key){
// make a REST call to google for coords of location
$base=http://maps.google.com/maps/geo?q=.urlencode
($location).key=.$key.output=csv;
$output=file_get_contents($base);
return explode(,,$output);
}

Hope this helps,

-Steve.
www.tweedar.com


On Feb 18, 8:17 pm, Pete Warden searchbrow...@gmail.com wrote:
 I needed a way for users to be able to enter readable place names and
 do searches restricted to the neighborhood. The search API only
 supports lat,long so I had to implement some geocoding to translate
 names into coordinates. I ended up using Yahoo's free GeoPlanet
 service, with 50,000 requests possible per month.

 Since I couldn't find any other public examples of how to do this
 (though I'm sure this must be in a lot of code out there) I put up my
 sample 
 code:http://petewarden.typepad.com/searchbrowser/2009/02/how-to-emulate-ne...

 It's a small PHP file, and works just like the normal search API call
 but with an additional near argument that gets translated by the
 geocoding. I'd love to see some more explanation on the docs wiki of
 this sort of workaround for 'near', but it seems that it's only
 editable by Twitter employees? Facebook's more open editing policy
 seems to work well for them.

 cheers,
            Pete


Re: Sample code for using Yahoo's geocoding to emulate near in the search API

2009-02-18 Thread Chad Etzel

I use this Y! Pipe for TweetGrid to accomplish geocoding:

http://pipes.yahoo.com/pipes/pipe.info?_id=27c113188a1f89baab07f2d133bc3557

it was lovingly copied and edited from a similar pipe by @JohnDBishop
(with permission).

I use this with a json callback (plus some regex matching) to
translate between near: within: syntax  and geocoding.

Anyone is welcome to clone/edit it for their own use.

-Chad

On Wed, Feb 18, 2009 at 3:17 PM, Pete Warden searchbrow...@gmail.com wrote:

 I needed a way for users to be able to enter readable place names and
 do searches restricted to the neighborhood. The search API only
 supports lat,long so I had to implement some geocoding to translate
 names into coordinates. I ended up using Yahoo's free GeoPlanet
 service, with 50,000 requests possible per month.

 Since I couldn't find any other public examples of how to do this
 (though I'm sure this must be in a lot of code out there) I put up my
 sample code:
 http://petewarden.typepad.com/searchbrowser/2009/02/how-to-emulate-near-in-the-twitter-search-api-using-geoplanet.html

 It's a small PHP file, and works just like the normal search API call
 but with an additional near argument that gets translated by the
 geocoding. I'd love to see some more explanation on the docs wiki of
 this sort of workaround for 'near', but it seems that it's only
 editable by Twitter employees? Facebook's more open editing policy
 seems to work well for them.

 cheers,
   Pete



Re: Sample code for using Yahoo's geocoding to emulate near in the search API

2009-02-18 Thread Chad Etzel

argh, hit send by mistake.. I was going to add:

Your sample looks great, and I may even start using it for some other
projects where the pipe would not be as useful.  Thanks for posting
the link, very nice.

I wasn't trying to trump your example, merely posting another way to
get around the non-near within sytanx availability on the API side.

-Chad

On Wed, Feb 18, 2009 at 4:28 PM, Chad Etzel jazzyc...@gmail.com wrote:
 I use this Y! Pipe for TweetGrid to accomplish geocoding:

 http://pipes.yahoo.com/pipes/pipe.info?_id=27c113188a1f89baab07f2d133bc3557

 it was lovingly copied and edited from a similar pipe by @JohnDBishop
 (with permission).

 I use this with a json callback (plus some regex matching) to
 translate between near: within: syntax  and geocoding.

 Anyone is welcome to clone/edit it for their own use.

 -Chad

 On Wed, Feb 18, 2009 at 3:17 PM, Pete Warden searchbrow...@gmail.com wrote:

 I needed a way for users to be able to enter readable place names and
 do searches restricted to the neighborhood. The search API only
 supports lat,long so I had to implement some geocoding to translate
 names into coordinates. I ended up using Yahoo's free GeoPlanet
 service, with 50,000 requests possible per month.

 Since I couldn't find any other public examples of how to do this
 (though I'm sure this must be in a lot of code out there) I put up my
 sample code:
 http://petewarden.typepad.com/searchbrowser/2009/02/how-to-emulate-near-in-the-twitter-search-api-using-geoplanet.html

 It's a small PHP file, and works just like the normal search API call
 but with an additional near argument that gets translated by the
 geocoding. I'd love to see some more explanation on the docs wiki of
 this sort of workaround for 'near', but it seems that it's only
 editable by Twitter employees? Facebook's more open editing policy
 seems to work well for them.

 cheers,
   Pete




Re: Sample code for using Yahoo's geocoding to emulate near in the search API

2009-02-18 Thread Pete Warden
Thanks Chad, mostly just wanted to get something into the search indexes for
anyone else looking. :) I'd never thought of using Pipes, that is a very
neat approach, feels more elegant than requiring PHP in a lot of situations.

cheers,
 Pete

On Wed, Feb 18, 2009 at 1:30 PM, Chad Etzel jazzyc...@gmail.com wrote:


 argh, hit send by mistake.. I was going to add:

 Your sample looks great, and I may even start using it for some other
 projects where the pipe would not be as useful.  Thanks for posting
 the link, very nice.

 I wasn't trying to trump your example, merely posting another way to
 get around the non-near within sytanx availability on the API side.

 -Chad

 On Wed, Feb 18, 2009 at 4:28 PM, Chad Etzel jazzyc...@gmail.com wrote:
  I use this Y! Pipe for TweetGrid to accomplish geocoding:
 
 
 http://pipes.yahoo.com/pipes/pipe.info?_id=27c113188a1f89baab07f2d133bc3557
 
  it was lovingly copied and edited from a similar pipe by @JohnDBishop
  (with permission).
 
  I use this with a json callback (plus some regex matching) to
  translate between near: within: syntax  and geocoding.
 
  Anyone is welcome to clone/edit it for their own use.
 
  -Chad
 
  On Wed, Feb 18, 2009 at 3:17 PM, Pete Warden searchbrow...@gmail.com
 wrote:
 
  I needed a way for users to be able to enter readable place names and
  do searches restricted to the neighborhood. The search API only
  supports lat,long so I had to implement some geocoding to translate
  names into coordinates. I ended up using Yahoo's free GeoPlanet
  service, with 50,000 requests possible per month.
 
  Since I couldn't find any other public examples of how to do this
  (though I'm sure this must be in a lot of code out there) I put up my
  sample code:
 
 http://petewarden.typepad.com/searchbrowser/2009/02/how-to-emulate-near-in-the-twitter-search-api-using-geoplanet.html
 
  It's a small PHP file, and works just like the normal search API call
  but with an additional near argument that gets translated by the
  geocoding. I'd love to see some more explanation on the docs wiki of
  this sort of workaround for 'near', but it seems that it's only
  editable by Twitter employees? Facebook's more open editing policy
  seems to work well for them.
 
  cheers,
Pete