Browse Source

move Rast_allocate_c_buf() after possible return, whitespace (merge from devbr6)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@56732 15284696-431f-4ddb-bdfa-cd5b030d7da7
Hamish Bowman 12 years ago
parent
commit
b5468646f2

+ 10 - 6
raster/r.li/r.li.patchdensity/main.c

@@ -68,20 +68,23 @@ int patch_density(int fd, char **par, struct area_entry *ad, double *result)
     double EW_DIST1, EW_DIST2, NS_DIST1, NS_DIST2;
     double EW_DIST1, EW_DIST2, NS_DIST1, NS_DIST2;
     int mask_fd = -1, *mask_buf, *mask_sup, null_count = 0;
     int mask_fd = -1, *mask_buf, *mask_sup, null_count = 0;
 
 
+    G_debug(1, "begin patch_density() index");
+
     Rast_set_c_null_value(&complete_value, 1);
     Rast_set_c_null_value(&complete_value, 1);
     Rast_get_cellhd(ad->raster, "", &hd);
     Rast_get_cellhd(ad->raster, "", &hd);
 
 
-    sup = Rast_allocate_c_buf();
-
     /* open mask if needed */
     /* open mask if needed */
     if (ad->mask == 1) {
     if (ad->mask == 1) {
 	if ((mask_fd = open(ad->mask_name, O_RDONLY, 0755)) < 0)
 	if ((mask_fd = open(ad->mask_name, O_RDONLY, 0755)) < 0)
 	    return 0;
 	    return 0;
+
 	mask_buf = malloc(ad->cl * sizeof(int));
 	mask_buf = malloc(ad->cl * sizeof(int));
 	mask_sup = malloc(ad->cl * sizeof(int));
 	mask_sup = malloc(ad->cl * sizeof(int));
     }
     }
 
 
-    /*calculate distance */
+    sup = Rast_allocate_c_buf();
+
+    /* calculate distance */
     G_begin_distance_calculations();
     G_begin_distance_calculations();
     /* EW Dist at North edge */
     /* EW Dist at North edge */
     EW_DIST1 = G_distance(hd.east, hd.north, hd.west, hd.north);
     EW_DIST1 = G_distance(hd.east, hd.north, hd.west, hd.north);
@@ -93,15 +96,15 @@ int patch_density(int fd, char **par, struct area_entry *ad, double *result)
     NS_DIST2 = G_distance(hd.west, hd.north, hd.west, hd.south);
     NS_DIST2 = G_distance(hd.west, hd.north, hd.west, hd.south);
 
 
 
 
-
-
-    /*calculate number of patch */
+    /* calculate number of patch */
 
 
     for (i = 0; i < ad->rl; i++) {
     for (i = 0; i < ad->rl; i++) {
 	buf = RLI_get_cell_raster_row(fd, i + ad->y, ad);
 	buf = RLI_get_cell_raster_row(fd, i + ad->y, ad);
+
 	if (i > 0) {
 	if (i > 0) {
 	    sup = RLI_get_cell_raster_row(fd, i - 1 + ad->y, ad);
 	    sup = RLI_get_cell_raster_row(fd, i - 1 + ad->y, ad);
 	}
 	}
+
 	/* mask values */
 	/* mask values */
 	if (ad->mask == 1) {
 	if (ad->mask == 1) {
 	    int k;
 	    int k;
@@ -201,5 +204,6 @@ int patch_density(int fd, char **par, struct area_entry *ad, double *result)
 	*result = -1;
 	*result = -1;
 
 
     G_free(sup);
     G_free(sup);
+
     return RLI_OK;
     return RLI_OK;
 }
 }

+ 15 - 6
raster/r.li/r.li.patchdensity/r.li.patchdensity.html

@@ -1,4 +1,5 @@
 <h2>DESCRIPTION</h2>
 <h2>DESCRIPTION</h2>
+
 <em>r.li.patchdensity</em> is a patch index for <em>r.li</em> suite.
 <em>r.li.patchdensity</em> is a patch index for <em>r.li</em> suite.
 It calculates the function:
 It calculates the function:
 
 
@@ -10,9 +11,11 @@ that is 1000000 by number of patch for area unit.
 This index is calculated using a 4 neighbour algorithm.
 This index is calculated using a 4 neighbour algorithm.
 
 
 <h2>EXAMPLES</h2>
 <h2>EXAMPLES</h2>
-To calculate patch density index on map <em>my_map</em>, using <em>my_conf</em>
-configuration file (previously defined with <em>r.li.setup</em>) and saving
-results in the raster map <em>my_out</em>, run:
+
+To calculate patch density index on map <em>my_map</em>, using
+<em>my_conf</em> configuration file (previously defined with
+<em>r.li.setup</em>) and saving results in the raster map
+<em>my_out</em>, run:
 
 
 <div class="code"><pre>
 <div class="code"><pre>
 r.li.patchdensity input=my_map conf=my_conf out=my_out
 r.li.patchdensity input=my_map conf=my_conf out=my_out
@@ -34,6 +37,7 @@ r.to.vect forests out=forests feature=area
 d.vect forests type=boundary
 d.vect forests type=boundary
 </pre></div>
 </pre></div>
 
 
+
 <h2>NOTES</h2>
 <h2>NOTES</h2>
 
 
 A map of NULL values is considered to have zero patches. <br>
 A map of NULL values is considered to have zero patches. <br>
@@ -43,17 +47,22 @@ r.null setnull=0 map=my_out
 </pre></div>
 </pre></div>
 after index calculation.<br>
 after index calculation.<br>
 <!-- next ??????: -->
 <!-- next ??????: -->
-If raster area is 0, <em>r.li.patchdensity</em> returns -1. This is only possible
-if the raster is masked.
+If raster area is 0, <em>r.li.patchdensity</em> returns -1. This is only
+possible if the raster is masked.
+
 
 
 <h2>SEE ALSO</h2>
 <h2>SEE ALSO</h2>
+
 <em><a href="r.li.html">r.li</A></em> package overview <br>
 <em><a href="r.li.html">r.li</A></em> package overview <br>
 <em><a href="r.li.daemon.html">r.li.daemon</A></em><br>
 <em><a href="r.li.daemon.html">r.li.daemon</A></em><br>
 <em><a href="r.li.setup.html">r.li.setup</A></em>
 <em><a href="r.li.setup.html">r.li.setup</A></em>
 
 
+
 <h2>AUTHORS</h2>
 <h2>AUTHORS</h2>
+
 Claudio Porta and Lucio Davide Spano, students of Computer Science 
 Claudio Porta and Lucio Davide Spano, students of Computer Science 
 University of Pisa (Italy).<br>
 University of Pisa (Italy).<br>
 Commission from Faunalia Pontedera (PI) (www.faunalia.it)<br>
 Commission from Faunalia Pontedera (PI) (www.faunalia.it)<br>
 
 
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>