[Marble-devel] Projection classes

Inge Wallin inge at lysator.liu.se
Thu May 1 10:49:54 CEST 2008


I have a design problem regarding projections.

I am currently working on finishing the Mercator projection, and have at the 
same time tried to restructure the handling of projections within Marble. I 
want to get rid of all the code of the form:

switch (projection) {
  case Sperical:
     xxx1
  case Rectangular:
     xxx2
  case Mercator:
     xxx3
}

because 1) this makes it very difficult to get an overview of what is specific 
to a projection, and 2) it makes it difficult to implement a new projection. 
Instead, I want all these issues to look like:

  currentProjection->doXXX()

...so that all handling that is projection specific can be collected into one 
file that implements a whole projection.

One thing that has been created because of this is the AbstractProjection 
class and 3 inherited classes: xxxProjection, where xxx is one of Spherical, 
Equirect, and Mercator.

Currently, these classes only handle mathematical properties of the 
projections, such as conversion between screen coordinates and globe 
coordinates (lon/lat) and similar things.  However, there is also a need of a 
place to collect actual code that is projection specific. An example of this 
is VectorMap::paintBase() which paints the background of the map before the 
actual map itself is painted. There are many more spread around the code.

So, where should I put code like that?  I can see two different roads:
 1. To enhance the current projection classes with code like this. 
 2. To keep the current projection classes as just mathematical abstractions 
and create some new classes where actual code is collected.

Right now I lean towards #1, but can be persuaded to use #2 or even some 
other, even better, scheme if somebody comes up with good arguments for 
either. 

Comments, please!

	-Inge


More information about the Marble-devel mailing list