فهرست منبع

v.to.db: Fix r70633; Don't throw a fatal error when there are no features

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@70706 15284696-431f-4ddb-bdfa-cd5b030d7da7
Huidae Cho 8 سال پیش
والد
کامیت
a9366cca25
1فایلهای تغییر یافته به همراه4 افزوده شده و 2 حذف شده
  1. 4 2
      vector/v.to.db/main.c

+ 4 - 2
vector/v.to.db/main.c

@@ -68,10 +68,10 @@ int main(int argc, char *argv[])
     }
 
     /* allocate array for values */
-    /* (+ 1 is for cat -1 (no category) reported at the end ) */
+    /* (+1 is for cat -1 (no category) reported at the end ) */
     findex = Vect_cidx_get_field_index(&Map, options.field);
     if (findex > -1) {
-	n = Vect_cidx_get_num_cats_by_index(&Map, findex);
+	n = Vect_cidx_get_num_unique_cats_by_index(&Map, findex);
     }
     else {
 	n = 0;
@@ -80,6 +80,8 @@ int main(int argc, char *argv[])
     Values = (struct value *) G_calloc(n + 1, sizeof(struct value));
 
     /* prepopulate Values */
+    if (n > 0)
+	n = Vect_cidx_get_num_cats_by_index(&Map, findex);
     i = 0;
     Values[i].cat = -1;		/* features without category */
     Values[i].used = 0;