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

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Apr 19 11:47:09 EDT 2012


Author: huhabla
Date: 2012-04-19 08:47:09 -0700 (Thu, 19 Apr 2012)
New Revision: 51477

Modified:
   grass/trunk/lib/gis/parser_wps.c
Log:
The key_descr field is used to set the occurence or literals.
Space time datasets are introduced.


Modified: grass/trunk/lib/gis/parser_wps.c
===================================================================
--- grass/trunk/lib/gis/parser_wps.c	2012-04-19 14:27:03 UTC (rev 51476)
+++ grass/trunk/lib/gis/parser_wps.c	2012-04-19 15:47:09 UTC (rev 51477)
@@ -25,6 +25,7 @@
 #define TYPE_PLAIN_TEXT 2
 #define TYPE_RANGE 3
 #define TYPE_LIST 4
+#define TYPE_STDS 5 /* Space time datasets of type raster, raster3d and vector */
 #define WPS_INPUT 0
 #define WPS_OUTPUT 1
 
@@ -49,6 +50,10 @@
 static void wps_print_mimetype_vector_zipped_shape(void);
 static void wps_print_mimetype_vector_grass_ascii(void);
 static void wps_print_mimetype_vector_grass_binary(void);
+static void wps_print_mimetype_space_time_datasets(void);
+static void wps_print_mimetype_space_time_datasets_tar(void);
+static void wps_print_mimetype_space_time_datasets_tar_gz(void);
+static void wps_print_mimetype_space_time_datasets_tar_bz2(void);
 
 static void wps_print_process_descriptions_begin(void);
 static void wps_print_process_descriptions_end(void);
@@ -101,11 +106,13 @@
  * Flags are supported as boolean values.
  *
  * The mime types for vector maps are GML, KML, dgn, shape and zipped shape. 
-*
+ *
  * The mime types for raster maps are tiff, geotiff, hfa, netcdf, gif, jpeg and png.
  *
- * The mime types are reflecting the capabilities of gdal and may be extended.
+ * Mime types for space time datasets are tar archives with gz, bzip or without compression
  *
+ * The mime types are reflecting the capabilities of grass and gdal and may be extended.
+ *
  * BoundignBox support is currently not available for inputs and outputs.
  * Literal data output (string, float or integer)  is currently not supported.
  *
@@ -141,9 +148,13 @@
     const char **keywords = NULL;
     int data_type, is_input, is_output;
     int num_raster_inputs = 0, num_raster_outputs = 0;
+    int num_strds_inputs = 0, num_strds_outputs = 0;
     int min = 0, max = 0;
     int num_keywords = 0;
     int found_output = 0;
+    int is_tuple; /* Checks the key_descr for comma separated values */
+    int num_tuples; /* Counts the "," in key_descr */
+
     new_prompt = G__uses_new_gisprompt();
 
     /* gettext converts strings to encoding returned by nl_langinfo(CODESET) */
@@ -203,8 +214,11 @@
             value = NULL;
             is_input = 1;
             is_output = 0;
+	    is_tuple = 0;
+	    num_tuples = 0;
             data_type = TYPE_OTHER;
 
+	    /* Check the gisprompt */
 	    if (opt->gisprompt) {
 		const char *atts[] = { "age", "element", "prompt", NULL };
 		top = G_calloc(strlen(opt->gisprompt) + 1, 1);
@@ -232,6 +246,16 @@
                     {
                         data_type = TYPE_VECTOR;
                     }
+                    if(strcmp(token, "stds") == 0 || strcmp(token, "strds") == 0 || strcmp(token, "stvds") == 0 || strcmp(token, "str3ds") == 0)
+                    {
+                        if(strcmp(token, "strds") == 0) {
+                            if(is_input == 1)
+                                num_strds_inputs++;
+                            if(is_output == 1)
+                                num_strds_outputs++;
+                        }
+                        data_type = TYPE_STDS;
+                    }
                     if(strcmp(token, "file") == 0)
                     {
                         data_type = TYPE_PLAIN_TEXT;
@@ -241,6 +265,22 @@
 		}
 		G_free(top);
 	    }
+
+	    /* Check the key description */
+	    if (opt->key_desc) {
+		top = G_calloc(strlen(opt->key_desc) + 1, 1);
+		strcpy(top, opt->key_desc);
+		s = strtok(top, ",");
+		/* Count comma's */
+                for (i = 0; s != NULL; i++) {
+                    num_tuples++;
+                    s = strtok(NULL, ",");
+		}
+                if(num_tuples > 1)
+                    is_tuple = 1;
+                
+		G_free(top);
+	    }
             /* We have an input option */
             if(is_input == 1)
             {
@@ -260,15 +300,24 @@
                 }
 
                 identifier = opt->key;
-                if(opt->required == YES)
-                    min = 1;
-                else
+
+                if(opt->required == YES) {
+                    if(is_tuple)
+                        min = num_tuples;
+                    else
+                        min = 1;
+                } else {
                     min = 0;
+                }
 
-                if(opt->multiple == YES)
+                if(opt->multiple == YES) {
                     max = 1024;
-                else
-                    max = 1;
+                } else {
+                    if(is_tuple)
+                        max = num_tuples;
+                    else
+                        max = 1;
+                }
 
                 if (opt->description) {
                     title = opt->description;
@@ -289,8 +338,7 @@
                     keywords = opt->opts;
                     num_keywords = i;
                 }
-
-                if(data_type == TYPE_RASTER || data_type == TYPE_VECTOR || data_type == TYPE_PLAIN_TEXT)
+                if(data_type == TYPE_RASTER || data_type == TYPE_VECTOR || data_type == TYPE_STDS || data_type == TYPE_PLAIN_TEXT)
                 {
                     /* 2048 is the maximum size of the map in mega bytes */
                     wps_print_complex_input(min, max, identifier, title, NULL, 2048, data_type);
@@ -329,7 +377,7 @@
     }
 
     /* We have two default options, which define the resolution of the created mapset */
-    if(num_raster_inputs > 0 || num_raster_outputs > 0) {
+    if(num_raster_inputs > 0 || num_raster_outputs > 0 || num_strds_inputs > 0 || num_strds_outputs > 0) {
         wps_print_literal_input_output(WPS_INPUT, 0, 1, "grass_resolution_ns", "Resolution of the mapset in north-south direction in meters or degrees",
             "This parameter defines the north-south resolution of the mapset in meter or degrees, which should be used to process the input and output raster data. To enable this setting, you need to specify north-south and east-west resolution.",
             "float", 1, NULL, 0, NULL, TYPE_OTHER);
@@ -350,7 +398,7 @@
 
     found_output = 0;
 
-    /*parse the output. only raster and vector map and stdout are supported */
+    /*parse the output. only raster, strds and vector map and stdout are supported */
     if (st->n_opts) {
 	opt = &st->first_option;
 	while (opt != NULL) {
@@ -382,6 +430,10 @@
                     {
                         data_type = TYPE_VECTOR;
                     }
+                    if(strcmp(token, "stds") == 0 || strcmp(token, "strds") == 0 || strcmp(token, "stvds") == 0 || strcmp(token, "str3ds") == 0)
+                    {
+                        data_type = TYPE_STDS;
+                    }
                     if(strcmp(token, "file") == 0)
                     {
                         data_type = TYPE_PLAIN_TEXT;
@@ -401,7 +453,7 @@
                 }
 
                 /* Only file, raster and vector output is supported by option */
-                if(data_type == TYPE_RASTER || data_type == TYPE_VECTOR  || data_type == TYPE_PLAIN_TEXT)
+                if(data_type == TYPE_RASTER || data_type == TYPE_VECTOR || data_type == TYPE_STDS || data_type == TYPE_PLAIN_TEXT)
                 {
                     wps_print_complex_output(identifier, title, NULL, data_type);
                     found_output = 1;
@@ -564,6 +616,10 @@
     {
             wps_print_mimetype_vector_gml311();
     }
+    else if(type == TYPE_STDS)
+    {
+            wps_print_mimetype_space_time_datasets_tar_gz();
+    }
     else if(type == TYPE_PLAIN_TEXT)
     {
             wps_print_mimetype_text_plain();
@@ -609,6 +665,10 @@
             	wps_print_mimetype_vector_kml22();
 	    }
     }
+    else if(type == TYPE_STDS)
+    {
+            wps_print_mimetype_space_time_datasets();
+    }
     else if(type == TYPE_PLAIN_TEXT)
     {
             wps_print_mimetype_text_plain();
@@ -852,6 +912,37 @@
     fprintf(stdout,"\t\t\t\t\t\t</Format>\n");
 }
 
+/* *** Space time dataset format using tar, tar.gz and tar.bz2 methods for packaging */
+
+static void wps_print_mimetype_space_time_datasets(void)
+{
+    wps_print_mimetype_space_time_datasets_tar();
+    wps_print_mimetype_space_time_datasets_tar_gz();
+    wps_print_mimetype_space_time_datasets_tar_bz2();
+}
+
+static void wps_print_mimetype_space_time_datasets_tar(void)
+{
+    fprintf(stdout,"\t\t\t\t\t\t<Format>\n");
+    fprintf(stdout,"\t\t\t\t\t\t\t<MimeType>application/x-tar</MimeType>\n");
+    fprintf(stdout,"\t\t\t\t\t\t</Format>\n");
+}
+
+static void wps_print_mimetype_space_time_datasets_tar_gz(void)
+{
+    fprintf(stdout,"\t\t\t\t\t\t<Format>\n");
+    fprintf(stdout,"\t\t\t\t\t\t\t<MimeType>application/x-tar-gz</MimeType>\n");
+    fprintf(stdout,"\t\t\t\t\t\t</Format>\n");
+}
+
+static void wps_print_mimetype_space_time_datasets_tar_bz2(void)
+{
+    fprintf(stdout,"\t\t\t\t\t\t<Format>\n");
+    fprintf(stdout,"\t\t\t\t\t\t\t<MimeType>application/x-tar-bzip</MimeType>\n");
+    fprintf(stdout,"\t\t\t\t\t\t</Format>\n");
+}
+
+
 /* ************************************************************************** */
 static void wps_print_mimetype_raster_gif(void)
 {



More information about the grass-commit mailing list