Sfoglia il codice sorgente

v.extract: use Vect_copy_map_dblinks()

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@48949 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 13 anni fa
parent
commit
5a6063d6f1
2 ha cambiato i file con 11 aggiunte e 17 eliminazioni
  1. 6 6
      vector/v.extract/extract.c
  2. 5 11
      vector/v.extract/main.c

+ 6 - 6
vector/v.extract/extract.c

@@ -194,7 +194,7 @@ int extract_line(int num_index, int *num_array, struct Map_info *In,
 		 struct Map_info *Out, int new, int select_type, int dissolve,
 		 int field, int type_only, int reverse)
 {
-    int line, nlines, is_ogr;
+    int line, nlines, native;
     struct line_pnts *Points;
     struct line_cats *Line_Cats_Old, *CCats;
 
@@ -220,10 +220,10 @@ int extract_line(int num_index, int *num_array, struct Map_info *In,
     qsort(cats_array, ncats_array, sizeof(int), cmp);
 
     /* writting OGR layers directly */
-    is_ogr = Vect_maptype(Out) == GV_FORMAT_OGR_DIRECT;
-    if (is_ogr && Vect_level(In) < 2)
+    native = Vect_maptype(Out) == GV_FORMAT_NATIVE;
+    if (!native && Vect_level(In) < 2)
 	G_warning(_("Topology level required for extracting areas "
-		    "for OGR layers"));
+		    "for OGR layers. Areas will be not processed."));
     
     /* Cycle through all lines */
     nlines = Vect_get_num_lines(In);
@@ -243,7 +243,7 @@ int extract_line(int num_index, int *num_array, struct Map_info *In,
 	type = Vect_read_line(In, Points, Line_Cats_Old, line);
 	G_debug(3, "type = %d ncats = %d", type, Line_Cats_Old->n_cats);
 
-	if (is_ogr && type == GV_BOUNDARY)
+	if (!native && type == GV_BOUNDARY)
 	    /* OGR layers writes areas as polygons */
 	    continue;
 	    
@@ -388,7 +388,7 @@ int extract_line(int num_index, int *num_array, struct Map_info *In,
 	if (write) {
 	    extract_cats(Line_Cats_Old, type_only, field, new, reverse);
 
-	    if (is_ogr && type == GV_CENTROID && area > 0)
+	    if (!native && type == GV_CENTROID && area > 0)
 		extract_area(In, Out, area, Points, Line_Cats_Old, field);
 	    else
 		Vect_write_line(Out, type, Points, Line_Cats_Old);

+ 5 - 11
vector/v.extract/main.c

@@ -43,7 +43,7 @@ static void add_cat(int);
 
 int main(int argc, char **argv)
 {
-    int i, new_cat, type, ncats, *cats, c, is_ogr;
+    int i, new_cat, type, ncats, *cats, c, native;
     int field, dissolve, x, y, type_only;
     char buffr[1024], text[80];
     char *input, *output;
@@ -349,16 +349,10 @@ int main(int argc, char **argv)
     
     G_message(_("Extracting features..."));
     
-    is_ogr = Vect_maptype(&Out) == GV_FORMAT_OGR_DIRECT;
-    if (!flag.t->answer && is_ogr) {
+    native = Vect_maptype(&Out) == GV_FORMAT_NATIVE;
+    if (!flag.t->answer && !native) {
 	/* Copy attributes for OGR output */
-	if (!Fi)
-	    Fi = Vect_get_field(&In, field);
-	if (!Fi)
-	    G_fatal_error(_("Database connection not defined for layer <%s>"),
-			  opt.field->answer);
-	Vect_map_add_dblink(&Out, Fi->number, Fi->name, Fi->table, Fi->key,
-			    Fi->database, Fi->driver);
+	Vect_copy_map_dblinks(&In, &Out, TRUE);
     }
 
     extract_line(cat_count, cat_array, &In, &Out, new_cat, type, dissolve, field,
@@ -367,7 +361,7 @@ int main(int argc, char **argv)
     Vect_build(&Out);
 
     /* Copy tables */
-    if (!flag.t->answer && !is_ogr) {
+    if (!flag.t->answer && native) {
 	copy_tabs(&In, field, new_cat, &Out);
     }