Hibernating Rhinos

Zero friction databases

Feature explained–Spatial Geocode from address

In August we added the option in spatial queries to get the Geocode by address.

We already did something like that in the “Events” page in the RavenDB website and It was quite easy with the Google Maps API.

However when we tried to implement it in the studio we discovered that to do that in Silverlight is not as simple.

Apparently in order to get Google API to work with Silverlight you need to set a bridge server that has the appropriate clientaccesspolicy.xml because the settings on the Google API server does not match the permissions required for Silverlight.

So we looked for another service that has the settings that allowed to work with Silverlight without any complications, what we found is that the Yahoo! Maps Geocoding does just that.

The setting of the Yahoo API was even easier then Google’s and is done like this:

   1: var url = "http://where.yahooapis.com/geocode?flags=JC&q=" + queryModel.Address;
   2:             var webRequest = WebRequest.Create(new Uri(url, UriKind.Absolute));
   3:             webRequest.GetResponseAsync().ContinueOnSuccessInTheUIThread(doc =>
   4:             {
   5:                 RavenJObject jsonData;
   6:                 using (var stream = doc.GetResponseStream())
   7:                 {
   8:                     jsonData = RavenJObject.Load(new JsonTextReader(new StreamReader(stream)));
   9:                 }
  10:  
  11:                 var result = jsonData["ResultSet"].SelectToken("Results").Values().FirstOrDefault();
  12:  
  13:                 if (result != null)
  14:                 {
  15:                     queryModel.Latitude = double.Parse(result.Value<string>("latitude"));
  16:                     queryModel.Longitude = double.Parse(result.Value<string>("longitude"));
  17:                 }
  18:  
  19:             }).Catch();
  20:  

As you can see it is simply a web request with a default url with the addition of the address

For mode information about the Yahoo geocode API: http://developer.yahoo.com/maps/rest/V1/geocode.html

Comments

njy
10/27/2012 01:55 PM by
njy

In the page you linked, the big red warning at the top that says "This API has been deprecated doesn't bother you guys :-\ ?

njy
10/27/2012 01:57 PM by
njy

Btw, they also say to use the "Place Finder API". But then you go on that page (here http://developer.yahoo.com/geo/placefinder/ ) and the say " the Placefinder and Placemaker services are planned to be replaced on November 17th 2012 by the new BOSS Geo service".

So, you go there ( http://developer.yahoo.com/boss/geo/ ) and... finally everything seem to be fine.

At least we hope :)

Nicolas Cadilhac
10/28/2012 02:48 PM by
Nicolas Cadilhac

finally everything seem to be fine Except that now the service wants 6$ / 1000 requests

Jason Brady
10/29/2012 04:13 PM by
Jason Brady

What about Silverlight being deprecated? I haven't found anything stating that it will be supported, and there is a lot of talk about Microsoft ending Silverlight since Windows 8 was announced.

http://janvanderhaegen.wordpress.com/2012/06/11/silverlight-is-dying-long-live-lightswitch/

Chris Marisic
10/30/2012 01:22 PM by
Chris Marisic

@Jason Brady no Microsoft is committed to SilverLight for atleast 10 years. At this point it has the feature set they desired which means that large releases will become more infrequent or that releases will become primarily maintenance or security releases.

A project that has succeeded is far opposite to dead.

VIncenzo
10/31/2012 10:20 AM by
VIncenzo

Why not use string.format?

Comments have been closed on this topic.