[GRASS-SVN] r44361 - grass/trunk/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 21 01:25:14 EST 2010


Author: huhabla
Date: 2010-11-20 22:25:14 -0800 (Sat, 20 Nov 2010)
New Revision: 44361

Modified:
   grass/trunk/lib/gis/parser_wps.c
Log:
Implemented check for range values in wps xml creation


Modified: grass/trunk/lib/gis/parser_wps.c
===================================================================
--- grass/trunk/lib/gis/parser_wps.c	2010-11-20 20:24:23 UTC (rev 44360)
+++ grass/trunk/lib/gis/parser_wps.c	2010-11-21 06:25:14 UTC (rev 44361)
@@ -660,6 +660,8 @@
                                 const char **choices, int num_choices, const char *default_value, int type)
 {
     int i;
+    char range[2][24];
+    char *str;
 
     if(inout_type == WPS_INPUT)
         fprintf(stdout,"\t\t\t<Input minOccurs=\"%i\" maxOccurs=\"%i\">\n", min, max);
@@ -689,13 +691,26 @@
         fprintf(stdout,"\t\t\t\t\t<ows:AnyValue/>\n");
     else
     {
+        /* Check for range values */
+        if(strcmp(datatype, "integer") == 0 || strcmp(datatype, "float") == 0) {
+            str = strtok((char*)choices[0], "-");
+            if(str != NULL) {
+                G_snprintf(range[0], 24, "%s", str);
+                str = strtok(NULL, "-");
+                if(str != NULL) {
+                    G_snprintf(range[1], 24, "%s", str);
+                    type = TYPE_RANGE;
+                }
+            }
+        }
+
         fprintf(stdout,"\t\t\t\t\t<ows:AllowedValues>\n");
-        if(type == TYPE_RANGE && num_choices > 1)
+        if(type == TYPE_RANGE)
         {
-        fprintf(stdout,"\t\t\t\t\t\t<ows:Range ows:rangeClosure=\"%s\">\n", "0");
-        fprintf(stdout,"\t\t\t\t\t\t\t<ows:MinimumValue>%s</ows:MinimumValue>\n", choices[0]);
-        fprintf(stdout,"\t\t\t\t\t\t\t<ows:MaximumValue>%s</ows:MaximumValue>\n", choices[1]);
-        fprintf(stdout,"\t\t\t\t\t\t</ows:Range>\n");
+            fprintf(stdout,"\t\t\t\t\t\t<ows:Range ows:rangeClosure=\"%s\">\n", "0");
+            fprintf(stdout,"\t\t\t\t\t\t\t<ows:MinimumValue>%s</ows:MinimumValue>\n", range[0]);
+            fprintf(stdout,"\t\t\t\t\t\t\t<ows:MaximumValue>%s</ows:MaximumValue>\n", range[1]);
+            fprintf(stdout,"\t\t\t\t\t\t</ows:Range>\n");
         }
         else
         {



More information about the grass-commit mailing list