Bug 300161

Summary: Polygon handling for ESRI shapefiles
Product: [Applications] marble Reporter: Dennis Nienhüser <nienhueser>
Component: generalAssignee: marble-bugs
Status: RESOLVED FIXED    
Severity: normal CC: agangwar, simonandric5
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
URL: http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/10m-admin-0-countries.zip
Latest Commit: Version Fixed In:

Description Dennis Nienhüser 2012-05-16 19:55:36 UTC
I used the shp plugin to open ne_10m_admin_0_countries.shp from http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/10m-admin-0-countries.zip
Many countries seem to be missing in the rendering. Looking into the issue I think one problem is the handling of polygons, which according to shp spec can have several parts and inner holes. As noted in the code already this is not respected correctly by the plugin at the moment.

I tried to work around that using a placemark with a MultiGeometry, treating each part as an outer boundary, but still many polygons were not rendered.

Then I used the even more hackish approach below, i.e. one new placemark for each part. Much more polygons were rendered now, but still some seem missing (e.g. spain).

diff --git a/src/plugins/runner/shp/ShpRunner.cpp b/src/plugins/runner/shp/ShpRunner.cpp
index cd720bc..683b319 100644
--- a/src/plugins/runner/shp/ShpRunner.cpp
+++ b/src/plugins/runner/shp/ShpRunner.cpp
@@ -128,8 +128,8 @@ void ShpRunner::parseFile( const QString &fileName, DocumentRole role = UnknownD
 
             case SHPT_POLYGON: {
                 if ( shape->nParts != 1 ) {
-                    GeoDataPolygon *poly = new GeoDataPolygon;
                     for( int j=0; j<shape->nParts-1; ++j ) {
+                        GeoDataPolygon *poly = new GeoDataPolygon;
                         GeoDataLinearRing ring;
                         for( int k=shape->panPartStart[j]; k<shape->panPartStart[j+1]; ++k ) {
                             ring.append( GeoDataCoordinates(
@@ -138,13 +138,15 @@ 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
-                        if ( j==0 ) {
+                        if ( j==0 || true ) {
                             poly->setOuterBoundary( ring );
+                            placemark->setGeometry( poly );
+                            placemark = new GeoDataPlacemark;
+                            document->append(placemark);
                         } else {
                             poly->appendInnerBoundary( ring );
                         }
                     }
-                    placemark->setGeometry( poly );
                     mDebug() << "donut " << placemark->name() << " " << shape->nParts;
 
                 } else {


Reproducible: Always
Comment 1 Dennis Nienhüser 2014-04-10 14:22:30 UTC
Please have a look at the ShpRunner.cpp git history for recent changes that might invalidate some of the things said above.
Comment 2 Abhinav Gangwar 2015-09-25 15:43:46 UTC
Fixed !