Picky: Geosearch 2 Tweet
This is a post in the Picky series on its workings.
In this quick one I’ll be using my own iPhone’s geodata as data for a space/time Picky search.
Lean back and enjoy the screencast.
Enjoy the show
I’ll be searching time and space for my own footprints in Switzerland, Germany and Australia.
Best viewed in full-screen. Warning: Safe for work with the possible exception of my voice, which has in the past triggered attacks by various animals/politicians.
View with subtitles.
(When I say “Apple is collecting”, I mean “‘Apple’ is collecting” – the phone)
So how do you get your iPhone’s geodata?
First of all, let me direct you to a nice OSX application: http://petewarden.github.com/iPhoneTracker/ This enables you to view your data nicely.
The third question in the FAQ explains how to get your data out of the phone: How can I examine the data without running the application? (Also look at the updates)
That’s it. At the end you should have access to a SQLite database, from where I extracted CSV data into the file
data/iphone_locations.csv (with header data removed).
What did I do with the data?
We’ll first be looking at the server, then at the client.
In the server, define an index like this:
iphone_locations = Index::Memory.new :iphone do source Sources::CSV.new( :mcc, :mnc, :lac, :ci, :timestamp, :latitude, :longitude, :horizontal_accuracy, :altitude, :vertical_accuracy, :speed, :course, :confidence, file: 'data/iphone_locations.csv' ) ranged_category :timestamp, 86_400, precision: 5, qualifiers: [:ts, :timestamp] geo_categories :latitude, :longitude, 25, precision: 3 end
As you can see, I’m only using timestamp, latitude and longitude. And wrote all the possible data fields for completeness’ sake if I need to refer to one of these later on.
The timestamp uses a “radius” of 86’400 seconds (a day). That means it includes all results around the given timestamp in a range of ts-1.day..ts+1.day.
It also sets a short qualifier (“ts”) such that the search input field is not completely filled, i.e. searching for “ts:…” is equivalent to searching for “timestamp:…”.
The geodata uses
geo_categories (see last post), with 25 km as radius and an average precision of 3 (1 = low, 5 = high).
Now you already could search your data e.g. with
curl 'localhost:8080/iphone?query=longitude:8.2'. Note that the timestamp data is saved as seconds since January 1st 2001 (as per the Apple data).
The client actually stayed almost exactly the same since the last blog post, with the geo data piggybacking on the results hash.
The only notable addition is the HTML5 slider, which is a simple
input[type=range], with a
change listener defined on it, which triggers the insertion of the (“ts:” qualified) search string.
Have fun doing crazy space/time searches!
… and don’t run into time paradoxes. Those are nasty. Watch Back to the Future 1 for tips and tricks. First one is free: Learn to play an electric guitar.
So we’ve seen
- how to extract your iPhone’s geodata.
- that you can search space/time.
- how you might write your own.
Hope you learnt something new!Next Phony: Phone Numbers
Previous Picky: Geosearch 1