I’ve been playing around some with the Google Maps API, via ym4r. I discovered, however, that its geocoding API doesn’t do anything with the “accuracy” information that Google gives you, which tells you if the address you fed it actually means much. The XML looks something like this:
<Placemark>
<address>Italy</address>
<AddressDetails Accuracy="1" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
I opened up geocoding.rb
, and had a look, figuring it had to be pretty simple, and indeed, with REXml’s XPath stuff, you can easily grab the elements you want. For example:
data_country = data['//CountryNameCode']
So… data['//AddressDetails'].attributes['Accuracy']
ought to give me what I want, right? Nope. The namespace in the sub element confuses everything. After some googling, I finally found the recipe:
data_accuracy = data['//*[local-name()="AddressDetails"]'].attributes['Accuracy']
Kind of a mess, but it works, I have my accuracy attribute, and I submitted a patch to the ym4r guy.