[GRASS-SVN] r47676 - in grass/trunk/raster/r.li: r.li.cwed
r.li.daemon r.li.edgedensity r.li.mpa r.li.padcv
r.li.padrange r.li.padsd r.li.patchdensity r.li.patchnum
r.li.pielou r.li.renyi
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 16 10:13:52 EDT 2011
Author: neteler
Date: 2011-08-16 07:13:52 -0700 (Tue, 16 Aug 2011)
New Revision: 47676
Modified:
grass/trunk/raster/r.li/r.li.cwed/cwed.c
grass/trunk/raster/r.li/r.li.daemon/avl.h
grass/trunk/raster/r.li/r.li.daemon/daemon.c
grass/trunk/raster/r.li/r.li.daemon/daemon.h
grass/trunk/raster/r.li/r.li.daemon/index.h
grass/trunk/raster/r.li/r.li.daemon/worker.c
grass/trunk/raster/r.li/r.li.edgedensity/edgedensity.c
grass/trunk/raster/r.li/r.li.mpa/mpa.c
grass/trunk/raster/r.li/r.li.padcv/padcv.c
grass/trunk/raster/r.li/r.li.padrange/padrange.c
grass/trunk/raster/r.li/r.li.padsd/padsd.c
grass/trunk/raster/r.li/r.li.patchdensity/main.c
grass/trunk/raster/r.li/r.li.patchnum/main.c
grass/trunk/raster/r.li/r.li.pielou/pielou.c
grass/trunk/raster/r.li/r.li.renyi/renyi.c
Log:
code layout fixes with indent
Modified: grass/trunk/raster/r.li/r.li.cwed/cwed.c
===================================================================
--- grass/trunk/raster/r.li/r.li.cwed/cwed.c 2011-08-16 14:13:05 UTC (rev 47675)
+++ grass/trunk/raster/r.li/r.li.cwed/cwed.c 2011-08-16 14:13:52 UTC (rev 47676)
@@ -430,7 +430,7 @@
G_free(mask_corr);
G_free(mask_sup);
}
-
+
G_free(buf_sup);
return RLI_OK;
}
Modified: grass/trunk/raster/r.li/r.li.daemon/avl.h
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/avl.h 2011-08-16 14:13:05 UTC (rev 47675)
+++ grass/trunk/raster/r.li/r.li.daemon/avl.h 2011-08-16 14:13:52 UTC (rev 47676)
@@ -14,7 +14,7 @@
typedef struct avl_node
{
- generic_cell key; /* key field is a CELL or a DCELL or a FCELL */
+ generic_cell key; /* key field is a CELL or a DCELL or a FCELL */
long counter; /* data */
struct avl_node *father;
struct avl_node *right_child;
Modified: grass/trunk/raster/r.li/r.li.daemon/daemon.c
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/daemon.c 2011-08-16 14:13:05 UTC (rev 47675)
+++ grass/trunk/raster/r.li/r.li.daemon/daemon.c 2011-08-16 14:13:52 UTC (rev 47676)
@@ -69,8 +69,9 @@
/* strip off leading path if present */
char testpath[GPATH_MAX];
+
sprintf(testpath, "%s%s", G_home(), "/.grass7/r.li/");
- if(strncmp(file, testpath, strlen(testpath)) == 0)
+ if (strncmp(file, testpath, strlen(testpath)) == 0)
file += strlen(testpath);
/* TODO: check if this path is portable */
@@ -100,8 +101,7 @@
sprintf(out, "%s/.grass7/", G_home());
doneDir = G_mkdir(out);
if (doneDir == -1 && errno != EEXIST)
- G_fatal_error(_("Cannot create %s/.grass7/ directory"),
- G_home());
+ G_fatal_error(_("Cannot create %s/.grass7/ directory"), G_home());
/* check if ~/.grass7/r.li/ exists */
sprintf(out, "%s/.grass7/r.li/", G_home());
@@ -127,35 +127,35 @@
/*first job scheduling */
if (next_Area(parsed, l, g, &m) != 0)
- /*body */
- while (next_Area(parsed, l, g, &m) != 0) {
- worker_process(&doneJob, &m);
+ /*body */
+ while (next_Area(parsed, l, g, &m) != 0) {
+ worker_process(&doneJob, &m);
- /*perc++; */
- /*G_percent (perc, WORKERS, 1); */
- if (doneJob.type == DONE) {
- double result;
+ /*perc++; */
+ /*G_percent (perc, WORKERS, 1); */
+ if (doneJob.type == DONE) {
+ double result;
- result = doneJob.f.f_d.res;
- /*output */
- if (parsed != MVWIN) {
- print_Output(res, doneJob);
+ result = doneJob.f.f_d.res;
+ /*output */
+ if (parsed != MVWIN) {
+ print_Output(res, doneJob);
+ }
+ else {
+ /*raster output */
+ raster_Output(random_access, doneJob.f.f_d.aid, g,
+ doneJob.f.f_d.res);
+ }
}
else {
- /*raster output */
- raster_Output(random_access, doneJob.f.f_d.aid, g,
- doneJob.f.f_d.res);
+ if (parsed != MVWIN) {
+ error_Output(res, doneJob);
+ }
+ else {
+ /*printf("todo ");fflush(stdout); *//* TODO scrivere su raster NULL ??? */
+ }
}
}
- else {
- if (parsed != MVWIN) {
- error_Output(res, doneJob);
- }
- else {
- /*printf("todo ");fflush(stdout); *//* TODO scrivere su raster NULL ??? */
- }
- }
- }
worker_end();
@@ -277,7 +277,7 @@
}
} while ((token = strtok(NULL, " ")) != NULL &&
- strcmp(token, "SAMPLEAREA") == 0);
+ strcmp(token, "SAMPLEAREA") == 0);
close(setup);
Modified: grass/trunk/raster/r.li/r.li.daemon/daemon.h
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/daemon.h 2011-08-16 14:13:05 UTC (rev 47675)
+++ grass/trunk/raster/r.li/r.li.daemon/daemon.h 2011-08-16 14:13:52 UTC (rev 47676)
@@ -203,7 +203,7 @@
*/
void worker_init(char *raster, int f(int, char **, area_des, double *),
char **parameters);
-void worker_process(msg *ret, msg *m);
+void worker_process(msg * ret, msg * m);
void worker_end(void);
/**
Modified: grass/trunk/raster/r.li/r.li.daemon/index.h
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/index.h 2011-08-16 14:13:05 UTC (rev 47675)
+++ grass/trunk/raster/r.li/r.li.daemon/index.h 2011-08-16 14:13:52 UTC (rev 47676)
@@ -5,7 +5,7 @@
*
* \author Claudio Porta, Lucio Davide Spano, Serena Pallecchi students of Computer Science University of Pisa (Italy)
* Commission from Faunalia Pontedera (PI) www.faunalia.it
- * Luca Delucchi and Duccio Rocchini, Fondazione Edmund Mach, Italy: r.li.pielou, r.li.renyi
+ * Luca Delucchi and Duccio Rocchini, Fondazione Edmund Mach, Italy: r.li.pielou, r.li.renyi
*
*
* This program is free software under the GPL (>=v2)
Modified: grass/trunk/raster/r.li/r.li.daemon/worker.c
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/worker.c 2011-08-16 14:13:05 UTC (rev 47675)
+++ grass/trunk/raster/r.li/r.li.daemon/worker.c 2011-08-16 14:13:52 UTC (rev 47676)
@@ -49,7 +49,7 @@
static fcell_manager fm;
static char *raster;
static char **parameters;
-static int (*func)(int, char **, area_des, double *);
+static int (*func) (int, char **, area_des, double *);
void worker_init(char *r, int f(int, char **, area_des, double *), char **p)
{
@@ -71,26 +71,26 @@
/* calculate rows in cache */
switch (data_type) {
case CELL_TYPE:{
- cache_rows = CACHESIZE / (hd.cols * sizeof(CELL));
- cm->cache = G_malloc(cache_rows * sizeof(CELL *));
- cm->contents = G_malloc(cache_rows * sizeof(int));
- cm->used = 0;
- cm->contents[0] = -1;
- } break;
+ cache_rows = CACHESIZE / (hd.cols * sizeof(CELL));
+ cm->cache = G_malloc(cache_rows * sizeof(CELL *));
+ cm->contents = G_malloc(cache_rows * sizeof(int));
+ cm->used = 0;
+ cm->contents[0] = -1;
+ } break;
case DCELL_TYPE:{
- cache_rows = CACHESIZE / (hd.cols * sizeof(DCELL));
- dm->cache = G_malloc(cache_rows * sizeof(DCELL *));
- dm->contents = G_malloc(cache_rows * sizeof(int));
- dm->used = 0;
- dm->contents[0] = -1;
- } break;
+ cache_rows = CACHESIZE / (hd.cols * sizeof(DCELL));
+ dm->cache = G_malloc(cache_rows * sizeof(DCELL *));
+ dm->contents = G_malloc(cache_rows * sizeof(int));
+ dm->used = 0;
+ dm->contents[0] = -1;
+ } break;
case FCELL_TYPE:{
- cache_rows = CACHESIZE / (hd.cols * sizeof(FCELL));
- fm->cache = G_malloc(cache_rows * sizeof(FCELL *));
- fm->contents = G_malloc(cache_rows * sizeof(int));
- fm->used = 0;
- fm->contents[0] = -1;
- } break;
+ cache_rows = CACHESIZE / (hd.cols * sizeof(FCELL));
+ fm->cache = G_malloc(cache_rows * sizeof(FCELL *));
+ fm->contents = G_malloc(cache_rows * sizeof(int));
+ fm->used = 0;
+ fm->contents[0] = -1;
+ } break;
}
ad->data_type = data_type;
ad->cm = cm;
@@ -98,7 +98,7 @@
ad->dm = dm;
}
-void worker_process(msg *ret, msg *m)
+void worker_process(msg * ret, msg * m)
{
switch (m->type) {
case AREA:
@@ -149,22 +149,22 @@
switch (data_type) {
case CELL_TYPE:{
- for (i = 0; i < (ad->rl - used); i++) {
- cm->cache[used + i] = Rast_allocate_c_buf();
+ for (i = 0; i < (ad->rl - used); i++) {
+ cm->cache[used + i] = Rast_allocate_c_buf();
+ }
}
- }
break;
case DCELL_TYPE:{
- for (i = 0; i < ad->rl - used; i++) {
- dm->cache[used + i] = Rast_allocate_d_buf();
+ for (i = 0; i < ad->rl - used; i++) {
+ dm->cache[used + i] = Rast_allocate_d_buf();
+ }
}
- }
break;
case FCELL_TYPE:{
- for (i = 0; i < ad->rl - used; i++) {
- fm->cache[used + i] = Rast_allocate_f_buf();
+ for (i = 0; i < ad->rl - used; i++) {
+ fm->cache[used + i] = Rast_allocate_f_buf();
+ }
}
- }
break;
}
cm->used = ad->rl;
Modified: grass/trunk/raster/r.li/r.li.edgedensity/edgedensity.c
===================================================================
--- grass/trunk/raster/r.li/r.li.edgedensity/edgedensity.c 2011-08-16 14:13:05 UTC (rev 47675)
+++ grass/trunk/raster/r.li/r.li.edgedensity/edgedensity.c 2011-08-16 14:13:52 UTC (rev 47676)
@@ -375,7 +375,7 @@
G_free(mask_inf);
G_free(mask_corr);
}
-
+
G_free(buf_sup);
return RLI_OK;
}
Modified: grass/trunk/raster/r.li/r.li.mpa/mpa.c
===================================================================
--- grass/trunk/raster/r.li/r.li.mpa/mpa.c 2011-08-16 14:13:05 UTC (rev 47675)
+++ grass/trunk/raster/r.li/r.li.mpa/mpa.c 2011-08-16 14:13:52 UTC (rev 47676)
@@ -169,6 +169,7 @@
}
return RLI_OK;
}
+
int calculateD(int fd, area_des ad, double *result)
{
DCELL *buf;
Modified: grass/trunk/raster/r.li/r.li.padcv/padcv.c
===================================================================
--- grass/trunk/raster/r.li/r.li.padcv/padcv.c 2011-08-16 14:13:05 UTC (rev 47675)
+++ grass/trunk/raster/r.li/r.li.padcv/padcv.c 2011-08-16 14:13:52 UTC (rev 47676)
@@ -57,6 +57,7 @@
return calculateIndex(conf->answer, patchAreaDistributionCV, NULL,
raster->answer, output->answer);
}
+
int patchAreaDistributionCV(int fd, char **par, area_des ad, double *result)
{
double indice = 0;
@@ -65,8 +66,7 @@
Rast_get_cellhd(ad->raster, "", &hd);
- switch (ad->data_type)
- {
+ switch (ad->data_type) {
case CELL_TYPE:
{
@@ -92,14 +92,14 @@
return RLI_ERRORE;
}
}
- if (ris != RLI_OK)
- {
+ if (ris != RLI_OK) {
*result = -1;
return RLI_ERRORE;
}
*result = indice;
return RLI_OK;
}
+
int calculate(int fd, area_des ad, double *result)
{
CELL *buf;
@@ -135,45 +135,38 @@
gc.t = CELL_TYPE;
/* open mask if needed */
- if (ad->mask == 1)
- {
+ if (ad->mask == 1) {
if ((mask_fd = open(ad->mask_name, O_RDONLY, 0755)) < 0)
return RLI_ERRORE;
mask_buf = G_malloc(ad->cl * sizeof(int));
- if (mask_buf == NULL)
- {
+ if (mask_buf == NULL) {
G_fatal_error("malloc mask_buf failed");
return RLI_ERRORE;
}
masked = TRUE;
}
mask_patch_sup = G_malloc(ad->cl * sizeof(long));
- if (mask_patch_sup == NULL)
- {
+ if (mask_patch_sup == NULL) {
G_fatal_error("malloc mask_patch_sup failed");
return RLI_ERRORE;
}
mask_patch_corr = G_malloc(ad->cl * sizeof(long));
- if (mask_patch_corr == NULL)
- {
+ if (mask_patch_corr == NULL) {
G_fatal_error("malloc mask_patch_corr failed");
return RLI_ERRORE;
}
buf_sup = Rast_allocate_c_buf();
- if (buf_sup == NULL)
- {
+ if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
buf = Rast_allocate_c_buf();
- if (buf == NULL)
- {
+ if (buf == NULL) {
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
Rast_set_c_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
- for (i = 0; i < ad->cl; i++)
- {
+ for (i = 0; i < ad->cl; i++) {
mask_patch_sup[i] = 0;
mask_patch_corr[i] = 0;
}
@@ -181,15 +174,12 @@
/*for each raster row */
{
- if (j > 0)
- {
+ if (j > 0) {
buf_sup = RLI_get_cell_raster_row(fd, j - 1 + ad->y, ad);
}
buf = RLI_get_cell_raster_row(fd, j + ad->y, ad);
- if (masked)
- {
- if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0)
- {
+ if (masked) {
+ if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0) {
G_fatal_error("mask read failed");
return RLI_ERRORE;
}
@@ -200,13 +190,11 @@
{
area++;
corrCell = buf[i + ad->x];
- if (masked && mask_buf[i + ad->x] == 0)
- {
+ if (masked && mask_buf[i + ad->x] == 0) {
Rast_set_c_null_value(&corrCell, 1);
area--;
}
- if (!(Rast_is_null_value(&corrCell, gc.t)))
- {
+ if (!(Rast_is_null_value(&corrCell, gc.t))) {
areaPatch++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
@@ -221,14 +209,12 @@
* 1 2
* */
{
- if (corrCell != supCell)
- {
+ if (corrCell != supCell) {
/* 3
* 1 2
* */
/*new patch */
- if (idCorr == 0)
- { /*first found patch */
+ if (idCorr == 0) { /*first found patch */
lastId = 1;
idCorr = 1;
totCorr = 1;
@@ -239,8 +225,7 @@
/*not first patch */
/* put in the tree the previous value */
{
- if (albero == NULL)
- {
+ if (albero == NULL) {
albero = avlID_make(idCorr, totCorr);
if (albero == NULL) {
G_fatal_error("avlID_make error");
@@ -253,8 +238,7 @@
/*tree not empty */
{
ris = avlID_add(&albero, idCorr, totCorr);
- switch (ris)
- {
+ switch (ris) {
case AVL_ERR:
{
@@ -338,8 +322,7 @@
* 1 1
*/
- if (corrCell == supCell)
- { /*current cell and upper cell are equal */
+ if (corrCell == supCell) { /*current cell and upper cell are equal */
/* 1
* 1 1
*/
@@ -428,10 +411,8 @@
- if (areaPatch != 0)
- {
- if (albero == NULL)
- {
+ if (areaPatch != 0) {
+ if (albero == NULL) {
albero = avlID_make(idCorr, totCorr);
if (albero == NULL) {
G_fatal_error("avlID_make error");
@@ -440,11 +421,9 @@
npatch++;
}
- else
- {
+ else {
ris = avlID_add(&albero, idCorr, totCorr);
- switch (ris)
- {
+ switch (ris) {
case AVL_ERR:
{
@@ -471,22 +450,18 @@
}
}
array = G_malloc(npatch * sizeof(avlID_tableRow));
- if (array == NULL)
- {
+ if (array == NULL) {
G_fatal_error("malloc array failed");
return RLI_ERRORE;
}
tot = avlID_to_array(albero, zero, array);
- if (tot != npatch)
- {
+ if (tot != npatch) {
G_warning
("avlID_to_array unaspected value. the result could be wrong");
return RLI_ERRORE;
}
- for (i = 0; i < npatch; i++)
- {
- if (array[i]->tot == 0)
- {
+ for (i = 0; i < npatch; i++) {
+ if (array[i]->tot == 0) {
doppi++;
}
}
@@ -495,13 +470,11 @@
mn = areaPatch / npatch;
/* calculate summary */
- for (i = 0; i < np; i++)
- {
+ for (i = 0; i < np; i++) {
long areaPi = 0;
double diff;
- if (array[i]->tot != 0)
- {
+ if (array[i]->tot != 0) {
ris = ris + array[i]->tot;
areaPi = (double)array[i]->tot;
diff = areaPi - mn;
@@ -524,6 +497,7 @@
G_free(buf_sup);
return RLI_OK;
}
+
int calculateD(int fd, area_des ad, double *result)
{
DCELL *buf;
@@ -559,45 +533,38 @@
gc.t = DCELL_TYPE;
/* open mask if needed */
- if (ad->mask == 1)
- {
+ if (ad->mask == 1) {
if ((mask_fd = open(ad->mask_name, O_RDONLY, 0755)) < 0)
return RLI_ERRORE;
mask_buf = G_malloc(ad->cl * sizeof(int));
- if (mask_buf == NULL)
- {
+ if (mask_buf == NULL) {
G_fatal_error("malloc mask_buf failed");
return RLI_ERRORE;
}
masked = TRUE;
}
mask_patch_sup = G_malloc(ad->cl * sizeof(long));
- if (mask_patch_sup == NULL)
- {
+ if (mask_patch_sup == NULL) {
G_fatal_error("malloc mask_patch_sup failed");
return RLI_ERRORE;
}
mask_patch_corr = G_malloc(ad->cl * sizeof(long));
- if (mask_patch_corr == NULL)
- {
+ if (mask_patch_corr == NULL) {
G_fatal_error("malloc mask_patch_corr failed");
return RLI_ERRORE;
}
buf_sup = Rast_allocate_d_buf();
- if (buf_sup == NULL)
- {
+ if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
buf = Rast_allocate_d_buf();
- if (buf == NULL)
- {
+ if (buf == NULL) {
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
Rast_set_d_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
- for (i = 0; i < ad->cl; i++)
- {
+ for (i = 0; i < ad->cl; i++) {
mask_patch_sup[i] = 0;
mask_patch_corr[i] = 0;
}
@@ -605,32 +572,26 @@
/*for each raster row */
{
- if (j > 0)
- {
+ if (j > 0) {
buf_sup = RLI_get_dcell_raster_row(fd, j - 1 + ad->y, ad);
}
buf = RLI_get_dcell_raster_row(fd, j + ad->y, ad);
- if (masked)
- {
- if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0)
- {
+ if (masked) {
+ if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0) {
G_fatal_error("mask read failed");
return RLI_ERRORE;
}
}
Rast_set_d_null_value(&precCell, 1);
- for (i = 0; i < ad->cl; i++)
- {
+ for (i = 0; i < ad->cl; i++) {
/* for each dcell in the row */
area++;
corrCell = buf[i + ad->x];
- if (masked && mask_buf[i + ad->x] == 0)
- {
+ if (masked && mask_buf[i + ad->x] == 0) {
Rast_set_d_null_value(&corrCell, 1);
area--;
}
- if (!(Rast_is_null_value(&corrCell, gc.t)))
- {
+ if (!(Rast_is_null_value(&corrCell, gc.t))) {
areaPatch++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
@@ -644,15 +605,13 @@
* 1 2
* */
{
- if (corrCell != supCell)
- {
+ if (corrCell != supCell) {
/* 3
* 1 2
* */
/*new patch */
- if (idCorr == 0)
- { /*first patch */
+ if (idCorr == 0) { /*first patch */
lastId = 1;
idCorr = 1;
totCorr = 1;
@@ -663,8 +622,7 @@
/*not first patch */
/* put in the tree the previous value */
{
- if (albero == NULL)
- {
+ if (albero == NULL) {
albero = avlID_make(idCorr, totCorr);
if (albero == NULL) {
G_fatal_error("avlID_make error");
@@ -677,8 +635,7 @@
/*tree not empty */
{
ris = avlID_add(&albero, idCorr, totCorr);
- switch (ris)
- {
+ switch (ris) {
case AVL_ERR:
{
@@ -762,8 +719,7 @@
* 1 1
*/
- if (corrCell == supCell)
- { /*current cell and upper cell are equal */
+ if (corrCell == supCell) { /*current cell and upper cell are equal */
/* 1
* 1 1
*/
@@ -851,10 +807,8 @@
- if (areaPatch != 0)
- {
- if (albero == NULL)
- {
+ if (areaPatch != 0) {
+ if (albero == NULL) {
albero = avlID_make(idCorr, totCorr);
if (albero == NULL) {
G_fatal_error("avlID_make error");
@@ -863,11 +817,9 @@
npatch++;
}
- else
- {
+ else {
ris = avlID_add(&albero, idCorr, totCorr);
- switch (ris)
- {
+ switch (ris) {
case AVL_ERR:
{
@@ -894,22 +846,18 @@
}
}
array = G_malloc(npatch * sizeof(avlID_tableRow));
- if (array == NULL)
- {
+ if (array == NULL) {
G_fatal_error("malloc array failed");
return RLI_ERRORE;
}
tot = avlID_to_array(albero, zero, array);
- if (tot != npatch)
- {
+ if (tot != npatch) {
G_warning
("avlID_to_array unaspected value. the result could be wrong");
return RLI_ERRORE;
}
- for (i = 0; i < npatch; i++)
- {
- if (array[i]->tot == 0)
- {
+ for (i = 0; i < npatch; i++) {
+ if (array[i]->tot == 0) {
doppi++;
}
}
@@ -918,13 +866,11 @@
mn = areaPatch / npatch;
/* calculate summary */
- for (i = 0; i < np; i++)
- {
+ for (i = 0; i < np; i++) {
long areaPi = 0;
double diff;
- if (array[i]->tot != 0)
- {
+ if (array[i]->tot != 0) {
ris = ris + array[i]->tot;
areaPi = (double)array[i]->tot;
diff = areaPi - mn;
@@ -945,6 +891,7 @@
*result = indice;
return RLI_OK;
}
+
int calculateF(int fd, area_des ad, double *result)
{
FCELL *buf;
@@ -980,45 +927,38 @@
gc.t = FCELL_TYPE;
/* open mask if needed */
- if (ad->mask == 1)
- {
+ if (ad->mask == 1) {
if ((mask_fd = open(ad->mask_name, O_RDONLY, 0755)) < 0)
return RLI_ERRORE;
mask_buf = G_malloc(ad->cl * sizeof(int));
- if (mask_buf == NULL)
- {
+ if (mask_buf == NULL) {
G_fatal_error("malloc mask_buf failed");
return RLI_ERRORE;
}
masked = TRUE;
}
mask_patch_sup = G_malloc(ad->cl * sizeof(long));
- if (mask_patch_sup == NULL)
- {
+ if (mask_patch_sup == NULL) {
G_fatal_error("malloc mask_patch_sup failed");
return RLI_ERRORE;
}
mask_patch_corr = G_malloc(ad->cl * sizeof(long));
- if (mask_patch_corr == NULL)
- {
+ if (mask_patch_corr == NULL) {
G_fatal_error("malloc mask_patch_corr failed");
return RLI_ERRORE;
}
buf_sup = Rast_allocate_f_buf();
- if (buf_sup == NULL)
- {
+ if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
buf = Rast_allocate_f_buf();
- if (buf == NULL)
- {
+ if (buf == NULL) {
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
Rast_set_f_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
- for (i = 0; i < ad->cl; i++)
- {
+ for (i = 0; i < ad->cl; i++) {
mask_patch_sup[i] = 0;
mask_patch_corr[i] = 0;
}
@@ -1026,32 +966,26 @@
/*for each raster row */
{
- if (j > 0)
- {
+ if (j > 0) {
buf_sup = RLI_get_fcell_raster_row(fd, j - 1 + ad->y, ad);
}
buf = RLI_get_fcell_raster_row(fd, j + ad->y, ad);
- if (masked)
- {
- if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0)
- {
+ if (masked) {
+ if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0) {
G_fatal_error("mask read failed");
return RLI_ERRORE;
}
}
Rast_set_f_null_value(&precCell, 1);
- for (i = 0; i < ad->cl; i++)
- {
+ for (i = 0; i < ad->cl; i++) {
/* for each fcell in the row */
area++;
corrCell = buf[i + ad->x];
- if (masked && mask_buf[i + ad->x] == 0)
- {
+ if (masked && mask_buf[i + ad->x] == 0) {
Rast_set_f_null_value(&corrCell, 1);
area--;
}
- if (!(Rast_is_null_value(&corrCell, gc.t)))
- {
+ if (!(Rast_is_null_value(&corrCell, gc.t))) {
areaPatch++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
@@ -1073,8 +1007,7 @@
{
/*new patch */
- if (idCorr == 0)
- { /*first patch */
+ if (idCorr == 0) { /*first patch */
lastId = 1;
idCorr = 1;
totCorr = 1;
@@ -1085,8 +1018,7 @@
/*not first patch */
/* put in the tree the previous value */
{
- if (albero == NULL)
- {
+ if (albero == NULL) {
albero = avlID_make(idCorr, totCorr);
if (albero == NULL) {
G_fatal_error("avlID_make error");
@@ -1099,8 +1031,7 @@
/*tree not empty */
{
ris = avlID_add(&albero, idCorr, totCorr);
- switch (ris)
- {
+ switch (ris) {
case AVL_ERR:
{
@@ -1184,8 +1115,7 @@
* 1 1
*/
- if (corrCell == supCell)
- { /*current cell and upper cell are equal */
+ if (corrCell == supCell) { /*current cell and upper cell are equal */
/* 1
* 1 1
*/
@@ -1274,10 +1204,8 @@
- if (areaPatch != 0)
- {
- if (albero == NULL)
- {
+ if (areaPatch != 0) {
+ if (albero == NULL) {
albero = avlID_make(idCorr, totCorr);
if (albero == NULL) {
G_fatal_error("avlID_make error");
@@ -1286,11 +1214,9 @@
npatch++;
}
- else
- {
+ else {
ris = avlID_add(&albero, idCorr, totCorr);
- switch (ris)
- {
+ switch (ris) {
case AVL_ERR:
{
@@ -1317,22 +1243,18 @@
}
}
array = G_malloc(npatch * sizeof(avlID_tableRow));
- if (array == NULL)
- {
+ if (array == NULL) {
G_fatal_error("malloc array failed");
return RLI_ERRORE;
}
tot = avlID_to_array(albero, zero, array);
- if (tot != npatch)
- {
+ if (tot != npatch) {
G_warning
("avlID_to_array unaspected value. the result could be wrong");
return RLI_ERRORE;
}
- for (i = 0; i < npatch; i++)
- {
- if (array[i]->tot == 0)
- {
+ for (i = 0; i < npatch; i++) {
+ if (array[i]->tot == 0) {
doppi++;
}
}
@@ -1341,13 +1263,11 @@
mn = areaPatch / npatch;
/* calculate summary */
- for (i = 0; i < np; i++)
- {
+ for (i = 0; i < np; i++) {
long areaPi = 0;
double diff;
- if (array[i]->tot != 0)
- {
+ if (array[i]->tot != 0) {
ris = ris + array[i]->tot;
areaPi = (double)array[i]->tot;
diff = areaPi - mn;
Modified: grass/trunk/raster/r.li/r.li.padrange/padrange.c
===================================================================
--- grass/trunk/raster/r.li/r.li.padrange/padrange.c 2011-08-16 14:13:05 UTC (rev 47675)
+++ grass/trunk/raster/r.li/r.li.padrange/padrange.c 2011-08-16 14:13:52 UTC (rev 47676)
@@ -57,6 +57,7 @@
return calculateIndex(conf->answer, patchAreaDistributionRANGE, NULL,
raster->answer, output->answer);
}
+
int patchAreaDistributionRANGE(int fd, char **par, area_des ad,
double *result)
{
@@ -66,8 +67,7 @@
Rast_get_cellhd(ad->raster, "", &hd);
- switch (ad->data_type)
- {
+ switch (ad->data_type) {
case CELL_TYPE:
{
@@ -92,8 +92,7 @@
return RLI_ERRORE;
}
}
- if (ris != RLI_OK)
- {
+ if (ris != RLI_OK) {
*result = -1;
return RLI_ERRORE;
}
@@ -337,8 +336,7 @@
* 1 1
*/
- if (corrCell == supCell)
- { /*current cell and upper cell are equal */
+ if (corrCell == supCell) { /*current cell and upper cell are equal */
/* 1
* 1 1
*/
@@ -543,45 +541,38 @@
gc.t = DCELL_TYPE;
/* open mask if needed */
- if (ad->mask == 1)
- {
+ if (ad->mask == 1) {
if ((mask_fd = open(ad->mask_name, O_RDONLY, 0755)) < 0)
return RLI_ERRORE;
mask_buf = G_malloc(ad->cl * sizeof(int));
- if (mask_buf == NULL)
- {
+ if (mask_buf == NULL) {
G_fatal_error("malloc mask_buf failed");
return RLI_ERRORE;
}
masked = TRUE;
}
mask_patch_sup = G_malloc(ad->cl * sizeof(long));
- if (mask_patch_sup == NULL)
- {
+ if (mask_patch_sup == NULL) {
G_fatal_error("malloc mask_patch_sup failed");
return RLI_ERRORE;
}
mask_patch_corr = G_malloc(ad->cl * sizeof(long));
- if (mask_patch_corr == NULL)
- {
+ if (mask_patch_corr == NULL) {
G_fatal_error("malloc mask_patch_corr failed");
return RLI_ERRORE;
}
buf_sup = Rast_allocate_d_buf();
- if (buf_sup == NULL)
- {
+ if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
buf = Rast_allocate_d_buf();
- if (buf == NULL)
- {
+ if (buf == NULL) {
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
Rast_set_d_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
- for (i = 0; i < ad->cl; i++)
- {
+ for (i = 0; i < ad->cl; i++) {
mask_patch_sup[i] = 0;
mask_patch_corr[i] = 0;
}
@@ -594,8 +585,7 @@
}
buf = RLI_get_dcell_raster_row(fd, j + ad->y, ad);
if (masked) {
- if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0)
- {
+ if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0) {
G_fatal_error("mask read failed");
return RLI_ERRORE;
}
@@ -733,8 +723,7 @@
* 1 1
*/
- if (corrCell == supCell)
- { /*current cell and upper cell are equal */
+ if (corrCell == supCell) { /*current cell and upper cell are equal */
/* 1
* 1 1
*/
@@ -935,39 +924,33 @@
gc.t = FCELL_TYPE;
/* open mask if needed */
- if (ad->mask == 1)
- {
+ if (ad->mask == 1) {
if ((mask_fd = open(ad->mask_name, O_RDONLY, 0755)) < 0)
return RLI_ERRORE;
mask_buf = G_malloc(ad->cl * sizeof(int));
- if (mask_buf == NULL)
- {
+ if (mask_buf == NULL) {
G_fatal_error("malloc mask_buf failed");
return RLI_ERRORE;
}
masked = TRUE;
}
mask_patch_sup = G_malloc(ad->cl * sizeof(long));
- if (mask_patch_sup == NULL)
- {
+ if (mask_patch_sup == NULL) {
G_fatal_error("malloc mask_patch_sup failed");
return RLI_ERRORE;
}
mask_patch_corr = G_malloc(ad->cl * sizeof(long));
- if (mask_patch_corr == NULL)
- {
+ if (mask_patch_corr == NULL) {
G_fatal_error("malloc mask_patch_corr failed");
return RLI_ERRORE;
}
buf_sup = Rast_allocate_f_buf();
- if (buf_sup == NULL)
- {
+ if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
buf = Rast_allocate_f_buf();
- if (buf == NULL)
- {
+ if (buf == NULL) {
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
@@ -981,15 +964,12 @@
/*for each raster row */
{
- if (j > 0)
- {
+ if (j > 0) {
buf_sup = RLI_get_fcell_raster_row(fd, j - 1 + ad->y, ad);
}
buf = RLI_get_fcell_raster_row(fd, j + ad->y, ad);
- if (masked)
- {
- if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0)
- {
+ if (masked) {
+ if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0) {
G_fatal_error("mask read failed");
return RLI_ERRORE;
}
@@ -1128,8 +1108,7 @@
* 1 1
*/
- if (corrCell == supCell)
- { /*current cell and upper cell are equal */
+ if (corrCell == supCell) { /*current cell and upper cell are equal */
/* 1
* 1 1
*/
Modified: grass/trunk/raster/r.li/r.li.padsd/padsd.c
===================================================================
--- grass/trunk/raster/r.li/r.li.padsd/padsd.c 2011-08-16 14:13:05 UTC (rev 47675)
+++ grass/trunk/raster/r.li/r.li.padsd/padsd.c 2011-08-16 14:13:52 UTC (rev 47676)
@@ -55,6 +55,7 @@
return calculateIndex(conf->answer, patchAreaDistributionSD, NULL,
raster->answer, output->answer);
}
+
int patchAreaDistributionSD(int fd, char **par, area_des ad, double *result)
{
double indice = 0;
@@ -63,8 +64,7 @@
Rast_get_cellhd(ad->raster, "", &hd);
- switch (ad->data_type)
- {
+ switch (ad->data_type) {
case CELL_TYPE:
{
@@ -90,14 +90,14 @@
return RLI_ERRORE;
}
}
- if (ris != RLI_OK)
- {
+ if (ris != RLI_OK) {
*result = -1;
return RLI_ERRORE;
}
*result = indice;
return RLI_OK;
}
+
int calculate(int fd, area_des ad, double *result)
{
CELL *buf;
@@ -132,45 +132,38 @@
gc.t = CELL_TYPE;
/* open mask if needed */
- if (ad->mask == 1)
- {
+ if (ad->mask == 1) {
if ((mask_fd = open(ad->mask_name, O_RDONLY, 0755)) < 0)
return RLI_ERRORE;
mask_buf = G_malloc(ad->cl * sizeof(int));
- if (mask_buf == NULL)
- {
+ if (mask_buf == NULL) {
G_fatal_error("malloc mask_buf failed");
return RLI_ERRORE;
}
masked = TRUE;
}
mask_patch_sup = G_malloc(ad->cl * sizeof(long));
- if (mask_patch_sup == NULL)
- {
+ if (mask_patch_sup == NULL) {
G_fatal_error("malloc mask_patch_sup failed");
return RLI_ERRORE;
}
mask_patch_corr = G_malloc(ad->cl * sizeof(long));
- if (mask_patch_corr == NULL)
- {
+ if (mask_patch_corr == NULL) {
G_fatal_error("malloc mask_patch_corr failed");
return RLI_ERRORE;
}
buf_sup = Rast_allocate_c_buf();
- if (buf_sup == NULL)
- {
+ if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
buf = Rast_allocate_c_buf();
- if (buf == NULL)
- {
+ if (buf == NULL) {
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
Rast_set_c_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
- for (i = 0; i < ad->cl; i++)
- {
+ for (i = 0; i < ad->cl; i++) {
mask_patch_sup[i] = 0;
mask_patch_corr[i] = 0;
}
@@ -178,15 +171,12 @@
/*for each raster row */
{
- if (j > 0)
- {
+ if (j > 0) {
buf_sup = RLI_get_cell_raster_row(fd, j - 1 + ad->y, ad);
}
buf = RLI_get_cell_raster_row(fd, j + ad->y, ad);
- if (masked)
- {
- if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0)
- {
+ if (masked) {
+ if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0) {
G_fatal_error("mask read failed");
return RLI_ERRORE;
}
@@ -197,13 +187,11 @@
{
area++;
corrCell = buf[i + ad->x];
- if (masked && mask_buf[i + ad->x] == 0)
- {
+ if (masked && mask_buf[i + ad->x] == 0) {
Rast_set_c_null_value(&corrCell, 1);
area--;
}
- if (!(Rast_is_null_value(&corrCell, gc.t)))
- {
+ if (!(Rast_is_null_value(&corrCell, gc.t))) {
areaPatch++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
@@ -218,8 +206,7 @@
* 1 2
* */
{
- if (corrCell != supCell)
- {
+ if (corrCell != supCell) {
/* 3
* 1 2
* */
@@ -238,8 +225,7 @@
/*not first patch */
/* put in the tree the previous value */
{
- if (albero == NULL)
- {
+ if (albero == NULL) {
albero = avlID_make(idCorr, totCorr);
if (albero == NULL) {
G_fatal_error("avlID_make error");
@@ -252,8 +238,7 @@
/*tree not empty */
{
ris = avlID_add(&albero, idCorr, totCorr);
- switch (ris)
- {
+ switch (ris) {
case AVL_ERR:
{
@@ -336,8 +321,7 @@
* 1 1
*/
- if (corrCell == supCell)
- { /*current cell and upper cell are equal */
+ if (corrCell == supCell) { /*current cell and upper cell are equal */
/* 1
* 1 1
*/
@@ -424,10 +408,8 @@
}
- if (areaPatch != 0)
- {
- if (albero == NULL)
- {
+ if (areaPatch != 0) {
+ if (albero == NULL) {
albero = avlID_make(idCorr, totCorr);
if (albero == NULL) {
G_fatal_error("avlID_make error");
@@ -436,11 +418,9 @@
npatch++;
}
- else
- {
+ else {
ris = avlID_add(&albero, idCorr, totCorr);
- switch (ris)
- {
+ switch (ris) {
case AVL_ERR:
{
@@ -467,22 +447,18 @@
}
}
array = G_malloc(npatch * sizeof(avlID_tableRow));
- if (array == NULL)
- {
+ if (array == NULL) {
G_fatal_error("malloc array failed");
return RLI_ERRORE;
}
tot = avlID_to_array(albero, zero, array);
- if (tot != npatch)
- {
+ if (tot != npatch) {
G_warning
("avlID_to_array unaspected value. the result could be wrong");
return RLI_ERRORE;
}
- for (i = 0; i < npatch; i++)
- {
- if (array[i]->tot == 0)
- {
+ for (i = 0; i < npatch; i++) {
+ if (array[i]->tot == 0) {
doppi++;
}
}
@@ -491,13 +467,11 @@
mn = areaPatch / npatch;
/* calculate summary */
- for (i = 0; i < np; i++)
- {
+ for (i = 0; i < np; i++) {
long areaPi = 0;
double diff;
- if (array[i]->tot != 0)
- {
+ if (array[i]->tot != 0) {
ris = ris + array[i]->tot;
areaPi = (double)array[i]->tot;
diff = areaPi - mn;
@@ -557,45 +531,38 @@
gc.t = DCELL_TYPE;
/* open mask if needed */
- if (ad->mask == 1)
- {
+ if (ad->mask == 1) {
if ((mask_fd = open(ad->mask_name, O_RDONLY, 0755)) < 0)
return RLI_ERRORE;
mask_buf = G_malloc(ad->cl * sizeof(int));
- if (mask_buf == NULL)
- {
+ if (mask_buf == NULL) {
G_fatal_error("malloc mask_buf failed");
return RLI_ERRORE;
}
masked = TRUE;
}
mask_patch_sup = G_malloc(ad->cl * sizeof(long));
- if (mask_patch_sup == NULL)
- {
+ if (mask_patch_sup == NULL) {
G_fatal_error("malloc mask_patch_sup failed");
return RLI_ERRORE;
}
mask_patch_corr = G_malloc(ad->cl * sizeof(long));
- if (mask_patch_corr == NULL)
- {
+ if (mask_patch_corr == NULL) {
G_fatal_error("malloc mask_patch_corr failed");
return RLI_ERRORE;
}
buf_sup = Rast_allocate_d_buf();
- if (buf_sup == NULL)
- {
+ if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
buf = Rast_allocate_d_buf();
- if (buf == NULL)
- {
+ if (buf == NULL) {
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
Rast_set_d_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
- for (i = 0; i < ad->cl; i++)
- {
+ for (i = 0; i < ad->cl; i++) {
mask_patch_sup[i] = 0;
mask_patch_corr[i] = 0;
}
@@ -603,15 +570,12 @@
/*for each raster row */
{
- if (j > 0)
- {
+ if (j > 0) {
buf_sup = RLI_get_dcell_raster_row(fd, j - 1 + ad->y, ad);
}
buf = RLI_get_dcell_raster_row(fd, j + ad->y, ad);
- if (masked)
- {
- if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0)
- {
+ if (masked) {
+ if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0) {
G_fatal_error("mask read failed");
return RLI_ERRORE;
}
@@ -622,13 +586,11 @@
{
area++;
corrCell = buf[i + ad->x];
- if (masked && mask_buf[i + ad->x] == 0)
- {
+ if (masked && mask_buf[i + ad->x] == 0) {
Rast_set_d_null_value(&corrCell, 1);
area--;
}
- if (!(Rast_is_null_value(&corrCell, gc.t)))
- {
+ if (!(Rast_is_null_value(&corrCell, gc.t))) {
areaPatch++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
@@ -642,14 +604,12 @@
* 1 2
* */
{
- if (corrCell != supCell)
- {
+ if (corrCell != supCell) {
/* 3
* 1 2
* */
/*new patch */
- if (idCorr == 0)
- { /*first patch */
+ if (idCorr == 0) { /*first patch */
lastId = 1;
idCorr = 1;
totCorr = 1;
@@ -660,8 +620,7 @@
/*not first patch */
/* put in the tree the previous value */
{
- if (albero == NULL)
- {
+ if (albero == NULL) {
albero = avlID_make(idCorr, totCorr);
if (albero == NULL) {
G_fatal_error("avlID_make error");
@@ -674,8 +633,7 @@
/*tree not empty */
{
ris = avlID_add(&albero, idCorr, totCorr);
- switch (ris)
- {
+ switch (ris) {
case AVL_ERR:
{
@@ -759,8 +717,7 @@
* 1 1
*/
- if (corrCell == supCell)
- { /*current cell and upper cell are equal */
+ if (corrCell == supCell) { /*current cell and upper cell are equal */
/* 1
* 1 1
*/
@@ -848,10 +805,8 @@
- if (areaPatch != 0)
- {
- if (albero == NULL)
- {
+ if (areaPatch != 0) {
+ if (albero == NULL) {
albero = avlID_make(idCorr, totCorr);
if (albero == NULL) {
G_fatal_error("avlID_make error");
@@ -860,11 +815,9 @@
npatch++;
}
- else
- {
+ else {
ris = avlID_add(&albero, idCorr, totCorr);
- switch (ris)
- {
+ switch (ris) {
case AVL_ERR:
{
@@ -891,22 +844,18 @@
}
}
array = G_malloc(npatch * sizeof(avlID_tableRow));
- if (array == NULL)
- {
+ if (array == NULL) {
G_fatal_error("malloc array failed");
return RLI_ERRORE;
}
tot = avlID_to_array(albero, zero, array);
- if (tot != npatch)
- {
+ if (tot != npatch) {
G_warning
("avlID_to_array unaspected value. the result could be wrong");
return RLI_ERRORE;
}
- for (i = 0; i < npatch; i++)
- {
- if (array[i]->tot == 0)
- {
+ for (i = 0; i < npatch; i++) {
+ if (array[i]->tot == 0) {
doppi++;
}
}
@@ -915,13 +864,11 @@
mn = areaPatch / npatch;
/* calculate summary */
- for (i = 0; i < np; i++)
- {
+ for (i = 0; i < np; i++) {
long areaPi = 0;
double diff;
- if (array[i]->tot != 0)
- {
+ if (array[i]->tot != 0) {
ris = ris + array[i]->tot;
areaPi = (double)array[i]->tot;
diff = areaPi - mn;
@@ -941,6 +888,7 @@
*result = indice;
return RLI_OK;
}
+
int calculateF(int fd, area_des ad, double *result)
{
FCELL *buf;
@@ -975,45 +923,38 @@
gc.t = FCELL_TYPE;
/* open mask if needed */
- if (ad->mask == 1)
- {
+ if (ad->mask == 1) {
if ((mask_fd = open(ad->mask_name, O_RDONLY, 0755)) < 0)
return RLI_ERRORE;
mask_buf = G_malloc(ad->cl * sizeof(int));
- if (mask_buf == NULL)
- {
+ if (mask_buf == NULL) {
G_fatal_error("malloc mask_buf failed");
return RLI_ERRORE;
}
masked = TRUE;
}
mask_patch_sup = G_malloc(ad->cl * sizeof(long));
- if (mask_patch_sup == NULL)
- {
+ if (mask_patch_sup == NULL) {
G_fatal_error("malloc mask_patch_sup failed");
return RLI_ERRORE;
}
mask_patch_corr = G_malloc(ad->cl * sizeof(long));
- if (mask_patch_corr == NULL)
- {
+ if (mask_patch_corr == NULL) {
G_fatal_error("malloc mask_patch_corr failed");
return RLI_ERRORE;
}
buf_sup = Rast_allocate_f_buf();
- if (buf_sup == NULL)
- {
+ if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
buf = Rast_allocate_f_buf();
- if (buf == NULL)
- {
+ if (buf == NULL) {
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
Rast_set_f_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
- for (i = 0; i < ad->cl; i++)
- {
+ for (i = 0; i < ad->cl; i++) {
mask_patch_sup[i] = 0;
mask_patch_corr[i] = 0;
}
@@ -1021,32 +962,26 @@
/*for each raster row */
{
- if (j > 0)
- {
+ if (j > 0) {
buf_sup = RLI_get_fcell_raster_row(fd, j - 1 + ad->y, ad);
}
buf = RLI_get_fcell_raster_row(fd, j + ad->y, ad);
- if (masked)
- {
- if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0)
- {
+ if (masked) {
+ if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0) {
G_fatal_error("mask read failed");
return RLI_ERRORE;
}
}
Rast_set_f_null_value(&precCell, 1);
- for (i = 0; i < ad->cl; i++)
- {
+ for (i = 0; i < ad->cl; i++) {
/* for each fcell in the row */
area++;
corrCell = buf[i + ad->x];
- if (masked && mask_buf[i + ad->x] == 0)
- {
+ if (masked && mask_buf[i + ad->x] == 0) {
Rast_set_f_null_value(&corrCell, 1);
area--;
}
- if (!(Rast_is_null_value(&corrCell, gc.t)))
- {
+ if (!(Rast_is_null_value(&corrCell, gc.t))) {
areaPatch++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
@@ -1060,14 +995,12 @@
* 1 2
* */
{
- if (corrCell != supCell)
- {
+ if (corrCell != supCell) {
/* 3
* 1 2
* */
/*new patch */
- if (idCorr == 0)
- { /*first patch */
+ if (idCorr == 0) { /*first patch */
lastId = 1;
idCorr = 1;
totCorr = 1;
@@ -1078,8 +1011,7 @@
/*not first patch */
/* put in the tree the previous value */
{
- if (albero == NULL)
- {
+ if (albero == NULL) {
albero = avlID_make(idCorr, totCorr);
if (albero == NULL) {
G_fatal_error("avlID_make error");
@@ -1092,8 +1024,7 @@
/*tree not empty */
{
ris = avlID_add(&albero, idCorr, totCorr);
- switch (ris)
- {
+ switch (ris) {
case AVL_ERR:
{
@@ -1177,8 +1108,7 @@
* 1 1
*/
- if (corrCell == supCell)
- { /*current cell and upper cell are equal */
+ if (corrCell == supCell) { /*current cell and upper cell are equal */
/* 1
* 1 1
*/
@@ -1266,10 +1196,8 @@
- if (areaPatch != 0)
- {
- if (albero == NULL)
- {
+ if (areaPatch != 0) {
+ if (albero == NULL) {
albero = avlID_make(idCorr, totCorr);
if (albero == NULL) {
G_fatal_error("avlID_make error");
@@ -1278,11 +1206,9 @@
npatch++;
}
- else
- {
+ else {
ris = avlID_add(&albero, idCorr, totCorr);
- switch (ris)
- {
+ switch (ris) {
case AVL_ERR:
{
@@ -1309,22 +1235,18 @@
}
}
array = G_malloc(npatch * sizeof(avlID_tableRow));
- if (array == NULL)
- {
+ if (array == NULL) {
G_fatal_error("malloc array failed");
return RLI_ERRORE;
}
tot = avlID_to_array(albero, zero, array);
- if (tot != npatch)
- {
+ if (tot != npatch) {
G_warning
("avlID_to_array unaspected value. the result could be wrong");
return RLI_ERRORE;
}
- for (i = 0; i < npatch; i++)
- {
- if (array[i]->tot == 0)
- {
+ for (i = 0; i < npatch; i++) {
+ if (array[i]->tot == 0) {
doppi++;
}
}
@@ -1333,13 +1255,11 @@
mn = areaPatch / npatch;
/* calculate summary */
- for (i = 0; i < np; i++)
- {
+ for (i = 0; i < np; i++) {
long areaPi = 0;
double diff;
- if (array[i]->tot != 0)
- {
+ if (array[i]->tot != 0) {
ris = ris + array[i]->tot;
areaPi = (double)array[i]->tot;
diff = areaPi - mn;
Modified: grass/trunk/raster/r.li/r.li.patchdensity/main.c
===================================================================
--- grass/trunk/raster/r.li/r.li.patchdensity/main.c 2011-08-16 14:13:05 UTC (rev 47675)
+++ grass/trunk/raster/r.li/r.li.patchdensity/main.c 2011-08-16 14:13:52 UTC (rev 47676)
@@ -135,8 +135,8 @@
if (buf[j + ad->x] != buf[j + 1 + ad->x]) {
complete_line = 0;
- if (!Rast_is_null_value(&(buf[j + 1 + ad->x]), CELL_TYPE) &&
- buf[j + 1 + ad->x] != complete_value)
+ if (!Rast_is_null_value(&(buf[j + 1 + ad->x]), CELL_TYPE)
+ && buf[j + 1 + ad->x] != complete_value)
count++;
}
@@ -179,7 +179,8 @@
}
if (!connected &&
sup[ad->cl - 1 + ad->x] != buf[ad->cl - 1 + ad->x]) {
- if (!Rast_is_null_value(&(buf[ad->cl - 1 + ad->x]), CELL_TYPE)) {
+ if (!Rast_is_null_value
+ (&(buf[ad->cl - 1 + ad->x]), CELL_TYPE)) {
count++;
complete_line = 0;
}
Modified: grass/trunk/raster/r.li/r.li.patchnum/main.c
===================================================================
--- grass/trunk/raster/r.li/r.li.patchnum/main.c 2011-08-16 14:13:05 UTC (rev 47675)
+++ grass/trunk/raster/r.li/r.li.patchnum/main.c 2011-08-16 14:13:52 UTC (rev 47676)
@@ -118,8 +118,8 @@
if (buf[j + ad->x] != buf[j + 1 + ad->x]) {
complete_line = 0;
- if (!Rast_is_null_value(&(buf[j + 1 + ad->x]), CELL_TYPE) &&
- buf[j + 1 + ad->x] != complete_value)
+ if (!Rast_is_null_value(&(buf[j + 1 + ad->x]), CELL_TYPE)
+ && buf[j + 1 + ad->x] != complete_value)
count++;
}
@@ -162,7 +162,8 @@
}
if (!connected &&
sup[ad->cl - 1 + ad->x] != buf[ad->cl - 1 + ad->x]) {
- if (!Rast_is_null_value(&(buf[ad->cl - 1 + ad->x]), CELL_TYPE)) {
+ if (!Rast_is_null_value
+ (&(buf[ad->cl - 1 + ad->x]), CELL_TYPE)) {
count++;
complete_line = 0;
}
Modified: grass/trunk/raster/r.li/r.li.pielou/pielou.c
===================================================================
--- grass/trunk/raster/r.li/r.li.pielou/pielou.c 2011-08-16 14:13:05 UTC (rev 47675)
+++ grass/trunk/raster/r.li/r.li.pielou/pielou.c 2011-08-16 14:13:52 UTC (rev 47676)
@@ -392,6 +392,7 @@
generic_cell cc;
generic_cell cc_passage; /*add to compute the number of class */
+
cc.t = DCELL_TYPE;
/* open mask if needed */
@@ -618,6 +619,7 @@
generic_cell cc;
generic_cell cc_passage;
+
cc.t = FCELL_TYPE;
/* open mask if needed */
Modified: grass/trunk/raster/r.li/r.li.renyi/renyi.c
===================================================================
--- grass/trunk/raster/r.li/r.li.renyi/renyi.c 2011-08-16 14:13:05 UTC (rev 47675)
+++ grass/trunk/raster/r.li/r.li.renyi/renyi.c 2011-08-16 14:13:52 UTC (rev 47676)
@@ -159,6 +159,7 @@
AVL_table *array;
generic_cell uc;
+
uc.t = CELL_TYPE;
/* open mask if needed */
@@ -307,7 +308,7 @@
for (i = 0; i < m; i++) {
t = (double)(array[i]->tot);
p = t / area;
- G_debug(1,"Valore p: %g, valore pow: %g",p,pow(p,alpha_double));
+ G_debug(1, "Valore p: %g, valore pow: %g", p, pow(p, alpha_double));
somma = somma + pow(p, alpha_double);
}
@@ -352,6 +353,7 @@
avl_tree albero = NULL;
AVL_table *array;
generic_cell uc;
+
uc.t = DCELL_TYPE;
/* open mask if needed */
@@ -501,7 +503,7 @@
for (i = 0; i < m; i++) {
t = (double)(array[i]->tot);
p = t / area;
- G_debug(1,"Valore p: %g, valore pow: %g",p,pow(p,alpha_double));
+ G_debug(1, "Valore p: %g, valore pow: %g", p, pow(p, alpha_double));
somma = somma + pow(p, alpha_double);
}
@@ -551,6 +553,7 @@
AVL_table *array;
generic_cell uc;
+
uc.t = FCELL_TYPE;
/* open mask if needed */
@@ -702,7 +705,7 @@
for (i = 0; i < m; i++) {
t = (double)(array[i]->tot);
p = t / area;
- G_debug(1,"Valore p: %g, valore pow: %g",p,pow(p,alpha_double));
+ G_debug(1, "Valore p: %g, valore pow: %g", p, pow(p, alpha_double));
somma = somma + pow(p, alpha_double);
}
More information about the grass-commit
mailing list