[GRASS-SVN] r40223 - in grass/trunk: doc/raster/r.example
imagery/i.albedo imagery/i.biomass imagery/i.cca
imagery/i.eb.eta imagery/i.eb.evapfr imagery/i.eb.h_SEBAL01
imagery/i.eb.soilheatflux imagery/i.emissivity
imagery/i.evapo.time_integration imagery/i.his.rgb
imagery/i.latlong imagery/i.modis.qc imagery/i.rectify
imagery/i.rgb.his imagery/i.sunhours imagery/i.vi include
lib/gpde lib/raster lib/rst/interp_float raster/r.bitpattern
raster/r.buffer raster/r.clump raster/r.composite
raster/r.compress raster/r.cross raster/r.his raster/r.in.mat
raster/r.in.poly raster/r.in.xyz raster/r.lake raster/r.los
raster/r.mapcalc raster/r.null raster/r.proj
raster/r.resamp.rst raster/r.resample raster/r.spreadpath
raster/r.support raster/r.terraflow raster/r.texture
raster/r.uslek raster/r.usler raster/r.watershed/seg
raster3d/r3.cross.rast raster3d/r3.to.rast vector/v.to.rast
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jan 4 17:27:32 EST 2010
Author: glynn
Date: 2010-01-04 17:27:30 -0500 (Mon, 04 Jan 2010)
New Revision: 40223
Modified:
grass/trunk/doc/raster/r.example/main.c
grass/trunk/imagery/i.albedo/main.c
grass/trunk/imagery/i.biomass/main.c
grass/trunk/imagery/i.cca/transform.c
grass/trunk/imagery/i.eb.eta/main.c
grass/trunk/imagery/i.eb.evapfr/main.c
grass/trunk/imagery/i.eb.h_SEBAL01/main.c
grass/trunk/imagery/i.eb.soilheatflux/main.c
grass/trunk/imagery/i.emissivity/main.c
grass/trunk/imagery/i.evapo.time_integration/main.c
grass/trunk/imagery/i.his.rgb/main.c
grass/trunk/imagery/i.latlong/main.c
grass/trunk/imagery/i.modis.qc/main.c
grass/trunk/imagery/i.rectify/write.c
grass/trunk/imagery/i.rgb.his/main.c
grass/trunk/imagery/i.sunhours/main.c
grass/trunk/imagery/i.vi/main.c
grass/trunk/include/rasterdefs.h
grass/trunk/lib/gpde/N_arrays_io.c
grass/trunk/lib/raster/put_row.c
grass/trunk/lib/rst/interp_float/resout2d.c
grass/trunk/lib/rst/interp_float/ressegm2d.c
grass/trunk/raster/r.bitpattern/main.c
grass/trunk/raster/r.buffer/write_map.c
grass/trunk/raster/r.clump/clump.c
grass/trunk/raster/r.composite/main.c
grass/trunk/raster/r.compress/main.c
grass/trunk/raster/r.cross/renumber.c
grass/trunk/raster/r.his/main.c
grass/trunk/raster/r.in.mat/main.c
grass/trunk/raster/r.in.poly/raster.c
grass/trunk/raster/r.in.xyz/main.c
grass/trunk/raster/r.lake/main.c
grass/trunk/raster/r.los/main.c
grass/trunk/raster/r.mapcalc/map.c
grass/trunk/raster/r.null/main.c
grass/trunk/raster/r.proj/main.c
grass/trunk/raster/r.resamp.rst/main.c
grass/trunk/raster/r.resample/main.c
grass/trunk/raster/r.spreadpath/main.c
grass/trunk/raster/r.support/main.c
grass/trunk/raster/r.terraflow/grass2str.h
grass/trunk/raster/r.texture/main.c
grass/trunk/raster/r.uslek/main.c
grass/trunk/raster/r.usler/main.c
grass/trunk/raster/r.watershed/seg/bseg_read.c
grass/trunk/raster/r.watershed/seg/bseg_write.c
grass/trunk/raster/r.watershed/seg/cseg_write.c
grass/trunk/raster/r.watershed/seg/dseg_write.c
grass/trunk/raster3d/r3.cross.rast/main.c
grass/trunk/raster3d/r3.to.rast/main.c
grass/trunk/vector/v.to.rast/raster.c
Log:
Rast_put_*_row* now generate errors rather than returning a status
Modified: grass/trunk/doc/raster/r.example/main.c
===================================================================
--- grass/trunk/doc/raster/r.example/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/doc/raster/r.example/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -160,8 +160,7 @@
}
/* write raster row to output raster map */
- if (Rast_put_row(outfd, outrast, data_type) < 0)
- G_fatal_error(_("Failed writing raster map <%s>"), result);
+ Rast_put_row(outfd, outrast, data_type);
}
/* memory cleanup */
Modified: grass/trunk/imagery/i.albedo/main.c
===================================================================
--- grass/trunk/imagery/i.albedo/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/imagery/i.albedo/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -376,9 +376,7 @@
}
((DCELL *) outrast)[col] = de;
}
- if (Rast_put_row(outfd, outrast, out_data_type) < 0)
- G_fatal_error(_("Failed writing raster map <%s> row %d"),
- result, row);
+ Rast_put_row(outfd, outrast, out_data_type);
}
for (i = 1; i <= nfiles; i++) {
G_free(inrast[i]);
Modified: grass/trunk/imagery/i.biomass/main.c
===================================================================
--- grass/trunk/imagery/i.biomass/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/imagery/i.biomass/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -166,8 +166,7 @@
outrast1[col] = d;
}
}
- if (Rast_put_d_row(outfd1, outrast1) < 0)
- G_fatal_error(_("Failed writing raster map <%s>"), result1);
+ Rast_put_d_row(outfd1, outrast1);
}
/* Color table for biomass */
Modified: grass/trunk/imagery/i.cca/transform.c
===================================================================
--- grass/trunk/imagery/i.cca/transform.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/imagery/i.cca/transform.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -47,8 +47,7 @@
/* output the row of data */
for (j = 0; j < bands; j++)
- if (Rast_put_row(outfds[j], rowbufs[j], CELL_TYPE) < 0)
- G_fatal_error(_("Error writing cell map during transform."));
+ Rast_put_row(outfds[j], rowbufs[j], CELL_TYPE);
}
for (i = 0; i < bands; i++)
G_free(rowbufs[i]);
Modified: grass/trunk/imagery/i.eb.eta/main.c
===================================================================
--- grass/trunk/imagery/i.eb.eta/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/imagery/i.eb.eta/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -120,8 +120,7 @@
outrast1[col] = d;
}
}
- if (Rast_put_d_row(outfd1,outrast1) < 0)
- G_fatal_error(_("Failed writing raster map <%s>"), result1);
+ Rast_put_d_row(outfd1,outrast1);
}
G_free(inrast_rnetday);
G_free(inrast_evapfr);
Modified: grass/trunk/imagery/i.eb.evapfr/main.c
===================================================================
--- grass/trunk/imagery/i.eb.evapfr/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/imagery/i.eb.evapfr/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -158,13 +158,9 @@
}
}
}
- if (Rast_put_d_row(outfd1, outrast1) < 0)
- G_fatal_error(_("Failed writing raster map <%s>"), result1);
+ Rast_put_d_row(outfd1, outrast1);
if (makin)
- {
- if (Rast_put_d_row(outfd2, outrast2) < 0)
- G_fatal_error(_("Failed writing raster map <%s>"), result2);
- }
+ Rast_put_d_row(outfd2, outrast2);
}
G_free(inrast_rnet);
G_free(inrast_g0);
Modified: grass/trunk/imagery/i.eb.h_SEBAL01/main.c
===================================================================
--- grass/trunk/imagery/i.eb.h_SEBAL01/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/imagery/i.eb.h_SEBAL01/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -605,8 +605,7 @@
outrast[col] = d_h3;
}
}
- if (Rast_put_d_row(outfd, outrast) < 0)
- G_fatal_error("Failed writing raster map <%s>", h0);
+ Rast_put_d_row(outfd, outrast);
}
Modified: grass/trunk/imagery/i.eb.soilheatflux/main.c
===================================================================
--- grass/trunk/imagery/i.eb.soilheatflux/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/imagery/i.eb.soilheatflux/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -153,8 +153,7 @@
outrast[col] = d;
}
}
- if (Rast_put_d_row(outfd, outrast) < 0)
- G_fatal_error(_("Failed writing raster map <%s>"), result);
+ Rast_put_d_row(outfd, outrast);
}
G_free(inrast_albedo);
G_free(inrast_ndvi);
Modified: grass/trunk/imagery/i.emissivity/main.c
===================================================================
--- grass/trunk/imagery/i.emissivity/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/imagery/i.emissivity/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -96,8 +96,7 @@
outr[col] = d;
}
}
- if (Rast_put_row(outfd, outr, DCELL_TYPE) < 0)
- G_fatal_error(_("Cannot write to output raster file"));
+ Rast_put_row(outfd, outr, DCELL_TYPE);
}
G_free(inr);
Rast_close(infd);
Modified: grass/trunk/imagery/i.evapo.time_integration/main.c
===================================================================
--- grass/trunk/imagery/i.evapo.time_integration/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/imagery/i.evapo.time_integration/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -386,8 +386,7 @@
}
}
}
- if (Rast_put_row(outfd, outrast, out_data_type) < 0)
- G_fatal_error(_("Unable to write to raster map<%s>"), result);
+ Rast_put_row(outfd, outrast, out_data_type);
}
for (i = 1; i <= nfiles; i++) {
Modified: grass/trunk/imagery/i.his.rgb/main.c
===================================================================
--- grass/trunk/imagery/i.his.rgb/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/imagery/i.his.rgb/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -101,9 +101,7 @@
/* write out the new row for each cell map */
for (band = 0; band < 3; band++)
- if (Rast_put_row(fd_output[band], rowbuffer[band], CELL_TYPE)
- < 0)
- G_fatal_error(_("Failed writing raster map row %d"), i);
+ Rast_put_row(fd_output[band], rowbuffer[band], CELL_TYPE);
}
closefiles(opt_red->answer, opt_green->answer, opt_blue->answer,
Modified: grass/trunk/imagery/i.latlong/main.c
===================================================================
--- grass/trunk/imagery/i.latlong/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/imagery/i.latlong/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -138,8 +138,7 @@
d = latitude;
outrast1[col] = d;
}
- if (Rast_put_d_row(outfd1, outrast1) < 0)
- G_fatal_error(_("Cannot write to output raster file"));
+ Rast_put_d_row(outfd1, outrast1);
}
G_free(inrast);
Rast_close(infd);
Modified: grass/trunk/imagery/i.modis.qc/main.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/imagery/i.modis.qc/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -318,9 +318,7 @@
outrast[col] = c;
}
- if (Rast_put_c_row(outfd, outrast) < 0)
- G_fatal_error(_("Failed writing raster map <%s> row %d"),
- output->answer, row);
+ Rast_put_c_row(outfd, outrast);
}
G_free(inrast);
Modified: grass/trunk/imagery/i.rectify/write.c
===================================================================
--- grass/trunk/imagery/i.rectify/write.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/imagery/i.rectify/write.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -52,11 +52,7 @@
if (read(temp_fd, rast, target_window.cols * Rast_cell_size(map_type))
!= target_window.cols * Rast_cell_size(map_type))
G_fatal_error(_("Error writing row %d"), row);
- if (Rast_put_row(fd, rast, map_type) < 0) {
- G_fatal_error(_("Failed writing raster map <%s> row %d"),
- name, row);
- unlink(temp_name);
- }
+ Rast_put_row(fd, rast, map_type);
}
close(temp_fd);
unlink(temp_name);
Modified: grass/trunk/imagery/i.rgb.his/main.c
===================================================================
--- grass/trunk/imagery/i.rgb.his/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/imagery/i.rgb.his/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -100,9 +100,7 @@
/* write out the new row for each cell map */
for (band = 0; band < 3; band++)
- if (Rast_put_row(fd_output[band], rowbuffer[band], CELL_TYPE)
- < 0)
- G_fatal_error(_("Failed writing raster map row %ld"), i);
+ Rast_put_row(fd_output[band], rowbuffer[band], CELL_TYPE);
}
G_percent(i, rows, 2);
Modified: grass/trunk/imagery/i.sunhours/main.c
===================================================================
--- grass/trunk/imagery/i.sunhours/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/imagery/i.sunhours/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -112,8 +112,7 @@
d_N = (360.0 / (15.0 * PI)) * d_Ws;
((DCELL *) outrast1)[col] = d_N;
}
- if (Rast_put_row(outfd1, outrast1, DCELL_TYPE) < 0)
- G_fatal_error(_("Cannot write to output raster file"));
+ Rast_put_row(outfd1, outrast1, DCELL_TYPE);
}
G_free(inrast_lat);
G_free(inrast_doy);
Modified: grass/trunk/imagery/i.vi/main.c
===================================================================
--- grass/trunk/imagery/i.vi/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/imagery/i.vi/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -346,9 +346,7 @@
outrast[col] = va_ri(d_redchan, d_greenchan, d_bluechan);
}
}
- if (Rast_put_d_row(outfd, outrast) < 0)
- G_fatal_error(_("Failed writing raster map <%s> row %d"),
- result, row);
+ Rast_put_d_row(outfd, outrast);
}
G_free(inrast_redchan);
Modified: grass/trunk/include/rasterdefs.h
===================================================================
--- grass/trunk/include/rasterdefs.h 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/include/rasterdefs.h 2010-01-04 22:27:30 UTC (rev 40223)
@@ -403,12 +403,12 @@
int Rast_put_cellhd(const char *, struct Cell_head *);
/* put_row.c */
-int Rast_put_row(int, const void *, RASTER_MAP_TYPE);
-int Rast_put_c_row(int, const CELL *);
-int Rast_put_f_row(int, const FCELL *);
-int Rast_put_d_row(int, const DCELL *);
+void Rast_put_row(int, const void *, RASTER_MAP_TYPE);
+void Rast_put_c_row(int, const CELL *);
+void Rast_put_f_row(int, const FCELL *);
+void Rast_put_d_row(int, const DCELL *);
int Rast__open_null_write(int);
-int Rast__write_null_bits(int, const unsigned char *, int, int, int);
+void Rast__write_null_bits(int, const unsigned char *, int, int, int);
/* put_title.c */
int Rast_put_cell_title(const char *, const char *);
Modified: grass/trunk/lib/gpde/N_arrays_io.c
===================================================================
--- grass/trunk/lib/gpde/N_arrays_io.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/lib/gpde/N_arrays_io.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -213,20 +213,11 @@
drast[x] = N_get_array_2d_d_value(array, x, y);
}
if (type == CELL_TYPE)
- if (!Rast_put_c_row(map, rast)) {
- Rast_unopen(map); /*unopen the new raster map */
- G_fatal_error(_("Unable to write raster row %i"), y);
- }
+ Rast_put_c_row(map, rast);
if (type == FCELL_TYPE)
- if (!Rast_put_f_row(map, frast)) {
- Rast_unopen(map); /*unopen the new raster map */
- G_fatal_error(_("Unable to write raster row %i"), y);
- }
+ Rast_put_f_row(map, frast);
if (type == DCELL_TYPE)
- if (!Rast_put_d_row(map, drast)) {
- Rast_unopen(map); /*unopen the new raster map */
- G_fatal_error(_("Unable to write raster row %i"), y);
- }
+ Rast_put_d_row(map, drast);
}
/* Close file */
Modified: grass/trunk/lib/raster/put_row.c
===================================================================
--- grass/trunk/lib/raster/put_row.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/lib/raster/put_row.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -29,40 +29,8 @@
#include "../gis/G.h"
#include "R.h"
-static int put_raster_data(int, char *, const void *, int, int, int,
- RASTER_MAP_TYPE);
-static int put_data(int, char *, const CELL *, int, int, int);
-static int check_open(const char *, int);
-static void write_error(int, int);
-static int same(const unsigned char *, const unsigned char *, int);
-static void set_file_pointer(int, int);
-static int put_fp_data(int, char *, const void *, int, int, RASTER_MAP_TYPE);
-static int put_null_data(int, const char *, int);
-static int convert_and_write_if(int, const CELL *);
-static int convert_and_write_id(int, const CELL *);
-static int convert_and_write_df(int, const DCELL *);
-static int convert_and_write_fd(int, const FCELL *);
-static int put_raster_row(int, const void *, RASTER_MAP_TYPE, int);
+static void put_raster_row(int, const void *, RASTER_MAP_TYPE, int);
-static int put_null_value_row(int fd, const char *buf)
-{
- struct fileinfo *fcb = &R__.fileinfo[fd];
-
- if (fcb->gdal)
- G_fatal_error(_("GDAL output doesn't support writing null rows separately"));
-
- switch (put_null_data(fd, buf, fcb->null_cur_row)) {
- case -1:
- return -1;
- case 0:
- return 1;
- }
-
- fcb->null_cur_row++;
-
- return 1;
-}
-
/*!
\brief Writes the next row for cell/fcell/dcell file
@@ -92,12 +60,11 @@
\param buf buffer holding data
\param data_type raster map type (CELL_TYPE, FCELL_TYPE, DCELL_TYPE)
- \return 1 on success
- \return -1 on failure
+ \return void
*/
-int Rast_put_row(int fd, const void *buf, RASTER_MAP_TYPE data_type)
+void Rast_put_row(int fd, const void *buf, RASTER_MAP_TYPE data_type)
{
- return put_raster_row(fd, buf, data_type, data_type);
+ put_raster_row(fd, buf, data_type, data_type);
}
/*!
@@ -108,12 +75,11 @@
\param fd file descriptor where data is to be written
\param buf buffer holding data
- \return 1 on success
- \return -1 on failure
+ \return void
*/
-int Rast_put_c_row(int fd, const CELL * buf)
+void Rast_put_c_row(int fd, const CELL * buf)
{
- return Rast_put_row(fd, buf, CELL_TYPE);
+ Rast_put_row(fd, buf, CELL_TYPE);
}
/*!
@@ -124,12 +90,11 @@
\param fd file descriptor where data is to be written
\param buf buffer holding data
- \return 1 on success
- \return -1 on failure
+ \return void
*/
-int Rast_put_f_row(int fd, const FCELL * buf)
+void Rast_put_f_row(int fd, const FCELL * buf)
{
- return Rast_put_row(fd, buf, FCELL_TYPE);
+ Rast_put_row(fd, buf, FCELL_TYPE);
}
/*!
@@ -140,71 +105,31 @@
\param fd file descriptor where data is to be written
\param buf buffer holding data
- \return 1 on success
- \return -1 on failure
+ \return void
*/
-int Rast_put_d_row(int fd, const DCELL * buf)
+void Rast_put_d_row(int fd, const DCELL * buf)
{
- return Rast_put_row(fd, buf, DCELL_TYPE);
+ Rast_put_row(fd, buf, DCELL_TYPE);
}
-static int check_open(const char *me, int fd)
+static void write_data(int fd, int row, unsigned char *buf, int n)
{
struct fileinfo *fcb = &R__.fileinfo[fd];
-
- switch (fcb->open_mode) {
- case OPEN_OLD:
- G_warning(_("%s: raster map <%s> not open for write - request ignored"),
- me, fcb->name);
- break;
- case OPEN_NEW_COMPRESSED:
- case OPEN_NEW_UNCOMPRESSED:
- return 1;
- break;
- default:
- G_warning(_("%s: unopened file descriptor - request ignored"), me);
- break;
- }
-
- return 0;
-}
-
-static void write_error(int fd, int row)
-{
- struct fileinfo *fcb = &R__.fileinfo[fd];
-
- if (fcb->io_error)
- return;
-
- G_warning(_("Raster map <%s> - unable to write row %d"), fcb->name, row);
-
- fcb->io_error = 1;
-}
-
-static int write_data(int fd, int row, unsigned char *buf, int n)
-{
- struct fileinfo *fcb = &R__.fileinfo[fd];
ssize_t nwrite = fcb->nbytes * n;
- if (write(fd, buf, nwrite) != nwrite) {
- write_error(fd, row);
- return -1;
- }
-
- return 0;
+ if (write(fd, buf, nwrite) != nwrite)
+ G_fatal_error(_("Error writing uncompressed FP data for row %d of <%s>"),
+ fcb->name, row);
}
-static int write_data_compressed(int fd, int row, unsigned char *buf, int n)
+static void write_data_compressed(int fd, int row, unsigned char *buf, int n)
{
struct fileinfo *fcb = &R__.fileinfo[fd];
int nwrite = fcb->nbytes * n;
- if (G_zlib_write(fd, buf, nwrite) < 0) {
- write_error(fd, row);
- return -1;
- }
-
- return 0;
+ if (G_zlib_write(fd, buf, nwrite) < 0)
+ G_fatal_error(_("Error writing compressed FP data for row %d of <%s>"),
+ fcb->name, row);
}
static void set_file_pointer(int fd, int row)
@@ -214,8 +139,8 @@
fcb->row_ptr[row] = lseek(fd, 0L, SEEK_CUR);
}
-static int convert_float(XDR * xdrs, char *null_buf, const FCELL * rast,
- int row, int n)
+static void convert_float(XDR * xdrs, char *null_buf, const FCELL * rast,
+ int row, int n)
{
int i;
@@ -230,17 +155,13 @@
else
f = rast[i];
- if (!xdr_float(xdrs, &f)) {
- G_warning(_("xdr_float failed for index %d of row %d"), i, row);
- return -1;
- }
+ if (!xdr_float(xdrs, &f))
+ G_fatal_error(_("xdr_float failed for index %d of row %d"), i, row);
}
-
- return 0;
}
-static int convert_double(XDR * xdrs, char *null_buf, const DCELL * rast,
- int row, int n)
+static void convert_double(XDR * xdrs, char *null_buf, const DCELL * rast,
+ int row, int n)
{
int i;
@@ -255,18 +176,14 @@
else
d = rast[i];
- if (!xdr_double(xdrs, &d)) {
- G_warning(_("xdr_double failed for index %d of row %d"), i, row);
- return -1;
- }
+ if (!xdr_double(xdrs, &d))
+ G_fatal_error(_("xdr_double failed for index %d of row %d"), i, row);
}
-
- return 0;
}
/* writes data to fcell file for either full or partial rows */
-static int put_fp_data(int fd, char *null_buf, const void *rast,
- int row, int n, RASTER_MAP_TYPE data_type)
+static void put_fp_data(int fd, char *null_buf, const void *rast,
+ int row, int n, RASTER_MAP_TYPE data_type)
{
struct fileinfo *fcb = &R__.fileinfo[fd];
int compressed = (fcb->open_mode == OPEN_NEW_COMPRESSED);
@@ -274,10 +191,10 @@
char *work_buf;
if (row < 0 || row >= fcb->cellhd.rows)
- return 0;
+ return;
if (n <= 0)
- return 0;
+ return;
work_buf = G__alloca(G__.window.cols * fcb->nbytes + 1);
@@ -288,35 +205,19 @@
(unsigned int)fcb->nbytes * fcb->cellhd.cols, XDR_ENCODE);
xdr_setpos(xdrs, 0);
- if (data_type == FCELL_TYPE) {
- if (convert_float(xdrs, null_buf, rast, row, n) < 0) {
- G__freea(work_buf);
- return -1;
- }
- }
- else {
- if (convert_double(xdrs, null_buf, rast, row, n) < 0) {
- G__freea(work_buf);
- return -1;
- }
- }
+ if (data_type == FCELL_TYPE)
+ convert_float(xdrs, null_buf, rast, row, n);
+ else
+ convert_double(xdrs, null_buf, rast, row, n);
xdr_destroy(&fcb->xdrstream);
- if (compressed) {
- if (write_data_compressed(fd, row, work_buf, n) == -1) {
- G__freea(work_buf);
- return -1;
- }
- }
- else if (write_data(fd, row, work_buf, n) == -1) {
- G__freea(work_buf);
- return -1;
- }
+ if (compressed)
+ write_data_compressed(fd, row, work_buf, n);
+ else
+ write_data(fd, row, work_buf, n);
G__freea(work_buf);
-
- return 1;
}
static void convert_int(unsigned char *wk, char *null_buf, const CELL * rast,
@@ -441,8 +342,8 @@
return (nwrite >= total) ? 0 : nwrite;
}
-static int put_data(int fd, char *null_buf, const CELL * cell,
- int row, int n, int zeros_r_nulls)
+static void put_data(int fd, char *null_buf, const CELL * cell,
+ int row, int n, int zeros_r_nulls)
{
struct fileinfo *fcb = &R__.fileinfo[fd];
int compressed = fcb->cellhd.compressed;
@@ -451,10 +352,10 @@
ssize_t nwrite;
if (row < 0 || row >= fcb->cellhd.rows)
- return 0;
+ return;
if (n <= 0)
- return 0;
+ return;
work_buf = G__alloca(G__.window.cols * sizeof(CELL) + 1);
wk = work_buf;
@@ -493,21 +394,15 @@
if (nwrite > 0) {
nwrite++;
- if (write(fd, compressed_buf, nwrite) != nwrite) {
- write_error(fd, row);
- G__freea(compressed_buf);
- G__freea(work_buf);
- return -1;
- }
+ if (write(fd, compressed_buf, nwrite) != nwrite)
+ G_fatal_error(_("Error writing compressed data for row %d of <%s>"),
+ row, fcb->name);
}
else {
nwrite = nbytes * n + 1;
- if (write(fd, work_buf, nwrite) != nwrite) {
- write_error(fd, row);
- G__freea(compressed_buf);
- G__freea(work_buf);
- return -1;
- }
+ if (write(fd, work_buf, nwrite) != nwrite)
+ G_fatal_error(_("Error writing compressed data for row %d of <%s>"),
+ row, fcb->name);
}
G__freea(compressed_buf);
@@ -515,20 +410,16 @@
else {
nwrite = fcb->nbytes * n;
- if (write(fd, work_buf, nwrite) != nwrite) {
- write_error(fd, row);
- G__freea(work_buf);
- return -1;
- }
+ if (write(fd, work_buf, nwrite) != nwrite)
+ G_fatal_error(_("Error writing uncompressed data for row %d of <%s>"),
+ row, fcb->name);
}
G__freea(work_buf);
-
- return 1;
}
-static int put_data_gdal(int fd, const void *rast, int row, int n,
- int zeros_r_nulls, RASTER_MAP_TYPE map_type)
+static void put_data_gdal(int fd, const void *rast, int row, int n,
+ int zeros_r_nulls, RASTER_MAP_TYPE map_type)
{
#ifdef HAVE_GDAL
struct fileinfo *fcb = &R__.fileinfo[fd];
@@ -541,10 +432,10 @@
int i;
if (row < 0 || row >= fcb->cellhd.rows)
- return 0;
+ return;
if (n <= 0)
- return 0;
+ return;
work_buf = G__alloca(n * size);
@@ -573,47 +464,55 @@
dst = G_incr_void_ptr(dst, size);
}
- err =
- Rast_gdal_raster_IO(fcb->gdal->band, GF_Write, 0, row, n, 1, work_buf,
- n, 1, datatype, 0, 0);
+ err = Rast_gdal_raster_IO(fcb->gdal->band, GF_Write, 0, row, n, 1,
+ work_buf, n, 1, datatype, 0, 0);
G__freea(work_buf);
- return err == CE_None ? 1 : -1;
-#else
- return -1;
+ if (err != CE_None)
+ G_fatal_error(_("Error writing data via GDAL for row %d of <%s>"),
+ row, fcb->name);
#endif
}
-static int put_raster_data(int fd, char *null_buf, const void *rast,
- int row, int n,
- int zeros_r_nulls, RASTER_MAP_TYPE map_type)
+static void put_raster_data(int fd, char *null_buf, const void *rast,
+ int row, int n,
+ int zeros_r_nulls, RASTER_MAP_TYPE map_type)
{
struct fileinfo *fcb = &R__.fileinfo[fd];
if (fcb->gdal)
- return put_data_gdal(fd, rast, row, n, zeros_r_nulls, map_type);
-
- return (map_type == CELL_TYPE)
- ? put_data(fd, null_buf, rast, row, n, zeros_r_nulls)
- : put_fp_data(fd, null_buf, rast, row, n, map_type);
+ put_data_gdal(fd, rast, row, n, zeros_r_nulls, map_type);
+ else if (map_type == CELL_TYPE)
+ put_data(fd, null_buf, rast, row, n, zeros_r_nulls);
+ else
+ put_fp_data(fd, null_buf, rast, row, n, map_type);
}
-static int put_null_data(int fd, const char *flags, int row)
+static void put_null_data(int fd, const char *flags, int row)
{
struct fileinfo *fcb = &R__.fileinfo[fd];
if (fcb->null_fd < 0)
- return -1;
+ G_fatal_error(_("No null file for <%s>"), fcb->name);
Rast__convert_01_flags(flags, fcb->null_bits,
fcb->cellhd.cols);
- if (Rast__write_null_bits(fcb->null_fd, fcb->null_bits, row,
- fcb->cellhd.cols, fd) < 0)
- return -1;
+ Rast__write_null_bits(fcb->null_fd, fcb->null_bits, row,
+ fcb->cellhd.cols, fd);
+}
- return 1;
+static void put_null_value_row(int fd, const char *buf)
+{
+ struct fileinfo *fcb = &R__.fileinfo[fd];
+
+ if (fcb->gdal)
+ G_fatal_error(_("GDAL output doesn't support writing null rows separately"));
+
+ put_null_data(fd, buf, fcb->null_cur_row);
+
+ fcb->null_cur_row++;
}
/*!
@@ -622,22 +521,20 @@
\param fd file descriptor of raster cell data file
\return field descriptor of null data file
- \return -1 on failure
*/
int Rast__open_null_write(int fd)
{
struct fileinfo *fcb = &R__.fileinfo[fd];
int null_fd;
- if (access(fcb->null_temp_name, 0) != 0) {
- G_warning(_("Unable to find a temporary null file <%s>"),
- fcb->null_temp_name);
- return -1;
- }
+ if (access(fcb->null_temp_name, 0) != 0)
+ G_fatal_error(_("Unable to find a temporary null file <%s>"),
+ fcb->null_temp_name);
null_fd = open(fcb->null_temp_name, O_WRONLY);
if (null_fd < 0)
- return -1;
+ G_fatal_error(_("Unable to open null file <%s>"),
+ fcb->null_temp_name);
return null_fd;
}
@@ -651,11 +548,10 @@
\param col col number
\param fd file descriptor of cell data file
- \return 1 on success
- \return -1 on failure
+ \return void
*/
-int Rast__write_null_bits(int null_fd, const unsigned char *flags, int row,
- int cols, int fd)
+void Rast__write_null_bits(int null_fd, const unsigned char *flags, int row,
+ int cols, int fd)
{
off_t offset;
size_t size;
@@ -663,21 +559,16 @@
size = Rast__null_bitstream_size(cols);
offset = (off_t) size *row;
- if (lseek(null_fd, offset, SEEK_SET) < 0) {
- G_warning(_("Error writing null row %d"), row);
- return -1;
- }
+ if (lseek(null_fd, offset, SEEK_SET) < 0)
+ G_fatal_error(_("Error writing null row %d"), row);
- if (write(null_fd, flags, size) != size) {
- G_warning(_("Error writing null row %d"), row);
- return -1;
- }
-
- return 1;
+ if (write(null_fd, flags, size) != size)
+ G_fatal_error(_("Error writing null row %d"), row);
}
-static int convert_and_write_if(int fd, const CELL * buf)
+static void convert_and_write_if(int fd, const void *vbuf)
{
+ const CELL *buf = vbuf;
struct fileinfo *fcb = &R__.fileinfo[fd];
FCELL *p = (FCELL *) fcb->data;
int i;
@@ -688,11 +579,12 @@
else
p[i] = (FCELL) buf[i];
- return Rast_put_f_row(fd, p);
+ Rast_put_f_row(fd, p);
}
-static int convert_and_write_df(int fd, const DCELL * buf)
+static void convert_and_write_df(int fd, const void *vbuf)
{
+ const DCELL *buf = vbuf;
struct fileinfo *fcb = &R__.fileinfo[fd];
FCELL *p = (FCELL *) fcb->data;
int i;
@@ -703,11 +595,12 @@
else
p[i] = (FCELL) buf[i];
- return Rast_put_f_row(fd, p);
+ Rast_put_f_row(fd, p);
}
-static int convert_and_write_id(int fd, const CELL * buf)
+static void convert_and_write_id(int fd, const void *vbuf)
{
+ const CELL *buf = vbuf;
struct fileinfo *fcb = &R__.fileinfo[fd];
DCELL *p = (DCELL *) fcb->data;
int i;
@@ -718,11 +611,12 @@
else
p[i] = (DCELL) buf[i];
- return Rast_put_d_row(fd, p);
+ Rast_put_d_row(fd, p);
}
-static int convert_and_write_fd(int fd, const FCELL * buf)
+static void convert_and_write_fd(int fd, const void *vbuf)
{
+ const FCELL *buf = vbuf;
struct fileinfo *fcb = &R__.fileinfo[fd];
DCELL *p = (DCELL *) fcb->data;
int i;
@@ -733,11 +627,12 @@
else
p[i] = (DCELL) buf[i];
- return Rast_put_d_row(fd, p);
+ Rast_put_d_row(fd, p);
}
-static int convert_and_write_fi(int fd, const FCELL * buf)
+static void convert_and_write_fi(int fd, const void *vbuf)
{
+ const FCELL *buf = vbuf;
struct fileinfo *fcb = &R__.fileinfo[fd];
CELL *p = (CELL *) fcb->data;
int i;
@@ -748,11 +643,12 @@
else
p[i] = (CELL) buf[i];
- return Rast_put_c_row(fd, p);
+ Rast_put_c_row(fd, p);
}
-static int convert_and_write_di(int fd, const DCELL * buf)
+static void convert_and_write_di(int fd, const void *vbuf)
{
+ const DCELL *buf = vbuf;
struct fileinfo *fcb = &R__.fileinfo[fd];
CELL *p = (CELL *) fcb->data;
int i;
@@ -763,7 +659,7 @@
else
p[i] = (CELL) buf[i];
- return Rast_put_c_row(fd, p);
+ Rast_put_c_row(fd, p);
}
/*!
@@ -777,41 +673,42 @@
\param fd file descriptor where data is to be written
\param buf buffer holding null data
- \return 0 if successful
- \return -1 on fail
+ \return void
*/
-static int put_raster_row(int fd, const void *buf, RASTER_MAP_TYPE data_type,
- int zeros_r_nulls)
+static void put_raster_row(int fd, const void *buf, RASTER_MAP_TYPE data_type,
+ int zeros_r_nulls)
{
- static int (*convert_and_write_FtypeOtype[3][3]) () = {
- {
- NULL, convert_and_write_if, convert_and_write_id}, {
- convert_and_write_fi, NULL, convert_and_write_fd}, {
- convert_and_write_di, convert_and_write_df, NULL}
+ static void (*convert_and_write_FtypeOtype[3][3])(int, const void *) = {
+ {NULL, convert_and_write_if, convert_and_write_id},
+ {convert_and_write_fi, NULL, convert_and_write_fd},
+ {convert_and_write_di, convert_and_write_df, NULL}
};
struct fileinfo *fcb = &R__.fileinfo[fd];
char *null_buf;
- int stat;
- if (!check_open("put_raster_row", fd))
- return -1;
+ switch (fcb->open_mode) {
+ case OPEN_OLD:
+ G_fatal_error(_("put_raster_row: raster map <%s> not open for write - request ignored"),
+ fcb->name);
+ break;
+ case OPEN_NEW_COMPRESSED:
+ case OPEN_NEW_UNCOMPRESSED:
+ break;
+ default:
+ G_fatal_error(_("put_raster_row: unopened file descriptor - request ignored"));
+ break;
+ }
- if (fcb->map_type != data_type)
- return convert_and_write_FtypeOtype[data_type][fcb->map_type] (fd,
- buf);
+ if (fcb->map_type != data_type) {
+ convert_and_write_FtypeOtype[data_type][fcb->map_type](fd, buf);
+ return;
+ }
null_buf = G__alloca(fcb->cellhd.cols);
G_zero(null_buf, fcb->cellhd.cols);
- switch (put_raster_data(fd, null_buf, buf, fcb->cur_row, fcb->cellhd.cols,
- zeros_r_nulls, data_type)) {
- case -1:
- G__freea(null_buf);
- return -1;
- case 0:
- G__freea(null_buf);
- return 1;
- }
+ put_raster_data(fd, null_buf, buf, fcb->cur_row, fcb->cellhd.cols,
+ zeros_r_nulls, data_type);
/* only for integer maps */
if (data_type == CELL_TYPE) {
@@ -827,10 +724,8 @@
fcb->cur_row++;
/* write the null row for the data row */
- if (fcb->gdal)
- stat = 0;
- else
- stat = put_null_value_row(fd, null_buf);
+ if (!fcb->gdal)
+ put_null_value_row(fd, null_buf);
+
G__freea(null_buf);
- return stat;
}
Modified: grass/trunk/lib/rst/interp_float/resout2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/resout2d.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/lib/rst/interp_float/resout2d.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -105,10 +105,7 @@
G_fseek(params->Tmp_fd_z, (off_t) (params->nsizr - 1 - i) *
params->nsizc * sizeof(FCELL), 0);
fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_z);
- if (Rast_put_f_row(cf1, cell1) < 0) {
- G_warning(_("Failed writing raster map"));
- return -1;
- }
+ Rast_put_f_row(cf1, cell1);
}
}
@@ -124,10 +121,7 @@
* fprintf(stderr,"%f ",cell1[ii]); }
* fprintf(stderr,"params->nsizc=%d \n",params->nsizc);
*/
- if (Rast_put_f_row(cf2, cell1) < 0) {
- G_warning(_("Failed writing raster map"));
- return -1;
- }
+ Rast_put_f_row(cf2, cell1);
}
}
@@ -138,10 +132,7 @@
G_fseek(params->Tmp_fd_dy, (off_t) (params->nsizr - 1 - i) *
params->nsizc * sizeof(FCELL), 0);
fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_dy);
- if (Rast_put_f_row(cf3, cell1) < 0) {
- G_warning(_("Failed writing raster map"));
- return -1;
- }
+ Rast_put_f_row(cf3, cell1);
}
}
@@ -152,10 +143,7 @@
G_fseek(params->Tmp_fd_xx, (off_t) (params->nsizr - 1 - i) *
params->nsizc * sizeof(FCELL), 0);
fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_xx);
- if (Rast_put_f_row(cf4, cell1) < 0) {
- G_warning(_("Failed writing raster map"));
- return -1;
- }
+ Rast_put_f_row(cf4, cell1);
}
}
@@ -166,10 +154,7 @@
G_fseek(params->Tmp_fd_yy, (off_t) (params->nsizr - 1 - i) *
params->nsizc * sizeof(FCELL), 0);
fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_yy);
- if (Rast_put_f_row(cf5, cell1) < 0) {
- G_warning(_("Failed writing raster map"));
- return -1;
- }
+ Rast_put_f_row(cf5, cell1);
}
}
@@ -180,10 +165,7 @@
G_fseek(params->Tmp_fd_xy, (off_t) (params->nsizr - 1 - i) *
params->nsizc * sizeof(FCELL), 0);
fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_xy);
- if (Rast_put_f_row(cf6, cell1) < 0) {
- G_warning(_("Failed writing raster map"));
- return -1;
- }
+ Rast_put_f_row(cf6, cell1);
}
}
Modified: grass/trunk/lib/rst/interp_float/ressegm2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/ressegm2d.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/lib/rst/interp_float/ressegm2d.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -494,7 +494,6 @@
{
double x, y, sm; /* input data and smoothing */
int m1, m2; /* loop counters */
- int ret_val, ret_val1; /* return values of Rast_get_c_row */
static FCELL *cellinp = NULL; /* cell buffer for input data */
static FCELL *cellsmooth = NULL; /* cell buffer for smoothing */
Modified: grass/trunk/raster/r.bitpattern/main.c
===================================================================
--- grass/trunk/raster/r.bitpattern/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.bitpattern/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -134,8 +134,7 @@
}
- if (Rast_put_row(outfd, outrast, data_type) < 0)
- G_fatal_error(_("Unable to write to <%s>"), result);
+ Rast_put_row(outfd, outrast, data_type);
}
G_free(inrast);
Modified: grass/trunk/raster/r.buffer/write_map.c
===================================================================
--- grass/trunk/raster/r.buffer/write_map.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.buffer/write_map.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -69,9 +69,7 @@
if (cell[k] == 0)
Rast_set_null_value(&cell[k], 1, CELL_TYPE);
- if (Rast_put_row(fd_out, cell, CELL_TYPE) < 0)
- G_fatal_error(_("Failed writing raster map <%s> row %d"), output,
- row);
+ Rast_put_row(fd_out, cell, CELL_TYPE);
}
G_percent(row, window.rows, 2);
Modified: grass/trunk/raster/r.clump/clump.c
===================================================================
--- grass/trunk/raster/r.clump/clump.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.clump/clump.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -219,8 +219,7 @@
for (col = 1; col <= ncols; col++)
out_cell[col] = index[cur_clump[col]];
- if (Rast_put_row (out_fd, out_cell+1, CELL_TYPE) < 0)
- G_fatal_error (_("Unable to properly write output raster map"));
+ Rast_put_row (out_fd, out_cell+1, CELL_TYPE);
*/
col = ncols;
temp_clump = cur_clump + 1; /* skip left edge */
@@ -233,9 +232,7 @@
if (out_cell[column] == 0)
Rast_set_null_value(&out_cell[column], 1, CELL_TYPE);
}
- if (Rast_put_row(out_fd, out_cell, CELL_TYPE) < 0)
- G_fatal_error(_("Failed writing raster map row %d"),
- row);
+ Rast_put_row(out_fd, out_cell, CELL_TYPE);
}
/* switch the buffers so that the current buffer becomes the previous */
Modified: grass/trunk/raster/r.composite/main.c
===================================================================
--- grass/trunk/raster/r.composite/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.composite/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -243,8 +243,7 @@
(val[2] * B[1].levels + val[1]) * B[0].levels + val[0];
}
- if (Rast_put_row(out_file, out_array, CELL_TYPE) < 0)
- G_fatal_error(_("Failed writing raster map <%s>"), out_name);
+ Rast_put_row(out_file, out_array, CELL_TYPE);
}
G_percent(window.rows, window.rows, 1);
Modified: grass/trunk/raster/r.compress/main.c
===================================================================
--- grass/trunk/raster/r.compress/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.compress/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -211,8 +211,7 @@
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
Rast_get_row_nomask(old, rast, row, map_type);
- if (Rast_put_row(new, rast, map_type) < 0)
- break;
+ Rast_put_row(new, rast, map_type);
}
G_free(rast);
Rast_close(old);
Modified: grass/trunk/raster/r.cross/renumber.c
===================================================================
--- grass/trunk/raster/r.cross/renumber.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.cross/renumber.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -39,8 +39,7 @@
*c = table[*c];
c++;
}
- if (Rast_put_row(out, cell, CELL_TYPE) < 0)
- exit(1);
+ Rast_put_row(out, cell, CELL_TYPE);
}
G_percent(row, nrows, 10);
G_free(cell);
Modified: grass/trunk/raster/r.his/main.c
===================================================================
--- grass/trunk/raster/r.his/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.his/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -239,16 +239,13 @@
}
if (r_used)
- if (Rast_put_row(r_file, r_array, CELL_TYPE) < 0)
- r_used = 0;
+ Rast_put_row(r_file, r_array, CELL_TYPE);
if (g_used)
- if (Rast_put_row(g_file, g_array, CELL_TYPE) < 0)
- g_used = 0;
+ Rast_put_row(g_file, g_array, CELL_TYPE);
if (b_used)
- if (Rast_put_row(b_file, b_array, CELL_TYPE) < 0)
- b_used = 0;
+ Rast_put_row(b_file, b_array, CELL_TYPE);
}
G_percent(window.rows, window.rows, 5);
Modified: grass/trunk/raster/r.in.mat/main.c
===================================================================
--- grass/trunk/raster/r.in.mat/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.in.mat/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -468,10 +468,7 @@
fprintf(stderr, "]\n");
#endif
- if (1 != Rast_put_row(cf, raster, map_type)) {
- Rast_close(cf);
- G_fatal_error(_("Writing raster map, row %d"), row);
- }
+ Rast_put_row(cf, raster, map_type);
G_percent(row, mrows, 5);
}
Modified: grass/trunk/raster/r.in.poly/raster.c
===================================================================
--- grass/trunk/raster/r.in.poly/raster.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.in.poly/raster.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -186,8 +186,7 @@
}
G_percent(i, page.rows, 2);
- if (Rast_put_row(fd, cell, CELL_TYPE) < 0)
- return ERROR;
+ Rast_put_row(fd, cell, CELL_TYPE);
}
G_percent(i, page.rows, 2);
return configure_plot();
Modified: grass/trunk/raster/r.in.xyz/main.c
===================================================================
--- grass/trunk/raster/r.in.xyz/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.in.xyz/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -1012,11 +1012,7 @@
}
/* write out line of raster data */
- if (1 != Rast_put_row(out_fd, raster_row, rtype)) {
- Rast_close(out_fd);
- G_fatal_error(_("Writing map, row %d"),
- ((pass - 1) * rows) + row);
- }
+ Rast_put_row(out_fd, raster_row, rtype);
}
/* free memory */
Modified: grass/trunk/raster/r.lake/main.c
===================================================================
--- grass/trunk/raster/r.lake/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.lake/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -76,8 +76,7 @@
if (out[row][col] < *min_depth)
*min_depth = out[row][col];
}
- if (Rast_put_f_row(out_fd, out[row]) == -1)
- G_fatal_error(_("Failed writing output raster map row %d"), row);
+ Rast_put_f_row(out_fd, out[row]);
G_percent(row + 1, rows, 5);
}
}
Modified: grass/trunk/raster/r.los/main.c
===================================================================
--- grass/trunk/raster/r.los/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.los/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -371,9 +371,7 @@
/* set to NULL if beyond max_dist (0) or blocked view (1) */
if (fcell[col] == 0 || fcell[col] == 1)
Rast_set_null_value(&fcell[col], 1, FCELL_TYPE);
- if (Rast_put_row(new, fcell, FCELL_TYPE) < 0)
- G_fatal_error(_("Failed writing raster map <%s> row %d"),
- out_layer, row);
+ Rast_put_row(new, fcell, FCELL_TYPE);
}
segment_release(&seg_in); /* release memory */
Modified: grass/trunk/raster/r.mapcalc/map.c
===================================================================
--- grass/trunk/raster/r.mapcalc/map.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.mapcalc/map.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -655,8 +655,7 @@
void put_map_row(int fd, void *buf, int res_type)
{
- if (Rast_put_row(fd, buf, res_type) < 0)
- G_fatal_error(_("Failed writing raster map row"));
+ Rast_put_row(fd, buf, res_type);
}
void close_output_map(int fd)
Modified: grass/trunk/raster/r.null/main.c
===================================================================
--- grass/trunk/raster/r.null/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.null/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -171,9 +171,7 @@
for (row = 0; row < cellhd.rows; row++) {
G_percent(row, cellhd.rows, 1);
- if (Rast__write_null_bits(null_fd, null_bits, row, cellhd.cols, 0) <
- 0)
- G_fatal_error(_("Error writing null row %d"), row);
+ Rast__write_null_bits(null_fd, null_bits, row, cellhd.cols, 0);
}
G_percent(row, cellhd.rows, 1);
close(null_fd);
@@ -328,11 +326,7 @@
mask_raster_array(rast, cellhd.cols, change_null, map_type);
- if (Rast_put_row(new, rast, map_type) < 0) {
- G_warning(_("Failed writing raster map <%s> row %d"),
- name, row);
- break;
- }
+ Rast_put_row(new, rast, map_type);
}
G_percent(row, cellhd.rows, 1);
G_free(rast);
Modified: grass/trunk/raster/r.proj/main.c
===================================================================
--- grass/trunk/raster/r.proj/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.proj/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -438,9 +438,7 @@
ycoord1 = ycoord2;
}
- if (Rast_put_row(fdo, obuffer, cell_type) < 0)
- G_fatal_error(_("Failed writing raster map <%s> row %d"), mapname,
- row);
+ Rast_put_row(fdo, obuffer, cell_type);
xcoord1 = xcoord2 = outcellhd.west + (outcellhd.ew_res / 2);
ycoord2 -= outcellhd.ns_res;
Modified: grass/trunk/raster/r.resamp.rst/main.c
===================================================================
--- grass/trunk/raster/r.resamp.rst/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.resamp.rst/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -124,7 +124,7 @@
int main(int argc, char *argv[])
{
- int m1, ret_val;
+ int m1;
struct FPRange range;
DCELL cellmin, cellmax;
FCELL *cellrow, fcellmin;
Modified: grass/trunk/raster/r.resample/main.c
===================================================================
--- grass/trunk/raster/r.resample/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.resample/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -113,8 +113,7 @@
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
Rast_get_row(infd, rast, row, data_type);
- if (Rast_put_row(outfd, rast, out_type) < 0)
- G_fatal_error(_("Error writing row %d"), row);
+ Rast_put_row(outfd, rast, out_type);
Rast_mark_cats(rast, ncols, &cats, data_type);
}
Modified: grass/trunk/raster/r.spreadpath/main.c
===================================================================
--- grass/trunk/raster/r.spreadpath/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.spreadpath/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -321,8 +321,7 @@
path_fd = Rast_open_c_new(path_layer);
for (row = 0; row < nrows; row++) {
segment_get_row(&out_seg, cell, row);
- if (Rast_put_row(path_fd, cell, CELL_TYPE) < 0)
- G_fatal_error("unable to write map row %d", row);
+ Rast_put_row(path_fd, cell, CELL_TYPE);
}
if (verbose)
Modified: grass/trunk/raster/r.support/main.c
===================================================================
--- grass/trunk/raster/r.support/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.support/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -326,9 +326,7 @@
G_message(_("Writing new null file for [%s]... "), raster->answer);
for (row = 0; row < cellhd.rows; row++) {
G_percent(row, cellhd.rows, 1);
- if (Rast__write_null_bits(null_fd, null_bits, row, cellhd.cols, 0) <
- 0)
- G_fatal_error(_("Error writing null row [%d]."), row);
+ Rast__write_null_bits(null_fd, null_bits, row, cellhd.cols, 0);
}
G_percent(row, cellhd.rows, 1);
Modified: grass/trunk/raster/r.terraflow/grass2str.h
===================================================================
--- grass/trunk/raster/r.terraflow/grass2str.h 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.terraflow/grass2str.h 2010-01-04 22:27:30 UTC (rev 40223)
@@ -210,8 +210,7 @@
}
} /* for j*/
- if (Rast_put_row (outfd, outrast, mtype) < 0)
- G_fatal_error ("Cannot write to <%s>",cellname);
+ Rast_put_row (outfd, outrast, mtype);
G_percent(i, nrows, 2);
}/* for i */
@@ -289,8 +288,7 @@
}
} /* for j*/
- if (Rast_put_row (outfd, outrast, CELL_TYPE) < 0)
- G_fatal_error ("Cannot write to <%s>",cellname);
+ Rast_put_row (outfd, outrast, CELL_TYPE);
G_percent(i, nrows, 2);
}/* for i */
@@ -363,8 +361,7 @@
}
} /* for j*/
- if (Rast_put_row (outfd, outrast, FCELL_TYPE) < 0)
- G_fatal_error ("Cannot write to <%s>",cellname);
+ Rast_put_row (outfd, outrast, FCELL_TYPE);
G_percent(i, nrows, 2);
}/* for i */
@@ -472,10 +469,8 @@
} /* for j*/
- if (Rast_put_row (fd1, rast1, FCELL_TYPE) < 0)
- G_fatal_error ("Cannot write to <%s>", cellname1);
- if (Rast_put_row (fd2, rast2, FCELL_TYPE) < 0)
- G_fatal_error ("Cannot write to <%s>", cellname2);
+ Rast_put_row (fd1, rast1, FCELL_TYPE);
+ Rast_put_row (fd2, rast2, FCELL_TYPE);
G_percent(i, nrows, 2);
Modified: grass/trunk/raster/r.texture/main.c
===================================================================
--- grass/trunk/raster/r.texture/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.texture/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -328,21 +328,14 @@
/* The early (size/2) samples take value from (size/2+1)'th sample */
if (row == 0)
for (j = 0; j < (size / 2); j++)
- if (Rast_put_row(outfd, outrast, out_data_type) <
- 0)
- G_fatal_error(_("Failed writing raster map <%s> row %d"),
- result, row);
+ Rast_put_row(outfd, outrast, out_data_type);
- if (Rast_put_row(outfd, outrast, out_data_type) < 0)
- G_fatal_error(_("Failed writing raster map <%s> row %d"),
- result, row);
+ Rast_put_row(outfd, outrast, out_data_type);
}
/* The last few (size/2) samples take value from nrows-(size/2+1)'th sample */
if ((row >= nrows - (size - 1)) && (row < nrows))
for (j = 0; j < (size / 2); j++)
- if (Rast_put_row(outfd, outrast, out_data_type) < 0)
- G_fatal_error(_("Failed writing raster map <%s> row %d"),
- result, row);
+ Rast_put_row(outfd, outrast, out_data_type);
Rast_close(outfd);
strcpy(mapname, filename);
Modified: grass/trunk/raster/r.uslek/main.c
===================================================================
--- grass/trunk/raster/r.uslek/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.uslek/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -151,9 +151,7 @@
}
}
}
- if (Rast_put_d_row(outfd, outrast) < 0)
- G_fatal_error(_("Failed writing raster map <%s> row %d"),
- result, row);
+ Rast_put_d_row(outfd, outrast);
}
G_free(inrast_psand);
G_free(inrast_psilt);
Modified: grass/trunk/raster/r.usler/main.c
===================================================================
--- grass/trunk/raster/r.usler/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.usler/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -126,9 +126,7 @@
outrast[col] = d ;
}
}
- if (Rast_put_d_row(outfd, outrast) < 0)
- G_fatal_error(_("Failed writing raster map <%s> row %d"),
- result, row);
+ Rast_put_d_row(outfd, outrast);
}
G_free(inrast_annual_pmm);
Rast_close(infd_annual_pmm);
Modified: grass/trunk/raster/r.watershed/seg/bseg_read.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/bseg_read.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.watershed/seg/bseg_read.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -3,8 +3,6 @@
#include <unistd.h>
#include "cseg.h"
-static char *me = "bseg_read_cell";
-
int bseg_read_cell(BSEG * bseg, char *map_name, char *mapset)
{
int row, nrows;
Modified: grass/trunk/raster/r.watershed/seg/bseg_write.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/bseg_write.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.watershed/seg/bseg_write.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -2,8 +2,6 @@
#include <grass/raster.h>
#include "cseg.h"
-static char *me = "bseg_write_cell";
-
int bseg_write_cellfile(BSEG * bseg, char *map_name)
{
int map_fd;
@@ -22,13 +20,7 @@
bseg_get(bseg, &value, row, col);
buffer[col] = value;
}
- if (Rast_put_row(map_fd, buffer, CELL_TYPE) < 0) {
- G_free(buffer);
- Rast_unopen(map_fd);
- G_warning("%s(): unable to write new map layer [%s], row %d",
- me, map_name, row);
- return -2;
- }
+ Rast_put_row(map_fd, buffer, CELL_TYPE);
}
G_percent(row, nrows, 1); /* finish it */
G_free(buffer);
Modified: grass/trunk/raster/r.watershed/seg/cseg_write.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/cseg_write.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.watershed/seg/cseg_write.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -3,8 +3,6 @@
#include <grass/segment.h>
#include "cseg.h"
-static char *me = "cseg_write_cell";
-
int cseg_write_cellfile(CSEG * cseg, char *map_name)
{
int map_fd;
@@ -18,13 +16,7 @@
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 1);
segment_get_row(&(cseg->seg), buffer, row);
- if (Rast_put_row(map_fd, buffer, CELL_TYPE) < 0) {
- G_free(buffer);
- Rast_unopen(map_fd);
- G_warning("%s(): unable to write new map layer [%s], row %d",
- me, map_name, row);
- return -2;
- }
+ Rast_put_row(map_fd, buffer, CELL_TYPE);
}
G_percent(row, nrows, 1); /* finish it */
G_free(buffer);
Modified: grass/trunk/raster/r.watershed/seg/dseg_write.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/dseg_write.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster/r.watershed/seg/dseg_write.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -3,8 +3,6 @@
#include <grass/segment.h>
#include "cseg.h"
-static char *me = "dseg_write_cell";
-
int dseg_write_cellfile(DSEG * dseg, char *map_name)
{
int map_fd;
@@ -19,13 +17,7 @@
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 1);
segment_get_row(&(dseg->seg), (DCELL *) dbuffer, row);
- if (Rast_put_row(map_fd, dbuffer, DCELL_TYPE) < 0) {
- G_free(dbuffer);
- Rast_unopen(map_fd);
- G_warning("%s(): unable to write new map layer [%s], row %d",
- me, map_name, row);
- return -2;
- }
+ Rast_put_row(map_fd, dbuffer, DCELL_TYPE);
}
G_percent(row, nrows, 1); /* finish it */
G_free(dbuffer);
Modified: grass/trunk/raster3d/r3.cross.rast/main.c
===================================================================
--- grass/trunk/raster3d/r3.cross.rast/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster3d/r3.cross.rast/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -118,7 +118,7 @@
void rast3d_cross_section(void *map, G3D_Region region, int elevfd, int outfd)
{
double d1 = 0, f1 = 0;
- int x, y, z, check = 0;
+ int x, y, z;
int rows, cols, depths, typeIntern;
FCELL *fcell = NULL;
DCELL *dcell = NULL;
@@ -221,19 +221,11 @@
}
/*Write the data to the output map */
- if (typeIntern == FCELL_TYPE) {
- check = Rast_put_f_row(outfd, fcell);
- if (check != 1)
- fatal_error(map, elevfd, outfd,
- _("Could not write raster row"));
- }
+ if (typeIntern == FCELL_TYPE)
+ Rast_put_f_row(outfd, fcell);
- if (typeIntern == DCELL_TYPE) {
- check = Rast_put_d_row(outfd, dcell);
- if (check != 1)
- fatal_error(map, elevfd, outfd,
- _("Could not write raster row"));
- }
+ if (typeIntern == DCELL_TYPE)
+ Rast_put_d_row(outfd, dcell);
}
G_debug(3, "\nDone\n");
Modified: grass/trunk/raster3d/r3.to.rast/main.c
===================================================================
--- grass/trunk/raster3d/r3.to.rast/main.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/raster3d/r3.to.rast/main.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -103,7 +103,7 @@
void g3d_to_raster(void *map, G3D_Region region, int *fd)
{
double d1 = 0, f1 = 0;
- int x, y, z, check = 0;
+ int x, y, z;
int rows, cols, depths, typeIntern, pos = 0;
FCELL *fcell = NULL;
DCELL *dcell = NULL;
@@ -146,19 +146,11 @@
dcell[x] = (DCELL) d1;
}
}
- if (typeIntern == FCELL_TYPE) {
- check = Rast_put_f_row(fd[pos], fcell);
- if (check != 1)
- fatal_error(map, fd, depths,
- _("Unable to write raster row"));
- }
+ if (typeIntern == FCELL_TYPE)
+ Rast_put_f_row(fd[pos], fcell);
- if (typeIntern == DCELL_TYPE) {
- check = Rast_put_d_row(fd[pos], dcell);
- if (check != 1)
- fatal_error(map, fd, depths,
- _("Unable to write raster row"));
- }
+ if (typeIntern == DCELL_TYPE)
+ Rast_put_d_row(fd[pos], dcell);
}
G_debug(2, "Finished writing map %d.", z + 1);
pos++;
Modified: grass/trunk/vector/v.to.rast/raster.c
===================================================================
--- grass/trunk/vector/v.to.rast/raster.c 2010-01-04 21:05:41 UTC (rev 40222)
+++ grass/trunk/vector/v.to.rast/raster.c 2010-01-04 22:27:30 UTC (rev 40223)
@@ -145,16 +145,14 @@
/* insert the NULL values */
Rast_insert_c_null_values(cell, null_flags[i], page.cols);
- if (Rast_put_c_row(fd, cell) < 0)
- return -1;
+ Rast_put_c_row(fd, cell);
break;
case USE_DCELL:
dcell = raster.dcell[i];
/* insert the NULL values */
Rast_insert_d_null_values(dcell, null_flags[i], page.cols);
- if (Rast_put_d_row(fd, dcell) < 0)
- return -1;
+ Rast_put_d_row(fd, dcell);
break;
}
}
More information about the grass-commit
mailing list