فهرست منبع

v.overlay: use GV_MTABLE for multiple output layers

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@69352 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 8 سال پیش
والد
کامیت
695362cbb3
1فایلهای تغییر یافته به همراه11 افزوده شده و 6 حذف شده
  1. 11 6
      vector/v.overlay/main.c

+ 11 - 6
vector/v.overlay/main.c

@@ -31,7 +31,7 @@
 
 #include "local.h"
 
-void copy_table(struct Map_info *, struct Map_info *, int, int);
+void copy_table(struct Map_info *, struct Map_info *, int, int, int);
 
 int main(int argc, char *argv[])
 {
@@ -50,6 +50,7 @@ int main(int argc, char *argv[])
     int verbose;
 
     struct field_info *Fi = NULL;
+    int table_type;
     char buf[DB_SQL_MAX];
     dbString stmt;
     dbString sql, value_string, col_defs;
@@ -161,6 +162,10 @@ int main(int argc, char *argv[])
 	i++;
     }
 
+    table_type = GV_1TABLE;
+    if ((ofield[0] > 0) + (ofield[1] > 0) + (ofield[2] > 0) > 1)
+	table_type = GV_MTABLE;
+
     if (operator_opt->answer[0] == 'a')
 	operator = OP_AND;
     else if (operator_opt->answer[0] == 'o')
@@ -223,7 +228,7 @@ int main(int argc, char *argv[])
 
     /* Create dblinks */
     if (ofield[0] > 0) {
-	Fi = Vect_default_field_info(&Out, ofield[0], NULL, GV_1TABLE);
+	Fi = Vect_default_field_info(&Out, ofield[0], NULL, table_type);
     }
 
     db_init_string(&sql);
@@ -622,11 +627,11 @@ int main(int argc, char *argv[])
 	/* TODO: copy only valid attributes */
 	/* copy attributes from ainput */
 	if (ofield[1] > 0 && field[0] > 0) {
-	    copy_table(&In[0], &Out, field[0], ofield[1]);
+	    copy_table(&In[0], &Out, field[0], ofield[1], table_type);
 	}
 	/* copy attributes from binput */
 	if (ofield[2] > 0 && field[1] > 0 && ofield[1] != ofield[2]) {
-	    copy_table(&In[1], &Out, field[1], ofield[2]);
+	    copy_table(&In[1], &Out, field[1], ofield[2], table_type);
 	}
     }
 
@@ -640,7 +645,7 @@ int main(int argc, char *argv[])
 }
 
 void copy_table(struct Map_info *In, struct Map_info *Out, int infield, 
-                int outfield)
+                int outfield, int table_type)
 {
     struct ilist *list;
     int findex;
@@ -652,7 +657,7 @@ void copy_table(struct Map_info *In, struct Map_info *Out, int infield,
     list = Vect_new_list();
     Vect_cidx_get_unique_cats_by_index(Out, findex, list);
     Vect_copy_table_by_cats(In, Out, infield, outfield, NULL,
-                            GV_1TABLE, list->value, list->n_values);
+                            table_type, list->value, list->n_values);
     
     Vect_destroy_list(list);
 }