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

List:       kde-commits
Subject:    [marble] src/plugins/runner/shp: In ShpRunner, for shapeType = SHPT_POLYGON, set Geometry of placema
From:       Torsten Rahn <rahn () kde ! org>
Date:       2014-08-09 18:01:22
Message-ID: E1XGAxG-0006e5-Da () scm ! kde ! org
[Download RAW message or body]

Git commit e6166aeab44c45d131a6e0d7100302812ae233d1 by Torsten Rahn, on behalf of Abhinav Gangwar.
Committed on 09/08/2014 at 17:53.
Pushed by rahn into branch 'master'.

In ShpRunner, for shapeType = SHPT_POLYGON, set Geometry of placemark to multi
geometry only when there are more than one polygons.

REVIEW: 119353

M  +13   -2    src/plugins/runner/shp/ShpRunner.cpp

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

diff --git a/src/plugins/runner/shp/ShpRunner.cpp b/src/plugins/runner/shp/ShpRunner.cpp
index 2e15688..53cb1d2 100644
--- a/src/plugins/runner/shp/ShpRunner.cpp
+++ b/src/plugins/runner/shp/ShpRunner.cpp
@@ -157,6 +157,7 @@ void ShpRunner::parseFile( const QString &fileName, DocumentRole role = UnknownD
                     bool isRingClockwise = false;
                     GeoDataMultiGeometry *multigeom = new GeoDataMultiGeometry;
                     GeoDataPolygon *poly = 0;
+                    int polygonCount = 0;
                     for( int j=0; j<shape->nParts; ++j ) {
                         GeoDataLinearRing ring;
                         int itStart = shape->panPartStart[j];
@@ -169,8 +170,11 @@ void ShpRunner::parseFile( const QString &fileName, DocumentRole role = UnknownD
                         isRingClockwise = ring.isClockwise();
                         if ( j == 0 || isRingClockwise ) {
                             poly = new GeoDataPolygon;
+                            ++polygonCount;
                             poly->setOuterBoundary( ring );
-                            multigeom->append( poly );
+                            if ( polygonCount > 1 ) {
+                                multigeom->append( poly );
+                            }
                         }
                         else {
                             poly->appendInnerBoundary( ring );
@@ -178,7 +182,14 @@ void ShpRunner::parseFile( const QString &fileName, DocumentRole role = UnknownD
                         // TODO: outer boundary per SHP spec is for the clockwise ring
                         // and inner holes are anticlockwise
                     }
-                    placemark->setGeometry( multigeom );
+                    if ( polygonCount > 1 ) {
+                        placemark->setGeometry( multigeom );
+                    }
+                    else {
+                        placemark->setGeometry( poly );
+                        delete multigeom;
+                        multigeom = 0;
+                    }
                     mDebug() << "donut " << placemark->name() << " " << shape->nParts;
 
                 } else {
[prev in list] [next in list] [prev in thread] [next in thread] 

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