Entries tagged “geocoding”

Caching REST with sfFunctionCache

[tags]geocoding, caching, REST, symfony, Cache_Lite, php, cache, sfFunctionCache[/tags]

For reviewsby.us we do a lot of geocoding. To facilitate we use Yahoo! Geocoding API. This helps us normalize data, obtain latitude and longitude, interpret location specific searches.

These REST queries happen a lot and will continue to happen, but this data that Yahoo! provides is fairly static. We’re basically querying a database of sorts. So it makes sense that we should cache this data.

We’ll demonstrate how to cache these queries using symfony’s sfFunctionCache class.

I wrote a wrapper (I’ll release it as a plugin if requested) for the Geocoding API, the bulk of the work (the REST call) occurs in a function called doQueryGIS:

The call to this function is always wrapped with queryGIS:

This wrapper creates a sfFunctionCache objet and calls the function and caches it for subsequent queries.

What this means is once Yahoo! teaches reviewsby.us that India is located at (25.42°, 77.830002°) and that the precision is ‘country’ we remember it in the future.

These features will be incorporated into future versions of reviewsby.us.

Read full post
Going international... kinda

Some of the first non-Minnesotan restaurants to show up were Flying Dog, Bangalore and Konstam… all of them outside the US. Wasn’t expecting that… but then again, I wasn’t really surprised.

I finally updated our location tables to account for different countries. Currently it’ll only plot what it can Geocode, and relies exclusively on Yahoo! for GeoCoding.

I’ve only tested this with a Canadian restaurant. Hopefully it’ll work elsewhere soon. If anybody plans on adding any non-US, non-Canadian restaurants, let me know if you can figure out how to GeoCode things properly.

Also, I’m pleased as punch that the map on the homepage shows three states as having recent restaurants. Rock on!

Read full post