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

List:       kde-commits
Subject:    KDE/kdeedu/marble
From:       Carlos Licea <carlos_licea () hotmail ! com>
Date:       2008-02-13 18:52:27
Message-ID: 1202928747.230534.14941.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 774651 by clicea:

2008-01-28  Carlos Licea  <carlos.licea@kdemail.net>
    *src/lib/MeasureTool.cpp: continue trying to fix the interpolation of the measure \
of two points which crosses the dateline. Not solved yet, although I still have to \
                deeply analize it.
    *src/lib/MarbleMap.cpp: added Mercator case to screenCoordinates and \
                geoCoordinates.
    *src/lib/TextureColorizer.cpp: make it work for the Mercator projection.
    *src/lib/FlatScanlineTextureMapper.cpp: let it work in the mercator projection \
                checking what projection are we painting, Mercator or \
                Equirectangular.
    *global.h: add Mercator projection to the enum Projection.
    *src/lib/MarbleModel.cpp: added the Mercator projection as an option for the \
texture.


 M  +13 -0     ChangeLog  
 M  +3 -7      src/lib/FlatScanlineTextureMapper.cpp  
 M  +44 -1     src/lib/MarbleMap.cpp  
 M  +4 -0      src/lib/MarbleModel.cpp  
 M  +4 -3      src/lib/MeasureTool.cpp  
 M  +5 -2      src/lib/TextureColorizer.cpp  
 M  +2 -2      src/lib/global.h  


--- trunk/KDE/kdeedu/marble/ChangeLog #774650:774651
@@ -1,3 +1,16 @@
+2008-01-28  Carlos Licea  <carlos.licea@kdemail.net>
+    *src/lib/MeasureTool.cpp: continue trying to fix the interpolation of the
+    measure of two points which crosses the dateline. Not solved yet,
+    although I still have to deeply analize it.
+    *src/lib/MarbleMap.cpp: added Mercator case to screenCoordinates and
+    geoCoordinates.
+    *src/lib/TextureColorizer.cpp: make it work for the Mercator projection.
+    *src/lib/FlatScanlineTextureMapper.cpp: let it work in the mercator projection
+    checking what projection are we painting, Mercator or Equirectangular.
+    *global.h: add Mercator projection to the enum Projection.
+    *src/lib/MarbleModel.cpp: added the Mercator projection as an option
+    for the texture.
+
 2008-02-12  Inge Wallin  <inge@lysator.liu.se>
 
 	Fix class documentation after the split widget -> widget + map
--- trunk/KDE/kdeedu/marble/src/lib/FlatScanlineTextureMapper.cpp #774650:774651
@@ -21,8 +21,6 @@
 #include "TextureTile.h"
 #include "TileLoader.h"
 
-// #define MERCATOR
-
 FlatScanlineTextureMapper::FlatScanlineTextureMapper( TileLoader *tileLoader, \
QObject * parent )  : AbstractScanlineTextureMapper( tileLoader, parent )
 {
@@ -78,14 +76,12 @@
     float leftLon = + centerLon - ( rad2Pixel * m_imageWidth / 2 );
     while ( leftLon < -M_PI ) leftLon += 2 * M_PI;
     while ( leftLon >  M_PI ) leftLon -= 2 * M_PI;
-
     // Paint the map.
     for ( int y = yPaintedTop ;y < yPaintedBottom; ++y ) {
-#ifdef MERCATOR
-            lat = atan( sinh( ((m_imageHeight / 2 + yCenterOffset) - y) / (double)(2 \
                * radius) * M_PI ) );
-#else
+        if( viewParams->m_projection == Equirectangular )
             lat = M_PI/2 - (y - yTop )* rad2Pixel;
-#endif
+        else if( viewParams->m_projection == Mercator )
+            lat = atan( sinh( ((m_imageHeight / 2 + yCenterOffset) - y) / (double)(2 \
* radius) * M_PI ) );  m_scanLine = (QRgb*)( canvasImage->scanLine( y ) );
         lon = leftLon;
 
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.cpp #774650:774651
@@ -7,6 +7,7 @@
 //
 // Copyright 2006-2007 Torsten Rahn <tackat@kde.org>"
 // Copyright 2007      Inge Wallin  <ingwa@kde.org>"
+// Copyright 2008      Carlos Licea <carlos.licea@kdemail.net>
 //
 
 #include "MarbleMap.h"
@@ -684,6 +685,7 @@
      }
  
      case Equirectangular:
+    {
          // Calculate translation of center point
          double centerLon, centerLat;
          d->m_viewParams.centerCoordinates(centerLon, centerLat);
@@ -691,9 +693,23 @@
  
          x = (int)( width() / 2 + ( lon * DEG2RAD + centerLon ) * rad2Pixel );
          y = (int)( height() / 2 + ( lat * DEG2RAD + centerLat ) * rad2Pixel );
+
+         return true;
+    }
+
+     case Mercator:
+    {
+         // Calculate translation of center point
+         double centerLon, centerLat;
+         d->m_viewParams.centerCoordinates(centerLon, centerLat);
+         double rad2Pixel = 2*d->m_viewParams.m_radius / M_PI;
  
+         x = (int)( width() / 2 + ( lon * DEG2RAD + centerLon ) * rad2Pixel );
+         y = (int)( log( tan(lat) + 1 / cos(lat) ));
+
          return true;
-     }
+    }
+    }
  
      return false;
 }
@@ -728,6 +744,7 @@
         break;
 
     case Equirectangular:
+    {
         // Calculate translation of center point
         double centerLon, centerLat;
         d->m_viewParams.centerCoordinates(centerLon, centerLat);
@@ -750,7 +767,33 @@
         }
         break;
     }
+    case Mercator:
+    {
+        // Calculate translation of center point
+        double centerLon, centerLat;
+        d->m_viewParams.centerCoordinates(centerLon, centerLat);
 
+        int yCenterOffset =  (int)((double)(2*radius()) / M_PI * centerLat);
+        int yTop = imageHalfHeight - radius() + yCenterOffset;
+        int yBottom = yTop + 2*radius();
+        if ( y >= yTop && y < yBottom ) {
+            int const xPixels = x - imageHalfWidth;
+            int const yPixels = y - imageHalfHeight;
+
+            double const pixel2rad = M_PI / (2 * radius());
+
+            lat = atan( sinh( ((imageHalfHeight + yCenterOffset) - y) / (double)(2 * \
radius()) * M_PI ) ); +            lon = + xPixels * pixel2rad + centerLon;
+
+            while( lon > M_PI ) lon -= 2*M_PI;
+            while( lon < -M_PI ) lon += 2*M_PI;
+
+            noerr = true;
+        }
+        break;
+    }
+    }
+
     if ( unit == GeoDataPoint::Degree ) {
         lon *= RAD2DEG;
         lat *= RAD2DEG;
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #774650:774651
@@ -269,6 +269,10 @@
             case Equirectangular:
                 d->m_texmapper = new FlatScanlineTextureMapper( d->m_tileLoader, \
this );  break;
+            case Mercator:
+                d->m_texmapper = new FlatScanlineTextureMapper( d->m_tileLoader, \
this ); +                break;
+
         }
 //         else
 //             d->m_texmapper->setMapTheme( "maps/earth/"
--- trunk/KDE/kdeedu/marble/src/lib/MeasureTool.cpp #774650:774651
@@ -7,6 +7,7 @@
 //
 // Copyright 2006-2007 Torsten Rahn <tackat@kde.org>"
 // Copyright 2007      Inge Wallin  <ingwa@kde.org>"
+// Copyright 2007-2008 Carlos Licea <carlos.licea@kdemail.net>
 //
 
 #include "MeasureTool.h"
@@ -359,9 +360,9 @@
         if( previousSign != currentSign && fabs(previousLon) + fabs(lon) > M_PI) {
             //FIXME:Fix the interpolation the problem is i think the (x - previousX) \
as is too wide  //          It's based on y = y1 + (y2-y1)/(x2-x1)*(x-x1)
-//             interpolatedY= previousY + ( y - previousY ) /
-//                             ( x - previousX ) *
-//                                 ( imgrx + previousSign*2*radius - previousX );
+//            interpolatedY= previousY + ( y - previousY ) /
+//                                       ( 4*radius - fabs( x - previousX ) ) *
+//                                ( imgwidth / 2 - m_rad2Pixel * (m_centerLon - lon) \
+ previousSign*2*radius - previousX );  //This is temporal just to be able to commit
             interpolatedY= ( y + previousY ) / 2;
             distancePath << QPointF( imgwidth / 2 - m_centerLon * m_rad2Pixel
--- trunk/KDE/kdeedu/marble/src/lib/TextureColorizer.cpp #774650:774651
@@ -7,6 +7,7 @@
 //
 // Copyright 2006-2007 Torsten Rahn <tackat@kde.org>"
 // Copyright 2007      Inge Wallin  <ingwa@kde.org>"
+// Copyright 2008      Carlos Licea <carlos.licea@kdemail.net>
 //
 
 #include "TextureColorizer.h"
@@ -56,12 +57,14 @@
     const bool showRelief = viewParams->m_showRelief;
 
     if ( radius * radius > imgradius
-         || viewParams->m_projection == Equirectangular )
+         || viewParams->m_projection == Equirectangular
+         || viewParams->m_projection == Mercator )
     {
         int yTop = 0;
         int yBottom = imgheight;
 
-        if( viewParams->m_projection == Equirectangular ) {
+        if( viewParams->m_projection == Equirectangular
+            || viewParams->m_projection == Mercator ) {
 
             // Calculate translation of center point
             double centerLon, centerLat;
--- trunk/KDE/kdeedu/marble/src/lib/global.h #774650:774651
@@ -22,8 +22,8 @@
 
 enum Projection { 
     Spherical,
-    Equirectangular
-    // Mercator
+    Equirectangular,
+    Mercator
 };
 
 const double DEG2RAD = M_PI / 180.0;


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

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