[GRASS-SVN] r70103 - grass/trunk/vector/v.select
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Dec 20 07:35:36 PST 2016
Author: mlennert
Date: 2016-12-20 07:35:36 -0800 (Tue, 20 Dec 2016)
New Revision: 70103
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: check whether any features are found and if not do not attempt to create an output map
Modified: grass/trunk/vector/v.select/main.c
===================================================================
--- grass/trunk/vector/v.select/main.c 2016-12-20 14:01:28 UTC (rev 70102)
+++ grass/trunk/vector/v.select/main.c 2016-12-20 15:35:36 UTC (rev 70103)
@@ -29,7 +29,7 @@
{
int iopt;
int operator;
- int nskipped[2], native;
+ int nskipped[2], native, nfound;
int itype[2], ifield[2];
int *ALines; /* List of lines: 0 do not output, 1 - write to output */
@@ -133,13 +133,13 @@
/* Select features */
#ifdef HAVE_GEOS
- select_lines(&(In[0]), itype[0], ifield[0],
+ nfound = select_lines(&(In[0]), itype[0], ifield[0],
&(In[1]), itype[1], ifield[1],
flag.cat->answer ? 1 : 0, operator,
parm.relate->answer,
ALines, AAreas, nskipped);
#else
- select_lines(&(In[0]), itype[0], ifield[0],
+ nfound = select_lines(&(In[0]), itype[0], ifield[0],
&(In[1]), itype[1], ifield[1],
flag.cat->answer ? 1 : 0, operator,
NULL,
@@ -150,6 +150,8 @@
finishGEOS();
#endif
+ if (nfound != 0) {
+
native = Vect_maptype(&Out) == GV_FORMAT_NATIVE;
nfields = Vect_cidx_get_num_fields(&(In[0]));
@@ -186,6 +188,9 @@
Vect_close(&Out);
G_done_msg(_("%d features written to output."), Vect_get_num_lines(&Out));
+ } else {
+ G_done_msg(_("No features found !"));
+ }
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/vector/v.select/proto.h
===================================================================
--- grass/trunk/vector/v.select/proto.h 2016-12-20 14:01:28 UTC (rev 70102)
+++ grass/trunk/vector/v.select/proto.h 2016-12-20 15:35:36 UTC (rev 70103)
@@ -36,7 +36,7 @@
#endif
/* select.c */
-void select_lines(struct Map_info *, int, int,
+int select_lines(struct Map_info *, int, int,
struct Map_info *, int, int,
int, int, const char *, int *, int*, int*);
Modified: grass/trunk/vector/v.select/select.c
===================================================================
--- grass/trunk/vector/v.select/select.c 2016-12-20 14:01:28 UTC (rev 70102)
+++ grass/trunk/vector/v.select/select.c 2016-12-20 15:35:36 UTC (rev 70103)
@@ -6,13 +6,14 @@
#include "proto.h"
-void select_lines(struct Map_info *aIn, int atype, int afield,
+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, int *AAreas, int* nskipped)
{
int i;
int nalines, aline, ltype;
+ int nfound = 0;
struct line_pnts *APoints, *BPoints;
struct ilist *BoundList, *LList;
@@ -115,6 +116,7 @@
if (found) {
ALines[aline] = 1;
+ nfound += 1;
continue; /* Go to next A line */
}
}
@@ -139,6 +141,7 @@
if(area_relate_geos(bIn, AGeom,
barea, operator, relate)) {
ALines[aline] = 1;
+ nfound += 1;
break;
}
#endif
@@ -146,6 +149,7 @@
else {
if (line_overlap_area(APoints, bIn, barea)) {
ALines[aline] = 1;
+ nfound += 1;
break;
}
}
@@ -212,6 +216,7 @@
if(line_relate_geos(bIn, AGeom,
bline, operator, relate)) {
add_aarea(aIn, aarea, ALines, AAreas);
+ nfound += 1;
break;
}
#endif
@@ -221,6 +226,7 @@
if (line_overlap_area(BPoints, aIn, aarea)) {
add_aarea(aIn, aarea, ALines, AAreas);
+ nfound += 1;
continue;
}
}
@@ -311,6 +317,7 @@
}
if (found) {
add_aarea(aIn, aarea, ALines, AAreas);
+ nfound += 1;
break;
}
}
@@ -331,5 +338,5 @@
Vect_destroy_boxlist(List);
Vect_destroy_boxlist(TmpList);
- return;
+ return nfound;
}
More information about the grass-commit
mailing list