[GRASS-SVN] r46347 - grass/trunk/lib/ogsf
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun May 22 03:34:30 EDT 2011
Author: mmetz
Date: 2011-05-22 00:34:30 -0700 (Sun, 22 May 2011)
New Revision: 46347
Modified:
grass/trunk/lib/ogsf/Gs3.c
Log:
do not use Rast_get_null_value_row
Modified: grass/trunk/lib/ogsf/Gs3.c
===================================================================
--- grass/trunk/lib/ogsf/Gs3.c 2011-05-22 06:59:06 UTC (rev 46346)
+++ grass/trunk/lib/ogsf/Gs3.c 2011-05-22 07:34:30 UTC (rev 46347)
@@ -117,7 +117,6 @@
{
FILEDESC cellfile;
const char *map_set;
- char *nullflags;
int offset, row, col;
G_debug(3, "Gs_loadmap_as_float(): name=%s", map_name);
@@ -129,11 +128,6 @@
}
*has_null = 0;
- nullflags = Rast_allocate_null_buf(); /* G_fatal_error */
- if (!nullflags) {
- G_fatal_error(_("Unable to allocate memory for a null buffer"));
- }
-
cellfile = Rast_open_old(map_name, map_set);
G_message(_("Loading raster map <%s>..."),
@@ -142,12 +136,11 @@
for (row = 0; row < wind->rows; row++) {
offset = row * wind->cols;
Rast_get_f_row(cellfile, &(buff[offset]), row);
- Rast_get_null_value_row(cellfile, nullflags, row);
G_percent(row, wind->rows, 2);
for (col = 0; col < wind->cols; col++) {
- if (nullflags[col] || Rast_is_f_null_value(buff + offset + col)) {
+ if (Rast_is_f_null_value(buff + offset + col)) {
*has_null = 1;
BM_set(nullmap, col, row, 1);
}
@@ -160,8 +153,6 @@
Rast_close(cellfile);
- G_free(nullflags);
-
return (1);
}
@@ -190,7 +181,6 @@
{
FILEDESC cellfile;
const char *map_set;
- char *nullflags;
int offset, row, col;
G_debug(3, "Gs_loadmap_as_int");
@@ -202,11 +192,6 @@
}
*has_null = 0;
- nullflags = Rast_allocate_null_buf(); /* G_fatal_error */
- if (!nullflags) {
- G_fatal_error(_("Unable to allocate memory for a null buffer"));
- }
-
cellfile = Rast_open_old(map_name, map_set);
G_message(_("Loading raster map <%s>..."),
@@ -215,12 +200,11 @@
for (row = 0; row < wind->rows; row++) {
offset = row * wind->cols;
Rast_get_c_row(cellfile, &(buff[offset]), row);
- Rast_get_null_value_row(cellfile, nullflags, row);
G_percent(row, wind->rows, 2);
for (col = 0; col < wind->cols; col++) {
- if (nullflags[col]) {
+ if (Rast_is_f_null_value(buff + offset + col)) {
*has_null = 1;
BM_set(nullmap, col, row, 1);
}
@@ -232,8 +216,6 @@
Rast_close(cellfile);
- G_free(nullflags);
-
return (1);
}
@@ -333,7 +315,6 @@
{
FILEDESC cellfile;
const char *map_set;
- char *nullflags;
int *ti, *tmp_buf;
int offset, row, col, val, max_short, overflow, shortsize, bitplace;
short *ts;
@@ -358,11 +339,6 @@
}
*has_null = 0;
- nullflags = Rast_allocate_null_buf();
- if (!nullflags) {
- G_fatal_error(_("Unable to allocate memory for a null buffer"));
- }
-
cellfile = Rast_open_old(map_name, map_set);
tmp_buf = (int *)G_malloc(wind->cols * sizeof(int)); /* G_fatal_error */
@@ -376,7 +352,6 @@
for (row = 0; row < wind->rows; row++) {
offset = row * wind->cols;
Rast_get_c_row(cellfile, tmp_buf, row);
- Rast_get_null_value_row(cellfile, nullflags, row);
G_percent(row, wind->rows, 2);
@@ -384,7 +359,7 @@
ti = tmp_buf;
for (col = 0; col < wind->cols; col++) {
- if (nullflags[col]) {
+ if (Rast_is_c_null_value(&tmp_buf[col])) {
*has_null = 1;
BM_set(nullmap, col, row, 1);
}
@@ -410,7 +385,6 @@
Rast_close(cellfile);
G_free(tmp_buf);
- G_free(nullflags);
return (overflow ? -2 : 1);
}
@@ -446,7 +420,6 @@
{
FILEDESC cellfile;
const char *map_set;
- char *nullflags;
int *ti, *tmp_buf;
int offset, row, col, val, max_char, overflow, charsize, bitplace;
unsigned char *tc;
@@ -472,11 +445,6 @@
}
*has_null = 0;
- nullflags = Rast_allocate_null_buf(); /* G_fatal_error */
- if (!nullflags) {
- G_fatal_error(_("Unable to allocate memory for a null buffer"));
- }
-
cellfile = Rast_open_old(map_name, map_set);
tmp_buf = (int *)G_malloc(wind->cols * sizeof(int)); /* G_fatal_error */
@@ -490,14 +458,13 @@
for (row = 0; row < wind->rows; row++) {
offset = row * wind->cols;
Rast_get_c_row(cellfile, tmp_buf, row);
- Rast_get_null_value_row(cellfile, nullflags, row);
tc = (unsigned char *)&(buff[offset]);
ti = tmp_buf;
G_percent(row, wind->rows, 2);
for (col = 0; col < wind->cols; col++) {
- if (nullflags[col]) {
+ if (Rast_is_c_null_value(&tmp_buf[col])) {
*has_null = 1;
BM_set(nullmap, col, row, 1);
}
@@ -525,7 +492,6 @@
Rast_close(cellfile);
G_free(tmp_buf);
- G_free(nullflags);
return (overflow ? -2 : 1);
}
@@ -554,7 +520,6 @@
{
FILEDESC cellfile;
const char *map_set;
- char *nullflags;
int *tmp_buf;
int row, col;
@@ -573,19 +538,14 @@
return -1;
}
- nullflags = Rast_allocate_null_buf();
- if (!nullflags) {
- G_fatal_error(_("Unable to allocate memory for a null buffer"));
- }
-
G_message(_("Loading raster map <%s>..."),
G_fully_qualified_name(map_name, map_set));
for (row = 0; row < wind->rows; row++) {
- Rast_get_null_value_row(cellfile, nullflags, row);
+ Rast_get_c_row(cellfile, tmp_buf, row);
for (col = 0; col < wind->cols; col++) {
- if (nullflags[col]) {
+ if (Rast_is_c_null_value(&tmp_buf[col])) {
/* no data */
BM_set(buff, col, row, 1);
}
@@ -598,7 +558,6 @@
Rast_close(cellfile);
G_free(tmp_buf);
- G_free(nullflags);
return (1);
}
@@ -822,7 +781,7 @@
CELL *buf;
DCELL *dbuf;
RASTER_MAP_TYPE map_type;
- int fd;
+ int fd = -1;
if ((mapset = G_find_raster2(filename, "")) == NULL) {
G_warning(_("Raster map <%s> not found"), filename);
@@ -868,12 +827,14 @@
}
else {
strcpy(catstr, "no category label");
+ return 0;
}
/* TODO: may want to keep these around for multiple queries */
Rast_free_cats(&cats);
- Rast_close(fd);
+ if (fd >= 0)
+ Rast_close(fd);
return (1);
}
More information about the grass-commit
mailing list