Use ViewportParams rather than AbstractProjection for projection calculations regarding the visible area

Review Request #5539 - Created Oct. 6, 2010 and updated

Information
Bernhard Beschow
kde
Reviewers
marble
Using ViewportParams rather than AbstractProjection simpliefies statements like viewport->currentProjection()->screenCoordinates(...,viewport,...) to viewport->screenCoordinates(...).

That way, in the future, ViewportParams could be used for projection calculations that need to take the current viewport (and possibly an elevation model) into account, while AbstractProjections represent the pure mathematical concept (i.e. no elevation model).
Works for me (KDE version of Marble).
Torsten Rahn
Ok, I had a look at this patch yesterday already. The motivation is nice since we also need some similar action for taking camera focus into account. 

Now the disadvantage of this patch is that almost all the projection methods need to get moved into the Viewport class. This kind of replicates lots of methods and introduces the awareness of the existance of GeoCoordinates into the ViewPorts class. So in a way this floods this class a bit with lots of stuff that had been encapsulated away before. 
Still this step makes sense to some degree: The only other option would be to "muddy" the projection classes with stuff like focus/elevation calculation. Putting an additional screenpixel conversion class (which would handle focus, elevation etc.) between Viewport and Abstractprojection might be another option but of course that could lead to other disadvantages. Any comments from your side regarding these thoughts? 
  1. > Any comments from your side regarding these thoughts? 
    
    Regarding the flooding, I think that the conversion (a.k.a. projection) methods actually make sense inside the ViewportParams class: Since we probably don't want to have an altitude concept in the projection classes, it should be implemented inside ViewportParams. That way, code that builds on ViewportParams will transparently use height information. So the conversion methods in ViewportParams will always calculate the correct (lon, lat) pair for each pixel and vice versa, no matter whehter an altitude model is active or not. Of course, we could also introduce a third class, but I'd like to try the pragramtic approach first.
    
    That said, I think that the projection classes (rather than ViewportParams) should be freed from the altitude concept, which is already present in the GeoDataCoordinates class. That way, the projection classes would only implement the bare mathematical conversion formulas which ideally shouldn't be polluted with other concepts. Unfortunately that is not possible in a naive way since the spherical projection depends on the rotation. So we may either pass the rotation as an additional argument to the conversion methods in the projection classes or pragmatically stay with the current virtual methods which take the viewport into account.
    
    As a benefit of freeing the projection classes from the altitude concept, they can be reused with less potential side effects elswhere. For instance, they could be applied to textures.
    
Torsten Rahn
> but I'd like to try the pragramtic approach first.

Ok, let's go for the pragmatic approach then first ;-)
Loading...