@@ -78,8 +78,7 @@ void QgsMeasure::activate()
7878 mRightMouseClicked = false ;
7979
8080 // ensure that we have correct settings
81- mCalc ->setDefaultEllipsoid ();
82- mCalc ->setProjectAsSourceSRS ();
81+ updateProjection ();
8382
8483 // If we suspect that they have data that is projected, yet the
8584 // map SRS is set to a geographic one, warn them.
@@ -98,6 +97,7 @@ void QgsMeasure::activate()
9897 " system using the <tt>Settings:Project Properties</tt> menu." ),
9998 QMessageBox::Ok,
10099 QMessageBox::NoButton);
100+ mWrongProjectProjection = true ;
101101 }
102102}
103103
@@ -125,6 +125,7 @@ QgsMeasure::~QgsMeasure()
125125
126126void QgsMeasure::restart (void )
127127{
128+ updateProjection ();
128129 mPoints .resize (0 );
129130 // Set one cell row where to update current distance
130131 // If measuring area, the table doesn't get shown
@@ -137,6 +138,7 @@ void QgsMeasure::restart(void )
137138 mRubberBand ->reset (mMeasureArea );
138139
139140 mRightMouseClicked = false ;
141+ mWrongProjectProjection = false ;
140142}
141143
142144void QgsMeasure::addPoint (QgsPoint &point)
@@ -145,6 +147,12 @@ void QgsMeasure::addPoint(QgsPoint &point)
145147 std::cout << " QgsMeasure::addPoint" << point.x () << " , " << point.y () << std::endl;
146148#endif
147149
150+ if (mWrongProjectProjection )
151+ {
152+ updateProjection ();
153+ mWrongProjectProjection = false ;
154+ }
155+
148156 // don't add points with the same coordinates
149157 if (mPoints .size () > 0 && point == mPoints [0 ])
150158 return ;
@@ -325,6 +333,12 @@ void QgsMeasure::updateUi()
325333
326334}
327335
336+ void QgsMeasure::updateProjection ()
337+ {
338+ mCalc ->setDefaultEllipsoid ();
339+ mCalc ->setProjectAsSourceSRS ();
340+ }
341+
328342// ////////////////////////
329343
330344void QgsMeasure::canvasPressEvent (QMouseEvent * e)
0 commit comments