diff --git a/src/gui/qgsmaptooldigitizefeature.cpp b/src/gui/qgsmaptooldigitizefeature.cpp index 51cf7be09d1a..a6d7120fda35 100644 --- a/src/gui/qgsmaptooldigitizefeature.cpp +++ b/src/gui/qgsmaptooldigitizefeature.cpp @@ -73,30 +73,34 @@ void QgsMapToolDigitizeFeature::layerGeometryCaptured( const QgsGeometry &geomet if ( !vlayer ) return; - const QgsWkbTypes::Type layerWKBType = vlayer->wkbType(); - - QgsGeometry layerGeometry; + QgsFeature f( vlayer->fields(), 0 ); - if ( mCheckGeometryType ) + if ( vlayer->isSpatial() ) { - double defaultZ = QgsSettingsRegistryCore::settingsDigitizingDefaultZValue.value(); - double defaultM = QgsSettingsRegistryCore::settingsDigitizingDefaultMValue.value(); - QVector layerGeometries = geometry.coerceToType( layerWKBType, defaultZ, defaultM ); - if ( layerGeometries.count() > 0 ) - layerGeometry = layerGeometries.at( 0 ); + const QgsWkbTypes::Type layerWKBType = vlayer->wkbType(); - if ( layerGeometry.wkbType() != layerWKBType && layerGeometry.wkbType() != QgsWkbTypes::linearType( layerWKBType ) ) + QgsGeometry layerGeometry; + + if ( mCheckGeometryType ) { - emit messageEmitted( tr( "The digitized geometry type (%1) does not correspond to the layer geometry type (%2)." ).arg( QgsWkbTypes::displayString( layerGeometry.wkbType() ) ).arg( QgsWkbTypes::displayString( layerWKBType ) ), Qgis::MessageLevel::Warning ); - return; + double defaultZ = QgsSettingsRegistryCore::settingsDigitizingDefaultZValue.value(); + double defaultM = QgsSettingsRegistryCore::settingsDigitizingDefaultMValue.value(); + QVector layerGeometries = geometry.coerceToType( layerWKBType, defaultZ, defaultM ); + if ( layerGeometries.count() > 0 ) + layerGeometry = layerGeometries.at( 0 ); + + if ( layerGeometry.wkbType() != layerWKBType && layerGeometry.wkbType() != QgsWkbTypes::linearType( layerWKBType ) ) + { + emit messageEmitted( tr( "The digitized geometry type (%1) does not correspond to the layer geometry type (%2)." ).arg( QgsWkbTypes::displayString( layerGeometry.wkbType() ), QgsWkbTypes::displayString( layerWKBType ) ), Qgis::MessageLevel::Warning ); + return; + } } + else + { + layerGeometry = geometry; + } + f.setGeometry( layerGeometry ); } - else - { - layerGeometry = geometry; - } - QgsFeature f( vlayer->fields(), 0 ); - f.setGeometry( layerGeometry ); f.setValid( true ); emit digitizingCompleted( f ); featureDigitized( f );