[GRASS-SVN] r56732 - grass/trunk/raster/r.li/r.li.patchdensity

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jun 16 04:18:36 PDT 2013


Author: hamish
Date: 2013-06-16 04:18:36 -0700 (Sun, 16 Jun 2013)
New Revision: 56732

Modified:
   grass/trunk/raster/r.li/r.li.patchdensity/main.c
   grass/trunk/raster/r.li/r.li.patchdensity/r.li.patchdensity.html
Log:
move Rast_allocate_c_buf() after possible return, whitespace (merge from devbr6)

Modified: grass/trunk/raster/r.li/r.li.patchdensity/main.c
===================================================================
--- grass/trunk/raster/r.li/r.li.patchdensity/main.c	2013-06-16 11:11:37 UTC (rev 56731)
+++ grass/trunk/raster/r.li/r.li.patchdensity/main.c	2013-06-16 11:18:36 UTC (rev 56732)
@@ -68,20 +68,23 @@
     double EW_DIST1, EW_DIST2, NS_DIST1, NS_DIST2;
     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_get_cellhd(ad->raster, "", &hd);
 
-    sup = Rast_allocate_c_buf();
-
     /* open mask if needed */
     if (ad->mask == 1) {
 	if ((mask_fd = open(ad->mask_name, O_RDONLY, 0755)) < 0)
 	    return 0;
+
 	mask_buf = 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();
     /* EW Dist at North edge */
     EW_DIST1 = G_distance(hd.east, hd.north, hd.west, hd.north);
@@ -93,15 +96,15 @@
     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++) {
 	buf = RLI_get_cell_raster_row(fd, i + ad->y, ad);
+
 	if (i > 0) {
 	    sup = RLI_get_cell_raster_row(fd, i - 1 + ad->y, ad);
 	}
+
 	/* mask values */
 	if (ad->mask == 1) {
 	    int k;
@@ -201,5 +204,6 @@
 	*result = -1;
 
     G_free(sup);
+
     return RLI_OK;
 }

Modified: grass/trunk/raster/r.li/r.li.patchdensity/r.li.patchdensity.html
===================================================================
--- grass/trunk/raster/r.li/r.li.patchdensity/r.li.patchdensity.html	2013-06-16 11:11:37 UTC (rev 56731)
+++ grass/trunk/raster/r.li/r.li.patchdensity/r.li.patchdensity.html	2013-06-16 11:18:36 UTC (rev 56732)
@@ -1,4 +1,5 @@
 <h2>DESCRIPTION</h2>
+
 <em>r.li.patchdensity</em> is a patch index for <em>r.li</em> suite.
 It calculates the function:
 
@@ -10,10 +11,12 @@
 This index is calculated using a 4 neighbour algorithm.
 
 <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>
 r.li.patchdensity input=my_map conf=my_conf out=my_out
 </pre></div>
@@ -34,6 +37,7 @@
 d.vect forests type=boundary
 </pre></div>
 
+
 <h2>NOTES</h2>
 
 A map of NULL values is considered to have zero patches. <br>
@@ -43,17 +47,22 @@
 </pre></div>
 after index calculation.<br>
 <!-- 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>
+
 <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.setup.html">r.li.setup</A></em>
 
+
 <h2>AUTHORS</h2>
+
 Claudio Porta and Lucio Davide Spano, students of Computer Science 
 University of Pisa (Italy).<br>
 Commission from Faunalia Pontedera (PI) (www.faunalia.it)<br>
 
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>



More information about the grass-commit mailing list