[GRASS-CVS] hamish: grass6/raster/r.coin prnt_entry.c,2.1,2.1.2.1

grass at intevation.de grass at intevation.de
Fri Nov 16 06:13:01 EST 2007


Author: hamish

Update of /grassrepository/grass6/raster/r.coin
In directory doto:/tmp/cvs-serv954/grass6/raster/r.coin

Modified Files:
      Tag: releasebranch_6_3
	prnt_entry.c 
Log Message:
more precise conversions to square miles and acres
  (merge from HEAD)


Index: prnt_entry.c
===================================================================
RCS file: /grassrepository/grass6/raster/r.coin/prnt_entry.c,v
retrieving revision 2.1
retrieving revision 2.1.2.1
diff -u -d -r2.1 -r2.1.2.1
--- prnt_entry.c	14 Sep 2006 01:41:09 -0000	2.1
+++ prnt_entry.c	16 Nov 2007 11:12:58 -0000	2.1.2.1
@@ -19,8 +19,10 @@
 
 
 #define F_CTOK(C)	((double)(C))/1000000.0
-#define F_CTOM(C)	F_CTOK(C) *   0.3861
-#define F_CTOA(C)	F_CTOK(C) * 247.1000
+	/* sq km -> sq miles = 1000^2 / (0.0254 * 12 * 5280)^2 */
+#define F_CTOM(C)	F_CTOK(C) *   0.386102158542446
+	/* sq km -> acres = sq miles * 640 */
+#define F_CTOA(C)	F_CTOK(C) * 247.105381467165
 #define F_CTOH(C)	F_CTOK(C) * 100.0000
 
 #define F_CTOP(C,R) ((int)R) ? (double)C / (double)R * 100.0 : 0.0
@@ -35,16 +37,16 @@
 
     switch (Conformat)
     {
-	case 'a': 
+	case 'a': /* acres */
 		print_area(F_CTOA(area));
 		break;
-	case 'h': 
+	case 'h': /* hectares */
 		print_area(F_CTOH(area));
 		break;
-	case 'k': 
+	case 'k': /* square km */
 		print_area(F_CTOK(area));
 		break;
-	case 'm': 
+	case 'm': /* square miles */
 		print_area(F_CTOM(area));
 		break;
 	case 'p': 
@@ -58,7 +60,7 @@
 		row_total(Rndex,1,&total_count,&total_area);
 		print_percent(F_CTOY(area,total_area));
 		break;
-	default:  
+	default: /* case 'c' */
 		fprintf(dumpfile," %9ld |", count);
 		break;
     }




More information about the grass-commit mailing list