Ariya Hidayat
Graphics Dojo
S60
Posted by Ariya Hidayat
 in Graphics Dojo, S60
 on Tuesday, August 04, 2009 @ 08:31

Like I promised few days ago, here is the demo that shows tile-based OpenStreetMap rendering on Qt/S60. If you never heard of OpenStreetMap before, it is “a collaborative project to create a free editable map of the world” (from its Wikipedia entry). You can try it at www.openstreetmap.org. It might not be as complete as other maps solutions, but surprisingly, OpenStreetMap coverage for many world big cities are detailed enough for most users.

The approach used in this example is by showing prerendered tiles stored as pixmaps, often known as Slippy Map. Of course, we also need to honor the tile usage policy. Much to my surprise, it takes only around 200 lines of code to achieve basic rendering, including tile downloads (via QNetworkAccessManager) and simple disk caching (thanks to QNetworkDiskCache). Add another 100 lines to support panning via mouse dragging and arrow keys. To have some more fun, I also brought the magnifying glass and night mode features and the total code is still less than 600 lines (which was good, as it did not cost me any sleepless night). On top of that, it also runs on Qt/S60 Tower release. Isn’t Qt wonderful?


While the screenshot above serves as a solid proof, these days nothing is more fascinating than watching a videocast from our very own Mr. Portale. See below or watch directly (on YouTube):

This simple maps exampe, dubbed lightmaps (remember Quake source code, anyone?) can be found in the Graphics Dojo repository. You need Qt 4.5, either the desktop or mobile version. So far it has been tested on touch devices like Nokia N97 and Nokia 5800, but it does work also on other phones like Nokia E71.

For the sake of keeping the example simple, I did put only minimal error handling and a very simple tile cache system. This means, the first time you want to zoom with the magnifying glass (tap and hold for a while with touch device, press middle button in the D-pad for other devices), there is a potential delay until the magnified portion is rendered. Since the tile pixmaps are cached, the next attempt will likely result in a faster painting.

What about vectorial rendering of the maps? While that would be a perfect solution (even allows semi 3-D with nice transformation like in common navigation system), unfortunately I believe the amount of code will exceed the suitable size for a typical example program. Of course, this feature along with other possible improvements (custom zoom level, search function, tiles prepackaging, more optimal tile caching, and soon) are always left as exercises for the brave readers.

I hope you are inspired to map-enable your cool apps. No more excuse! :)

8 Responses to “OpenStreetMap and Qt and (S60)”

» Posted by Richard Stellingwerff
 on Tuesday, August 04, 2009 @ 10:41

This is incredibly cool! I myself have an HTC Touch Pro2, and tried doing some Qt stuff on it, but its performance is really bad. Seeing how well it performs on that nokia phone, I wonder if I could somehow get better performance on my HTC as well.

I haven’t tried this example on my HTC yet, though… Will try that soon!

» Posted by Sune
 on Tuesday, August 04, 2009 @ 10:46

Nice. Can it talk with the gps in many nokia phones as well - or is it just a map ?

» Posted by ariya
 on Tuesday, August 04, 2009 @ 10:54
Ariya Hidayat

@Sune: The GPS integration is left as an exercise for casual S60 programmers.

» Posted by jannek
 on Tuesday, August 04, 2009 @ 13:27

@ariya @Sune http://wiki.forum.nokia.com/index.php/Mobile_Extensions#9._Location_API
Might be a good starting point for such casual exercise :)

» Posted by ianwood
 on Tuesday, August 04, 2009 @ 14:36

I guess the next step would be to render the tiles on device rather than rely on the network connection (as in Nokia Maps).

» Posted by n8dgr8
 on Tuesday, August 04, 2009 @ 22:24

What? No flickcharm on this thing? ;-)

Excellent example! Thank you!

» Posted by Matthew Davidson
 on Tuesday, August 04, 2009 @ 22:31

It’s worth noting that while OpenStreetMap.org is not yet “as complete as other maps solutions”, the areas it does cover are likely to be more up to date. I live in a large town on the east coast of Australia. A couple of years ago, OpenStreetMap.org’s coverage of our town was the highway running through it. Since then people have been mapping like crazy, and our town on OpenStreetMap.org is not only as complete as on Google Maps, but more up to date. If you’re relying on Google Maps to get you here, you’re likely to get lost, because a major highway bypass, on OpenStreetMap.org from the day it opened early this year, is not shown on Google Maps. Nor is another major road project connecting the north and south sides of town, although that was completed (and to be found on OpenStreetMaps.org) about two years ago. Unlike some countries, government-collected mapping data is not public domain in Australia, so all of this data is voluntarily contributed.

Google’s maps of our area do not seem to have been updated once since they first covered our part of the world (in 2006, from memory). As with software, you can raise a lot of money on the promise of great financial returns from proprietary data, and this will get you up and running very quickly. However, free community-maintained data sources will inevitably catch up, and from that point on, you cannot hope to compete.

» Posted by Hannes
 on Thursday, August 13, 2009 @ 14:48

Holly cow… i was a little bit scared when i saw the screen in my feedreader couze thats just the place i was at the time (my working place if you will) .. haha nice Coincidence. Also a nice Application of course!



© 2008 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners.