Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression when adding feature without geom #46687 #47840

Merged
merged 1 commit into from
Apr 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 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 );
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 );
Expand Down