Projections

Map projections are methods of representing the surface of a sphere / a three-dimensional object (i.e. the Earth) on a plane. Marble has a total number of three different kinds of projections:

1. Spherical Projection

2.Equirectangular Projection

3. Mercator Projection

The last two, as you can see, are pretty similar, and these similarities also reflect into the code. Each of the three projections is represented by a class, with its own particularities. For example, the Spherical map contains horizons (because a side of the Earth can not be seen at each moment), while the Cylindrical maps (Mercator + Equirectangular) contain the International Date Line and so on.

There is an abstract class, AbstractProjection, that contains all the methods which are supposed to be common for all the projections, and therefore is inherited by each of SphericalProjection, MercatorProjection and EquirectProjection. Since Equirectangular and Mercator projections are so similar, and so different from Spherical projection, many corner cases have arisen in different methods of AbstractProjection. My job was to create a new class, CylindricalProjection, which would inherit AbstractProjection and would be inherited by EquirectProjection and by MercatorProjection, containing all the things Equirect and Mercator have in common.

A major difficulty I had to overcome (by the way, thanks tackat and idis, my mentors, for all the help with regard to this issue) was implementing the Shared D-Pointer. Briefly, one of KDE’s coding policies is that you are not allowed to have private members in public classes, so if they are needed, you need to implement a class, called BaseClassNamePrivate, which will incorporate the necessary private methods. If the class hierarchy is big enough, then you are encouraged to use the shared d-pointer, which makes the access to all the members much easier, but, as I have experienced, is pretty harsh to declare and become functional.

That was my second task, and the first major one, that actually involved dealing with the code (a lot!). The next one is a tutorial again, see you soon!

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s