Skip to content
Permalink
Browse files

[ogr] return multipart geometry for multipart datasets in feature ite…

…rator
  • Loading branch information
nirvn committed Jul 10, 2017
1 parent 1aa0091 commit 5b149fb3897c5fe4ba28685b6196b408b3bbbeee
Showing with 12 additions and 1 deletion.
  1. +11 −1 src/providers/ogr/qgsogrfeatureiterator.cpp
  2. +1 −0 src/providers/ogr/qgsogrfeatureiterator.h
@@ -25,6 +25,7 @@
#include "qgsmessagelog.h"
#include "qgssettings.h"
#include "qgsexception.h"
#include "qgswkbtypes.h"

#include <QTextCodec>
#include <QFile>
@@ -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();
@@ -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 ) );
@@ -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;

0 comments on commit 5b149fb

Please sign in to comment.
You can’t perform that action at this time.