[GRASS-SVN] r52135 - grass/trunk/lib/vector/neta
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jun 19 08:40:18 PDT 2012
Author: mmetz
Date: 2012-06-19 08:40:18 -0700 (Tue, 19 Jun 2012)
New Revision: 52135
Modified:
grass/trunk/lib/vector/neta/utils.c
Log:
neta lib: fix return value
Modified: grass/trunk/lib/vector/neta/utils.c
===================================================================
--- grass/trunk/lib/vector/neta/utils.c 2012-06-19 10:32:54 UTC (rev 52134)
+++ grass/trunk/lib/vector/neta/utils.c 2012-06-19 15:40:18 UTC (rev 52135)
@@ -218,46 +218,47 @@
\param cat ?
\param[out] pointer to varray structure
- \return ?
+ \return number of items set
+ \return -1 on error
*/
int NetA_initialise_varray(struct Map_info *In, int layer, int mask_type,
char *where, char *cat, struct varray **varray)
{
+ int n, ni;
+
+ n = Vect_get_num_lines(In);
+ *varray = Vect_new_varray(n);
+ ni = 0;
+
/* parse filter option and select appropriate lines */
if (where) {
if (layer < 1)
G_fatal_error(_("'%s' must be > 0 for '%s'"), "layer", "where");
if (cat)
G_warning(_("'where' and 'cats' parameters were supplied, cat will be ignored"));
- *varray = Vect_new_varray(Vect_get_num_lines(In));
- if (Vect_set_varray_from_db
- (In, layer, where, mask_type, 1, *varray) == -1) {
+ ni = Vect_set_varray_from_db(In, layer, where, mask_type, 1, *varray);
+ if (ni == -1) {
G_warning(_("Unable to load data from database"));
- return 0;
}
- return 1;
+ return ni;
}
else if (cat) {
if (layer < 1)
G_fatal_error(_("'%s' must be > 0 for '%s'"), "layer", "categories");
- *varray = Vect_new_varray(Vect_get_num_lines(In));
- if (Vect_set_varray_from_cat_string
- (In, layer, cat, mask_type, 1, *varray) == -1) {
+ ni = Vect_set_varray_from_cat_string(In, layer, cat, mask_type, 1, *varray);
+ if (ni == -1) {
G_warning(_("Problem loading category values"));
- return 0;
}
- return 1;
+ return ni;
}
else { /* all features of given layer */
- int i, n, cat;
+ int i, cat;
int ltype; /* line type */
struct line_cats *Cats;
if (layer < 1)
G_fatal_error(_("'%s' must be > 0 for '%s'"), "layer", "categories");
- n = Vect_get_num_lines(In);
- *varray = Vect_new_varray(n);
Cats = Vect_new_cats_struct();
for (i = 1; i <= n; i++) {
@@ -266,13 +267,13 @@
if (!(ltype & mask_type))
continue; /* is not specified type */
- if (Vect_cat_get(Cats, layer, &cat))
+ if (Vect_cat_get(Cats, layer, &cat)) {
(*varray)->c[i] = 1;
+ ni++;
+ }
}
Vect_destroy_cats_struct(Cats);
- return 2;
+ return ni;
}
-
-
}
More information about the grass-commit
mailing list