[GRASS-SVN] r48949 - grass/trunk/vector/v.extract

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Oct 26 05:14:58 EDT 2011


Author: martinl
Date: 2011-10-26 02:14:58 -0700 (Wed, 26 Oct 2011)
New Revision: 48949

Modified:
   grass/trunk/vector/v.extract/extract.c
   grass/trunk/vector/v.extract/main.c
Log:
v.extract: use Vect_copy_map_dblinks()


Modified: grass/trunk/vector/v.extract/extract.c
===================================================================
--- grass/trunk/vector/v.extract/extract.c	2011-10-26 09:06:05 UTC (rev 48948)
+++ grass/trunk/vector/v.extract/extract.c	2011-10-26 09:14:58 UTC (rev 48949)
@@ -194,7 +194,7 @@
 		 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 @@
     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 @@
 	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 @@
 	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);

Modified: grass/trunk/vector/v.extract/main.c
===================================================================
--- grass/trunk/vector/v.extract/main.c	2011-10-26 09:06:05 UTC (rev 48948)
+++ grass/trunk/vector/v.extract/main.c	2011-10-26 09:14:58 UTC (rev 48949)
@@ -43,7 +43,7 @@
 
 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 @@
     
     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 @@
     Vect_build(&Out);
 
     /* Copy tables */
-    if (!flag.t->answer && !is_ogr) {
+    if (!flag.t->answer && native) {
 	copy_tabs(&In, field, new_cat, &Out);
     }
     



More information about the grass-commit mailing list