Status
mixture of reveling in the new stash of hoppy and fermented beverages acquired as well as how to crack open some geodatabases from
Location
Arlington, VA
Subscribe to GeoRSS Subscribe to KML


Geo search in Leopard Spotlight

Published in Technology  |  1 Comment


Spotlight has been in Mac OS X for quite awhile now, but in general, I haven’t found it very useful. However, when this tip came across at Mac OSX Hints on how to use operators for ranges in Spotlight metadata I got some ideas about doing geo-searches on my desktop machines.

To summarize, Spotlight is a system-wide metadata storage engine. Mac OS X provides a nominal vocabulary of metadata you can store, but you can also extend this to add your own metadata. Various applications like Yojimbo add metadata keys to store tags and other info with files. What’s especially great is that by applications using Spotlight, it means you can tie into this underlying metadata without having to use the application itself.

Using simple command-line parameters, you can do search for words, or specific metadata such as file type:

  • mdfind -s "Hawaii"
  • mdfind -interpret "keyword kind:image"

Great, but what about the range queries and Geo search? One of the default metadata items stored are kMDItemLatitude and kMDItemLongitude. In fact, you can use mdimport -A to get a list and description of all available metadata items.

Spotlight Geo Search

You can then do geographic queries like: latitude:<20 longitude:>20 and get all files you’ve created (such as photos or documents) while in Hawaii. You can also do better bounding box searches. To play with this I wrote a small RubyCocoa app to do geographic queries and display the location on a map.

GeoSpotlight allows you to search without a box and add other Spotlight predicates to search by, say, keyword, title, city, time, etc. Check out the Query Expression Syntax for details on how to do this.

GeoSpotlight

This was a quick mock-up and I’ll probably extend it to do bounding box specifying using the map interface and also locating documents via drag and drop.

Similar Posts


Responses

  1. Dane says:

    January 28th, 2008 at 5:41 pm (#)

    Slick use of spotlight and rubycocoa. Would you be willing to post the source for Geospotlight? I’d be great to see how you put it together.

Leave a Response