tralfamadore.com
get unstuck, in time

01 September 2008

Locatable roadmap and feature planning

I thought I'd give an update on where I'm going with Locatable and I'd love to hear feedback or suggestions for new functionality. I've just tested a better technique for saving data to the client-side database from the Locatable application which means that the app itself should not need any network connectivity. This is good news as there's a risk of settings becoming unsynchronized between the app and the database the way it's working right now (e.g. if the connection fails). This means rewriting all the preferences-saving and preferences-loading code and won't have any visible effect on the UI. Preferences anyway are about to get more complex. Now that Locatable is tracking per-site preferences (so you can choose to only be prompted once or twice per site to share location), there needs to be a UI to see what sites are currently in the list and manage their individual settings. I'm thinking of it a lot like the cookie manager in Firefox — you should be able to blacklist and whitelist individual sites that you visit, as well as alter their settings individually. So that's the task for Locatable 0.4. The other item on the TODO list requires a schema upgrade, which is why I've been procrastinating on it. It would be good to store the horizontal accuracy of the reading so this can be shared (via the W3C API and redirector). It would be nice to have altitude and vertical accuracy as well, though I'm not sure if these even work (certainly not on an iPod Touch!). Once those are in there, the plan is to submit to the AppStore. If accepted, the only difference between the jailbroken version and the AppStore one will be the inclusion of Relocatable, which of course won't work. (I won't be discontinuing development on it, but it may become its own package in Cydia.) In the meantime I'm open to suggestions on other functionality that should be included. Primarily what I've been hearing about is people using Relocatable to do their own lojack-type apps. I'd really like to get some feedback on using Locatable on your web sites to integrate positioning data, do maps mash-ups, and so on. Private feedback is fine, public is even better (and I'll be happy to put links on the Featured Sites page).

Labels: , , , ,

16 Comments:

Blogger Gregory L said...

I'm using Relocatable for a lo-jack type of purpose. While it seems unlikely that my phone will be stolen, it's a vaguely cool way for friends and family to stalk me.

In its current form, relocatable hits add.php?lat=@lat@&long=@long@&hacc=@hacc@ on my website.

This then generates a frame page, with a small php frame with text in the form of:
Last checked in [X] seconds ago at [time] [date] whilst reporting an accuracy of about [hacc] metres.

The main pane of the page uses a simple Google Maps search to present http://maps.google.com.au/maps?f=q&hl=en&geocode=&q=-27.495986938479,152.997940063488&ie=UTF8&z=17

It also writes information to a CSV file for historical recording purposes. The next step is to put this data into a database and implement the Maps API onto my website or Facebook page.

September 4, 2008 1:52 AM  
Blogger Wesley said...

Sounds great, Gregory. Thanks for posting.

September 4, 2008 3:11 PM  
Blogger Dave said...

I just set it up to do much the same as gregory. The phone hits a CGI on my site, which in turn dumps the location data to a MySQL database. Then another CGI script for viewing my most recent position overlaid on a Google map, as well as the last 24 hours of tracking.

I don't really intend to use it as a lojack type utility, just for the usual friends & family stalking.

My only complaint is not with the software, but with the phone. I have a first generation iPhone -- I knew it wasn't going to be super accurate, but what annoys me is that it won't get a location fix at all when it's moving. So on a driving trip, I go for quite a ways without a position update, until it gets lucky and tries for a fix when I'm stopped in traffic or something.

Now that you have the iPhone 3G, I'm curious -- is it behaving better in this regard?

September 8, 2008 6:21 AM  
Blogger Gregory L said...

I find it to be usually quite accurate, to about 50 or so metres. Sometimes, it'll be anywhere between 100 and 5000 metres (yes, 5km sometimes) inaccurate. Reported/calculated accuracy (hacc) often has no correlation with actual accuracy. It seems to be fine at tracking while moving at a walking pace and it seems to track fine (but incorporating the aforementioned errors) while moving on public transport.

Sometimes it seems to not refresh position on each update. eg (I hope this renders!)
2008-09-08--1515,-27.496178977815,153.014423954473
2008-09-08--1524,-27.492309570000,153.027938840000
2008-09-08--1556,-27.492309570000,153.027938840000
2008-09-08--1648,-27.492309570000,153.027938840000

1515 is the correct location, 1524-1648 is a false positioning but as you see it doesn't change at all.

Two things could be happening:
-relocatable caches position for some reason;
-or the calculated position remains the same because cell signals don't change. (Most of my locations are calculated inside buildings, thus no GPS.)
I guess Wesley could clear that one up.

So, my observations are:
1. Sometimes wildly off.
2. Often doesn't seem to get a new fix. (But this might be because of lack of change of triangulation signals.)

September 8, 2008 9:59 AM  
Blogger Wesley said...

From the sound of it, you both have done more detailed all-the-time testing than me, but it jibes with my general impression that there are a lot of times when the iPhone is simply unable to find a location fix.

There are two things that I'm aware of:

1) if the phone is truly asleep (this usually happens about 30 seconds after the screen goes blank) it won't wake up to run background apps. The only way I know of to get around this is to install the Insomnia application. I've heard that this will tend to drain battery like dracula on the proletariat of Transylvania, though, so use with caution.

2) locationd has trouble getting a fix while moving (e.g. on a train), when you're on a WiFi network it can't geolocate (my work office private network has this problem), and of course if it can't get any network access. This is where I'm haziest but so far I haven't seen any difference between locations where Locatable will work and locations where the Google Maps app will work.

In the cases where Locatable can't get a new position, the position it will report is the "last known" one -- so yes, in that sense it is caching it. I could change this so it doesn't invoke the script, but I think what I'd actually prefer to do is make the timestamp of the reading itself available to your command. This way you'll know it's running (because you get a hit) but you can compare the timestamp and see if it's stale. Let me know what you think of that idea...

Also, I'm thinking of adding a "show my current location/update now" button to Locatable so you can check the last reading in realtime without going to the command line. In the meantime, if you find situations where Google can locate you, but Locatable can't, let me know so I can follow up on debugging those.

September 8, 2008 5:49 PM  
Blogger Dave said...

I think the idea of a timestamp for last known fix would be handy.

On the sleep issue -- I know there is a way to schedule a hardware wakeup, but I don't know how to do it :-). I remember someone offering up a utility on the modmyifone.com forums that could run a specified command at a particular time, regardless of the phone's sleep state, using a hardware feature of the iPhone that will wake it up enough to run something. Probably the same method Apple uses for e-mail checking & such.

I wish I knew more specifics. If locationd could wake up every 10 minutes that would be the icing on the cake. If Apple would let you sell *that* version via the App Store, you could make a few bucks for sure.

September 11, 2008 4:15 AM  
Blogger Wilson said...

wow... Reading all the comments here makes me feel stupid for not knowing php.

Is there a way to upload the GPS data to a free public service with this app like the forms you can create from Google Documents? Since most people won't be able to host their own website, it would really be great it works. In fact, I am sure this will be a 'killer-app' on the iPhone if the data can be converted to google maps format, and uploaded to a free public service, all while running in the background. (I understand this is really not where locatable is going but it'd be cool if this was a seperate app based on locatable)

Here's a sample google docs form if it's any help. http://spreadsheets.google.com/viewform?key=pjN_5-Dzg8JqmdvMvIjRUUw

Thanks in advance

September 14, 2008 9:22 AM  
Blogger Wesley said...

@dave -- thanks for the suggestion, I'll look into the hardware wakeup API.

@wilson -- You might also want to look at sites like FireEagle and my.loki.com that provide the sort of service you describe (and for free). What you'd need is a plugin that took the location fix from Locatable/Relocatable and invoked the server-side APIs for those services. Any enterprising programmers out there want to try it?

September 22, 2008 11:26 PM  
Blogger Trian said...

I've got a similar app to gregory and dave's set up for myself. Mine adds each data point to a MySQL database with added fields for a name for the phone (so it can track both my phone and my wife's), the IP address the phone is coming from, and the forwarded IP if one exists in the HTTP request. Then another script uses the google maps API to display the last 5 locations seen.

The insomnia developer mentions on the google code site that he can give additional info on the hardware wake-up code, I've been tempted to see how difficult that is.

I have noticed since upgrading to the 2.1 firmware that relocatable doesn't like to run from the command line for me - I get an error that it couldn't open the master database, and when it calls my web page it doesn't give any location. I didn't notice this until after I tried compiling relocatable from source (both the official install and my compiled version do the same thing), so I'm not sure if I installed something before that point that is messing with it. I'm a little nervous about trying to restore the phone to check, since during the upgrade I ran into the vibrating apple screen of doom whenever my backup was restored.

September 24, 2008 2:39 PM  
Blogger Trian said...

It looks like FireEagle might be the easier of the two mentioned sites to try to integrate with, but I haven't delved too deeply into it.


In the interests of helping out those who can host something at their own site, I've cleaned up the php code I use a bit and packaged it at http://www.why-bother-me.com/relocatable_web.tar.gz

It's a *very* quick-and-dirty bit of code, and it probably wouldn't be a bad idea to password-protect the storage script (with changes to the curl command that is called by relocatable). It's a good initial starting point but I haven't spent a lot of time on it yet.

September 24, 2008 8:15 PM  
Blogger Wesley said...

@trian -- if you're getting the "can't open master database" error, it might mean you've never run Locatable.app from Springboard. This is required in order to create the tables that Relocatable then uses. I might change this in the future but it's a dependency at the moment.

September 28, 2008 2:22 PM  
Blogger Gregory L said...

Dave, I am interested in changing my tracking page into an API-based Google Maps page. I was wondering if you would be able to email me some information about your setup. I have SQL on my webserver, but have no idea of how to structure a webpage to do what you say you've done. Would you be able to email me at bilious at gmail if it's not too much trouble? Much appreciated.

September 29, 2008 3:37 AM  
Blogger Trian said...

@wesley: That looks like it was the issue, thanks. I also finally figured out what was causing the zero location reporting (stupid mistake on my part, not worth going into).

Relocatable is now the first real app that I've successfully compiled and run on my iphone. Thank you for being open!

September 29, 2008 2:26 PM  
Blogger Michael Ansel said...

I did the same thing as gregory, dave, and trian (PHP/MySQL log-and-display) and also ran into the same issue (iPhone 1G, 2.0.1): I'm getting stale locations, and sometimes no reports at all for hours on end (set for every 30 minutes).
Would it work better if you ran it like a cron job instead of a daemon? I know there is a way to do that with .plist files, but not off the top of my head. (I'll give it a shot when I figure it out and report back)

Also, in case anyone is interested, here is the source for my scripts (one to record the location and another generate a KML for Google Earth/Maps showing the points from the current day and connecting them in the order they were recorded).

October 5, 2008 12:19 AM  
Anonymous Zero Cool - aka Denis said...

the links you have posted are dead :( I was looking forward to trying out your code.

March 9, 2009 9:42 PM  
Blogger Michael Ansel said...

Zero Cool: They should be working now. I switched stuff up on there and forgot to make sure phps was still working.

March 10, 2009 12:02 AM  

Post a Comment

<< Home

Copyright (C) 2001-2008 Tralfamadore.com