|
23 | 23 | #include "qgsmaptopixel.h"
|
24 | 24 | #include "qgsrubberband.h"
|
25 | 25 |
|
| 26 | +#include "QMessageBox" |
26 | 27 | #include <QSettings>
|
27 | 28 | #include <iostream>
|
28 | 29 |
|
@@ -70,6 +71,29 @@ void QgsMeasure::activate()
|
70 | 71 | restorePosition();
|
71 | 72 | QgsMapTool::activate();
|
72 | 73 | mRightMouseClicked = false;
|
| 74 | + |
| 75 | + // ensure that we have correct settings |
| 76 | + mCalc->setDefaultEllipsoid(); |
| 77 | + mCalc->setProjectAsSourceSRS(); |
| 78 | + |
| 79 | + // If we suspect that they have data that is projected, yet the |
| 80 | + // map SRS is set to a geographic one, warn them. |
| 81 | + if (mCalc->geographic() && |
| 82 | + (mMapCanvas->extent().height() > 360 || |
| 83 | + mMapCanvas->extent().width() > 720)) |
| 84 | + { |
| 85 | + QMessageBox::warning(this, tr("Incorrect measure results"), |
| 86 | + tr("<p>This map is defined with a geographic coordinate system " |
| 87 | + "(latitude/longitude) " |
| 88 | + "but the map extents suggest that it is actually a projected " |
| 89 | + "coordinate system (e.g., Mercator). " |
| 90 | + "If so, the results from line or area measurements will be " |
| 91 | + "incorrect.</p>" |
| 92 | + "<p>To fix this, explicitly set an appropriate map coordinate " |
| 93 | + "system using the <tt>Settings:Project Properties</tt> menu."), |
| 94 | + QMessageBox::Ok, |
| 95 | + QMessageBox::NoButton); |
| 96 | + } |
73 | 97 | }
|
74 | 98 |
|
75 | 99 | void QgsMeasure::deactivate()
|
@@ -120,13 +144,6 @@ void QgsMeasure::addPoint(QgsPoint &point)
|
120 | 144 | QgsPoint pnt(point);
|
121 | 145 | mPoints.push_back(pnt);
|
122 | 146 |
|
123 |
| - if (mPoints.size() == 1) |
124 |
| - { |
125 |
| - // ensure that we have correct settings |
126 |
| - mCalc->setDefaultEllipsoid(); |
127 |
| - mCalc->setProjectAsSourceSRS(); |
128 |
| - } |
129 |
| - |
130 | 147 | if (mMeasureArea && mPoints.size() > 2)
|
131 | 148 | {
|
132 | 149 | double area = mCalc->measurePolygon(mPoints);
|
|
0 commit comments