Skip to content

Commit

Permalink
[ogr] return multipart geometry for multipart datasets in feature ite…
Browse files Browse the repository at this point in the history
…rator
  • Loading branch information
nirvn committed Jul 10, 2017
1 parent 1aa0091 commit 5b149fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/providers/ogr/qgsogrfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "qgsmessagelog.h"
#include "qgssettings.h"
#include "qgsexception.h"
#include "qgswkbtypes.h"

#include <QTextCodec>
#include <QFile>
Expand Down Expand Up @@ -334,7 +335,15 @@ bool QgsOgrFeatureIterator::readFeature( OGRFeatureH fet, QgsFeature &feature )

if ( geom )
{
feature.setGeometry( QgsOgrUtils::ogrGeometryToQgsGeometry( geom ) );
QgsGeometry g = QgsOgrUtils::ogrGeometryToQgsGeometry( geom );

// Insure that multipart datasets return multipart geometry
if ( QgsWkbTypes::isMultiType( mSource->mWkbType ) && !g.isMultipart() )
{
g.convertToMultiType();
}

feature.setGeometry( g );
}
else
feature.clearGeometry();
Expand Down Expand Up @@ -390,6 +399,7 @@ QgsOgrFeatureSource::QgsOgrFeatureSource( const QgsOgrProvider *p )
, mOgrGeometryTypeFilter( QgsOgrProvider::ogrWkbSingleFlatten( p->mOgrGeometryTypeFilter ) )
, mDriverName( p->ogrDriverName )
, mCrs( p->crs() )
, mWkbType( p->wkbType() )
{
for ( int i = ( p->mFirstFieldIsFid ) ? 1 : 0; i < mFields.size(); i++ )
mFieldsWithoutFid.append( mFields.at( i ) );
Expand Down
1 change: 1 addition & 0 deletions src/providers/ogr/qgsogrfeatureiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class QgsOgrFeatureSource : public QgsAbstractFeatureSource
OGRwkbGeometryType mOgrGeometryTypeFilter;
QString mDriverName;
QgsCoordinateReferenceSystem mCrs;
QgsWkbTypes::Type mWkbType = QgsWkbTypes::Unknown;

friend class QgsOgrFeatureIterator;
friend class QgsOgrExpressionCompiler;
Expand Down

0 comments on commit 5b149fb

Please sign in to comment.