Skip to content

Commit ce99b8e

Browse files
committedJun 29, 2015
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. (cherry picked from commit 8289891)
1 parent 3ed1ae4 commit ce99b8e

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6208,12 +6208,13 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer )
62086208
// convert geometry to match destination layer
62096209
QGis::GeometryType destType = pasteVectorLayer->geometryType();
62106210
bool destIsMulti = QGis::isMultiType( pasteVectorLayer->wkbType() );
6211-
if ( pasteVectorLayer->storageType() == "ESRI Shapefile" && destType != QGis::Point )
6211+
if ( pasteVectorLayer->dataProvider() &&
6212+
!pasteVectorLayer->dataProvider()->doesStrictFeatureTypeCheck() )
62126213
{
6213-
// force destination to multi if shapefile if it's not a point file
6214-
// Should we really force anything here? Isn't it better to just transform?
6214+
// force destination to multi if provider doesn't do a feature strict check
62156215
destIsMulti = true;
62166216
}
6217+
62176218
if ( destType != QGis::UnknownGeometry )
62186219
{
62196220
QgsGeometry* newGeometry = featureIt->geometry()->convertToType( destType, destIsMulti );

‎src/providers/ogr/qgsogrprovider.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,6 +2526,12 @@ void QgsOgrProvider::recalculateFeatureCount()
25262526
}
25272527
}
25282528

2529+
bool QgsOgrProvider::doesStrictFeatureTypeCheck() const
2530+
{
2531+
// FIXME probably other drivers too...
2532+
return ogrDriverName != "ESRI Shapefile" || geomType == wkbPoint;
2533+
}
2534+
25292535
OGRwkbGeometryType QgsOgrProvider::ogrWkbSingleFlatten( OGRwkbGeometryType type )
25302536
{
25312537
type = wkbFlatten( type );

‎src/providers/ogr/qgsogrprovider.h

Lines changed: 3 additions & 3 deletions
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)
Please sign in to comment.