diff --git a/src/core/qgis.h b/src/core/qgis.h index e78b0013dfe9..4e9918c74d62 100644 --- a/src/core/qgis.h +++ b/src/core/qgis.h @@ -66,6 +66,27 @@ class CORE_EXPORT QGis WKBMultiPolygon25D, }; + static WkbType flatType( WkbType type ) + { + switch ( type ) + { + case WKBMultiPoint: + return WKBPoint; + case WKBMultiLineString: + return WKBLineString; + case WKBMultiPolygon: + return WKBPolygon; + case WKBMultiPoint25D: + return WKBPoint25D; + case WKBMultiLineString25D: + return WKBLineString25D; + case WKBMultiPolygon25D: + return WKBPolygon25D; + default: + return type; + } + } + enum GeometryType { Point, diff --git a/src/core/qgsvectorfilewriter.cpp b/src/core/qgsvectorfilewriter.cpp index 4d7df1ceec4a..8ee912590ec2 100644 --- a/src/core/qgsvectorfilewriter.cpp +++ b/src/core/qgsvectorfilewriter.cpp @@ -482,6 +482,13 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature ) { // build geometry from WKB QgsGeometry *geom = feature.geometry(); + + // turn single geoemetry to multi geometry if needed + if ( geom && geom->wkbType() != mWkbType && geom->wkbType() == QGis::flatType( mWkbType ) ) + { + geom->convertToMultiType(); + } + if ( geom && geom->wkbType() != mWkbType ) { // there's a problem when layer type is set as wkbtype Polygon diff --git a/src/providers/postgres/qgspostgresprovider.cpp b/src/providers/postgres/qgspostgresprovider.cpp index fa030ee68727..5ba35aabf891 100644 --- a/src/providers/postgres/qgspostgresprovider.cpp +++ b/src/providers/postgres/qgspostgresprovider.cpp @@ -683,7 +683,7 @@ QString QgsPostgresProvider::pkParamWhereClause( int offset, const char *alias ) QString whereClause; QString aliased; - if ( alias ) aliased = QString("%1.").arg( alias ); + if ( alias ) aliased = QString( "%1." ).arg( alias ); switch ( mPrimaryKeyType ) {