Skip to content

Commit 9c0eda3

Browse files
author
mhugent
committedDec 6, 2009
Fix for bug 2188. Provider has the possibility to announce that it handles 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

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed
 

‎python/core/qgsvectordataprovider.sip

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,4 +275,8 @@ class QgsVectorDataProvider : QgsDataProvider
275275
*/
276276
void enableGeometrylessFeatures(bool fetch);
277277

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

‎src/app/qgisapp.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4332,6 +4332,13 @@ void QgisApp::mergeSelectedFeatures()
43324332
return;
43334333
}
43344334

4335+
QgsVectorDataProvider* dp = vl->dataProvider();
4336+
bool providerChecksTypeStrictly = true;
4337+
if ( dp )
4338+
{
4339+
providerChecksTypeStrictly = dp->doesStrictFeatureTypeCheck();
4340+
}
4341+
43354342
//get selected feature ids (as a QSet<int> )
43364343
const QgsFeatureIds& featureIdSet = vl->selectedFeaturesIds();
43374344
if ( featureIdSet.size() < 2 )
@@ -4351,7 +4358,7 @@ void QgisApp::mergeSelectedFeatures()
43514358
//make a first geometry union and notify the user straight away if the union geometry type does not match the layer one
43524359
QGis::WkbType originalType = vl->wkbType();
43534360
QGis::WkbType newType = unionGeom->wkbType();
4354-
if ( unionGeom->wkbType() != vl->wkbType() )
4361+
if ( providerChecksTypeStrictly && unionGeom->wkbType() != vl->wkbType() )
43554362
{
43564363
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" ) );
43574364
delete unionGeom;
@@ -4387,7 +4394,7 @@ void QgisApp::mergeSelectedFeatures()
43874394

43884395
originalType = vl->wkbType();
43894396
newType = unionGeom->wkbType();
4390-
if ( unionGeom->wkbType() != vl->wkbType() )
4397+
if ( providerChecksTypeStrictly && unionGeom->wkbType() != vl->wkbType() )
43914398
{
43924399
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" ) );
43934400
delete unionGeom;

‎src/core/qgsvectordataprovider.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
7171
/** DEPRECATED - do not use */
7272
RandomSelectGeometryAtId = 1 << 10,
7373
/** DEPRECATED - do not use */
74-
SequentialSelectGeometryAtId = 1 << 11
74+
SequentialSelectGeometryAtId = 1 << 11,
7575
};
7676

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

346+
/** Returns true if the provider is strict about the type of inserted features
347+
(e.g. no multipolygon in a polygon layer)
348+
@note: added in version 1.4*/
349+
virtual bool doesStrictFeatureTypeCheck() const { return true;}
350+
346351
protected:
347352
QVariant convertValue( QVariant::Type type, QString value );
348353

‎src/providers/ogr/qgsogrprovider.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ class QgsOgrProvider : public QgsVectorDataProvider
233233
*/
234234
QString description() const;
235235

236+
/** Returns true if the provider is strict about the type of inserted features
237+
(e.g. no multipolygon in a polygon layer)
238+
@note: added in version 1.4*/
239+
virtual bool doesStrictFeatureTypeCheck() const { return false;}
240+
236241
protected:
237242
/** loads fields from input file to member attributeFields */
238243
void loadFields();

0 commit comments

Comments
 (0)
Please sign in to comment.