[Marble-bugs] [Bug 300161] New: Polygon handling for ESRI shapefiles

Dennis Nienhüser earthwings at gentoo.org
Wed May 16 19:55:36 UTC 2012


https://bugs.kde.org/show_bug.cgi?id=300161

            Bug ID: 300161
          Severity: normal
               URL: http://www.naturalearthdata.com/http//www.naturalearth
                    data.com/download/10m/cultural/10m-admin-0-countries.z
                    ip
           Version: unspecified
          Priority: NOR
          Assignee: marble-bugs at kde.org
           Summary: Polygon handling for ESRI shapefiles
    Classification: Unclassified
                OS: Linux
          Reporter: earthwings at gentoo.org
          Hardware: Other
            Status: NEW
         Component: general
           Product: marble

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

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Marble-bugs mailing list