Skip to content
Permalink
Browse files

allow saving single geometries as multi geometries

  • Loading branch information
jef-n committed Nov 5, 2012
1 parent 214b593 commit 368146c17720c74b553bad4e3c0661b5e84eff3c
Showing with 29 additions and 1 deletion.
  1. +21 −0 src/core/qgis.h
  2. +7 −0 src/core/qgsvectorfilewriter.cpp
  3. +1 −1 src/providers/postgres/qgspostgresprovider.cpp
@@ -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,
@@ -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
@@ -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 )
{

0 comments on commit 368146c

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