Quellcode durchsuchen

i.landsat.toar: avoid endless loop and exit if approximation of atmospheric transmittance coefficients is unstable (DOS4 method) (contributed by Dmitry Kolesov, fix https://trac.osgeo.org/grass/ticket/2918)

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@69795 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler vor 8 Jahren
Ursprung
Commit
f75b6217eb
1 geänderte Dateien mit 3 neuen und 0 gelöschten Zeilen
  1. 3 0
      imagery/i.landsat.toar/landsat.c

+ 3 - 0
imagery/i.landsat.toar/landsat.c

@@ -2,6 +2,7 @@
 #include <stdlib.h>
 #include <math.h>
 #include <grass/gis.h>
+#include <grass/glocale.h>
 
 #include "landsat.h"
 
@@ -111,6 +112,8 @@ void lsat_bandctes(lsat_data * lsat, int i, char method,
 		    TAUv = Tv;
 		    Lp = Ro - percent * TAUv * (lsat->band[i].esun * sin_e * TAUz + PI * Lp) / pi_d2;
 		    Tz = 1. - (4. * pi_d2 * Lp) / (lsat->band[i].esun * sin_e);
+		    if (Tz <= 0)
+			G_fatal_error(_("The DOS4 method is not applicable here: approximation of atmospheric transmittance coefficients is unstable. Use another DOS method or use other sun_elevation parameter"));
 		    Tv = exp(sin_e * log(Tz) / cos_v);
 		} while (TAUv != Tv && TAUz != Tz);
 		TAUz = (Tz < 1. ? Tz : 1.);