[GRASS-SVN] r62356 - grass/trunk/vector/v.select

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Oct 22 06:12:33 PDT 2014


Author: martinl
Date: 2014-10-22 06:12:33 -0700 (Wed, 22 Oct 2014)
New Revision: 62356

Modified:
   grass/trunk/vector/v.select/main.c
   grass/trunk/vector/v.select/proto.h
   grass/trunk/vector/v.select/select.c
Log:
v.select: print info about skipped features separately for ainput and binput


Modified: grass/trunk/vector/v.select/main.c
===================================================================
--- grass/trunk/vector/v.select/main.c	2014-10-22 12:44:42 UTC (rev 62355)
+++ grass/trunk/vector/v.select/main.c	2014-10-22 13:12:33 UTC (rev 62356)
@@ -29,7 +29,7 @@
 {
     int iopt;
     int operator;
-    int nskipped, native;
+    int nskipped[2], native;
     int itype[2], ifield[2];
 
     int *ALines; /* List of lines: 0 do not output, 1 - write to output */
@@ -129,21 +129,19 @@
     
     /* Select features */
 #ifdef HAVE_GEOS
-    nskipped = select_lines(&(In[0]), itype[0], ifield[0],
-			    &(In[1]), itype[1], ifield[1],
-			    flag.cat->answer ? 1 : 0, operator,
-			    parm.relate->answer,
-			    ALines);
+    select_lines(&(In[0]), itype[0], ifield[0],
+                 &(In[1]), itype[1], ifield[1],
+                 flag.cat->answer ? 1 : 0, operator,
+                 parm.relate->answer,
+                 ALines, nskipped);
 #else
-    nskipped = select_lines(&(In[0]), itype[0], ifield[0],
-			    &(In[1]), itype[1], ifield[1],
-			    flag.cat->answer ? 1 : 0, operator,
-			    NULL,
-			    ALines);
+    select_lines(&(In[0]), itype[0], ifield[0],
+                 &(In[1]), itype[1], ifield[1],
+                 flag.cat->answer ? 1 : 0, operator,
+                 NULL,
+                 ALines, nskipped);
 #endif
     
-    Vect_close(&(In[1]));
-
 #ifdef HAVE_GEOS
     finishGEOS();
 #endif
@@ -170,16 +168,19 @@
 	copy_tabs(&(In[0]), &Out,
 		  nfields, fields, ncats, cats);
     }
-    
-    Vect_close(&(In[0]));
 
+    /* print info about skipped features & close input maps */
+    for (iopt = 0; iopt < 2; iopt++) {
+        if (nskipped[iopt] > 0) {
+            G_warning(_("%d features from <%s> without category skipped"),
+                      nskipped[iopt], Vect_get_full_name(&(In[iopt])));
+        }
+        Vect_close(&(In[iopt]));
+    }
+
     Vect_build(&Out);
     Vect_close(&Out);
 
-    if (nskipped > 0) {
-	G_warning(_("%d features without category skipped"), nskipped);
-    }
-    
     G_done_msg(_("%d features written to output."), Vect_get_num_lines(&Out));
 
     exit(EXIT_SUCCESS);

Modified: grass/trunk/vector/v.select/proto.h
===================================================================
--- grass/trunk/vector/v.select/proto.h	2014-10-22 12:44:42 UTC (rev 62355)
+++ grass/trunk/vector/v.select/proto.h	2014-10-22 13:12:33 UTC (rev 62356)
@@ -36,9 +36,9 @@
 #endif
 
 /* select.c */
-int select_lines(struct Map_info *, int, int,
-		 struct Map_info *, int, int,
-		 int, int, const char *, int *);
+void select_lines(struct Map_info *, int, int,
+                  struct Map_info *, int, int,
+                  int, int, const char *, int *, int*);
 
 /* overlap.c */
 void add_aarea(struct Map_info *, int, int *);

Modified: grass/trunk/vector/v.select/select.c
===================================================================
--- grass/trunk/vector/v.select/select.c	2014-10-22 12:44:42 UTC (rev 62355)
+++ grass/trunk/vector/v.select/select.c	2014-10-22 13:12:33 UTC (rev 62356)
@@ -6,13 +6,13 @@
 
 #include "proto.h"
 
-int select_lines(struct Map_info *aIn, int atype, int afield,
-		 struct Map_info *bIn, int btype, int bfield,
-		 int cat_flag, int operator, const char *relate,
-		 int *ALines)
+void select_lines(struct Map_info *aIn, int atype, int afield,
+                  struct Map_info *bIn, int btype, int bfield,
+                  int cat_flag, int operator, const char *relate,
+                  int *ALines, int* nskipped)
 {
     int i;
-    int nalines, aline, nskipped, ltype;
+    int nalines, aline, ltype;
     
     struct line_pnts *APoints, *BPoints;
     struct ilist *BoundList, *LList;
@@ -25,7 +25,7 @@
     void *AGeom = NULL;
 #endif
 
-    nskipped = 0;
+    nskipped[0] = nskipped[1] = 0;
     APoints = Vect_new_line_struct();
     BPoints = Vect_new_line_struct();
     List = Vect_new_boxlist(1);
@@ -48,7 +48,7 @@
 
 	    /* Check category */
 	    if (!cat_flag && Vect_get_line_cat(aIn, aline, afield) < 0) {
-		nskipped++;
+		nskipped[0]++;
 		continue;
 	    }
 
@@ -89,7 +89,7 @@
 		    /* Check category */
 		    if (!cat_flag &&
 			Vect_get_line_cat(bIn, bline, bfield) < 0) {
-			nskipped++;
+			nskipped[1]++;
 			continue;
 		    }
 		    
@@ -130,7 +130,7 @@
 		    G_debug(3, "  barea = %d", barea);
 		    
 		    if (Vect_get_area_cat(bIn, barea, bfield) < 0) {
-			nskipped++;
+			nskipped[1]++;
 			continue;
 		    }
 
@@ -175,7 +175,7 @@
 	    G_percent(aarea, naareas, 1);
 
 	    if (Vect_get_area_cat(aIn, aarea, afield) < 0) {
-		nskipped++;
+		nskipped[0]++;
 		continue;
 	    }
 	
@@ -203,7 +203,7 @@
 
 		    if (!cat_flag &&
 			Vect_get_line_cat(bIn, bline, bfield) < 0) {
-			nskipped++;
+			nskipped[1]++;
 			continue;
 		    }
 		    
@@ -270,7 +270,7 @@
 			G_debug(3, "  barea = %d", barea);
 
 			if (Vect_get_area_cat(bIn, barea, bfield) < 0) {
-			    nskipped++;
+			    nskipped[1]++;
 			    continue;
 			}
 
@@ -331,5 +331,5 @@
     Vect_destroy_boxlist(List);
     Vect_destroy_boxlist(TmpList);
 
-    return nskipped;
+    return;
 }



More information about the grass-commit mailing list