[GRASS-SVN] r56731 - grass/branches/develbranch_6/raster/r.li/r.li.patchdensity

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jun 16 04:11:37 PDT 2013


Author: hamish
Date: 2013-06-16 04:11:37 -0700 (Sun, 16 Jun 2013)
New Revision: 56731

Modified:
   grass/branches/develbranch_6/raster/r.li/r.li.patchdensity/description.html
   grass/branches/develbranch_6/raster/r.li/r.li.patchdensity/main.c
Log:
move G_allocate_cell_buf() after possible return, html fixes, whitespace

Modified: grass/branches/develbranch_6/raster/r.li/r.li.patchdensity/description.html
===================================================================
--- grass/branches/develbranch_6/raster/r.li/r.li.patchdensity/description.html	2013-06-16 10:39:55 UTC (rev 56730)
+++ grass/branches/develbranch_6/raster/r.li/r.li.patchdensity/description.html	2013-06-16 11:11:37 UTC (rev 56731)
@@ -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:
 
@@ -9,11 +10,14 @@
 that is 1000000 by number of patch for area unit.
 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 map=my_map conf=my_conf out=my_out
 </pre></div>
@@ -34,27 +38,32 @@
 d.vect forests type=boundary
 </pre></div>
 
+
 <H2>NOTES</H2>
 
 A map of NULL values is considered to have zero patches. <br>
 If you want to have null values instead run <br>
 <div class="code"><pre>
 r.null setnull=0 map=my_out
-<pre></div>
+</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<pre>
+<i>Last changed: $Date$</i>

Modified: grass/branches/develbranch_6/raster/r.li/r.li.patchdensity/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.li/r.li.patchdensity/main.c	2013-06-16 10:39:55 UTC (rev 56730)
+++ grass/branches/develbranch_6/raster/r.li/r.li.patchdensity/main.c	2013-06-16 11:11:37 UTC (rev 56731)
@@ -68,21 +68,25 @@
     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");
+
     G_set_c_null_value(&complete_value, 1);
     mapset = G_find_cell(ad->raster, "");
     if (G_get_cellhd(ad->raster, mapset, &hd) == -1)
 	return 0;
-    sup = G_allocate_cell_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 = G_allocate_cell_buf();
+
+    /* calculate distance */
     G_begin_distance_calculations();
     /* EW Dist at North edge */
     EW_DIST1 = G_distance(hd.east, hd.north, hd.west, hd.north);
@@ -94,15 +98,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 +205,6 @@
 	*result = -1;
 
     G_free(sup);
+
     return RLI_OK;
 }



More information about the grass-commit mailing list