Skip to content
Permalink
Browse files

Move information about strict provider geometry type check on point s…

…hapefiles

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.
  • Loading branch information
jef-n committed Jun 9, 2015
1 parent 920f2eb commit 8289891b78953581f22e944565e0e1c9678a09c3
Showing with 13 additions and 6 deletions.
  1. +4 −3 src/app/qgisapp.cpp
  2. +6 −0 src/providers/ogr/qgsogrprovider.cpp
  3. +3 −3 src/providers/ogr/qgsogrprovider.h
@@ -6296,12 +6296,13 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer )
// convert geometry to match destination layer
QGis::GeometryType destType = pasteVectorLayer->geometryType();
bool destIsMulti = QGis::isMultiType( pasteVectorLayer->wkbType() );
if ( pasteVectorLayer->storageType() == "ESRI Shapefile" && destType != QGis::Point )
if ( pasteVectorLayer->dataProvider() &&
!pasteVectorLayer->dataProvider()->doesStrictFeatureTypeCheck() )
{
// force destination to multi if shapefile if it's not a point file
// Should we really force anything here? Isn't it better to just transform?
// force destination to multi if provider doesn't do a feature strict check
destIsMulti = true;
}

if ( destType != QGis::UnknownGeometry )
{
QgsGeometry* newGeometry = featureIt->constGeometry()->convertToType( destType, destIsMulti );
@@ -2530,6 +2530,12 @@ void QgsOgrProvider::recalculateFeatureCount()
QgsOgrConnPool::instance()->invalidateConnections( filePath() );
}

bool QgsOgrProvider::doesStrictFeatureTypeCheck() const
{
// FIXME probably other drivers too...
return ogrDriverName != "ESRI Shapefile" || geomType == wkbPoint;
}

OGRwkbGeometryType QgsOgrProvider::ogrWkbSingleFlatten( OGRwkbGeometryType type )
{
type = wkbFlatten( type );
@@ -243,9 +243,9 @@ class QgsOgrProvider : public QgsVectorDataProvider
QString description() const override;

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

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

0 comments on commit 8289891

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