Skip to content
Permalink
Browse files
Fix regression when adding feature without geom #46687
  • Loading branch information
Gustry authored and 3nids committed Apr 4, 2022
1 parent 5b6b43e commit 2282a05113c2e8fe397653d819ba4be879173e25
Showing 1 changed file with 22 additions and 18 deletions.
@@ -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<QgsGeometry> 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<QgsGeometry> 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 );

0 comments on commit 2282a05

Please sign in to comment.