@@ -138,10 +138,20 @@ void DistanceArea::setGeometry( Geometry *geometry )
138
138
139
139
qreal DistanceArea::length () const
140
140
{
141
+ double length = std::numeric_limits<double >::quiet_NaN ();
141
142
if ( mRubberbandModel )
142
- return mDistanceArea .measureLine ( mRubberbandModel ->flatPointSequence ( mCrs ) );
143
+ {
144
+ try
145
+ {
146
+ length = mDistanceArea .measureLine ( mRubberbandModel ->flatPointSequence ( mCrs ) );
147
+ }
148
+ catch ( const QgsException & )
149
+ {
150
+ length = std::numeric_limits<double >::quiet_NaN ();
151
+ }
152
+ }
143
153
144
- return qQNaN () ;
154
+ return length ;
145
155
}
146
156
147
157
bool DistanceArea::lengthValid () const
@@ -197,10 +207,20 @@ bool DistanceArea::perimeterValid() const
197
207
198
208
qreal DistanceArea::area () const
199
209
{
210
+ double area = std::numeric_limits<double >::quiet_NaN ();
200
211
if ( mRubberbandModel )
201
- return mDistanceArea .measurePolygon ( mRubberbandModel ->flatPointSequence ( mCrs ) );
212
+ {
213
+ try
214
+ {
215
+ area = mDistanceArea .measurePolygon ( mRubberbandModel ->flatPointSequence ( mCrs ) );
216
+ }
217
+ catch ( const QgsException & )
218
+ {
219
+ area = std::numeric_limits<double >::quiet_NaN ();
220
+ }
221
+ }
202
222
203
- return qQNaN () ;
223
+ return area ;
204
224
}
205
225
206
226
bool DistanceArea::areaValid () const
@@ -242,7 +262,16 @@ qreal DistanceArea::segmentLength() const
242
262
pointIt--;
243
263
flatPoints << *pointIt;
244
264
245
- return mDistanceArea .measureLine ( flatPoints );
265
+ double length = std::numeric_limits<double >::quiet_NaN ();
266
+ try
267
+ {
268
+ length = mDistanceArea .measureLine ( flatPoints );
269
+ }
270
+ catch ( const QgsException & )
271
+ {
272
+ length = std::numeric_limits<double >::quiet_NaN ();
273
+ }
274
+ return length;
246
275
}
247
276
248
277
qreal DistanceArea::azimuth () const
0 commit comments