[GRASS-SVN] r63219 - in grass/branches/releasebranch_7_0/raster/r.li: r.li.edgedensity r.li.mpa

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Nov 28 00:59:02 PST 2014


Author: mmetz
Date: 2014-11-28 00:59:02 -0800 (Fri, 28 Nov 2014)
New Revision: 63219

Modified:
   grass/branches/releasebranch_7_0/raster/r.li/r.li.edgedensity/edgedensity.c
   grass/branches/releasebranch_7_0/raster/r.li/r.li.mpa/mpa.c
Log:
r.li: sync to trunk

Modified: grass/branches/releasebranch_7_0/raster/r.li/r.li.edgedensity/edgedensity.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.li/r.li.edgedensity/edgedensity.c	2014-11-28 08:30:51 UTC (rev 63218)
+++ grass/branches/releasebranch_7_0/raster/r.li/r.li.edgedensity/edgedensity.c	2014-11-28 08:59:02 UTC (rev 63219)
@@ -32,9 +32,12 @@
 int calculateD(int fd, struct area_entry *ad, char **par, double *result);
 int calculateF(int fd, struct area_entry *ad, char **par, double *result);
 
+static int brdr = 1;
+
 int main(int argc, char *argv[])
 {
     struct Option *raster, *conf, *output, *class;
+    struct Flag *flag_brdr;
     struct GModule *module;
     char **par = NULL;
 
@@ -66,7 +69,11 @@
     class->description = _("It can be integer, double or float; "
 			   "it will be changed in function of map type");
 
+    flag_brdr = G_define_flag();
+    flag_brdr->key = 'b';
+    flag_brdr->description = _("Exclude border edges");
 
+
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
@@ -75,6 +82,7 @@
     else
 	par = &class->answer;
 
+    brdr = flag_brdr->answer == 0;
 
     return calculateIndex(conf->answer, edgedensity, par, raster->answer,
 			  output->answer);
@@ -206,33 +214,62 @@
 		Rast_set_c_null_value(&supCell, 1);
 	    }
 
-	    if (!Rast_is_c_null_value(&corrCell)) {
-		area++; 
-	        if (Rast_is_c_null_value(&ptype) || corrCell == ptype) {
-		    
-		    if (Rast_is_c_null_value(&precCell) || precCell != corrCell) {
-			nedges++;
+	    if (brdr) {
+		if (!Rast_is_c_null_value(&corrCell)) {
+		    area++; 
+		    if (Rast_is_c_null_value(&ptype) || corrCell == ptype) {
+			if (Rast_is_c_null_value(&precCell) || precCell != corrCell) {
+			    nedges++;
+			}
+			if (Rast_is_c_null_value(&supCell) || supCell != corrCell) {
+			    nedges++;
+			}
+			/* right and bottom */
+			if (i == ad->rl - 1)
+			    nedges++;
+			if (j == ad->cl - 1)
+			    nedges++;
 		    }
-		    if (Rast_is_c_null_value(&supCell) || supCell != corrCell) {
-			nedges++;
+		}
+		else /* corrCell == NULL */ {
+		    if (!Rast_is_c_null_value(&precCell)) {
+			if (Rast_is_c_null_value(&ptype) || precCell == ptype) {
+			    nedges++;
+			}
 		    }
-		    /* right and bottom */
-		    if (i == ad->rl - 1)
-			nedges++;
-		    if (j == ad->cl - 1)
-			nedges++;
+		    if (!Rast_is_c_null_value(&supCell)) {
+			if (Rast_is_c_null_value(&ptype) || supCell == ptype) {
+			    nedges++;
+			}
+		    }
 		}
 	    }
-	    else /* corrCell == NULL */ {
-		if (!Rast_is_c_null_value(&precCell)) {
-		    if (Rast_is_c_null_value(&ptype) || precCell == ptype) {
-			nedges++;
+	    else {
+		/* exclude border edges */
+		if (!Rast_is_c_null_value(&corrCell)) {
+		    area++; 
+		    if (Rast_is_c_null_value(&ptype) || corrCell == ptype) {
+			if (j > 0 && !(masked && mask_buf[j - 1] == 0) &&
+			    (Rast_is_c_null_value(&precCell) || precCell != corrCell)) {
+			    nedges++;
+			}
+			if (i > 0 && !(masked && mask_sup[i - 1] == 0) &&
+			    (Rast_is_c_null_value(&supCell) || supCell != corrCell)) {
+			    nedges++;
+			}
 		    }
 		}
-		if (!Rast_is_c_null_value(&supCell)) {
-		    if (Rast_is_c_null_value(&ptype) || supCell == ptype) {
-			nedges++;
+		else if (Rast_is_c_null_value(&corrCell) && !(masked && mask_buf[j] == 0)) {
+		    if (!Rast_is_c_null_value(&precCell)) {
+			if (Rast_is_c_null_value(&ptype) || precCell == ptype) {
+			    nedges++;
+			}
 		    }
+		    if (!Rast_is_c_null_value(&supCell)) {
+			if (Rast_is_c_null_value(&ptype) || supCell == ptype) {
+			    nedges++;
+			}
+		    }
 		}
 	    }
 	    precCell = corrCell;
@@ -365,33 +402,62 @@
 		Rast_set_d_null_value(&supCell, 1);
 	    }
 
-	    if (!Rast_is_d_null_value(&corrCell)) {
-		area++; 
-	        if (Rast_is_d_null_value(&ptype) || corrCell == ptype) {
-		    
-		    if (Rast_is_d_null_value(&precCell) || precCell != corrCell) {
-			nedges++;
+	    if (brdr) {
+		if (!Rast_is_d_null_value(&corrCell)) {
+		    area++; 
+		    if (Rast_is_d_null_value(&ptype) || corrCell == ptype) {
+			if (Rast_is_d_null_value(&precCell) || precCell != corrCell) {
+			    nedges++;
+			}
+			if (Rast_is_d_null_value(&supCell) || supCell != corrCell) {
+			    nedges++;
+			}
+			/* right and bottom */
+			if (i == ad->rl - 1)
+			    nedges++;
+			if (j == ad->cl - 1)
+			    nedges++;
 		    }
-		    if (Rast_is_d_null_value(&supCell) || supCell != corrCell) {
-			nedges++;
+		}
+		else /* corrCell == NULL */ {
+		    if (!Rast_is_d_null_value(&precCell)) {
+			if (Rast_is_d_null_value(&ptype) || precCell == ptype) {
+			    nedges++;
+			}
 		    }
-		    /* right and bottom */
-		    if (i == ad->rl - 1)
-			nedges++;
-		    if (j == ad->cl - 1)
-			nedges++;
+		    if (!Rast_is_d_null_value(&supCell)) {
+			if (Rast_is_d_null_value(&ptype) || supCell == ptype) {
+			    nedges++;
+			}
+		    }
 		}
 	    }
-	    else /* corrCell == NULL */ {
-		if (!Rast_is_d_null_value(&precCell)) {
-		    if (Rast_is_d_null_value(&ptype) || precCell == ptype) {
-			nedges++;
+	    else {
+		/* exclude border edges */
+		if (!Rast_is_d_null_value(&corrCell)) {
+		    area++; 
+		    if (Rast_is_d_null_value(&ptype) || corrCell == ptype) {
+			if (j > 0 && !(masked && mask_buf[j - 1] == 0) &&
+			    (Rast_is_d_null_value(&precCell) || precCell != corrCell)) {
+			    nedges++;
+			}
+			if (i > 0 && !(masked && mask_sup[i - 1] == 0) &&
+			    (Rast_is_d_null_value(&supCell) || supCell != corrCell)) {
+			    nedges++;
+			}
 		    }
 		}
-		if (!Rast_is_d_null_value(&supCell)) {
-		    if (Rast_is_d_null_value(&ptype) || supCell == ptype) {
-			nedges++;
+		else if (Rast_is_d_null_value(&corrCell) && !(masked && mask_buf[j] == 0)) {
+		    if (!Rast_is_d_null_value(&precCell)) {
+			if (Rast_is_d_null_value(&ptype) || precCell == ptype) {
+			    nedges++;
+			}
 		    }
+		    if (!Rast_is_d_null_value(&supCell)) {
+			if (Rast_is_d_null_value(&ptype) || supCell == ptype) {
+			    nedges++;
+			}
+		    }
 		}
 	    }
 	    precCell = corrCell;
@@ -524,33 +590,62 @@
 		Rast_set_f_null_value(&supCell, 1);
 	    }
 
-	    if (!Rast_is_f_null_value(&corrCell)) {
-		area++; 
-	        if (Rast_is_f_null_value(&ptype) || corrCell == ptype) {
-		    
-		    if (Rast_is_f_null_value(&precCell) || precCell != corrCell) {
-			nedges++;
+	    if (brdr) {
+		if (!Rast_is_f_null_value(&corrCell)) {
+		    area++; 
+		    if (Rast_is_f_null_value(&ptype) || corrCell == ptype) {
+			if (Rast_is_f_null_value(&precCell) || precCell != corrCell) {
+			    nedges++;
+			}
+			if (Rast_is_f_null_value(&supCell) || supCell != corrCell) {
+			    nedges++;
+			}
+			/* right and bottom */
+			if (i == ad->rl - 1)
+			    nedges++;
+			if (j == ad->cl - 1)
+			    nedges++;
 		    }
-		    if (Rast_is_f_null_value(&supCell) || supCell != corrCell) {
-			nedges++;
+		}
+		else /* corrCell == NULL */ {
+		    if (!Rast_is_f_null_value(&precCell)) {
+			if (Rast_is_f_null_value(&ptype) || precCell == ptype) {
+			    nedges++;
+			}
 		    }
-		    /* right and bottom */
-		    if (i == ad->rl - 1)
-			nedges++;
-		    if (j == ad->cl - 1)
-			nedges++;
+		    if (!Rast_is_f_null_value(&supCell)) {
+			if (Rast_is_f_null_value(&ptype) || supCell == ptype) {
+			    nedges++;
+			}
+		    }
 		}
 	    }
-	    else /* corrCell == NULL */ {
-		if (!Rast_is_f_null_value(&precCell)) {
-		    if (Rast_is_f_null_value(&ptype) || precCell == ptype) {
-			nedges++;
+	    else {
+		/* exclude border edges */
+		if (!Rast_is_f_null_value(&corrCell)) {
+		    area++; 
+		    if (Rast_is_f_null_value(&ptype) || corrCell == ptype) {
+			if (j > 0 && !(masked && mask_buf[j - 1] == 0) &&
+			    (Rast_is_f_null_value(&precCell) || precCell != corrCell)) {
+			    nedges++;
+			}
+			if (i > 0 && !(masked && mask_sup[i - 1] == 0) &&
+			    (Rast_is_f_null_value(&supCell) || supCell != corrCell)) {
+			    nedges++;
+			}
 		    }
 		}
-		if (!Rast_is_f_null_value(&supCell)) {
-		    if (Rast_is_f_null_value(&ptype) || supCell == ptype) {
-			nedges++;
+		else if (Rast_is_f_null_value(&corrCell) && !(masked && mask_buf[j] == 0)) {
+		    if (!Rast_is_f_null_value(&precCell)) {
+			if (Rast_is_f_null_value(&ptype) || precCell == ptype) {
+			    nedges++;
+			}
 		    }
+		    if (!Rast_is_f_null_value(&supCell)) {
+			if (Rast_is_f_null_value(&ptype) || supCell == ptype) {
+			    nedges++;
+			}
+		    }
 		}
 	    }
 	    precCell = corrCell;

Modified: grass/branches/releasebranch_7_0/raster/r.li/r.li.mpa/mpa.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.li/r.li.mpa/mpa.c	2014-11-28 08:30:51 UTC (rev 63218)
+++ grass/branches/releasebranch_7_0/raster/r.li/r.li.mpa/mpa.c	2014-11-28 08:59:02 UTC (rev 63219)
@@ -15,14 +15,13 @@
  *
  *****************************************************************************/
 
-#include <grass/gis.h>
-#include <grass/raster.h>
-#include <grass/glocale.h>
-
 #include <stdlib.h>
 #include <fcntl.h>
 #include <math.h>
 
+#include <grass/gis.h>
+#include <grass/raster.h>
+#include <grass/glocale.h>
 
 #include "../r.li.daemon/defs.h"
 #include "../r.li.daemon/daemon.h"



More information about the grass-commit mailing list