Skip to content

Commit

Permalink
Use default Z/M values instead of NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
domi4484 committed Jan 7, 2023
1 parent e3b12a6 commit 720082a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/app/vertextool/qgsvertextool.cpp
Expand Up @@ -2190,19 +2190,19 @@ void QgsVertexTool::moveVertex( const QgsPointXY &mapPoint, const QgsPointLocato
QgsAbstractGeometry *geomTmp = geom.constGet()->clone();

// If moving point is not 3D but destination yes, check if it can be promoted
if ( layerPoint.is3D() && !geom.vertexAt( dragVertexId ).is3D() && QgsWkbTypes::hasZ( dragLayer->wkbType() ) )
if ( layerPoint.is3D() && !geomTmp->is3D() && QgsWkbTypes::hasZ( dragLayer->wkbType() ) )
{
if ( !geomTmp->addZValue( std::numeric_limits<double>::quiet_NaN() ) )
if ( !geomTmp->addZValue( defaultZValue() ) )
{
QgsDebugMsg( QStringLiteral( "add Z value to vertex failed!" ) );
return;
}
}

// If moving point has not M-value but destination yes, check if it can be promoted
if ( layerPoint.isMeasure() && !geom.vertexAt( dragVertexId ).isMeasure() && QgsWkbTypes::hasM( dragLayer->wkbType() ) )
if ( layerPoint.isMeasure() && !geomTmp->isMeasure() && QgsWkbTypes::hasM( dragLayer->wkbType() ) )
{
if ( !geomTmp->addMValue( std::numeric_limits<double>::quiet_NaN() ) )
if ( !geomTmp->addMValue( defaultMValue() ) )
{
QgsDebugMsg( QStringLiteral( "add M value to vertex failed!" ) );
return;
Expand Down
9 changes: 5 additions & 4 deletions src/core/vector/qgsvectorlayereditutils.cpp
Expand Up @@ -27,6 +27,7 @@
#include "qgsvectorlayer.h"
#include "qgsgeometryoptions.h"
#include "qgsabstractgeometry.h"
#include "qgssettingsregistrycore.h"

#include <limits>

Expand Down Expand Up @@ -88,16 +89,16 @@ bool QgsVectorLayerEditUtils::moveVertex( const QgsPoint &p, QgsFeatureId atFeat
QgsGeometry geometry = f.geometry();

// If original point is not 3D but destination yes, check if it can be promoted
if ( p.is3D() && !geometry.vertexAt( atVertex ).is3D() && QgsWkbTypes::hasZ( mLayer->wkbType() ) )
if ( p.is3D() && !geometry.constGet()->is3D() && QgsWkbTypes::hasZ( mLayer->wkbType() ) )
{
if ( !geometry.get()->addZValue( std::numeric_limits<double>::quiet_NaN() ) )
if ( !geometry.get()->addZValue( QgsSettingsRegistryCore::settingsDigitizingDefaultZValue.value() ) )
return false;
}

// If original point has not M-value but destination yes, check if it can be promoted
if ( p.isMeasure() && !geometry.vertexAt( atVertex ).isMeasure() && QgsWkbTypes::hasM( mLayer->wkbType() ) )
if ( p.isMeasure() && !geometry.constGet()->isMeasure() && QgsWkbTypes::hasM( mLayer->wkbType() ) )
{
if ( !geometry.get()->addMValue( std::numeric_limits<double>::quiet_NaN() ) )
if ( !geometry.get()->addMValue( QgsSettingsRegistryCore::settingsDigitizingDefaultMValue.value() ) )
return false;
}

Expand Down

0 comments on commit 720082a

Please sign in to comment.