[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [marble] src/plugins/render/graticule: - Refactor the UTM exception rendering into its own method
From:       Torsten Rahn <rahn () kde ! org>
Date:       2013-01-13 23:18:07
Message-ID: 20130113231807.E3F8EA6091 () git ! kde ! org
[Download RAW message or body]

Git commit fff42adf562b8197b3fbb0f403af7f670565a29f by Torsten Rahn.
Committed on 14/01/2013 at 00:15.
Pushed by rahn into branch 'master'.

- Refactor the UTM exception rendering into its own method
- Call renderUtmExceptions for the Dateline case as well
- Create the string for the dateline case as well.

UTM grid works well now.

M  +79   -39   src/plugins/render/graticule/GraticulePlugin.cpp
M  +28   -2    src/plugins/render/graticule/GraticulePlugin.h

http://commits.kde.org/marble/fff42adf562b8197b3fbb0f403af7f670565a29f

diff --git a/src/plugins/render/graticule/GraticulePlugin.cpp \
b/src/plugins/render/graticule/GraticulePlugin.cpp index e3f72b2..84017ad 100644
--- a/src/plugins/render/graticule/GraticulePlugin.cpp
+++ b/src/plugins/render/graticule/GraticulePlugin.cpp
@@ -544,6 +544,50 @@ void GraticulePlugin::renderLatitudeLines( GeoPainter *painter,
     }
 }
 
+
+void GraticulePlugin::renderUtmExceptions( GeoPainter *painter,
+                                            const GeoDataLatLonAltBox& \
viewLatLonAltBox, +                                            qreal itStep, qreal \
northPolarGap, qreal southPolarGap, +                                            \
const QString & label, +                                            \
LabelPositionFlags labelPositionFlags ) +{
+    // This code renders the so called "exceptions" in the UTM coordinate grid
+    // See: http://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system#Exceptions
 +    if ( northPolarGap == 6.0 && southPolarGap == 162.0) {
+        if ( label == "31" ) {
+            renderLongitudeLine( painter, itStep+3.0, viewLatLonAltBox, \
northPolarGap, +            southPolarGap, label, labelPositionFlags );
+        } else if ( label == "33" ) {
+            renderLongitudeLine( painter, itStep+3.0, viewLatLonAltBox, \
northPolarGap, +            southPolarGap, label, labelPositionFlags );
+        } else if ( label == "35" ) {
+            renderLongitudeLine( painter, itStep+3.0, viewLatLonAltBox, \
northPolarGap, +            southPolarGap, label, labelPositionFlags );
+        } else if ( label == "37" ) {
+            renderLongitudeLine( painter, itStep, viewLatLonAltBox, northPolarGap,
+            southPolarGap, label, labelPositionFlags );
+        } else if ( label == "32" || label == "34" || label == "36" ) {
+            // paint nothing
+        } else {
+            renderLongitudeLine( painter, itStep, viewLatLonAltBox, northPolarGap,
+            southPolarGap, label, labelPositionFlags );
+        }
+    }
+    else if ( northPolarGap == 26.0 && southPolarGap == 146.0 ) {
+        if ( label == "31" ) {
+            renderLongitudeLine( painter, itStep-3.0, viewLatLonAltBox, \
northPolarGap, +            southPolarGap, label, labelPositionFlags );
+        } else {
+            renderLongitudeLine( painter, itStep, viewLatLonAltBox, northPolarGap,
+            southPolarGap, label, labelPositionFlags );
+        }
+    }
+    else {
+        renderLongitudeLine( painter, itStep, viewLatLonAltBox, northPolarGap,
+        southPolarGap, label, labelPositionFlags );
+    }
+}
+
 void GraticulePlugin::renderLongitudeLines( GeoPainter *painter, 
                                             const GeoDataLatLonAltBox& \
                viewLatLonAltBox, 
                                             qreal step, qreal northPolarGap, qreal \
southPolarGap, @@ -587,7 +631,6 @@ void GraticulePlugin::renderLongitudeLines( \
GeoPainter *painter,  while ( itStep < eastLineLon ) {
             // Create a matching label
             QString label;
-            // FIXME: East of 66 ° zones are notated in degrees.
             if ( notation == GeoDataCoordinates::UTM ) {
                 int zoneNumber = static_cast<int>( itStep / 6.0 ) + 30;
                 label = QString::number( zoneNumber );
@@ -607,34 +650,9 @@ void GraticulePlugin::renderLongitudeLines( GeoPainter *painter,
             // Paint all longitude coordinate lines except for the meridians
             if ( itStep != 0.0 || itStep != 180.0 || itStep != -180.0 ) {
                 // handle exceptions for UTM grid
-                if ( northPolarGap == 6.0 && southPolarGap == 162.0 && notation == \
                GeoDataCoordinates::UTM ) {
-                    if ( label == "31" ) {
-                        renderLongitudeLine( painter, itStep+3.0, viewLatLonAltBox, \
                northPolarGap,
-                        southPolarGap, label, labelPositionFlags );
-                    } else if ( label == "33" ) {
-                        renderLongitudeLine( painter, itStep+3.0, viewLatLonAltBox, \
                northPolarGap,
-                        southPolarGap, label, labelPositionFlags );
-                    } else if ( label == "35" ) {
-                        renderLongitudeLine( painter, itStep+3.0, viewLatLonAltBox, \
                northPolarGap,
-                        southPolarGap, label, labelPositionFlags );
-                    } else if ( label == "37" ) {
-                        renderLongitudeLine( painter, itStep, viewLatLonAltBox, \
                northPolarGap,
-                        southPolarGap, label, labelPositionFlags );
-                    } else if ( label == "32" || label == "34" || label == "36" ) {
-                        // paint nothing
-                    } else {
-                        renderLongitudeLine( painter, itStep, viewLatLonAltBox, \
                northPolarGap,
-                        southPolarGap, label, labelPositionFlags );
-                    }
-                }
-                 else if ( northPolarGap == 26.0 && southPolarGap == 146.0 && \
                notation == GeoDataCoordinates::UTM ) {
-                    if ( label == "31" ) {
-                        renderLongitudeLine( painter, itStep-3.0, viewLatLonAltBox, \
                northPolarGap,
-                        southPolarGap, label, labelPositionFlags );
-                    } else {
-                        renderLongitudeLine( painter, itStep, viewLatLonAltBox, \
                northPolarGap,
-                        southPolarGap, label, labelPositionFlags );
-                    }
+                if (notation == GeoDataCoordinates::UTM ) {
+                    renderUtmExceptions( painter, viewLatLonAltBox, itStep, \
northPolarGap, +                    southPolarGap, label, labelPositionFlags );
                 } else {
                     renderLongitudeLine( painter, itStep, viewLatLonAltBox, \
northPolarGap,  southPolarGap, label, labelPositionFlags );
@@ -649,9 +667,15 @@ void GraticulePlugin::renderLongitudeLines( GeoPainter *painter,
         while ( itStep < 180.0 ) {
 
             // Create a matching label
-            QString label = GeoDataCoordinates::lonToString( itStep, 
-                                notation, GeoDataCoordinates::Degree, 
-                                -1, 'g' );
+            QString label;
+            if ( notation == GeoDataCoordinates::UTM ) {
+                int zoneNumber = static_cast<int>( itStep / 6.0 ) + 30;
+                label = QString::number( zoneNumber );
+            } else {
+                label = GeoDataCoordinates::lonToString( itStep,
+                                  notation, GeoDataCoordinates::Degree,
+                                  -1, 'g' );
+            }
 
             // No additional labels for the prime meridian and the antimeridian
 
@@ -662,8 +686,13 @@ void GraticulePlugin::renderLongitudeLines( GeoPainter *painter,
 
             // Paint all longitude coordinate lines except for the meridians
             if ( itStep != 0.0 || itStep != 180.0 || itStep != -180.0 ) {
-                renderLongitudeLine( painter, itStep, viewLatLonAltBox, \
                northPolarGap,
-                                     southPolarGap, label, labelPositionFlags );
+                if (notation == GeoDataCoordinates::UTM ) {
+                    renderUtmExceptions( painter, viewLatLonAltBox, itStep, \
northPolarGap, +                    southPolarGap, label, labelPositionFlags );
+                } else {
+                    renderLongitudeLine( painter, itStep, viewLatLonAltBox, \
northPolarGap, +                    southPolarGap, label, labelPositionFlags );
+                }
             }
             itStep += step;
         }
@@ -672,9 +701,15 @@ void GraticulePlugin::renderLongitudeLines( GeoPainter *painter,
         while ( itStep < westLineLon ) {
 
             // Create a matching label
-            QString label = GeoDataCoordinates::lonToString( itStep, 
-                                notation, GeoDataCoordinates::Degree, 
-                                -1, 'g' );
+            QString label;
+            if ( notation == GeoDataCoordinates::UTM ) {
+                int zoneNumber = static_cast<int>( itStep / 6.0 ) + 30;
+                label = QString::number( zoneNumber );
+            } else {
+                label = GeoDataCoordinates::lonToString( itStep,
+                                  notation, GeoDataCoordinates::Degree,
+                                  -1, 'g' );
+            }
 
             // No additional labels for the prime meridian and the antimeridian
             if ( labelPositionFlags.testFlag( LineCenter ) && ( itStep == 0.0 || \
itStep == 180.0 || itStep == -180.0 ) ) @@ -684,8 +719,13 @@ void \
GraticulePlugin::renderLongitudeLines( GeoPainter *painter,  
             // Paint all longitude coordinate lines except for the meridians
             if ( itStep != 0.0 || itStep != 180.0 || itStep != -180.0 ) {
-                renderLongitudeLine( painter, itStep, viewLatLonAltBox, \
                northPolarGap,
-                                     southPolarGap, label, labelPositionFlags );
+                if (notation == GeoDataCoordinates::UTM ) {
+                    renderUtmExceptions( painter, viewLatLonAltBox, itStep, \
northPolarGap, +                    southPolarGap, label, labelPositionFlags );
+                } else {
+                    renderLongitudeLine( painter, itStep, viewLatLonAltBox, \
northPolarGap, +                    southPolarGap, label, labelPositionFlags );
+                }
             }
             itStep += step;
         }
diff --git a/src/plugins/render/graticule/GraticulePlugin.h \
b/src/plugins/render/graticule/GraticulePlugin.h index 18d4412..6c265da 100644
--- a/src/plugins/render/graticule/GraticulePlugin.h
+++ b/src/plugins/render/graticule/GraticulePlugin.h
@@ -162,11 +162,15 @@ class GraticulePlugin : public RenderPlugin, public \
DialogConfigurationInterface  );
 
     /**
-     * @brief Renders the latitude lines that are visible within the defined view \
bounding box. +     * @brief Renders the longitude lines that are visible within the \
                defined view bounding box.
      * @param painter the painter used to draw the latitude lines
      * @param viewLatLonAltBox the latitude longitude bounding box that is covered \
                by the view.
      * @param step the angular distance between the lines measured in degrees .
-     * @param polarGap the area around the poles in which most longitude lines are \
not drawn +     * @param northPolarGap the area around the north pole in which most \
longitude lines are not drawn +     *        for reasons of aesthetics and clarity of \
the map. The polarGap avoids narrow +     *        concurring lines around the poles \
which obstruct the view onto the surface. +     *        The radius of the polarGap \
area is measured in degrees. +     * @param southPolarGap the area around the south \
                pole in which most longitude lines are not drawn
      *        for reasons of aesthetics and clarity of the map. The polarGap avoids \
                narrow
      *        concurring lines around the poles which obstruct the view onto the \
                surface.
      *        The radius of the polarGap area is measured in degrees. 
@@ -179,6 +183,28 @@ class GraticulePlugin : public RenderPlugin, public \
DialogConfigurationInterface  );
 
     /**
+     * @brief Renders UTM exceptions that are visible within the defined view \
bounding box. +     * @param painter the painter used to draw the latitude lines
+     * @param viewLatLonAltBox the latitude longitude bounding box that is covered \
by the view. +     * @param step the angular distance between the lines measured in \
degrees . +     * @param northPolarGap the area around the north pole in which most \
longitude lines are not drawn +     *        for reasons of aesthetics and clarity of \
the map. The polarGap avoids narrow +     *        concurring lines around the poles \
which obstruct the view onto the surface. +     *        The radius of the polarGap \
area is measured in degrees. +     * @param southPolarGap the area around the south \
pole in which most longitude lines are not drawn +     *        for reasons of \
aesthetics and clarity of the map. The polarGap avoids narrow +     *        \
concurring lines around the poles which obstruct the view onto the surface. +     *   \
The radius of the polarGap area is measured in degrees. +     */
+    void renderUtmExceptions( GeoPainter *painter,
+                              const GeoDataLatLonAltBox& viewLatLonAltBox,
+                              qreal step,
+                              qreal northPolarGap, qreal southPolarGap,
+                              const QString & label,
+                              LabelPositionFlags labelPositionFlags
+                             );
+
+    /**
      * @brief Maps the number of coordinate lines per 360 deg against the globe \
                radius on the screen.
      * @param notation Determines whether the graticule is according to the DMS or \
                Decimal system.
      */


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic