@@ -58,8 +58,8 @@ QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool* tool, Qt::WFlags f )
58
58
else
59
59
mcbProjectionEnabled->setCheckState ( Qt::Unchecked );
60
60
61
- connect ( mcbProjectionEnabled, SIGNAL ( stateChanged (int ) ),
62
- this , SLOT ( changeProjectionEnabledState () ));
61
+ connect ( mcbProjectionEnabled, SIGNAL ( stateChanged ( int ) ),
62
+ this , SLOT ( changeProjectionEnabledState () ) );
63
63
64
64
updateUi ();
65
65
}
@@ -99,14 +99,12 @@ void QgsMeasureDialog::mouseMove( QgsPoint &point )
99
99
int decimalPlaces = settings.value ( " /qgis/measure/decimalplaces" , " 3" ).toInt ();
100
100
101
101
// Create QgsDistance Area for customization ProjectionEnabled setting
102
- QgsDistanceArea myDa;
103
- myDa.setSourceCrs ( mTool ->canvas ()->mapRenderer ()->destinationSrs ().srsid () );
104
- myDa.setEllipsoid ( mTool ->canvas ()->mapRenderer ()->distanceArea ()->ellipsoid () );
105
- myDa.setProjectionsEnabled ( mcbProjectionEnabled->isChecked () );
102
+ QgsDistanceArea myDa;
103
+ configureDistanceArea ( myDa );
106
104
107
105
// show current distance/area while moving the point
108
106
// by creating a temporary copy of point array
109
- // and adding moving point at the end
107
+ // and adding moving point at the end
110
108
if ( mMeasureArea && mTool ->points ().size () > 1 )
111
109
{
112
110
QList<QgsPoint> tmpPoints = mTool ->points ();
@@ -134,10 +132,8 @@ void QgsMeasureDialog::addPoint( QgsPoint &point )
134
132
int decimalPlaces = settings.value ( " /qgis/measure/decimalplaces" , " 3" ).toInt ();
135
133
136
134
// Create QgsDistance Area for customization ProjectionEnabled setting
137
- QgsDistanceArea myDa;
138
- myDa.setSourceCrs ( mTool ->canvas ()->mapRenderer ()->destinationSrs ().srsid () );
139
- myDa.setEllipsoid ( mTool ->canvas ()->mapRenderer ()->distanceArea ()->ellipsoid () );
140
- myDa.setProjectionsEnabled ( mcbProjectionEnabled->isChecked () );
135
+ QgsDistanceArea myDa;
136
+ configureDistanceArea ( myDa );
141
137
142
138
int numPoints = mTool ->points ().size ();
143
139
if ( mMeasureArea && numPoints > 2 )
@@ -269,19 +265,18 @@ void QgsMeasureDialog::convertMeasurement( double &measure, QGis::UnitType &u, b
269
265
// The parameter &u is out only...
270
266
271
267
QGis::UnitType myUnits = mTool ->canvas ()->mapUnits ();
272
- if (( myUnits == QGis::Degrees || myUnits == QGis::Feet ) &&
273
- mTool ->canvas ()->mapRenderer ()->distanceArea ()->ellipsoid () != " NONE" &&
268
+ if (( myUnits == QGis::Degrees || myUnits == QGis::Feet ) &&
274
269
mcbProjectionEnabled->isChecked () )
275
270
{
276
271
// Measuring on an ellipsoid returns meters, and so does using projections???
277
272
myUnits = QGis::Meters;
278
273
QgsDebugMsg ( " We're measuring on an ellipsoid or using projections, the system is returning meters" );
279
274
}
280
-
275
+
281
276
// Get the units for display
282
277
QSettings settings;
283
278
QString myDisplayUnitsTxt = settings.value ( " /qgis/measure/displayunits" , " meters" ).toString ();
284
-
279
+
285
280
// Only convert between meters and feet
286
281
if ( myUnits == QGis::Meters && myDisplayUnitsTxt == " feet" )
287
282
{
@@ -314,9 +309,9 @@ void QgsMeasureDialog::changeProjectionEnabledState()
314
309
// store value
315
310
QSettings settings;
316
311
if ( mcbProjectionEnabled->isChecked () )
317
- settings.setValue ( " /qgis/measure/projectionEnabled" , 2 );
312
+ settings.setValue ( " /qgis/measure/projectionEnabled" , 2 );
318
313
else
319
- settings.setValue ( " /qgis/measure/projectionEnabled" , 0 );
314
+ settings.setValue ( " /qgis/measure/projectionEnabled" , 0 );
320
315
321
316
// clear interface
322
317
mTable ->clear ();
@@ -327,13 +322,11 @@ void QgsMeasureDialog::changeProjectionEnabledState()
327
322
updateUi ();
328
323
329
324
int decimalPlaces = settings.value ( " /qgis/measure/decimalplaces" , " 3" ).toInt ();
330
-
325
+
331
326
// create DistanceArea
332
- QgsDistanceArea myDa;
333
- myDa.setSourceCrs ( mTool ->canvas ()->mapRenderer ()->destinationSrs ().srsid () );
334
- myDa.setEllipsoid ( mTool ->canvas ()->mapRenderer ()->distanceArea ()->ellipsoid () );
335
- myDa.setProjectionsEnabled ( mcbProjectionEnabled->isChecked () );
336
-
327
+ QgsDistanceArea myDa;
328
+ configureDistanceArea ( myDa );
329
+
337
330
if ( mMeasureArea )
338
331
{
339
332
double area = 0.0 ;
@@ -342,14 +335,15 @@ void QgsMeasureDialog::changeProjectionEnabledState()
342
335
area = myDa.measurePolygon ( mTool ->points () );
343
336
}
344
337
editTotal->setText ( formatArea ( area, decimalPlaces ) );
345
- }else
338
+ }
339
+ else
346
340
{
347
341
QList<QgsPoint>::const_iterator it;
348
342
bool b = true ; // first point
349
-
350
- QgsPoint p1,p2;
351
-
352
- for (it= mTool ->points ().constBegin (); it != mTool ->points ().constEnd (); ++it)
343
+
344
+ QgsPoint p1, p2;
345
+
346
+ for ( it = mTool ->points ().constBegin (); it != mTool ->points ().constEnd (); ++it )
353
347
{
354
348
p2 = *it;
355
349
if ( !b )
@@ -373,3 +367,12 @@ void QgsMeasureDialog::changeProjectionEnabledState()
373
367
}
374
368
}
375
369
}
370
+
371
+ void QgsMeasureDialog::configureDistanceArea ( QgsDistanceArea& da )
372
+ {
373
+ QSettings settings;
374
+ QString ellipsoidId = settings.value ( " /qgis/measure/ellipsoid" , " WGS84" ).toString ();
375
+ da.setSourceCrs ( mTool ->canvas ()->mapRenderer ()->destinationSrs ().srsid () );
376
+ da.setEllipsoid ( ellipsoidId );
377
+ da.setProjectionsEnabled ( mcbProjectionEnabled->isChecked () );
378
+ }
0 commit comments