[GRASS-SVN] r31576 - grass-addons/gipe/r.soiltex2prop

svn_grass at osgeo.org svn_grass at osgeo.org
Fri May 30 04:16:56 EDT 2008


Author: ychemin
Date: 2008-05-30 04:16:56 -0400 (Fri, 30 May 2008)
New Revision: 31576

Modified:
   grass-addons/gipe/r.soiltex2prop/main.c
   grass-addons/gipe/r.soiltex2prop/prct2porosity.c
Log:
bug fixing

Modified: grass-addons/gipe/r.soiltex2prop/main.c
===================================================================
--- grass-addons/gipe/r.soiltex2prop/main.c	2008-05-30 08:03:20 UTC (rev 31575)
+++ grass-addons/gipe/r.soiltex2prop/main.c	2008-05-30 08:16:56 UTC (rev 31576)
@@ -166,11 +166,11 @@
 			} else {
 				/************************************/
 				/* convert to porosity		    */
-				d = prct2porosity(d_sand, d_clay);
+				d = prct2porosity(d_sand*100.0,d_clay*100.0);
 				outrast1[col] = d;
-				d = prct2ksat(d_sand, d_clay);	
+				d = prct2ksat(d_sand*100.0,d_clay*100.0);
 				outrast2[col] = d;
-				d = prct2hf(d_sand, d_clay);	
+				d = prct2hf(d_sand*100.0, d_clay*100.0);
 				outrast3[col] = d;
 			}
 		}

Modified: grass-addons/gipe/r.soiltex2prop/prct2porosity.c
===================================================================
--- grass-addons/gipe/r.soiltex2prop/prct2porosity.c	2008-05-30 08:03:20 UTC (rev 31575)
+++ grass-addons/gipe/r.soiltex2prop/prct2porosity.c	2008-05-30 08:16:56 UTC (rev 31576)
@@ -13,8 +13,6 @@
 	double temp,porosity;
 	double silt_input=0.0; 	//Rawls et al (1990)
 				//do not have silt input
-	// set up mark index for inside/outside polygon check
-	double mark[POLYGON_DIMENSION]={0.0};
 	//printf("in prct2poros(), Volume Fraction\n");
 	//setup the 3Dvectors and initialize them
 	struct vector cls[POLYGON_DIMENSION] = {0.0};
@@ -24,65 +22,73 @@
 		cls[i].clay=0.0;
 		cls[i].silt=0.0;
 	}
-	//transform input from [0,1] to [0,100]
-	sand_input *= 100.0;
-	clay_input *= 100.0;
-	//fill up initial polygon points
+	//printf("0=>sand:%.2f\tclay:%.2f\n", sand_input,clay_input);
 	cls[0].sand=0.0;
 	cls[0].clay=100.0;
 	cls[1].sand=10.0;
 	cls[1].clay=90.0;
 	cls[2].sand=25.0;
 	cls[2].clay=75.0;
+	//printf("sand0:%.2f\tclay0:%.2f\tsilt0:%.2f\n",cls[0].sand,cls[0].clay,cls[0].silt);
+	//printf("sand1:%.2f\tclay1:%.2f\tsilt1:%.2f\n",cls[1].sand,cls[1].clay,cls[1].silt);
+	//printf("sand2:%.2f\tclay2:%.2f\tsilt2:%.2f\n",cls[2].sand,cls[2].clay,cls[2].silt);
 	//Get started
-	mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
-	if(mark[0]==1){
+	index = point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
+	if(index==1){
 		porosity=0.575;
-		index=1;
 		//printf("Poros=0.575\n");
-	}
+	} 
 	if (index==0){// if index not found then continue
+		//printf("1=>sand:%.2f\tclay:%.2f\n",sand_input,clay_input);
 		cls[0].sand=10.0;
 		cls[0].clay=0.0;
 		cls[1].sand=20.0;
 		cls[1].clay=20.0;
 		cls[2].sand=50.0;
 		cls[2].clay=0.0;
-		mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
-		if(mark[0]==1){
-			index=1;
+		//printf("sand0:%.2f\tclay0:%.2f\tsilt0:%.2f\n",cls[0].sand,cls[0].clay,cls[0].silt);
+		//printf("sand1:%.2f\tclay1:%.2f\tsilt1:%.2f\n",cls[1].sand,cls[1].clay,cls[1].silt);
+		//printf("sand2:%.2f\tclay2:%.2f\tsilt2:%.2f\n",cls[2].sand,cls[2].clay,cls[2].silt);
+		index = point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
+		if(index==1){
 			//printf("Poros=0.575\n");
 			porosity=0.575;
 		}
-	}
+	} 
 	if (index==0){// if index not found then continue
+		//printf("2=>sand:%.2f\tclay:%.2f\n",sand_input,clay_input);
 		cls[0].sand=100.0;
 		cls[0].clay=0.0;
 		cls[1].sand=50.0;
 		cls[1].clay=50.0;
 		cls[2].sand=50.0;
 		cls[2].clay=43.0;
-		mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
-		if(mark[0]==1){
-			index=1;
+		//printf("sand0:%.2f\tclay0:%.2f\tsilt0:%.2f\n",cls[0].sand,cls[0].clay,cls[0].silt);
+		//printf("sand1:%.2f\tclay1:%.2f\tsilt1:%.2f\n",cls[1].sand,cls[1].clay,cls[1].silt);
+		//printf("sand2:%.2f\tclay2:%.2f\tsilt2:%.2f\n",cls[2].sand,cls[2].clay,cls[2].silt);
+		index = point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
+		if(index==1){
 			//printf("Poros=0.425\n");
 			porosity=0.425;
 		}
-	}
+	} 
 	if (index==0){// if index not found then continue
+		//printf("3=>sand:%.2f\tclay:%.2f\n",sand_input,clay_input);
 		cls[0].sand=100.0;
 		cls[0].clay=0.0;
 		cls[1].sand=50.0;
 		cls[1].clay=43.0;
 		cls[2].sand=52.0;
 		cls[2].clay=33.0;
-		mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
-		if(mark[0]==1){
-			index=1;
+		////printf("sand0:%.2f\tclay0:%.2f\tsilt0:%.2f\n",cls[0].sand,cls[0].clay,cls[0].silt);
+		////printf("sand1:%.2f\tclay1:%.2f\tsilt1:%.2f\n",cls[1].sand,cls[1].clay,cls[1].silt);
+		////printf("sand2:%.2f\tclay2:%.2f\tsilt2:%.2f\n",cls[2].sand,cls[2].clay,cls[2].silt);
+		index = point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
+		if(index==1){
 			//printf("Poros=0.425\n");
 			porosity=0.425;
 		}
-	}
+	} 
 	if (index==0){// if index not found then continue
 		cls[0].sand=100.0;
 		cls[0].clay=0.0;
@@ -90,9 +96,8 @@
 		cls[1].clay=33.0;
 		cls[2].sand=57.0;
 		cls[2].clay=25.0;
-		mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
-		if(mark[0]==1){
-			index=1;
+		index = point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
+		if(index==1){
 			//printf("Poros=0.425\n");
 			porosity=0.425;
 		}
@@ -104,13 +109,12 @@
 		cls[1].clay=25.0;
 		cls[2].sand=87.0;
 		cls[2].clay=0.0;
-		mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
-		if(mark[0]==1){
-			index=1;
+		index = point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
+		if(index==1){
 			//printf("Poros=0.425\n");
 			porosity=0.425;
 		}
-	}
+	} 
 	if (index==0){// if index not found then continue
 		cls[0].sand=0.0;
 		cls[0].clay=0.0;
@@ -118,13 +122,12 @@
 		cls[1].clay=75.0;
 		cls[2].sand=0.0;
 		cls[2].clay=90.0;
-		mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
-		if(mark[0]==1){
-			index=1;
+		index = point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
+		if(index == 1){
 			//printf("Poros=0.525\n");
 			porosity=0.525;
 		}
-	}
+	} 
 	if (index==0){// if index not found then continue
 		cls[0].sand=0.0;
 		cls[0].clay=0.0;
@@ -132,13 +135,12 @@
 		cls[1].clay=75.0;
 		cls[2].sand=10.0;
 		cls[2].clay=0.0;
-		mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
-		if(mark[0]==1){
-			index=1;
+		index = point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
+		if(index==1){
 			//printf("Poros=0.525\n");
 			porosity=0.525;
 		}
-	}
+	} 
 	if (index==0){// if index not found then continue
 		cls[0].sand=10.0;
 		cls[0].clay=0.0;
@@ -146,9 +148,8 @@
 		cls[1].clay=75.0;
 		cls[2].sand=20.0;
 		cls[2].clay=20.0;
-		mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
-		if(mark[0]==1){
-			index=1;
+		index = point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
+		if(index==1){
 			//printf("Poros=0.525\n");
 			porosity=0.525;
 		}
@@ -160,9 +161,8 @@
 		cls[1].clay=75.0;
 		cls[2].sand=25.0;
 		cls[2].clay=55.0;
-		mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
-		if(mark[0]==1){
-			index=1;
+		index = point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
+		if(index==1){
 			//printf("Poros=0.525\n");
 			porosity=0.525;
 		}
@@ -174,13 +174,12 @@
 		cls[1].clay=55.0;
 		cls[2].sand=27.0;
 		cls[2].clay=45.0;
-		mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
-		if(mark[0]==1){
-			index=1;
+		index = point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
+		if(index==1){
 			//printf("Poros=0.525\n");
 			porosity=0.525;
 		}
-	}
+	} 
 	if (index==0){// if index not found then continue
 		cls[0].sand=20.0;
 		cls[0].clay=20.0;
@@ -188,27 +187,25 @@
 		cls[1].clay=45.0;
 		cls[2].sand=50.0;
 		cls[2].clay=0.0;
-		mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
-		if(mark[0]==1){
-			index=1;
+		index = point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
+		if(index==1){
 			//printf("Poros=0.525\n");
 			porosity=0.525;
 		}
-	}
-	if (index==0){// if index not found then continue
+	} 
+ 	if (index==0){// if index not found then continue
 		cls[0].sand=50.0;
 		cls[0].clay=0.0;
 		cls[1].sand=70.0;
 		cls[1].clay=0.0;
 		cls[2].sand=37.0;
 		cls[2].clay=25.0;
-		mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
-		if(mark[0]==1){
-			index=1;
+		index = point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
+		if(index==1){
 			//printf("Poros=0.525\n");
 			porosity=0.525;
 		}
-	}
+	} 
 	if (index==0){// if index not found then continue
 		cls[0].sand=25.0;
 		cls[0].clay=75.0;
@@ -216,13 +213,12 @@
 		cls[1].clay=55.0;
 		cls[2].sand=28.0;
 		cls[2].clay=61.0;
-		mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
-		if(mark[0]==1){
-			index=1;
+		index = point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
+		if(index==1){
 			//printf("Poros=0.525\n");
 			porosity=0.525;
 		}
-	}
+	} 
 	if (index==0){// if index not found then continue
 		cls[0].sand=25.0;
 		cls[0].clay=75.0;
@@ -230,16 +226,14 @@
 		cls[1].clay=65.0;
 		cls[2].sand=28.0;
 		cls[2].clay=61.0;
-		mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
-		if(mark[0]==1){
-			index=1;
+		index = point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
+		if(index==1){
 			//printf("Poros=0.525\n");
 			porosity=0.525;
 		}
-	}
+	} 
 	if (index==0){// if index not found then continue
-		index=1;
-		//printf("Poros=0.475\n");
+		//printf("Poros=0.475 (final choice...)\n");
 		porosity=0.475;
 	}
 	return porosity;



More information about the grass-commit mailing list