« Best. Picture. Ever | Main | Nokia E61 Review (from the perspective of a Treo 650 User) »

February 27, 2007

Export Mac OS X Address Book Entries to TomTom POI

After finding out that my TomTom didn’t know how to retrieve the telephone numbers from either my Treo 650 or my Nokia E61, I wrote an AppleScript that exported the Mac OS X Address Book’s telephone numbers directly to the file format used in the TomTom. You can read about that and grab the script here.

Unfortunately, the TomTom’s address book only stored two fields, Name and Number. I thought it an obvious omission that TomTom did not expand that to full street addresses so that TomTom users could navigate to their friends.

So again, I did some research…

I discovered that the only way to expand the TomTom’s database of navigatable places was by creating a custom POI (Points of Interest) database. I had already previously downloaded a freely supplied 3rd party database with all the fixed red light and speed cameras in Australia, so I knew creating my own was possible.

However, problems ensued when I discovered that POI databases only have three fields, Name, Latitude and Longitude. So, I needed to convert all the entries in my OS X Address Book from addresses to latitude and longitude. Lastly, unlike the telephone address book which stored its data in a simple CSV, the POI’s were stored in a proprietary format called OV2. TomTom supplies a Windows command line tool for converting a three field CSV into an OV2.

[UPDATE: While looking for a link to the Windows tool, I’ve found an untested PHP tool!]

So, with all that in mind, it began:

Step 1: Convert OS X Address Book addresses into Latitude and Longitude

After recently doing a project with some Google Maps integration, it seemed like the natural winner. The next decision was deciding where to store it in the OS X Address Book. While Address Book has a lot of extra fields that I suspect very few people use, nothing really suited:

Mac OS X Address Book Fields

Basically, because I had people with multiple addresses, I really needed latitude and longitude to be attached to each address group, e.g. Street, City, State, Postcode, Latitude, Longitude (c’mon Apple! make it so!). The best alternative I could come up with was to stick a line for each latitude and longitude (referencing which address it belonged to) in the notes of each contact, looking something like this:

Mac OS X Address Book Notes with Location

So, without further ado, here is the script for obtaining the Latitude and Longitude of whatever contacts you have selected in Address Book:

AppleScript icon - click to Download script
Download ‘Add Location to Notes’

My favorite bit of the script is one line which executes AppleScript, shell and php scripting in one line (nice one Apple!):

set shellScript to "php -r \"echo urlencode(‘" & formattedAddress & "’);\""

set query to queryPrefix & (do shell script shellScript)

So, what this script will do is to add Latitude and Longtitude to each person (that you have selected) IF they have enough address data to accomplish this. You’ll get a meaningful report at the end saying how many succeeded, how many Google Maps failed to find, and how many just didn’t have enough data.

I added a Smart Address Book Group that helped show me which contacts had enough data and had not yet been passed through this script. I was only after Australian contacts, so you might need to alter this to suit yourself. The last line is the one that hides those you’ve already nailed the lat/long for:

Mac OS X Address Book Smart Group

OK, I’m outta time, so I’ll have to finish the remaining steps at another time. Leave a comment if if you’re interested or if you have any questions.

Posted by Jay in technology at 5:20 PM

Comments

For editing TomTom Poi Ov2 files or import Csv you can use PoiView, a freeware application for Mac OS X.

The application is now traslated in English and i'ts avaible at SampoSoft Web Site.

http://www.samposoft.com

Posted by: Francesco at January 23, 2008 1:02 AM

Post a comment




Remember Me?


login