[GRASS-SVN] r58274 - grass/branches/releasebranch_6_4/imagery/i.landsat.toar

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 21 14:16:20 PST 2013


Author: neteler
Date: 2013-11-21 14:16:19 -0800 (Thu, 21 Nov 2013)
New Revision: 58274

Modified:
   grass/branches/releasebranch_6_4/imagery/i.landsat.toar/landsat_met.c
Log:
i.landsat.toar: fixes for Landsat-8 metadata file support (author: E. Jorge Tizado)

Modified: grass/branches/releasebranch_6_4/imagery/i.landsat.toar/landsat_met.c
===================================================================
--- grass/branches/releasebranch_6_4/imagery/i.landsat.toar/landsat_met.c	2013-11-21 22:15:55 UTC (rev 58273)
+++ grass/branches/releasebranch_6_4/imagery/i.landsat.toar/landsat_met.c	2013-11-21 22:16:19 UTC (rev 58274)
@@ -57,6 +57,7 @@
     value[i] = '\0';
 }
 
+/* future implementation
 double get_metdouble(const char metadata[], char *format, int code, char value[])
 {
     char key[MAX_STR];
@@ -65,6 +66,7 @@
     get_metformat(metadata, key, value);
     return atof(value);			    
 }
+*/
 
 
 /* NEW Metadata Files */
@@ -85,6 +87,7 @@
     value[i] = '\0';
 }
 
+/* future implementation
 double get_mtldouble(const char metadata[], char *format, int code, char value[])
 {
     char key[MAX_STR];
@@ -93,9 +96,9 @@
     get_mtlformat(metadata, key, value);
     return atof(value);			    
 }
+*/
 
 
-
 /****************************************************************************
  * PURPOSE:     Read parameters from Landsat metadata files
  *****************************************************************************/
@@ -106,9 +109,8 @@
     char mtldata[METADATA_SIZE];
     char key[MAX_STR], value[MAX_STR];
     void (*get_mtldata) (const char[], char *, char[]);
-    void (*get_mtlreal) (const char[], char *, int, char[]);
+    /* void (*get_mtlreal) (const char[], char *, int, char[]); */
     int i, j, ver_mtl;
-    double X2;
 
     /* store metadata in ram */
     if ((f = fopen(metafile, "r")) == NULL)
@@ -117,7 +119,8 @@
     (void)fclose(f);
 
     /* set version of the metadata file */
-    /* get_mtldata = (strstr(mtldata, " VALUE ") != NULL) ? get_metformat : get_mtlformat; */
+    get_mtldata = (strstr(mtldata, " VALUE ") != NULL) ? get_metformat : get_mtlformat;
+    /* future implementation
     if (strstr(mtldata, " VALUE ") != NULL)
     {
 	get_mtldata = get_metformat;
@@ -128,6 +131,7 @@
 	get_mtldata = get_mtlformat;
 	get_mtlreal = get_mtldouble;
     }
+    */
     ver_mtl = (strstr(mtldata, "QCALMAX_BAND") != NULL) ? 0 : 1;
 
     /* Fill with product metadata */
@@ -310,18 +314,20 @@
 		    if (lsat->band[i].thermal) {
 			sprintf(key, "K1_CONSTANT_BAND_%d", lsat->band[i].code);
 			get_mtldata(mtldata, key, value);
-			lsat->band[i].K1 = atof(value);
+			if (value[0] != '\0')
+			    lsat->band[i].K1 = atof(value);
 			sprintf(key, "K2_CONSTANT_BAND_%d", lsat->band[i].code);
 			get_mtldata(mtldata, key, value);
-			lsat->band[i].K2 = atof(value);
+			if (value[0] != '\0')
+			    lsat->band[i].K2 = atof(value);
 		    }
 		    else if (lsat->number == 8)
 		    {
 			/* ESUN from  REFLECTANCE and RADIANCE ADD_BAND */
 			sprintf(key, "REFLECTANCE_MAXIMUM_BAND_%d", lsat->band[i].code);
 			get_mtldata(mtldata, key, value);
-			X2 = atof(value);
-			lsat->band[i].esun = (double)(PI * lsat->dist_es * lsat->dist_es * lsat->band[i].lmax) / X2;
+			if (value[0] != '\0')
+			    lsat->band[i].esun = (double)(PI * lsat->dist_es * lsat->dist_es * lsat->band[i].lmax) / atof(value);
 		    }
 		}
 		if (lsat->number == 8)



More information about the grass-commit mailing list