Tuesday, March 9, 2010

Roll your own live parking data app

Last week, the developer of Park-a-Lot Lite { SG } removed the app's ability to show live data on parking availability after the LTA told them to.

As a result, iPhone users no longer have access to this data because the website that this data comes from uses Flash to encode the information.

If you're an iPhone developer though, there are ways to get around this.

Local developer Melvin Tan has discovered that while the front-end use Flash, it just displays information that is grabbed from another URL. Using this insight, Melvin has created his own iPhone app to display the live parking data.

If you want to make your own live parking data app too, here's what you need to do:

First, you'll have to grab the data itself, which is stored in three different URLs. You can get it from:

http://interactivemap.onemotoring.com.sg/mapapp/images/Parking/Harbfront_pgs
http://interactivemap.onemotoring.com.sg/mapapp/images/Parking/Orchard_pgs
http://interactivemap.onemotoring.com.sg/mapapp/images/Parking/Marina_pgs

Then you need to write some code to display the information.

Says Melvin: "They have left out the file extension (they are jpg images) so that Mobile Safari will not be able to view it. Thus, for the iPhone App, I have to read in the URL as a data object, and feed it into the UIWebView and specify it as MIMEType 'jpeg'."

This is what Melvin did:

NSURL *url = [NSURL URLWithString:@"http://interactivemap.onemotoring.com.sg/mapapp/images/Parking/Orchard_pgs"];
NSData *data = [NSData dataWithContentsOfURL:url];
[webView loadData:data MIMEType:@"image/jpeg" textEncodingName:@"utf-8" baseURL:url];

And this is the result:

Thanks for sharing Melvin. Maybe some kind soul will create a web app for the rest of us.


2 comments:

sh2sg said...

these symbian and windows mobile apps show live parking data in a different way.

check these screenshots:
http://i.sh2sg.com/wm/roadmatelive.html

Jimmy Yap said...

Interesting!