[GRASS-SVN] r51991 - grass-addons/grass7/vector/v.in.ply
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jun 6 09:34:01 PDT 2012
Author: mmetz
Date: 2012-06-06 09:34:00 -0700 (Wed, 06 Jun 2012)
New Revision: 51991
Modified:
grass-addons/grass7/vector/v.in.ply/main.c
Log:
v.in.ply: code cleanup
Modified: grass-addons/grass7/vector/v.in.ply/main.c
===================================================================
--- grass-addons/grass7/vector/v.in.ply/main.c 2012-06-06 15:48:50 UTC (rev 51990)
+++ grass-addons/grass7/vector/v.in.ply/main.c 2012-06-06 16:34:00 UTC (rev 51991)
@@ -30,9 +30,9 @@
{
struct GModule *module;
struct Option *old, *new, *x_opt, *y_opt, *z_opt;
- struct Flag *notab_flag, *notopo_flag;
+ struct Flag *notab_flag, *notopo_flag, *prop_flag;
char *colname, buf[2000];
- int i, j, type, max_cat;
+ int i, j, type;
int zcoor = WITHOUT_Z, make_table;
int xprop, yprop, zprop;
struct ply_file ply;
@@ -98,6 +98,10 @@
notopo_flag->key = 'b';
notopo_flag->description = _("Do not build topology");
+ prop_flag = G_define_flag();
+ prop_flag->key = 'p';
+ prop_flag->description = _("Only print PLY element types and their properties.");
+
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
@@ -140,17 +144,19 @@
/* read ply header */
read_ply_header(&ply);
- for (i = 0; i < ply.n_elements; i++) {
- G_debug(1, "element name: %s", ply.element[i]->name);
- G_debug(1, "element type: %d", ply.element[i]->type);
+ if (prop_flag->answer) {
+ for (i = 0; i < ply.n_elements; i++) {
+ fprintf(stdout, "element name: %s\n", ply.element[i]->name);
+ fprintf(stdout, "element type: %d\n", ply.element[i]->type);
- for (j = 0; j < ply.element[i]->n_properties; j++) {
- G_debug(1, "poperty name: %s", ply.element[i]->property[j]->name);
- G_debug(1, "poperty type: %d", ply.element[i]->property[j]->type);
+ for (j = 0; j < ply.element[i]->n_properties; j++) {
+ fprintf(stdout, "property name: %s\n", ply.element[i]->property[j]->name);
+ fprintf(stdout, "property type: %d\n", ply.element[i]->property[j]->type);
+ }
}
+ exit(EXIT_SUCCESS);
}
-
-
+
/* vertices present ? */
ply.curr_element = NULL;
for (i = 0; i < ply.n_elements; i++) {
@@ -249,10 +255,9 @@
Points = Vect_new_line_struct();
Cats = Vect_new_cats_struct();
- G_message(_("%d vertices"), ply.curr_element->n);
+ G_message(_("Importing %d vertices ..."), ply.curr_element->n);
x = y = z = 0.0;
- max_cat = 0;
for (i = 0; i < ply.curr_element->n; i++) {
G_percent(i, ply.curr_element->n, 4);
get_element_data(&ply, data);
@@ -260,7 +265,6 @@
Vect_reset_line(Points);
Vect_reset_cats(Cats);
Vect_cat_set(Cats, 1, i);
-
/* Attributes */
if (make_table) {
@@ -321,8 +325,6 @@
db_get_string(&sql));
}
}
-
- max_cat = i;
}
G_percent(1, 1, 1);
G_free(data);
@@ -373,7 +375,6 @@
}
-
if (!notopo_flag->answer)
Vect_build(&Map);
More information about the grass-commit
mailing list