Skip to content

Commit

Permalink
allow saving single geometries as multi geometries
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Nov 5, 2012
1 parent 214b593 commit 368146c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/core/qgis.h
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions src/core/qgsvectorfilewriter.cpp
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -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 )
{
Expand Down

0 comments on commit 368146c

Please sign in to comment.