Sunday, December 30, 2007

More Maps on the iPhone

After my previous efforts with Google Maps for Sky and the native Maps.app on the iPod touch, Ryan Scranton at Google pointed me in the direction of a Google Code project that was attempting to provide a more friendly user interface to the online Javascript version of Google Maps on the iPhone and the iPod touch.

It turned out to be a fairly trivial project to modify the code to use the new Sky maps, so on yet another wet Sunday afternoon, I did...


The results aren't quite as slick as the native version, but it was a lot less effort. You can drag the map around the screen using two fingers, although unfortunately you can't use the pinch action to zoom in and out. Crucially since it's just the normal maps with extra Javascript wrappers you can make use of the Maps API to add placemarks and overlays and other interesting things...

However getting used to using two fingers to drag the map around instead of one is surprisingly hard, it's very anti-intuitive for some reason. I'm also not entirely convinced it runs fast enough, at least for my purposes, it seems much less responsive and much more jerky during scrolling than the native Maps.app application. It's a great hack, but not the solution to my problem. But don't take my word for it, if you've got an iPhone or an iPod touch you can try it for yourself.

Back to the hex editor perhaps?

Update: For comparison with the native version here is a screen shot from the online javascript version of Google Maps.


The Carinae Nebula in Google Maps

Monday, December 17, 2007

Hacking Maps.app on the iPhone

The release of the new Google Maps API for Sky got me thinking. Google Maps, and Maps for Sky, doesn't really work very well inside Safari.app on the iPhone or the iPod touch. The maps in the browser aren't set up to trigger on the correct Javascript events, and as a result scrolling and zooming just doesn't work correctly. However there is a mobile Maps.app for the iPhone, which not only scrolls, pans, and zooms properly, but is also a whole lot faster than the browser based version.

So I didn't really want to play with the browser based version of Google Maps on my iPod, I wanted to play with the mobile version. So the obvious thing to do would be to hack the mobile version of Maps.app to support the Sky. It's just a different tile set, shouldn't be too hard?

There is nothing obvious in the plist files associated with the Maps application or the GMM.framework itself, but this is only really to be expected. So I pulled out my hex editor of choice, I recommend Hex Fiend by the way, to see what I could be done. Initially, and unfortunately somewhat optimistically, I thought that it should just be a case of tracking down the strings containing the URLs where Maps pulls tiles from the remote server, and changing these to point to the Sky tile server instead. But after poking around for a while inside the GMM.framework this didn't look like it was going to be too easy, at least without decompiling the code. However I did discover references to a SQL database which the application was using as a tile cache for downloaded tiles. Pulling this database off the phone an into SQLLite on my desktop let me examine the schema, which has three separate tables,

images(zoom int, x int, y int, flags int, length int, data blob);
version(version int);
index1 on images (zoom,x,y,flags);

The x, y and z were self explanatory. That's just the x and y position of the tile at zoom level z. The flags looks to be whether the tile is a map (flag is 2) or satellite (flag is 3) tile, the blob was presumably the tile itself and length was obviously the length of the binary blob in bytes. Probably...

The obvious strategy at this point was to download all the tiles, and yes, I mean all the tiles, from the Google Sky tile server, and poke them into the tile cache database in the appropriate places to fake out the Maps.app application into thinking it didn't have to go to the web to download those tiles after all.

Oddly enough the maps tiles served by Google Maps for Sky are JPG files, and the maps tiles in the cache database are PNG files. The JPG's also seem to be 256×256 pixels in size, while the tiles in the cache file are 128×128 pixels in size. So we had a bit of an issue here. I could either take the thousands of downloaded tiles, convert them to PNG, and split them up into smaller tiles, or I could just try throwing them into the cache and see what happened. Want to take a guess at which one I chose to do first?

Pulling the eatblob.c out of the SQLite tutorial, I hacked together a quick script to push all 5,461 tiles (zoom level 0 to zoom level 6) into the cache database. Copying the new enlarged database back onto my iPod, I restarted the iPod and fired up Maps.app but things didn't exactly go as planned. Predictably I didn't get the mapping between the x and y's of the Sky tiles and the Map tiles quite right. In fact I got my x and y's round the wrong way in one of my scripts. Second time was the charm though...


SMC in Google Maps on an Jailbroken iPod touch

Basically at this point I've got Google Maps for Sky working on my iPod touch under Firmware 1.1.2. This hack will presumably also work on the iPhone since my Maps.app was taken off a Jailbroken iPhone in the first place, after all my iPod touch didn't ship with the Maps application in the first place...

Despite all this there are still predictably some problems with the current implementation. First and foremost, the Sky map only occupies the upper left quarter of Earth map when zoomed out all the way out. The best explanation I can come up with for this is simply the fact I haven't yet cut my "big" tiles into quarters. If generate 4×(128×128) tiles out of each of my current 256×256 tiles at each of the current zoom levels then I reckon I'll fill the map.

Of course even with this solved there are two fundamental problems which means that this project is almost entirely an intellectual exercise. The current lack of zoom levels in the Sky data means than when you zoom in far enough you eventually drop back down onto the Earth. For instance the SMC is located somewhere over Marrakech, and if you zoom in far enough sub-Saharan Africa starts to poke through the star field. This could probably be lived with except for the fact that the only way to find the SMC in the first place is do a search for Marrakech, after all the search utility still thinks it's looking at the Earth's surface.

The other major problem is that the Maps.app application doesn't actually have the Maps API, the very thing I need so that I can manipulate the map at the very basic level of even adding a placemark. There are presumably hidden hooks into the application, and maybe those will appear in the Apple SDK due in February . But there still isn't any word on the licensing provisions for the SDK. Who knows if I can get access to it, especially if there is a issue surrounding the digital signatures rumoured to be needed for an "official" application. Finding the money needed, possibly a lot of money, for the SDK could be an interesting proposition. That's even if those hooks exist in the first place.

Anyway, the easiest thing for you to do if you want to replicate my hack is to download the hacked database file (29MB) I generated and copy it into /var/root/Library/Caches/MapTiles/. Make sure you make a copy of your existing MapTiles.sqlitedb database before dropping the new one ontop of it, you'll probably want to back out of the hack at some point. After copying the database file into the right place, simply reboot your iPhone or iPod touch. At that point it should all just work...

Source Code

If you're crazy enough to want to waste your time playing around with this I've attached the source code that will let you rebuild the MapTiles.sqlitedb database directly from the Sky tile servers. Hopefully the guys at Google won't be too cross, as I doubt the handful of people crazy enough to go off and duplicate this stunt will add any significant load to the tile servers...

download_tiles.plDownload all of the tiles from the server
eatblob.cProgram to push the tiles in the the SQLite DB
getdelim.c getdelim.h   Needed by eatblob.c
getline.c getline.h   Needed by eatblob.c
push_tiles.plScript to run eatblob.c in harness for all tiles.

Video

Of course if you don't want to get your hands dirty with the insides of the Maps application, you can always just watch the video...

Apple breaking EU regulations?

Reports are starting to come in that Apple have applied a country lock, so that French iPhones only work on French mobile networks, to the "unlocked" iPhones on sale in France. I guess they haven't heard about the regulations forbidding restrictions on trade and commerce between EU member countries? I can't see any way they can justify this move the face of the current EU regulations, and presumably we'll see someone pull them up on it very shortly...

While the iPhone is a success in the US market, Apple seems to have failed to understand how the European and US markets differ. If the iPhone takes off here, it's going to be despite all the Apple is doing, not because of it...

Update: The Register is now reporting that Orange France is denying the rumours, and saying that "Once legally unlocked, the iPhone will operate with any SIM card, including foreign ones..."

Sunday, December 16, 2007

Turning Google Maps into Tupperware

We've know this was coming for a while, but not when. News of Google Maps for Sky leaked out last week on the Google Maps API forum, quickly followed by the official Google announcement on Friday.


You can create a Sky map in the same way you did your plain old regular map, all you have to do is pass it the correct mapType. So something like this will get you a handle to a Sky Map,
     var map = new GMap2(document.getElementById("map"), 
{ mapTypes : G_SKY_MAP_TYPES });

However if you want to do anything to the map, the coordinate mapping isn't pretty. If you've got your RA and Dec in decimal degrees, you'll need to fudge them like this to push a marker pin into the sky,

     var point = new GLatLng( dec, -ra + 180 );
var marker = new GMarker(point);
map.addOverlay(marker);

This initially had me very confused, not only is it back-to-front, it's not what you have to do to your RA and Dec to plot it in Google Earth. There you have to subtract 180 from your RA value before throwing it into your KML file. Which of course brings me to KML support, there doesn't seem to be any right now...

The lack of KML support is a bit disappointing, it'd be nice to be able to take the KML network link that has the live feed of event messages flowing across the eSTAR network, and throw it directly into Maps. But right now that isn't possible. No worries though, this is an early release in every sense of the word. It's coming, I'm sure I can count on the Googlers.

With that in mind, it'd be daft for me to rewrite the code to throw the live events into Google Maps, because if KML support is coming, and surely it is, I'd just be wasting my effort. So I decided to sit down and PLASTIC-enable Maps instead. A few months ago I did the same for Google Earth, although obviously I had to take a slightly different tack this time around while turning Google Maps for Sky into so called "tupperware".


As before I've written a small PLASTIC application, a facade, which registers with the PLASTIC Hub as normal and listens for ivo://votech.org/sky/pointAtCoords messages. These are PLASTIC messages telling interested applications to "point at" an RA & Dec. When such a message is passed through the Hub, say by CDS Aladin, it is forwarded to the facade application, which then injects this into a boiler plate HTML file. The facade application then exposes this HTML file via an embedded web server. If you point a web browser at this end point you get a map with the marker plotted at the relevant RA & Dec.

Additionally when you send a PLASTIC message into facade application the place mark it generates has a link which, when clicked, will call back to the facade application's embedded webserver and allow you to send a PLASTIC message back to the Hub. This means there is bi-directional control, both in and out, of Google Maps with PLASTIC.

I've uploaded the source code again, but be warned, this is proof-of-concept stuff and when you're dealing with Perl that can get pretty torturous. Especially since I based it on the previous proof-of-concept code I wrote for Google Earth and never got round to fixing up.

There are obvious problems with my implementation, after all it was just a wet Sunday afternoon's work, but most of these are fixable with a little refactoring. However it does work, and uses a lot of the same concepts as my previous effort. This hints strongly that it really is time I got round to writing that general use PLASTIC module for Perl that I've been talking about for a year or more...

Update: More Google Maps for Sky, this time on the iPod touch.

Because the iPhone is not a phone

I saw today that Daniel Dilger noted that the iPhone has grabbed 27% of the US smart phone market, I think he has the reasons for this totally wrong. The reason for this is that the iPhone is not really a phone, it just happens to be able to make phone calls.

The iPhone isn't competing against the rest of the smart phone market. If anything the iPhone, especially after jailbreak, is competing with the ultra-portable market. It's closest competition is the iPod touch not the Nokia N95.

The iPhone now accounts for 0.09% of all web usage. That doesn't sound like a lot until you realise that all Windows CE devices combined account for only 0.06%, with all of the Series 60 devices combined accounting for 0.01%. Despite being around for a much shorter time, and having a lot fewer units out in the wild, the iPhone accounts for 9 times as much web traffic as all of the Series 60 devices put together. Doesn't that tell us something?

It tells me that people are actually using the iPhone to browse the web, not just the quick in and out raids to specific sites that is all most people do with their phone. The iPhone seems to be the first mobile device that has got the ergonomics right so that people are willing to use it to interact with the web, rather than just grab critical stuff like train times and phone numbers off cut down and butchered sites specifically designed for that purpose.

In the longer term Apple have, by design or accident who knows, opened up a new market. Back in 2004 I confidently stated that Apple wouldn't release a phone because the market was saturated and the margins we vanishingly thin. It looks like they've solved the problem by reinventing the market rather than playing in the existing game. Clever Apple...

Saturday, December 15, 2007

More rumours of an Apple ultra-portable

More rumours of the long awaited Apple sub-notebook ahead of Macworld in January. Quickly countered by people noting that 13.3-inches isn't a sub-notebook and assertions that Apple would be crazy to release a sub-notebook at all. I guess we'll have to wait till January...

First, do no harm

Whether active SETI is a danger (via Slashdot) is something that has long been debated inside the SETI community, but late last year the debate boiled over into the public arena after the Nature published an editorial scolding the SETI community for failing to conduct an open discussion on the risks of actively transmitting high powered signals.

Image curtsey of Seed Magazine.
The Interstellar Rosetta Stone

Of course one of the reasons the SETI community has been avoiding the debate is that, through long and bitter experience, they know they need to keep their heads down. With the Proxmire era well and truely behind them, the past few years have almost been a golden age for the SETI community, with public perception of SETI very much changed, they still feel the cold wind of unrespectability on their necks.

The arrival of major private funding, notably the Allen Telescope Array paid for by Microsoft co-founder Paul Allen, has lent an air of respectability that perhaps has been lacking in the past. However the notions of Active SETI is, in popular perception at least, still intertwined with the notions of UFOs and the main-stream SETI community really doesn't want to get sucked into that quagmire. They just don't want to be seen as cranks.

But despite the poor reputation the field has had in the past, it's always been viewed as basically harmless. Low capital and operational costs, along with some fringe benefits such as detailed microwave maps of the sky, mean that the field was fairly inoffensive. After all, it can't hurt just to listen, can it?

Of course the the SETI community have been listening for a long time, and they haven't found anything yet. Perhaps because of the increased funding and the improvement of the public perception of the field, the amount of frustration at that lack has increased to match. Because of this frustration perhaps, METI, or active SETI, is starting to be viewed more favourably especially in the former Soviet Republics.

METI pursues not a local, but a more global purpose – to overcome the Great Silence in the Universe, bringing to our extraterrestrial neighbors the long-expected annunciation “You are not alone!” - Alexander Zaitsev

Of course the roots of active SETI go back a long way, all the way back to the Frank Drake, most famous for the Drake equation, and the Arecibo message in 1974.

The main arguement against active SETI is that its proponents are no longer doing science, they're playing with politics,

Let’s be clear about this. Active SETI is not scientific research. It is a deliberate attempt to provoke a response by an alien civilization whose capabilities, intentions, and distance are not known to us. That makes it a policy issue. - Michael Michaud, SETI League

Carl Sagan, one of the greatest SETI supporters and a deep believer in the notion of altruistic alien civilizations, called such a move deeply unwise and immature. - David Brin

If aliens are so advanced and altruistic... and yet are choosing to remain silent... should we not consider following their example and doing likewise? At least for a little while? Is it possible that they are silent because they know something we don't know? - David Brin

Which seems, at least to me, to be a telling blow. In the long term being silent and listening hard for the next fifty years or so won't make a lot of difference. But the increasing strident cries of the birth of our civilisation are equivalent to us shouting into the darkness "Here we are, look at us...", and that seems a dangerous course of action. All the more so because the proponents of Active SETI refuse to consult with either the astronomical or diplomatic communities. Instead they take it upon themselves to speak for humanity.

First, do no harm...

Thursday, December 13, 2007

Touch screen iMacs

No, not another Apple rumour. Earlier in the month Troll Touch, the company that'll touch enable your Mac, released a touchscreen iMac (via CrunchGear). For a hefty mark up of course, you can now have a touchscreen technology on your desktop, as well as your iPhone. Old news now, but I hadn't seen the YouTube video so thought it was worth a quick post. Now why hasn't Apple done this?

The 3 Skypephone Review

Just under a month ago I was lent two Skypephones by the UK network operator 3. They're scheduled to go back in a week or so, so I thought I'd sit down and write up what I think of the handset and perhaps more importantly, what the appearance of the first not only officially sanctioned, but heavily promoted, VoIP application on a phone targeted at the average consumer means for the industry.


Like most first offerings there are problems here that aren't really symptomatic of the concept, but are because when you're rolling out new hardware, or new software, there are always problems. So despite the large amount of criticism I'm going to level at the Skypephone in this post I want to make it clear that it's a decent handset. Not too flashy, but decent enough, and the Skype application works well.

Lets start on the hardware. As I've mentioned before, the handsets are small, light, and fit easily into your pocket. Although it's not the most attractive phone in the world, compared to Nokia's N-series or the Apple iPhone it is clunky and somewhat dated. But it's a solid enough handset and the rubberised case feels quite good in your hand. Ergonomically, you can't complain.

What you can complain about is the screen, I've had the handset less than a month and the screen is scratched quite badly. The phone hasn't been dropped, or suffered any major trauma, it's been in the same pocket as my Nokia N80 and my iPod touch. I've had the Nokia for just over a year and it's far less bashed about than the Skypephone. The iPod touch I've had for only a little longer than the Skypephone, and it's probably seen more trauma than the Skypephone, after all 3's handset was only on loan. There isn't a scratch on my iPod's screen, but the Skypephone's screen has taken a serious beating.

I got fed up years ago trying to keep my portable electronics in little protective cases, if they can't handle the day to day knocks and bumps then it falls by the way side fairly quickly. If you actually have to coddle something that's been designed to go in your pocket, then it hasn't been designed well.

I haven't dared put the Skypephone through something like the stress test PC World gave the iPhone. I'm not sure it'd give a good account of itself, and I do have to put it back in the post in a few days in more or less one piece.

Next up, software. The handset's operating system isn't really as polished as the latest Nokia, or the iPhone. This is especially apparent when it comes to browsing the web. Compared to my iPod touch or Apple's iPhone, web browsing on 3's Skypephone is a joke. I'm not interested in 3's walled garden, but found myself more or less restricted to it because the web browser that comes with the phone did such a remarkably bad job of rendering web pages.

Of course part of the problem is the screen, it's small, and the number of pixel per inch isn't anything like the iPhone, and to be fair that's okay. This isn't a smart phone, or at least it isn't what passes as a smart phone these days. Okay, so you can browse the web, but that isn't why you'd buy a 3 Skypephone is it? You'd buy it because it has Skype...

The main question you have to ask about something marketed as a Skypephone is how well does it handle Skype, the answer is pretty well. The few calls I've actually managed to make have had fairly good voice quality, although there is sometimes noticeable lag between sending and receiving that (as a heavy VoIP user) came as a bit of a surprise to me.

Which brings me to my main problem with the handset, which again I've mentioned before, and isn't anything to do with the handset itself. It's to do with the network the handset is on, I can't get any coverage. I was loaned two handsets, I had one, and my wife had the other. The places where there isn't any 3 coverage is getting rather long: our house, her parent's house, her office, my office, the cities and towns we visit regularly. The list of places where there is coverage is considerably shorter, and that's bad. Although to be fair there basically isn't any mobile phone reception in our village at all, between us my wife and I have Orange, O2 and T-Mobile handsets, and none of them work either. So there at least, it's not just 3 that's got a problem.

Of course with only having the phone on loan I wasn't really prepared to move "my life" onto the new handset, although to be fair I'd have found it hard. The phone isn't supported by Mac OSX, so it would be difficult to sync my contacts and calendars onto the phone, and perhaps I just haven't given the handset a fair chance because of that problem? After all, without all that information the handset is just a brick that can make telephone calls, admittedly a small and cute brick.

My final swipe at this handset is of course, standards. You only have to go to Google too see the controversy around the proprietary peer-to-peer Skype versus centralised, but standards based, SIP debate. There are a lot of criticisms of the proprietary Skype protocol, but I'd probably argue that Skype and SIP attack different problems. Despite advertising Skype is not a SIP-killer, nor despite the outcry of the open source community is SIP the answer to Skype.

That said I find 3's decision to go with Skype for a VoIP rollout curious, has Skype already got the mind share in the consumer market to make it so attractive? Surely a network operator, who lives and dies by standards, would have been more attracted to a SIP solution. Why isn't this the Gizmo phone for instance?

I think that's a telling point, and it's going to be interesting to see how this works out when 3's exclusivity agreement with Skype runs out. Are other operators going to jump on the band wagon, are they going to go with SIP. Are they going to, unsuccessfully, ignore the whole thing?

As I mentioned earlier today I think we're at a tipping point, and the 3 Skypephone is a symptomatic. VoIP on mobile handsets is here to stay and you only have to look at Nokia's commitment to putting SIP stacks on their new handsets, despite operator pressure not to, to realise that.

But despite all these complaints, am I going to regret saying goodbye to my Skypephones? Probably...

If you're interested in trying out a handset yourself, the guys over at www.3mobilebuzz.com, the people than gave me the loaner handsets, are running a little competition. I'll let them explain it themselves...

We at www.3mobilebuzz.com are running a little competition - the winner gets three 3 Skypephones, second place gets two and third place gets one. Also two devices will be awarded to the blog that refers the winning entry.

All entrants need to do is tell us why they want a 3 Skypephone – and it can be done however they want as long as it can be linked to. For example, it could be a blog post, forum thread or simple webpage, a picture or a set on Flickr (here’s something that www.3mobilebuzz.com knocked together), a link to a YouTube video (can you do better than this?) or even a Facebook group where 100 friends sign up and support the quest for a 3 Skypephones. The more creative the better.

The only rules are: the content needs to be original, not ripped off an insignificant YouTuber (we’ll know because you have to tag all your videos 3mobilebuzzcomp1), and the URL of the site which brought the competition to entrants attention needs to be included on the entry email. The deadline for submissions is midday on Monday 17th December.

Entries must be sent to the hallowed keeper of prizes, enforcer of rules and judge of all, Jack@3mobilebuzz.com. As always we’ll keep everyone updated as to the best submissions via www.3mobilebuzz.com.

VoIP on the iPod touch

So we've known for just under a month that, despite not coming with a microphone bulit-in, the audio input pins on the iPod touch dock connector are active (via Engadget).

CREDIT: touchmods.blog.com

The discovery of the live audio pins immediately led to lots of speculation about using the device for VoIP. Although to be honest, having used many large screen "smart phones" over the years, the ergonomics are wrong. Without Bluetooth using the iPod touch as a phone will be pretty tiresome. But the general consensus seems to be, it looks like an iPhone, why shouldn't it be able to make calls?

Shortly after the discovery of the live audio input pins, the same people hacked a mic in a dock connector (via Engadget). Now all that was lacking was some VoIP software...

CREDIT: touchmods.blog.com

A couple of days ago reports surfaced that the SvSIP stack has now been ported (via TUAW) and is being tested and that it's been confirmed that registration and signalization is working.

CREDIT: touchmods.blog.com

The translation is that "it all just works". As far as I know nobody has made an actual voice call yet, but all the right bits of software have already been written, and just need to be connected together. It's just a matter of time before that happens, and the fact that people are willing to go to this length to hack VoIP onto a device which out of the box fundamentally lacks even hardware support is telling.

Mobile phones have been commodity items, at least in the UK and Europe, for several years. What the drive for VoIP on the iPod touch is telling me is that the network providers, and the infrastructure they provide that sit behind the telephone calls you make, are starting to become exactly that. Infrastructure. The network of cell towers are just another commodity, and can be swapped out and replaced by a different infrastructure, in this case WiFi, without the user noticing much of a difference. The interesting stuff, the packet data level, sits on top, transparently.

This has been rubbed home to me by two things, the Skypephone which I've got on loan from Three, and the realisation that I haven't actually used my fixed line at home for several months now. It sits there, carries my ADSL connection, and as a consequence my phone calls which are now almost exclusively done over VoIP. But actual POTS calls? Not for a while...

The mobile network providers are dinosaurs, as are the fixed line telephone companies. It's going to be interesting to see it they can reinvent themselves, as Three are trying to do with the Skypephone, and provide what people actually seem to want. Commodity bandwidth.

Thursday, December 06, 2007

Hotel Mauna Kea

This You Tube video (via Samwise) is currently going viral amoungst the astronomers who use the observatories on top of Mauna Kea. Starts off slow and instrumental, but wait for the vocals...