Skip to content

Commit

Permalink
Fix regression when adding feature without geom #46687
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Mar 17, 2022
1 parent 180ae3b commit ff87afd
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions src/gui/qgsmaptooldigitizefeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

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() ) ).arg( QgsWkbTypes::displayString( layerWKBType ) ), Qgis::MessageLevel::Warning );
return;
}
const QgsWkbTypes::Type layerWKBType = vlayer->wkbType();

QgsGeometry layerGeometry;

if ( mCheckGeometryType )
{
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 );
Expand Down

0 comments on commit ff87afd

Please sign in to comment.