FEB
9
2008
|
Marble's Secrets Part I: Behind the Scenes of Marble...This is the first part of a new series about Marble. I'll try to address a few frequently asked questions as well as the current status of the development. So stay tuned. If you've ever followed KDE 4 development then you've probably heard about Marble. Marble is a virtual globe which displays the earth. So Marble can be used as a nice digital replacement for your desktop globe at home where you can look up places. But wait! There's more to it: Actually these days Marble can also display flat maps (thanks to Carlos Licea), can show different "map themes" and can serve as a Qt4-widget as well as an application! This means that as a programmer you can use Marble in your very own project as a map widget (License: LGPL). Marble was designed to run on any device and on any operating system supported by Qt4 without any further requirements. You can download the latest version of Marble together with KDE 4.0.1 here (It's part of the KDE-EDU module). How Marble stores texture data If you start Marble you might realize that the startup time is pretty good: It usually takes maybe 2-5 secs to start Marble (and we are working on improving that dramatically). If you zoom into the earth you might notice that Marble doesn't get slower while zooming in. Looking at the amount of memory being used up you will also see that memory numbers don't change either. No matter how much you zoom in it's as little as 65-100MB which is pretty lean compared to other virtual globes. This means that for different zoomlevels the map is available at different pixel resolutions: Loading maps this large would exceed the physical memory or would at least take very long to load. So the maps are stored as a 2:1 ratio checkboard of several tiles. In Marble each of those tiles measures 675x675 pixel. The next higher zoom level gets created by dividing every tile into 4 pieces measuring 675x675 pixel each: So level 0 consists of a row of two 675x675 pixel tiles (1350x675). Level 1 consists of two rows of 675x675 pixel tiles with four columns each (2700x1300) and so on. You can see this in the screenshots which also show the filenames of the tiles: They contain the row number (counted from north to south) and the column number (counted from west to east). As you can see Marble will only load about 5-6 tiles for any view. For Spherical Projection ("Globe") these tiles get mapped onto the globe. So in theory there is technically no limit as to how far Marble can zoom into the earth. As you can see in the screenshot we have tested Marble with data from the kind folks from the OpenStreetMap Project ( http://www.openstreetmap.org ) already and there we are down to approximately level 13 where you can see objects that can reasonably get measured at the order of centimeters already (The test data tiles were kindly created by Artem Pavlenko of Mapnik fame). During the very first application start of Marble you might have noticed that the first start takes a bit longer: According to the dialog Marble needs to "initialize the map". Actually it just creates the tiles from the huge base image while showing the dialog. How to create your own maps in Marble? Marble looks for maps on the local file system: these maps get specified in a .dgml-files. So that's what Marble will look for right from the start. Marble will search your home directory's ~/.marble/data/maps/earth as well as the respective system directory ( e.g. /usr/share/apps/marble/data/maps/earth ). The *.dgml file is a small XML-file that mostly contains
You can simply create your own map by copying over an existing directory ( e.g. "citylights" ) from the system directory. Of course you need to change the name of the target directory to something different: Then you just need to rename the citylights.dgml-file (e.g. to "mymap.dgml") and load it with a text editor. After adjusting the 4-5 values inside the xml file you are almost done and you just need to provide a random icon (preferably at a size of 128x128) and the basemap. The basemap needs to be provided in a special, but very commmon and simple format, called Equirectangular Projection or Plate Carrée. Once you are done you should (re)start Marble to detect the new map. If everything is ok there should be a new map available in the "Map View" listview labeled with the name that you have chosen. Once you select it Marble will start creating the needed tiles. It needs to be said that this way of creating maps is only suitable for "small" maps as there is a limitation: Automatically Marble can only create tiles from base images that measure up to approximately 10800x5400 pixel. If you want to create tiles from larger images then you are on your own: You need to find a suitable tool or you need to create a script that will create the tiles for you. In this case make sure that you adhere to the naming scheme of directories and tiles (note that tile rows and columns need to get specified in 6-digit format): If you have a Marble version >= 0.5.1 installed then you can even create a custom legend, too:
In the next part I'll cover a topic that outlines a few pretty unique internal features of Marble. Until then I hope that you have fun creating your own maps! Of course I'd be happy about any screenshots or links to actual new maps sent to [email protected] by mail. For help or questions you can join us on IRC ( irc.kde.org, #kde-edu ) or send a mail to our mailing list. Marble Junior Jobs Given that Marble is a globe we have a pretty good chance for reaching world domination. However we need your help in terms of patches to accomplish this aim. If you plan to look into Marble's code here are a few easy junior jobs that you might want to start with: First you need to spend 10 minutes to get Marble from the sources and to compile it. You need to check out Marble "trunk". Once that is done you can take the plunge:
|
![]() |
Comments
Data dirs
You might want to think about using the xdg-base-dir spec recommended directories for applications data usually referred to as xdg_data_dirs (global directory list and local prefix overridable by environment variable).
I implemented this for Akonadi in xdgbasedirs.h/.cpp in libakonadi
Well the system directory's
Well the system directory's path is not hardcoded. You can specify where Marble should search its data either at run or compile time using the Marble Data Path. See the last chapter of:
http://edu.kde.org/marble/obtain.php
Re: Data dirs
I looked into your source code and yes, we'd definetely like to have the XDG paths being honored. The only difficulty will be to introduce this without breaking things ...
compatability
You'll probably need something like I did with "AKONADICONFIG", i.e. a constant defined in a build-time modified header (akonadi-prefix)
The user irectory might be a bit more difficult.
Yeah the AKONADI CONFIG
Yeah the AKONADI CONFIG solved my issues too... putting that in the build-time header helped clean up the directory structure. I learned about it from the kde techbase:
http://techbase.kde.org/Development/vbs/Tutorials/Akonadi/Resources