Skip to content

Commit

Permalink
[bugfix] Fix Z&M edition. Fix double conversion from locale.
Browse files Browse the repository at this point in the history
Mnually Cherry-picked from 0ba36ac
  • Loading branch information
elpaso committed Jun 11, 2018
1 parent 85b9d37 commit d9afb89
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/app/vertextool/qgsvertexeditor.cpp
Expand Up @@ -199,15 +199,23 @@ bool QgsVertexEditorModel::setData( const QModelIndex &index, const QVariant &va
return false;
}

double x = ( index.column() == 0 ? value.toDouble() : mSelectedFeature->vertexMap().at( index.row() )->point().x() );
double y = ( index.column() == 1 ? value.toDouble() : mSelectedFeature->vertexMap().at( index.row() )->point().y() );
// Get double value wrt current locale.
bool ok;
double doubleValue = QLocale().toDouble( value.toString(), &ok );
// If not valid and locale's decimal point is not '.' let's try with english locale
if ( ! ok && QLocale().decimalPoint() != '.' )
{
doubleValue = QLocale( QLocale::English ).toDouble( value.toString() );
}

double x = ( index.column() == 0 ? doubleValue : mSelectedFeature->vertexMap().at( index.row() )->point().x() );
double y = ( index.column() == 1 ? doubleValue : mSelectedFeature->vertexMap().at( index.row() )->point().y() );

if ( index.column() == mRCol ) // radius modified
{
if ( index.row() == 0 || index.row() >= mSelectedFeature->vertexMap().count() - 1 )
return false;

double r = value.toDouble();
double x1 = mSelectedFeature->vertexMap().at( index.row() - 1 )->point().x();
double y1 = mSelectedFeature->vertexMap().at( index.row() - 1 )->point().y();
double x2 = x;
Expand All @@ -216,7 +224,7 @@ bool QgsVertexEditorModel::setData( const QModelIndex &index, const QVariant &va
double y3 = mSelectedFeature->vertexMap().at( index.row() + 1 )->point().y();

QgsPoint result;
if ( QgsGeometryUtils::segmentMidPoint( QgsPoint( x1, y1 ), QgsPoint( x3, y3 ), result, r, QgsPoint( x2, y2 ) ) )
if ( QgsGeometryUtils::segmentMidPoint( QgsPoint( x1, y1 ), QgsPoint( x3, y3 ), result, doubleValue, QgsPoint( x2, y2 ) ) )
{
x = result.x();
y = result.y();
Expand Down

0 comments on commit d9afb89

Please sign in to comment.