Skip to content
Permalink
Browse files
SL provider: convert geometries to multipart when necessary (fix #6257)
  • Loading branch information
brushtyler committed Dec 5, 2012
1 parent e169735 commit 1bde6c58df3ed73e200e98809ab508e6d6b62d38
@@ -3720,6 +3720,49 @@ void QgsSpatiaLiteProvider::uniqueValues( int index, QList < QVariant > &uniqueV
return;
}

QString QgsSpatiaLiteProvider::geomParam() const
{
QString geometry;

bool forceMulti = false;

switch ( geometryType() )
{
case QGis::WKBPoint:
case QGis::WKBLineString:
case QGis::WKBPolygon:
case QGis::WKBPoint25D:
case QGis::WKBLineString25D:
case QGis::WKBPolygon25D:
case QGis::WKBUnknown:
case QGis::WKBNoGeometry:
forceMulti = false;
break;

case QGis::WKBMultiPoint:
case QGis::WKBMultiLineString:
case QGis::WKBMultiPolygon:
case QGis::WKBMultiPoint25D:
case QGis::WKBMultiLineString25D:
case QGis::WKBMultiPolygon25D:
forceMulti = true;
break;
}

if ( forceMulti )
{
geometry += "ST_Multi(";
}

geometry += QString( "GeomFromWKB(?, %2)" ).arg( mSrid );

if ( forceMulti )
{
geometry += ")";
}

return geometry;
}

bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
{
@@ -3750,7 +3793,7 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
if ( !mGeometryColumn.isNull() )
{
sql += separator + quotedIdentifier( mGeometryColumn );
values += separator + QString( "GeomFromWKB(?, %2)" ).arg( mSrid );
values += separator + geomParam();
separator = ",";
}

@@ -286,6 +286,8 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
/** convert a QgsField to work with SL */
static bool convertField( QgsField &field );

QString geomParam() const;

QgsFieldMap attributeFields;
/**
* Flag indicating if the layer data source is a valid SpatiaLite layer

0 comments on commit 1bde6c5

Please sign in to comment.