Skip to content
Permalink
Browse files

Fix for bug 2188. Provider has the possibility to announce that it ha…

…ndles geometry type handling not very strict, e.g. inserting multipolygon in polygon layers

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12340 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Dec 6, 2009
1 parent e5d3471 commit 9c0eda377d7d9534f989d8639cb687e33b3efb6c
@@ -275,4 +275,8 @@ class QgsVectorDataProvider : QgsDataProvider
*/
void enableGeometrylessFeatures(bool fetch);

/** Returns true if the provider is strict about the type of inserted features
(e.g. no multipolygon in a polygon layer)
@note: added in version 1.4*/
bool doesStrictFeatureTypeCheck() const;
};
@@ -4332,6 +4332,13 @@ void QgisApp::mergeSelectedFeatures()
return;
}

QgsVectorDataProvider* dp = vl->dataProvider();
bool providerChecksTypeStrictly = true;
if ( dp )
{
providerChecksTypeStrictly = dp->doesStrictFeatureTypeCheck();
}

//get selected feature ids (as a QSet<int> )
const QgsFeatureIds& featureIdSet = vl->selectedFeaturesIds();
if ( featureIdSet.size() < 2 )
@@ -4351,7 +4358,7 @@ void QgisApp::mergeSelectedFeatures()
//make a first geometry union and notify the user straight away if the union geometry type does not match the layer one
QGis::WkbType originalType = vl->wkbType();
QGis::WkbType newType = unionGeom->wkbType();
if ( unionGeom->wkbType() != vl->wkbType() )
if ( providerChecksTypeStrictly && unionGeom->wkbType() != vl->wkbType() )
{
QMessageBox::critical( 0, "Union operation canceled", tr( "The union operation would result in a geometry type that is not compatible with the current layer and therefore is canceled" ) );
delete unionGeom;
@@ -4387,7 +4394,7 @@ void QgisApp::mergeSelectedFeatures()

originalType = vl->wkbType();
newType = unionGeom->wkbType();
if ( unionGeom->wkbType() != vl->wkbType() )
if ( providerChecksTypeStrictly && unionGeom->wkbType() != vl->wkbType() )
{
QMessageBox::critical( 0, "Union operation canceled", tr( "The union operation would result in a geometry type that is not compatible with the current layer and therefore is canceled" ) );
delete unionGeom;
@@ -71,7 +71,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
/** DEPRECATED - do not use */
RandomSelectGeometryAtId = 1 << 10,
/** DEPRECATED - do not use */
SequentialSelectGeometryAtId = 1 << 11
SequentialSelectGeometryAtId = 1 << 11,
};

/** bitmask of all provider's editing capabilities */
@@ -343,6 +343,11 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
*/
const QMap<QString, QVariant::Type> &supportedNativeTypes() const;

/** Returns true if the provider is strict about the type of inserted features
(e.g. no multipolygon in a polygon layer)
@note: added in version 1.4*/
virtual bool doesStrictFeatureTypeCheck() const { return true;}

protected:
QVariant convertValue( QVariant::Type type, QString value );

@@ -233,6 +233,11 @@ class QgsOgrProvider : public QgsVectorDataProvider
*/
QString description() const;

/** Returns true if the provider is strict about the type of inserted features
(e.g. no multipolygon in a polygon layer)
@note: added in version 1.4*/
virtual bool doesStrictFeatureTypeCheck() const { return false;}

protected:
/** loads fields from input file to member attributeFields */
void loadFields();

0 comments on commit 9c0eda3

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