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

List:       kde-commits
Subject:    [marble] /: CylindricalProjection: close polygons which circle around one pole
From:       Thibaut Gridel <tgridel () free ! fr>
Date:       2013-03-11 22:16:53
Message-ID: 20130311221653.C6403A6103 () git ! kde ! org
[Download RAW message or body]

Git commit d80173b5a133d113ae2482b3fd9194442964e6f5 by Thibaut Gridel.
Committed on 20/02/2013 at 21:03.
Pushed by tgridel into branch 'master'.

CylindricalProjection: close polygons which circle around one pole

M  +12   -7    src/lib/Projections/CylindricalProjection.cpp
M  +4    -2    tests/ViewportParamsTest.cpp

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

diff --git a/src/lib/Projections/CylindricalProjection.cpp \
b/src/lib/Projections/CylindricalProjection.cpp index f7f8105..be9d52a 100644
--- a/src/lib/Projections/CylindricalProjection.cpp
+++ b/src/lib/Projections/CylindricalProjection.cpp
@@ -206,8 +206,18 @@ bool CylindricalProjectionPrivate::lineStringToPolygon( const \
GeoDataLineString  }
     }
 
-    if ( polygons.last()->size() <= 1 ){
-        polygons.pop_back(); // Clean up "unused" empty polygon instances
+    GeoDataLatLonAltBox box = lineString.latLonAltBox();
+    if( box.width() == 2*M_PI ) {
+        QPolygonF *poly = polygons.last();
+        if( box.containsPole( NorthPole ) ) {
+            poly->push_front( QPointF( poly->first().x(), 0 ) );
+            poly->push_back( QPointF( poly->last().x(), 0 ) );
+            poly->push_back( QPointF( poly->first().x(), 0 ) );
+        } else {
+            poly->push_front( QPointF( poly->first().x(), viewport->height() ) );
+            poly->push_back( QPointF( poly->last().x(), viewport->height() ) );
+            poly->push_back( QPointF( poly->first().x(), viewport->height() ) );
+        }
     }
 
     repeatPolygons( viewport, polygons );
@@ -220,11 +230,6 @@ void CylindricalProjectionPrivate::repeatPolygons( const \
ViewportParams *viewpor  {
     Q_Q( const CylindricalProjection );
 
-    if ( !q->repeatX() ) {
-        // The projection doesn't allow repeats in direction of the x-axis
-        return;
-    }
-    
     bool globeHidesPoint = false;
 
     qreal xEast = 0;
diff --git a/tests/ViewportParamsTest.cpp b/tests/ViewportParamsTest.cpp
index 8135adf..251a40e 100644
--- a/tests/ViewportParamsTest.cpp
+++ b/tests/ViewportParamsTest.cpp
@@ -296,8 +296,8 @@ void ViewportParamsTest::geoDataLinearRing_data()
 
     GeoDataLinearRing aroundSPoleRing;
     aroundSPoleRing << GeoDataCoordinates(-175, -65, 0, deg )
-                 << GeoDataCoordinates(115, -70, 0, deg )
-                    << GeoDataCoordinates(105, -75, 0, deg );
+                 << GeoDataCoordinates(-55, -70, 0, deg )
+                    << GeoDataCoordinates(65, -75, 0, deg );
 
     Projection projection = Mercator;
 
@@ -417,6 +417,8 @@ void ViewportParamsTest::geoDataLinearRing()
         // at least 3 points in one poly
         QVERIFY( poly->size() > 2 );
         QPointF oldCoord = poly->first();
+        // polygon comes back to same point
+        QVERIFY( poly->isClosed() );
         poly->pop_front();
 
         foreach(const QPointF &coord, *poly) {


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

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