Bug 300161 - Polygon handling for ESRI shapefiles
Summary: Polygon handling for ESRI shapefiles
Status: RESOLVED FIXED
Alias: None
Product: marble
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: marble-bugs
URL: http://www.naturalearthdata.com/http/...
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-16 19:55 UTC by Dennis Nienhüser
Modified: 2015-10-15 17:15 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 !