Skip to content

Commit 8289891

Browse files
committed
Move information about strict provider geometry type check on point shapefiles
to OGR provider and make use of it when pasting & merging features (fixes #12488, refs #10672, refs #10747) TODO: check if other OGR drivers have similar restrictions.
1 parent 920f2eb commit 8289891

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/app/qgisapp.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -6296,12 +6296,13 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer )
62966296
// convert geometry to match destination layer
62976297
QGis::GeometryType destType = pasteVectorLayer->geometryType();
62986298
bool destIsMulti = QGis::isMultiType( pasteVectorLayer->wkbType() );
6299-
if ( pasteVectorLayer->storageType() == "ESRI Shapefile" && destType != QGis::Point )
6299+
if ( pasteVectorLayer->dataProvider() &&
6300+
!pasteVectorLayer->dataProvider()->doesStrictFeatureTypeCheck() )
63006301
{
6301-
// force destination to multi if shapefile if it's not a point file
6302-
// Should we really force anything here? Isn't it better to just transform?
6302+
// force destination to multi if provider doesn't do a feature strict check
63036303
destIsMulti = true;
63046304
}
6305+
63056306
if ( destType != QGis::UnknownGeometry )
63066307
{
63076308
QgsGeometry* newGeometry = featureIt->constGeometry()->convertToType( destType, destIsMulti );

src/providers/ogr/qgsogrprovider.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -2530,6 +2530,12 @@ void QgsOgrProvider::recalculateFeatureCount()
25302530
QgsOgrConnPool::instance()->invalidateConnections( filePath() );
25312531
}
25322532

2533+
bool QgsOgrProvider::doesStrictFeatureTypeCheck() const
2534+
{
2535+
// FIXME probably other drivers too...
2536+
return ogrDriverName != "ESRI Shapefile" || geomType == wkbPoint;
2537+
}
2538+
25332539
OGRwkbGeometryType QgsOgrProvider::ogrWkbSingleFlatten( OGRwkbGeometryType type )
25342540
{
25352541
type = wkbFlatten( type );

src/providers/ogr/qgsogrprovider.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ class QgsOgrProvider : public QgsVectorDataProvider
243243
QString description() const override;
244244

245245
/** Returns true if the provider is strict about the type of inserted features
246-
(e.g. no multipolygon in a polygon layer)
247-
*/
248-
virtual bool doesStrictFeatureTypeCheck() const override { return false;}
246+
(e.g. no multipolygon in a polygon layer)
247+
*/
248+
virtual bool doesStrictFeatureTypeCheck() const override;
249249

250250
/** return OGR geometry type */
251251
static OGRwkbGeometryType getOgrGeomType( OGRLayerH ogrLayer );

0 commit comments

Comments
 (0)