Geo standards on the web

Location-aware web applications are rising, and I'm personally very interested in this space. Besides the obvious cool-factor, I think there are a lot of uses for location-aware information. This post is a short overview of geo-related standards and api's.

The heart of it all lies in 2 numbers, latitude and longitude.

How to get these numbers?

However you publish the GPS coordinates, the information will at one point in time come from a user. However, asking a user to enter these numbers is not the best end-user experience.

Use a map

A very common way is simply ask a user to pinpoint their location on a map. The most common two providers for these are:

Google maps is the most popular (no numbers!), but if you are looking for more flexibility, yahoo maps might be the best choice. Yahoo maps has an Actionscript API which enables you to add a lot of customizations. Justin Everett-Church has some cool examples of what's possible. Yahoo also provides a REST api, allowing you to just fetch the tiles and do all the stitching yourself.

Address to GPS translation.

This is called Geocoding. Yahoo has a very easy to use REST API to do this translation. Google also provides an API, which is also able to spit out kml as well.

Browser plugins!

W3c currently has a draft for a geo location api, which is also part of the HTML5 movement.

The user interface is nice too. You are asked by the site if you are ok with supplying your coordinates, which then get sent back to the client.

The best implementation I've seen from this is the Geode extension. I can highly recommend to install the add-on and give the demo's a shot. This extension will only work if your computer has WiFi. It makes use of Sky Hook, which has mapped locations of wifi routers across the world. It mainly seems to have done the urban areas in north america and europe.

Geode in action

I actually moved a month or two ago from 43.651904 -79.428498 to 43.645466 -79.448729. For the first month our router was still mapped to the old address, but it updated recently to reflect my new address. Creepy, but cool!

Gears also has a javascript API, which might be a bit more common. My personal experience has been that I've only been able to get information to up to 4 decimals, which placed me in a different part of town.

Firefox 3.1 will also come with the api built in HOWEVER, it serves as an empty shell for extension implementors. You'll still need to install an extension to actually provide the coordinates, which could work through WiFi mapping, Cell-tower triangulation (the method the iPhone uses) or manual input. An extension that does this through manual input of an address is 'Geolocation'.

From devices

There are a couple devices on the market that track geo information. I wrote a small overview earlier today, and the most impressive seems to be the Amod AGL3080. Its conceptually very simple and when you plug it into your machine, it will show up as an external harddrive with a CSV.

Next to that more camera-phones appear on the market that have support for embedding GPS information within the EXIF data of JPEG's. Most notably recent blackberries and the iPhone. Its reasonably easy to extract this information if it is available. PHP has an extension to read it out, but you'll need to do some conversion from the stored coordinates, as they are specified as the (now less common) degrees, minutes, seconds format.

Publishing

Clearly the easiest way to publish location information is through maps, but the concept of adding this meta-data to the documents you produce (be that html, api's, rss ..) can be much more interesting. This will allow people to re-use the data and present it somewhere else.

Geo RSS

Adding geo information to RSS is an easy one. RSS and Atom is already very widely used. Originally used for feeding blogposts, it has gotten much wider usage such as aggregating pictures, video, etc.

georss.org has some simple examples on how to do this. Flickr is already pretty big on GEO information, it confuses me why they haven't yet integrated the standard.

HTML meta tags

This will allow you add GPS information to a specific site or page There's two ways to define this:

  1. <meta name="geo.position" content="62.300626;-84.023437" />
  2. <meta name="ICBM" content="62.300626, -84.023437" />

There's no harm in including both. It's not very clear to me which one is used more, but the former seems to have more popularity in recent implementations.

Geo microformat

There is also a microformat spec for geo information. Personally, I'm not a big fan of microformats, but would like to be proven wrong in its usefulness.

Microblogging

A standard way to include GPS information for microblogging (and with microblogging, 99% reads twitter.), using a very easy format. This allows cool applications such as Twittervision and Twinkle. The latter had an interesting review on the ever offensive Something Awful.

KML

KML is also on its way to become a standard for the geo-web. KML covers much complexer drawing and is already supported by a number of apps, most prominently Google Earth and Nasa Worldwind. People who have google earth installed can be directed straight to a location on the map by serving a .kml file.

Conclusion

Well, I think the geo-aware web has a big and bright future. Having appropriate standards in place to consume and publish this information is very important. Even though a minimal amount of users will immediately benefit from for example geo information in your html head section. Allowing other developers or applications to access this information today will help pave the future for a fully geo-enabled web. I say all this realizing this blog does not provide this information, but hey.. nobody is perfect :). I can proudly say however I have some geo-aware applications in the works.

I'm very interested in your ideas of examples of interesting use of GPS information! If I missed an important or relevant API or you have a cool example, make sure to leave a comment.

/me goes off to find a restaurant near me and wonders where my friends would hang out on a cold saturday night in december.

Gps trackers - any advice?

Like half of the web development community, I recently became really interested in location-enabled stuff ;)

I really want to get a GPS tracker (for christmas!, hint hint!), there seem to be a couple out there, so I'm wondering if there's any people who have such a device and what their experiences are. Ideal features:

  • Small! I don't need to display, I just want to drop it in my backpack and forget about it.
  • Has USB, all I need is something that spits out cvs data (or similar format) on the drive which I can extract.
  • Somewhat good battery life (>24h).
  • Most importantly, charges through USB. Batteries is a no-go (for any device for that matter, I'm looking at you wii controller.)

So we have some options:

Professional mini tracker key

Pro:

  • Title of the product is completely written in uppercase, has to mean something right?
  • Logs data every second.

Con:

  • Uses AA batteries.
  • No specs on battery life.
  • No specs on how to extract the data, but has USB.
  • On the expensive side ($278.99).

TRACKING KEY LAS-1505

Pro:

  • "Ideal For Parents Who Want To See If Their Teenagers Are Speeding", seriously.. the page says that literally.

Con:

  • Runs on AA batteries.
  • Price ($206).

Amod AGL3080

Pro:

  • Looks like a more decent product.
  • Price: $69
  • Uses standard format for data (works as csv on usb drive), accessible with my scripting powers.
  • Works on a set interval or 'Push to log'.
  • Works for 15 hours (good enough).

Con:

  • AA batteries.

Zoombak ZMBK200

Pro:

  • Totally rad name!
  • A/C wall charger! (the only one so far).

Con:

  • Battery life for 150 location requests.
  • Subscription fee! (this is where I'm not even going to look for more cons).

Trackstick 2

Pro:

  • Reasonable price: $114.
  • Exports to CSV.

Con:

  • 1MB flash drive.
  • AA batteries.

Conclusion so far:

The Amod AGL3080 seems by a stretch the most impressive device, not only does it seem to have a good battery life, and plenty of storage. Just judging from the page on amazon, it quite frankly seems the most professional, despite it having the lowest price on the list.

Dear lazyweb, am I making a mistake? Are there better devices out there?

Forking and MySQL connections

For some of our long-running processes we use PHP. It makes total sense from our perspective, because we can re-use all our existing business logic from our main PHP web application.

To make things more efficient, I recently started some work on using forks and have a couple of worker processes around.

This application is essentially the core of our transcoder. The parent process would retrieve new jobs from the queue and fire up a number of workers to actually transcode the file. The main problem is that the parent opens up a MySQL connection and fires off some queries. After the child process is done, it actually closes the MySQL connection regardless of if it was actually used or not.

This means I'll have to close all mysql connections before forking, and re-connecting right after. No big deal, but still at least a bit annoying.

  1. <?php
  2.  
  3. $db = new MySQLi('hostname','user','password');
  4.  
  5. if (pcntl_fork()) {
  6.  
  7.     $status = 0;
  8.     // parent
  9.     pcntl_wait($status);
  10.  
  11.    $result = $db->query('select version()');
  12.    if ($db->error) echo $db->error;
  13.  
  14. } else {
  15.  
  16.    // the child process does nothing and exits gracefully
  17.  
  18. }
  19.  
  20. ?>

Output:

  1. MySQL server has gone away

MP4 fast-start woes

In order to play MP4 files while they are still downloading (either by for example Quicktime of Flash), in most cases you'll need to move the so called 'MOOV' atom to the beginning of the file.

The MOOV atom is in essence a block of data, containing an index of the rest of the file. Most authoring tools will place this data on the end of the file, because the size of the block will have to change dynamically as changes are made to the video. If the atom was right at the beginning, the entire file would have to be rewritten for a lot of smaller changes.

So, there are a couple of tools that do this for you, but none of them seem to work really well. FFMpeg contains a tool called 'qt-faststart', but I had to kill it after I discovered it had been running for 12 hours on a relatively small mp4 file.

Some suggestions on the FFMpeg mailing list led me to two other tools, MP4Box and MPEG4IP. MP4Box dies with a big:

  1. MP4Box /tmp/508842_22.mp4  -inter 500
  2. Saving /tmp/508842_22.mp4: 0.500 secs Interleaving
  3. *** glibc detected *** double free or corruption (!prev): 0x08071108 ***
  4. Aborted

On top of that their forum seems mostly dead. MPEG4IP simply has the following message on their download page:

NOTE: currently, the tarball is corrupt, and I do not have a way to remake it at this point. Hopefully that will change in a few weeks.

Dear lazyweb, has anyone else came across similar issues? How would one go about solving this? :(

Update: Reading through it again, it seems as if the mpeg4ip project has simply died in 2007.

Update 2: My problem with MP4Box was solved! I needed to explicitly supply the -out parameter.

 1

About

My name is Evert, and I've been writing semi-regularly on this blog since 2006.

I'm currently available for contract work.

more info.

Subscribe

Dropbox

Dropbox is a simple cross-platform online backup and sync application. The first 2GB of space is free, and both you and me get an extra 250MB extra space if you sign up through this link.