Explorar el Código

v.select: print info about skipped features separately for ainput and binput

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@62356 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa hace 10 años
padre
commit
5f6c242953
Se han modificado 3 ficheros con 36 adiciones y 35 borrados
  1. 20 19
      vector/v.select/main.c
  2. 3 3
      vector/v.select/proto.h
  3. 13 13
      vector/v.select/select.c

+ 20 - 19
vector/v.select/main.c

@@ -29,7 +29,7 @@ int main(int argc, char *argv[])
 {
 {
     int iopt;
     int iopt;
     int operator;
     int operator;
-    int nskipped, native;
+    int nskipped[2], native;
     int itype[2], ifield[2];
     int itype[2], ifield[2];
 
 
     int *ALines; /* List of lines: 0 do not output, 1 - write to output */
     int *ALines; /* List of lines: 0 do not output, 1 - write to output */
@@ -129,21 +129,19 @@ int main(int argc, char *argv[])
     
     
     /* Select features */
     /* Select features */
 #ifdef HAVE_GEOS
 #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
 #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
 #endif
     
     
-    Vect_close(&(In[1]));
-
 #ifdef HAVE_GEOS
 #ifdef HAVE_GEOS
     finishGEOS();
     finishGEOS();
 #endif
 #endif
@@ -170,16 +168,19 @@ int main(int argc, char *argv[])
 	copy_tabs(&(In[0]), &Out,
 	copy_tabs(&(In[0]), &Out,
 		  nfields, fields, ncats, cats);
 		  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_build(&Out);
     Vect_close(&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));
     G_done_msg(_("%d features written to output."), Vect_get_num_lines(&Out));
 
 
     exit(EXIT_SUCCESS);
     exit(EXIT_SUCCESS);

+ 3 - 3
vector/v.select/proto.h

@@ -36,9 +36,9 @@ int area_relate_geos(struct Map_info *, const GEOSGeometry *,
 #endif
 #endif
 
 
 /* select.c */
 /* 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 */
 /* overlap.c */
 void add_aarea(struct Map_info *, int, int *);
 void add_aarea(struct Map_info *, int, int *);

+ 13 - 13
vector/v.select/select.c

@@ -6,13 +6,13 @@
 
 
 #include "proto.h"
 #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 i;
-    int nalines, aline, nskipped, ltype;
+    int nalines, aline, ltype;
     
     
     struct line_pnts *APoints, *BPoints;
     struct line_pnts *APoints, *BPoints;
     struct ilist *BoundList, *LList;
     struct ilist *BoundList, *LList;
@@ -25,7 +25,7 @@ int select_lines(struct Map_info *aIn, int atype, int afield,
     void *AGeom = NULL;
     void *AGeom = NULL;
 #endif
 #endif
 
 
-    nskipped = 0;
+    nskipped[0] = nskipped[1] = 0;
     APoints = Vect_new_line_struct();
     APoints = Vect_new_line_struct();
     BPoints = Vect_new_line_struct();
     BPoints = Vect_new_line_struct();
     List = Vect_new_boxlist(1);
     List = Vect_new_boxlist(1);
@@ -48,7 +48,7 @@ int select_lines(struct Map_info *aIn, int atype, int afield,
 
 
 	    /* Check category */
 	    /* Check category */
 	    if (!cat_flag && Vect_get_line_cat(aIn, aline, afield) < 0) {
 	    if (!cat_flag && Vect_get_line_cat(aIn, aline, afield) < 0) {
-		nskipped++;
+		nskipped[0]++;
 		continue;
 		continue;
 	    }
 	    }
 
 
@@ -89,7 +89,7 @@ int select_lines(struct Map_info *aIn, int atype, int afield,
 		    /* Check category */
 		    /* Check category */
 		    if (!cat_flag &&
 		    if (!cat_flag &&
 			Vect_get_line_cat(bIn, bline, bfield) < 0) {
 			Vect_get_line_cat(bIn, bline, bfield) < 0) {
-			nskipped++;
+			nskipped[1]++;
 			continue;
 			continue;
 		    }
 		    }
 		    
 		    
@@ -130,7 +130,7 @@ int select_lines(struct Map_info *aIn, int atype, int afield,
 		    G_debug(3, "  barea = %d", barea);
 		    G_debug(3, "  barea = %d", barea);
 		    
 		    
 		    if (Vect_get_area_cat(bIn, barea, bfield) < 0) {
 		    if (Vect_get_area_cat(bIn, barea, bfield) < 0) {
-			nskipped++;
+			nskipped[1]++;
 			continue;
 			continue;
 		    }
 		    }
 
 
@@ -175,7 +175,7 @@ int select_lines(struct Map_info *aIn, int atype, int afield,
 	    G_percent(aarea, naareas, 1);
 	    G_percent(aarea, naareas, 1);
 
 
 	    if (Vect_get_area_cat(aIn, aarea, afield) < 0) {
 	    if (Vect_get_area_cat(aIn, aarea, afield) < 0) {
-		nskipped++;
+		nskipped[0]++;
 		continue;
 		continue;
 	    }
 	    }
 	
 	
@@ -203,7 +203,7 @@ int select_lines(struct Map_info *aIn, int atype, int afield,
 
 
 		    if (!cat_flag &&
 		    if (!cat_flag &&
 			Vect_get_line_cat(bIn, bline, bfield) < 0) {
 			Vect_get_line_cat(bIn, bline, bfield) < 0) {
-			nskipped++;
+			nskipped[1]++;
 			continue;
 			continue;
 		    }
 		    }
 		    
 		    
@@ -270,7 +270,7 @@ int select_lines(struct Map_info *aIn, int atype, int afield,
 			G_debug(3, "  barea = %d", barea);
 			G_debug(3, "  barea = %d", barea);
 
 
 			if (Vect_get_area_cat(bIn, barea, bfield) < 0) {
 			if (Vect_get_area_cat(bIn, barea, bfield) < 0) {
-			    nskipped++;
+			    nskipped[1]++;
 			    continue;
 			    continue;
 			}
 			}
 
 
@@ -331,5 +331,5 @@ int select_lines(struct Map_info *aIn, int atype, int afield,
     Vect_destroy_boxlist(List);
     Vect_destroy_boxlist(List);
     Vect_destroy_boxlist(TmpList);
     Vect_destroy_boxlist(TmpList);
 
 
-    return nskipped;
+    return;
 }
 }