[GRASS-SVN] r56204 - grass/trunk/vector/v.to.3d
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat May 11 09:59:16 PDT 2013
Author: martinl
Date: 2013-05-11 09:59:16 -0700 (Sat, 11 May 2013)
New Revision: 56204
Modified:
grass/trunk/vector/v.to.3d/local_proto.h
grass/trunk/vector/v.to.3d/main.c
grass/trunk/vector/v.to.3d/trans2.c
grass/trunk/vector/v.to.3d/trans3.c
Log:
v.to.3d: call G_fatal_error() immediately
Modified: grass/trunk/vector/v.to.3d/local_proto.h
===================================================================
--- grass/trunk/vector/v.to.3d/local_proto.h 2013-05-11 16:50:19 UTC (rev 56203)
+++ grass/trunk/vector/v.to.3d/local_proto.h 2013-05-11 16:59:16 UTC (rev 56204)
@@ -14,9 +14,9 @@
void parse_args(struct opts *);
/* trans2.c */
-int trans2d(struct Map_info *, struct Map_info *, int,
- double, const char *, const char *);
+void trans2d(struct Map_info *, struct Map_info *, int,
+ double, const char *, const char *);
/* trans3.c */
-int trans3d(struct Map_info *, struct Map_info *, int,
- const char *, const char *);
+void trans3d(struct Map_info *, struct Map_info *, int,
+ const char *, const char *);
Modified: grass/trunk/vector/v.to.3d/main.c
===================================================================
--- grass/trunk/vector/v.to.3d/main.c 2013-05-11 16:50:19 UTC (rev 56203)
+++ grass/trunk/vector/v.to.3d/main.c 2013-05-11 16:59:16 UTC (rev 56204)
@@ -29,7 +29,6 @@
struct Map_info In, Out;
struct bound_box box;
int type;
- int ret;
G_gisinit(argv[0]);
@@ -100,10 +99,9 @@
}
}
- ret = 0;
if (opt.reverse->answer) {
/* 3d -> 2d */
- ret = trans3d(&In, &Out, type, opt.field->answer, opt.column->answer);
+ trans3d(&In, &Out, type, opt.field->answer, opt.column->answer);
}
else {
/* 2d -> 3d */
@@ -112,13 +110,9 @@
if (opt.height->answer) {
height = atof(opt.height->answer);
}
- ret = trans2d(&In, &Out, type, height, opt.field->answer, opt.column->answer);
+ trans2d(&In, &Out, type, height, opt.field->answer, opt.column->answer);
}
- if (ret < 0) {
- G_fatal_error(_("%s failed"), G_program_name());
- }
-
if (!opt.reverse->answer && !opt.table->answer) {
G_message(_("Copying attributes..."));
if (Vect_copy_tables(&In, &Out, 0) == -1) {
Modified: grass/trunk/vector/v.to.3d/trans2.c
===================================================================
--- grass/trunk/vector/v.to.3d/trans2.c 2013-05-11 16:50:19 UTC (rev 56203)
+++ grass/trunk/vector/v.to.3d/trans2.c 2013-05-11 16:59:16 UTC (rev 56204)
@@ -14,11 +14,8 @@
\param height fixed height (used only if column is NULL)
\param field layer number
\param column attribute column used for height
-
- \return number of writen features
- \return -1 on error
*/
-int trans2d(struct Map_info *In, struct Map_info *Out, int type,
+void trans2d(struct Map_info *In, struct Map_info *Out, int type,
double height, const char *field_name, const char *column)
{
int i, ltype, line, field;
@@ -49,28 +46,25 @@
Fi = Vect_get_field(In, field);
if (!Fi) {
- G_warning(_("Database connection not defined for layer <%s>"),
- field_name);
- return -1;
+ G_fatal_error(_("Database connection not defined for layer <%s>"),
+ field_name);
}
driver = db_start_driver_open_database(Fi->driver, Fi->database);
if (!driver) {
- G_warning(_("Unable to open database <%s> by driver <%s>"),
- Fi->database, Fi->driver);
- return -1;
+ G_fatal_error(_("Unable to open database <%s> by driver <%s>"),
+ Fi->database, Fi->driver);
}
-
+ db_set_error_handler_driver(driver);
+
/* column type must numeric */
ctype = db_column_Ctype(driver, Fi->table, column);
if (ctype == -1) {
- G_warning(_("Column <%s> not found in table <%s>"),
- column, Fi->table);
- return -1;
+ G_fatal_error(_("Column <%s> not found in table <%s>"),
+ column, Fi->table);
}
if (ctype != DB_C_TYPE_INT && ctype != DB_C_TYPE_DOUBLE) {
- G_warning(_("Column must be numeric"));
- return -1;
+ G_fatal_error(_("Column must be numeric"));
}
G_message(_("Fetching height from <%s> column..."), column);
@@ -87,8 +81,7 @@
while (1) {
ltype = Vect_read_next_line(In, Points, Cats);
if (ltype == -1) {
- G_warning(_("Unable to read vector map"));
- return -1;
+ G_fatal_error(_("Unable to read vector map"));
}
if (ltype == -2) { /* EOF */
break;
@@ -136,6 +129,4 @@
Vect_destroy_line_struct(Points);
Vect_destroy_cats_struct(Cats);
-
- return line - 1;
}
Modified: grass/trunk/vector/v.to.3d/trans3.c
===================================================================
--- grass/trunk/vector/v.to.3d/trans3.c 2013-05-11 16:50:19 UTC (rev 56203)
+++ grass/trunk/vector/v.to.3d/trans3.c 2013-05-11 16:59:16 UTC (rev 56204)
@@ -16,11 +16,8 @@
\param type feature type to be transformed
\param field layer number
\param zcolumn attribute column where to store height
-
- \return number of writen features
- \return -1 on error
*/
-int trans3d(struct Map_info *In, struct Map_info *Out, int type,
+void trans3d(struct Map_info *In, struct Map_info *Out, int type,
const char *field_name, const char *zcolumn)
{
int ltype, line;
@@ -51,28 +48,25 @@
Fi = Vect_get_field(Out, field);
if (!Fi) {
- G_warning(_("Database connection not defined for layer <%s>"),
- field_name);
- return -1;
+ G_fatal_error(_("Database connection not defined for layer <%s>"),
+ field_name);
}
driver = db_start_driver_open_database(Fi->driver, Fi->database);
if (!driver) {
- G_warning(_("Unable to open database <%s> by driver <%s>"),
- Fi->database, Fi->driver);
- return -1;
+ G_fatal_error(_("Unable to open database <%s> by driver <%s>"),
+ Fi->database, Fi->driver);
}
-
+ db_set_error_handler_driver(driver);
+
/* column type must numeric */
ctype = db_column_Ctype(driver, Fi->table, zcolumn);
if (ctype == -1) {
- G_warning(_("Column <%s> not found in table <%s>"),
- zcolumn, Fi->table);
- return -1;
+ G_fatal_error(_("Column <%s> not found in table <%s>"),
+ zcolumn, Fi->table);
}
if (ctype != DB_C_TYPE_INT && ctype != DB_C_TYPE_DOUBLE) {
- G_warning(_("Column must be numeric"));
- return -1;
+ G_fatal_error(_("Column must be numeric"));
}
db_begin_transaction(driver);
@@ -88,8 +82,7 @@
while (1) {
ltype = Vect_read_next_line(In, Points, Cats);
if (ltype == -1) {
- G_warning(_("Unable to read vector map"));
- return -1;
+ G_fatal_error(_("Unable to read vector map"));
}
if (ltype == -2) { /* EOF */
break;
@@ -155,8 +148,6 @@
Vect_destroy_line_struct(Points);
Vect_destroy_cats_struct(Cats);
-
- return line - 1;
}
int srch(const void *pa, const void *pb)
More information about the grass-commit
mailing list