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

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 7 12:34:38 EST 2010


Author: martinl
Date: 2010-11-07 09:34:38 -0800 (Sun, 07 Nov 2010)
New Revision: 44216

Modified:
   grass/trunk/vector/v.select/args.c
   grass/trunk/vector/v.select/main.c
   grass/trunk/vector/v.select/proto.h
   grass/trunk/vector/v.select/v.select.html
Log:
v.select: simplify module interface (no geos flag)


Modified: grass/trunk/vector/v.select/args.c
===================================================================
--- grass/trunk/vector/v.select/args.c	2010-11-07 16:07:04 UTC (rev 44215)
+++ grass/trunk/vector/v.select/args.c	2010-11-07 17:34:38 UTC (rev 44216)
@@ -46,24 +46,25 @@
     parm->operator->description =
 	_("A feature is written to output if the result of operation 'ainput operator binput' is true. "
 	  "An input feature is considered to be true, if category of given layer is defined.");
+    parm->operator->answer = "overlap";
 #ifndef HAVE_GEOS
-    parm->operator->options = "overlaps";
-    parm->operator->answer = "overlaps";
-    parm->operator->descriptions = _("overlaps;features partially or completely overlap");
+    parm->operator->options = "overlap";
+    parm->operator->descriptions = _("overlap;features partially or completely overlap");
 
     parm->relate = NULL;
 #else
-    parm->operator->options = "equals,disjoint,intersects,touches,crosses,within,contains,overlaps,relate";
-    parm->operator->descriptions = _("equals;features are spatially equals (requires flag 'g');"
-				    "disjoint;features do not spatially intersect (requires flag 'g');"
-				    "intersects;features spatially intersect (requires flag 'g');"
-				    "touches;features spatially touches (requires flag 'g');"
-				    "crosses;features spatially crosses (requires flag 'g');"
-				    "within;feature A is completely inside feature B (requires flag 'g');"
-				    "contains;feature B is completely inside feature A (requires flag 'g');"
-				    "overlaps;features spatilly overlap;"
-				    "relate;feature A is spatially related to feature B "
-				    "(requires 'relate' option and flag 'g');");
+    parm->operator->options = "overlap,equals,disjoint,intersects,touches,crosses,within,contains,overlaps,relate";
+    parm->operator->descriptions = _("overlap;features partially or completely overlap;"
+				     "equals;features are spatially equals (using GEOS);"
+				    "disjoint;features do not spatially intersect (using GEOS);"
+				    "intersects;features spatially intersect (using GEOS);"
+				    "touches;features spatially touches (using GEOS);"
+				    "crosses;features spatially crosses (using GEOS);"
+				    "within;feature A is completely inside feature B (using GEOS);"
+				    "contains;feature B is completely inside feature A (using GEOS);"
+				    "overlaps;features spatially overlap (using GEOS);"
+				    "relate;feature A is spatially related to feature B (using GEOS, "
+				    "requires 'relate' option);");
     
     parm->relate = G_define_option();
     parm->relate->key = "relate";
@@ -85,11 +86,4 @@
     flag->reverse->key = 'r';
     flag->reverse->description = _("Reverse selection");
     flag->reverse->guisection = _("Selection");
-#ifdef HAVE_GEOS
-    flag->geos = G_define_flag();
-    flag->geos->key = 'g';
-    flag->geos->description = _("Use GEOS operators");
-#else
-    flag->geos = NULL;
-#endif
 }

Modified: grass/trunk/vector/v.select/main.c
===================================================================
--- grass/trunk/vector/v.select/main.c	2010-11-07 16:07:04 UTC (rev 44215)
+++ grass/trunk/vector/v.select/main.c	2010-11-07 17:34:38 UTC (rev 44216)
@@ -76,18 +76,17 @@
 	operator = OP_WITHIN;
     else if (parm.operator->answer[0] == 'c' && parm.operator->answer[1] == 'o')
 	operator = OP_CONTAINS;
-    else if (parm.operator->answer[0] == 'o')
-	operator = OP_OVERLAPS;
+    else if (parm.operator->answer[0] == 'o') {
+	if (strcmp(parm.operator->answer, "overlaps") == 0)
+	    operator = OP_OVERLAPS;
+	else
+	    operator = OP_OVERLAP;
+    }
     else if (parm.operator->answer[0] == 'r')
 	operator = OP_RELATE;
     else
 	G_fatal_error(_("Unknown operator"));
     
-    if (operator != OP_OVERLAPS && flag.geos && !flag.geos->answer) {
-	G_fatal_error(_("Enable GEOS operators (flag '%c') to use '%s'"),
-		      flag.geos->key, parm.operator->answer);
-    }
-
     if (operator == OP_RELATE && !parm.relate->answer) {
 	G_fatal_error(_("Required parameter <%s> not set"),
 		      parm.relate->key);
@@ -153,7 +152,7 @@
 	    }
 
 	    /* Read line and check type */
-	    if (flag.geos && flag.geos->answer) {
+	    if (operator != OP_OVERLAP) {
 #ifdef HAVE_GEOS
 		AGeom = Vect_read_line_geos(&(In[0]), aline, &ltype);
 #endif
@@ -195,7 +194,7 @@
 			continue;
 		    }
 		    
-		    if (flag.geos && flag.geos->answer) {
+		    if (operator != OP_OVERLAP) {
 #ifdef HAVE_GEOS
 			if(line_relate_geos(&(In[1]), AGeom,
 					    bline, operator, parm.relate->answer)) {
@@ -237,7 +236,7 @@
 			continue;
 		    }
 
-		    if (flag.geos && flag.geos->answer) {
+		    if (operator != OP_OVERLAP) {
 #ifdef HAVE_GEOS
 			if(area_relate_geos(&(In[1]), AGeom,
 					    barea, operator, parm.relate->answer)) {
@@ -254,7 +253,7 @@
 		    }
 		}
 	    }
-	    if (flag.geos && flag.geos->answer) {
+	    if (operator != OP_OVERLAP) {
 #ifdef HAVE_GEOS
 		GEOSGeom_destroy(AGeom);
 #endif
@@ -285,7 +284,7 @@
 	    abox.T = PORT_DOUBLE_MAX;
 	    abox.B = -PORT_DOUBLE_MAX;
 
-	    if (flag.geos && flag.geos->answer) { 
+	    if (operator != OP_OVERLAP) {
 #ifdef HAVE_GEOS
 		AGeom = Vect_read_area_geos(&(In[0]), aarea);
 #endif
@@ -308,7 +307,7 @@
 			continue;
 		    }
 		    
-		    if (flag.geos && flag.geos->answer) {
+		    if (operator != OP_OVERLAP) {
 #ifdef HAVE_GEOS
 			if(line_relate_geos(&(In[1]), AGeom,
 					    bline, operator, parm.relate->answer)) {
@@ -377,7 +376,7 @@
 			bcentroid = Vect_get_area_centroid(&(In[1]), barea);
 			Vect_read_line(&(In[1]), BPoints, NULL, bcentroid);
 
-			if (flag.geos && flag.geos->answer) {
+			if (operator != OP_OVERLAP) {
 #ifdef HAVE_GEOS
 			    if(area_relate_geos(&(In[1]), AGeom,
 						barea, operator, parm.relate->answer)) {
@@ -407,7 +406,7 @@
 		    }
 		}
 	    }
-	    if (flag.geos && flag.geos->answer) {
+	    if (operator != OP_OVERLAP) {
 #ifdef HAVE_GEOS
 		GEOSGeom_destroy(AGeom);
 #endif

Modified: grass/trunk/vector/v.select/proto.h
===================================================================
--- grass/trunk/vector/v.select/proto.h	2010-11-07 16:07:04 UTC (rev 44215)
+++ grass/trunk/vector/v.select/proto.h	2010-11-07 17:34:38 UTC (rev 44216)
@@ -9,14 +9,15 @@
 #define OP_WITHIN     5
 #define OP_CONTAINS   6
 #define OP_OVERLAPS   7
-#define OP_RELATE     8
+#define OP_OVERLAP    8
+#define OP_RELATE     9
 
 struct GParm {
     struct Option *input[2], *output, *type[2], *field[2],
 	*operator, *relate;
 };
 struct GFlag {
-    struct Flag *table, *reverse, *geos, *cat;
+    struct Flag *table, *reverse, *cat;
 };
 
 /* args.c */

Modified: grass/trunk/vector/v.select/v.select.html
===================================================================
--- grass/trunk/vector/v.select/v.select.html	2010-11-07 16:07:04 UTC (rev 44215)
+++ grass/trunk/vector/v.select/v.select.html	2010-11-07 17:34:38 UTC (rev 44216)
@@ -6,7 +6,7 @@
 <p>
 Supported operators (without GEOS):
 <ul>
-  <li><tt>overlaps</tt> - features partially or completely overlap
+  <li><tt>overlap</tt> - features partially or completely overlap
 </ul>
 
 Supported operators (with GEOS):
@@ -43,14 +43,14 @@
 Extract forest fire points from larger fire vector map:
 
 <div class="code"><pre>
-v.select ainput=fire binput=forest output=forest_fire operator=overlaps
+v.select ainput=fire binput=forest output=forest_fire operator=overlap
 </pre></div>
 
 Extract Italian rivers from VMAP0 watercourses map:
 
 <div class="code"><pre>
 v.select ainput=watrcrsl_eurnasia_wgs84 binput=italy_area \
-         output=watrcrsl_italy operator=overlaps
+         output=watrcrsl_italy operator=overlap
 </pre></div>
 
 <h2>TODO</h2>



More information about the grass-commit mailing list