Where am I?

I first come across Plazes a few months ago. The idea is pretty neat – you update a service to let people know where you are.

I’m not a big fan of the implementation though. It’s too tied to using the network you’re connected to to identify where you are – which means it can’t seem to tell the difference between any IBM site in Europe. And as I spend the majority of my time connected to an IBM network, that leaves Plazes thinking that I’m somewhere in Germany half the time. Not very impressive.

It has an API which is always a good thing, but that won’t let you create any new ‘Plaze’ which it doesn’t already know about. Which makes it a little useless for many circumstances.

And it relies on me being at my laptop. This is a bit limiting as I don’t always have my laptop with me. What would be really cool would be a service which actually updates where I am. (Okay, so they have a mobile client, but that’s for Symbian only so that’s no use to me 🙂 )

With this in mind (and my newly rediscovered love for PHP after having to do some work on the SYA database on Tuesday), tonight I decided to have a go at knocking together a solution that would better suit my needs…

The idea

I forget to tell my wife that I have a meeting for SYA or something. She can check and see that I’m at the SYA building. Or check to see if I’ve left work yet.

With precise and regular enough updates, it is perhaps not impossible to envisage a couple of mobile clients being useful for her to find me in a large busy shopping centre.

Okay, so I’m pretty much making up reasons. But humour me, I thought it might be fun to try writing it anyway, even if I don’t use it 🙂

The approach

The idea is pretty simple – have a web service that can receive location updates, and then display the updates on request. I can then send updates from my phone – a better choice for me than a laptop, as my phone is the one thing I have with me all the time.

My phone lends itself particularly well to this because:

  1. Wifi – My phone has wireless, which should be a quick way to identify where I am. I’m not talking about using the IP address or connection like Plazes, but just giving it a list of hotspots with a known location. For example, if it can see a wifi signal with an SSID of “daleshomewifi” then it’s not a massive leap to assume that it’s at my home. If it can see the SSID “ibmwifi”, then I’m probably at work. With enough options added, this could let it locate me for a large majority of my time.
  2. Integrated GPS – My phone has a GPS chip, and .NET has a nice API to get the location out of it. So when it can’t see a wifi signal it recognises, it can get it’s exact coordinates and use that instead.
  3. Unlimited Internet access – I’ve paid for the unlimited data plan, so I’m not too fussed if I chew up much bandwidth sending updates. (That said, we’re not really talking about massive amounts of data, so I doubt it would have been an issue if I hadn’t.).

The web service – putting locations in

Well, it was originally gonna be a web service. I was thinking a little SOAP service to get XML updates which wrap up coordinates, a description, timestamp and so on. But I figured this was probably overkill for what is really a small amount of data in each update.

I settled on a php script getting the information from query values in the HTTP POST, separating them out and dumping them in an XML file like this:


<locupdates>
   <locupdate>
      <timestamp>20070412222923</timestamp>
      <comment>at home</comment>
      <lat>50.973583</lat>
      <long>-1.354981</long>
      <validfor>60</validfor>
      <accuracy>1</accuracy>
   </locupdate>
...

The URLs will end up long and icky, but as they’re not intended to be generated by a user, I don’t really care. Plus it meant I write the whole thing in under 140 lines of php (and it was only that long cos I’m paranoid about trying to handle URL variables safely. Incidentally, I nicked a few ideas from an article on safely extracting variables in PHP which I came across a couple of days ago. It’s worth a look.).

So I have a nice easy way to register updates:

http://daleswebserver/recordlocation.php?username=dalelane
&password=mangledpassword&lat=59.23421&long=-1.45328
&comment=at the fish and chip shop

The not-really-a-web-service – getting locations out

Next, I needed ways to get the locations out of the XML file on the server. I’d like to have a bunch of different ways, but to start with I thought I’d try three:

  1. Text – something simple and low-bandwidth, that can be grabbed easily from any device with an Internet connection.
  2. HTML – not that different from text, but wrapped in some div’s and span’s so I can embed it in a sidebar of my website and make it look pretty (when I get round to it!)
  3. Google Maps mashup – show the location on a map. That’s pretty neat. Other than adding options to crop height and width (again thinking that I’ll end up embedding it somewhere), I’ve not done much else with this.

I might have a go at supporting an RSS output too, but that can be something for another night. Would be good to be able to see previous updates as well as the current one, too. That could be nice on the google maps output – I could plot each previous update with it’s timestamp…

The mobile client

The decision to make the service available just using HTTP made this easy – I use HTTPWebRequest in .NET Compact Framework to point at the PHP script, and throw the query variables down the request stream.

The (slightly) tricky bits are accessing the connection manager to identify nearby SSIDs if wifi is enabled, and using the GPS API to get sat nav coordinates. I’ve nearly got the GPS bit working, but havent started the wifi bit yet. Hopefully, I’ll come back to this another night to finish off. 🙂

screenshotTo start with, I have got a basic GUI which can let a user choose from a list of known locations and then send that as an update to the server.

Ideally, the client should have a regular interval at which it works out where it is as best it can, and send an update. The user can specify this interval, but otherwise shouldn’t need to do much else with it.

I’m not quite there yet. It’s still a bit hand-cranked : choose the method of update, and hit the update button. Even then, choosing wifi does nothing, and choosing GPS nearly gets a location (but doesn’t quite, and quietly gives up). 🙂

screenshotMore helpfully, choosing ‘Known location’ shows the list of places shown in the screenshot to the right – which I can choose from then hit the ‘Update’ soft-key, sending the location to the server.

And choosing ‘Custom text’ pops up a text box where I can describe where I am – which can be sent to the server when wifi and GPS are both no good. Sort of like twitter. (This wont help the google-maps output, but will be fine for text and html outputs.)


Okay… so there are holes in the basic idea

GPS isn’t very useful indoors. And I spend a lot of time indoors. So, in places where it could be the most useful, like my slightly sketchy busy-shopping-centre scenario, it probably wont be much help. And who knows what it will do to my battery life to poll my GPS location regularly. 🙂

Then there’s the whole security issue. I wonder if it’s a good idea to let everyone know when I’m not at home… That said, you could probably work out when I go on holiday by watching my blog and twitter feeds anyway, so perhaps I’ve already got that problem. I guess the burglars of Eastleigh don’t follow my blog!

Other ideas

I’m thinking of getting the mobile client to access my Outlook calendar to add some context to the updates – it knows where I should be. Not sure about whether I want this… plus it could kinda defeat some of the purpose of people using this to work out where I am if I’m late turning up to something, for example.

All of this is something to look at another day. As a first stab, I’m pleased with how it’s looking so far. Sleep time now. 🙂

14 Responses to “Where am I?”

  1. dale says:

    RE: “…the whole security issue…” or broadcasting-when-your-house-is-gonna-by-empty

    Andy pointed out that this seems to be a topical thought at the moment, with a similar comment on another blog.

    It’s a shame… cos I like the idea of declarative living in principle.

    But then your mind starts to wonder… for example, is there a risk in someone potentially being able to piece together: my name; my address; photos of my daughter; her name; where she goes to nursery; together with where I am. I don’t think so, but I dunno… the worst-case-scenario is a little scary.

    Hmmm… not a good line of thought for 1am!

  2. andyp says:

    Get hold of a copy of Everyware, and read it.
    Not tonight though. It’s very very late.

  3. dale says:

    looks interesting – will give it a try, thanks

    (grr… why aren’t all books on ereader? making me carry around primitive paper copies… bah, humbug, etc. 😉 )

  4. Ian says:

    Hi,
    I saw something like this on coolsmartphone.com called GPSGate. You do, however, have to pay for it…

    Ian

  5. Anne-Aymone says:

    Hi Dale,
    you can use Plazes SMS with any mobile on the go:
    http://beta.plazes.com/locate/sms.php
    Best,
    Anne-Aymone

  6. dale says:

    Hi – thanks for the comment.

    It’s true – I should have pointed out that SMS is an option with plazes. But to be honest, it’s not really the same as having a mobile client – it’s all a bit too manual. If I had to send a text everytime I went somewhere, I probably wouldn’t stick with it for too long.

    It’s a shame the create a new Plaze functionality you can do by SMS can’t be done from the API.

    D

  7. […] learning something new random things that I learn that I find interesting… « Where am I? […]

  8. abirkill says:

    SPV-Developers used to run a CellDB service (not sure if they still do) that could be used in conjunction with software on the phone that would determine your position based on the GSM cell IDs your phone could currently ‘see’.

    The cell IDs would be crossreferenced with the CellDB to get a friendly location name. Obviously it’s not as accurate as GPS, but it would be a good solution when inside a building without WiFi. Maybe that’s something you could integrate into your software in the future.

  9. dale says:

    ooh – that’s quite cool. haven’t seen this before…

    thanks!

  10. Roo Reynolds says:

    By the way, Plazes let you set location by SMS as well now. Be warned though, there’s one phone number for the US and one for Europe (umm, it’s either Belgium, Finland or Germany. Not sure which) so far. Hopefully more will be added.

  11. […] mentioned before that I have tried stuff like Plazes, as well as trying out my own approach (which you can see in […]

  12. […] So I thought I’d go back to some of the Google Maps API stuff I last played with about a month ago. […]

  13. […] fact that you no longer have to rely on the Plazer is a big deal… it might persuade people like Dale to take another look I guess for me, the biggest question is how easy this will be to mashup with […]

  14. […] all for declarative living and putting everything about myself online, but it’s not for everyone. I’m thinking […]