[GRASS-SVN] r59047 - grass/trunk/raster/r.li/r.li.mpa
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Feb 14 05:10:49 PST 2014
Author: mmetz
Date: 2014-02-14 05:10:48 -0800 (Fri, 14 Feb 2014)
New Revision: 59047
Modified:
grass/trunk/raster/r.li/r.li.mpa/mpa.c
Log:
r.li.mpa: fix mask
Modified: grass/trunk/raster/r.li/r.li.mpa/mpa.c
===================================================================
--- grass/trunk/raster/r.li/r.li.mpa/mpa.c 2014-02-14 13:09:19 UTC (rev 59046)
+++ grass/trunk/raster/r.li/r.li.mpa/mpa.c 2014-02-14 13:10:48 UTC (rev 59047)
@@ -56,8 +56,6 @@
return calculateIndex(conf->answer, meanPixelAttribute, NULL,
raster->answer, output->answer);
-
-
}
@@ -65,10 +63,7 @@
{
int ris = 0;
double indice = 0;
- struct Cell_head hd;
- Rast_get_cellhd(ad->raster, "", &hd);
-
switch (ad->data_type) {
case CELL_TYPE:
{
@@ -96,27 +91,24 @@
return RLI_ERRORE;
}
-
*result = indice;
return RLI_OK;
}
-
int calculate(int fd, struct area_entry *ad, double *result)
{
CELL *buf;
int i, j;
- int mask_fd = -1, *mask_buf;
+ int mask_fd = -1, *mask_buf = NULL;
int masked = FALSE;
double area = 0;
double indice = 0;
double somma = 0;
-
/* open mask if needed */
if (ad->mask == 1) {
if ((mask_fd = open(ad->mask_name, O_RDONLY, 0755)) < 0) {
@@ -163,6 +155,7 @@
*result = indice;
if (masked) {
+ close(mask_fd);
G_free(mask_buf);
}
return RLI_OK;
@@ -173,14 +166,13 @@
DCELL *buf;
int i, j;
- int mask_fd = -1, *mask_buf;
+ int mask_fd = -1, *mask_buf = NULL;
int masked = FALSE;
double area = 0;
double indice = 0;
double somma = 0;
-
/* open mask if needed */
if (ad->mask == 1) {
if ((mask_fd = open(ad->mask_name, O_RDONLY, 0755)) < 0) {
@@ -195,8 +187,6 @@
masked = TRUE;
}
-
-
for (j = 0; j < ad->rl; j++) { /*for each raster row */
buf = RLI_get_dcell_raster_row(fd, j + ad->y, ad); /*read raster row */
@@ -220,7 +210,6 @@
}
}
-
if (area == 0)
indice = (double)-1;
else
@@ -228,6 +217,7 @@
*result = indice;
if (masked) {
+ close(mask_fd);
G_free(mask_buf);
}
return RLI_OK;
@@ -238,14 +228,13 @@
FCELL *buf;
int i, j;
- int mask_fd = -1, *mask_buf;
+ int mask_fd = -1, *mask_buf = NULL;
int masked = FALSE;
double area = 0;
double indice = 0;
double somma = 0;
-
/* open mask if needed */
if (ad->mask == 1) {
if ((mask_fd = open(ad->mask_name, O_RDONLY, 0755)) < 0) {
@@ -260,8 +249,6 @@
masked = TRUE;
}
-
-
for (j = 0; j < ad->rl; j++) { /*for each raster row */
buf = RLI_get_fcell_raster_row(fd, j + ad->y, ad); /*read raster row */
@@ -286,7 +273,6 @@
}
}
-
if (area == 0)
indice = (double)-1;
else
@@ -294,6 +280,7 @@
*result = indice;
if (masked) {
+ close(mask_fd);
G_free(mask_buf);
}
return RLI_OK;
More information about the grass-commit
mailing list