@@ -78,8 +78,7 @@ void QgsMeasure::activate()
78
78
mRightMouseClicked = false ;
79
79
80
80
// ensure that we have correct settings
81
- mCalc ->setDefaultEllipsoid ();
82
- mCalc ->setProjectAsSourceSRS ();
81
+ updateProjection ();
83
82
84
83
QSettings settings;
85
84
int myRed = settings.value (" /qgis/default_measure_color_red" , 180 ).toInt ();
@@ -104,6 +103,7 @@ void QgsMeasure::activate()
104
103
" system using the <tt>Settings:Project Properties</tt> menu." ),
105
104
QMessageBox::Ok,
106
105
QMessageBox::NoButton);
106
+ mWrongProjectProjection = true ;
107
107
}
108
108
}
109
109
@@ -131,6 +131,7 @@ QgsMeasure::~QgsMeasure()
131
131
132
132
void QgsMeasure::restart (void )
133
133
{
134
+ updateProjection ();
134
135
mPoints .resize (0 );
135
136
// Set one cell row where to update current distance
136
137
// If measuring area, the table doesn't get shown
@@ -150,6 +151,7 @@ void QgsMeasure::restart(void )
150
151
mRubberBand ->setColor (QColor (myRed, myGreen, myBlue));
151
152
152
153
mRightMouseClicked = false ;
154
+ mWrongProjectProjection = false ;
153
155
}
154
156
155
157
void QgsMeasure::addPoint (QgsPoint &point)
@@ -158,6 +160,12 @@ void QgsMeasure::addPoint(QgsPoint &point)
158
160
std::cout << " QgsMeasure::addPoint" << point.x () << " , " << point.y () << std::endl;
159
161
#endif
160
162
163
+ if (mWrongProjectProjection )
164
+ {
165
+ updateProjection ();
166
+ mWrongProjectProjection = false ;
167
+ }
168
+
161
169
// don't add points with the same coordinates
162
170
if (mPoints .size () > 0 && point == mPoints [0 ])
163
171
return ;
@@ -338,6 +346,12 @@ void QgsMeasure::updateUi()
338
346
339
347
}
340
348
349
+ void QgsMeasure::updateProjection ()
350
+ {
351
+ mCalc ->setDefaultEllipsoid ();
352
+ mCalc ->setProjectAsSourceSRS ();
353
+ }
354
+
341
355
// ////////////////////////
342
356
343
357
void QgsMeasure::canvasPressEvent (QMouseEvent * e)
0 commit comments