[mapserver-commits] r12478 - in trunk/mapserver/mapcache: include src

svn at osgeo.org svn at osgeo.org
Fri Aug 26 07:30:07 EDT 2011


Author: tbonfort
Date: 2011-08-26 04:30:07 -0700 (Fri, 26 Aug 2011)
New Revision: 12478

Modified:
   trunk/mapserver/mapcache/include/geocache.h
   trunk/mapserver/mapcache/src/configuration_xml.c
   trunk/mapserver/mapcache/src/geocache_seed.c
   trunk/mapserver/mapcache/src/service_wms.c
   trunk/mapserver/mapcache/src/util.c
Log:


Modified: trunk/mapserver/mapcache/include/geocache.h
===================================================================
--- trunk/mapserver/mapcache/include/geocache.h	2011-08-26 11:30:01 UTC (rev 12477)
+++ trunk/mapserver/mapcache/include/geocache.h	2011-08-26 11:30:07 UTC (rev 12478)
@@ -1252,9 +1252,9 @@
 void geocache_grid_compute_limits(const geocache_grid *grid, const double *extent, int **limits);
 
 /* in util.c */
-int geocache_util_extract_int_list(geocache_context *ctx, const char* args, const char sep, int **numbers,
+int geocache_util_extract_int_list(geocache_context *ctx, const char* args, const char *sep, int **numbers,
         int *numbers_count);
-int geocache_util_extract_double_list(geocache_context *ctx, const char* args, const char sep, double **numbers,
+int geocache_util_extract_double_list(geocache_context *ctx, const char* args, const char *sep, double **numbers,
         int *numbers_count);
 char *geocache_util_str_replace(apr_pool_t *pool, const char *string, const char *substr,
       const char *replacement );

Modified: trunk/mapserver/mapcache/src/configuration_xml.c
===================================================================
--- trunk/mapserver/mapcache/src/configuration_xml.c	2011-08-26 11:30:01 UTC (rev 12477)
+++ trunk/mapserver/mapcache/src/configuration_xml.c	2011-08-26 11:30:07 UTC (rev 12478)
@@ -120,7 +120,7 @@
       double *values;
       int nvalues;
       value = apr_pstrdup(ctx->pool,cur_node->txt);
-      if(GEOCACHE_SUCCESS != geocache_util_extract_double_list(ctx, value, ' ', &values, &nvalues) ||
+      if(GEOCACHE_SUCCESS != geocache_util_extract_double_list(ctx, value, NULL, &values, &nvalues) ||
             nvalues != 4) {
          ctx->set_error(ctx, 400, "failed to parse extent array %s."
                "(expecting 4 space separated numbers, got %d (%f %f %f %f)"
@@ -164,7 +164,7 @@
    if ((cur_node = ezxml_child(node,"size")) != NULL) {
       value = apr_pstrdup(ctx->pool,cur_node->txt);
       int *sizes, nsizes;
-      if(GEOCACHE_SUCCESS != geocache_util_extract_int_list(ctx, value, ' ', &sizes, &nsizes) ||
+      if(GEOCACHE_SUCCESS != geocache_util_extract_int_list(ctx, value, NULL, &sizes, &nsizes) ||
             nsizes != 2) {
          ctx->set_error(ctx, 400, "failed to parse size array %s in  grid %s"
                "(expecting two space separated integers, eg <size>256 256</size>",
@@ -179,7 +179,7 @@
       value = apr_pstrdup(ctx->pool,cur_node->txt);
       int nvalues;
       double *values;
-      if(GEOCACHE_SUCCESS != geocache_util_extract_double_list(ctx, value, ' ', &values, &nvalues) ||
+      if(GEOCACHE_SUCCESS != geocache_util_extract_double_list(ctx, value, NULL, &values, &nvalues) ||
             !nvalues) {
          ctx->set_error(ctx, 400, "failed to parse resolutions array %s."
                "(expecting space separated numbers, "
@@ -459,7 +459,7 @@
       double *values;
       int nvalues;
       value = apr_pstrdup(ctx->pool,value);
-      if(GEOCACHE_SUCCESS != geocache_util_extract_double_list(ctx, value, ' ', &values, &nvalues) ||
+      if(GEOCACHE_SUCCESS != geocache_util_extract_double_list(ctx, value, NULL, &values, &nvalues) ||
             nvalues != 4) {
          ctx->set_error(ctx, 400, "failed to parse extent array %s."
                "(expecting 4 space separated numbers, got %d (%f %f %f %f)"
@@ -497,7 +497,7 @@
       if(restrictedExtent) {
          int nvalues;
          restrictedExtent = apr_pstrdup(ctx->pool,restrictedExtent);
-         if(GEOCACHE_SUCCESS != geocache_util_extract_double_list(ctx, restrictedExtent, ' ', &gridlink->restricted_extent, &nvalues) ||
+         if(GEOCACHE_SUCCESS != geocache_util_extract_double_list(ctx, restrictedExtent, NULL, &gridlink->restricted_extent, &nvalues) ||
                nvalues != 4) {
             ctx->set_error(ctx, 400, "failed to parse extent array %s."
                   "(expecting 4 space separated numbers, "
@@ -550,7 +550,7 @@
    if ((cur_node = ezxml_child(node,"metatile")) != NULL) {
       value = apr_pstrdup(ctx->pool,cur_node->txt);
          int *values, nvalues;
-         if(GEOCACHE_SUCCESS != geocache_util_extract_int_list(ctx, cur_node->txt,' ', 
+         if(GEOCACHE_SUCCESS != geocache_util_extract_int_list(ctx, cur_node->txt, NULL,
                   &values, &nvalues) ||
                nvalues != 2) {
             ctx->set_error(ctx, 400, "failed to parse metatile dimension %s."

Modified: trunk/mapserver/mapcache/src/geocache_seed.c
===================================================================
--- trunk/mapserver/mapcache/src/geocache_seed.c	2011-08-26 11:30:01 UTC (rev 12477)
+++ trunk/mapserver/mapcache/src/geocache_seed.c	2011-08-26 11:30:07 UTC (rev 12478)
@@ -440,13 +440,13 @@
                 nthreads = (int)strtol(optarg, NULL, 10);
                 break;
             case 'e':
-                if ( GEOCACHE_SUCCESS != geocache_util_extract_double_list(&ctx, (char*)optarg, ',', &extent, &n) ||
+                if ( GEOCACHE_SUCCESS != geocache_util_extract_double_list(&ctx, (char*)optarg, ",", &extent, &n) ||
                         n != 4 || extent[0] >= extent[2] || extent[1] >= extent[3] ) {
                     return usage(argv[0], "failed to parse extent, expecting comma separated 4 doubles");
                 }
                 break;
             case 'z':
-                if ( GEOCACHE_SUCCESS != geocache_util_extract_int_list(&ctx, (char*)optarg, ',', &zooms, &n) ||
+                if ( GEOCACHE_SUCCESS != geocache_util_extract_int_list(&ctx, (char*)optarg, ",", &zooms, &n) ||
                         n != 2 || zooms[0] > zooms[1]) {
                     return usage(argv[0], "failed to parse zooms, expecting comma separated 2 ints");
                 } else {

Modified: trunk/mapserver/mapcache/src/service_wms.c
===================================================================
--- trunk/mapserver/mapcache/src/service_wms.c	2011-08-26 11:30:01 UTC (rev 12477)
+++ trunk/mapserver/mapcache/src/service_wms.c	2011-08-26 11:30:07 UTC (rev 12478)
@@ -350,7 +350,7 @@
       goto proxies;
    } else {
       int nextents;
-      if(GEOCACHE_SUCCESS != geocache_util_extract_double_list(ctx, str,',',&bbox,&nextents) ||
+      if(GEOCACHE_SUCCESS != geocache_util_extract_double_list(ctx, str,",",&bbox,&nextents) ||
             nextents != 4) {
          errcode = 400;
          errmsg = "received wms request with invalid bbox";
@@ -427,7 +427,6 @@
          const char *key;
          int count=1;
          int i,layeridx;
-         char *sep=",";
          int x,y,z;
          geocache_request_get_map *map_req = NULL;
          geocache_request_get_tile *tile_req = NULL;
@@ -448,7 +447,7 @@
             key = str;
          } else {
             layers = apr_pstrdup(ctx->pool,str);
-            key = apr_strtok(layers, sep, &last); /* extract first layer */
+            key = apr_strtok(layers, ",", &last); /* extract first layer */
          }
          main_tileset = geocache_configuration_get_tileset(config,key);
          if(!main_tileset) {
@@ -511,8 +510,8 @@
          if(count>1)
             layers = apr_pstrdup(ctx->pool,str); /* apr_strtok modifies its input string */
 
-         for (layeridx=0,key = ((count==1)?str:apr_strtok(layers, sep, &last)); key != NULL;
-               key = ((count==1)?NULL:apr_strtok(NULL, sep, &last)),layeridx++) {
+         for (layeridx=0,key = ((count==1)?str:apr_strtok(layers, ",", &last)); key != NULL;
+               key = ((count==1)?NULL:apr_strtok(NULL, ",", &last)),layeridx++) {
             geocache_tileset *tileset = main_tileset;
             geocache_grid_link *grid_link = main_grid_link;
             apr_table_t *dimtable = NULL;
@@ -535,8 +534,8 @@
                   /* the tileset does not reference the grid of the first tileset */
                   errcode = 400;
                   errmsg = apr_psprintf(ctx->pool,
-                        "tileset %s does not reference grid %s (referenced by tileset %s",
-                        tileset->name, grid_link->grid->name,main_tileset->name);
+                        "tileset %s does not reference grid %s (referenced by tileset %s)",
+                        tileset->name, main_grid_link->grid->name,main_tileset->name);
                   goto proxies;
                }
             }

Modified: trunk/mapserver/mapcache/src/util.c
===================================================================
--- trunk/mapserver/mapcache/src/util.c	2011-08-26 11:30:01 UTC (rev 12477)
+++ trunk/mapserver/mapcache/src/util.c	2011-08-26 11:30:07 UTC (rev 12478)
@@ -27,20 +27,23 @@
 #endif
 const double geocache_meters_per_unit[GEOCACHE_UNITS_COUNT] = {1.0,6378137.0 * 2.0 * M_PI / 360,0.3048};
 
-int geocache_util_extract_int_list(geocache_context *ctx, const char* cargs, const char sep, int **numbers,
-      int *numbers_count) {
+int geocache_util_extract_int_list(geocache_context *ctx, const char* cargs,
+      const char *sdelim, int **numbers, int *numbers_count) {
    char *last, *key, *endptr;
    char *args = apr_pstrdup(ctx->pool,cargs);
    int tmpcount=1;
-   char delim[2];
-   delim[0] = sep;
-   delim[1] = 0;
-
+   const char *delim = (sdelim)?sdelim:" ,\t\r\n";
+   char sep;
    *numbers_count = 0;
-   for(key=args;*key;key++) {
-      if(*key == sep)
-         tmpcount++;
+   int i=strlen(delim);
+   while(i--) {
+      sep = delim[i];
+      for(key=args;*key;key++) {
+         if(*key == sep)
+            tmpcount++;
+      }
    }
+   
    *numbers = (int*)apr_pcalloc(ctx->pool,tmpcount*sizeof(int));
    for (key = apr_strtok(args, delim, &last); key != NULL;
          key = apr_strtok(NULL, delim, &last)) {
@@ -51,19 +54,21 @@
    return GEOCACHE_SUCCESS;
 }
 
-int geocache_util_extract_double_list(geocache_context *ctx, const char* cargs, const char sep, double **numbers,
-      int *numbers_count) {
+int geocache_util_extract_double_list(geocache_context *ctx, const char* cargs, 
+      const char *sdelim, double **numbers, int *numbers_count) {
    char *last, *key, *endptr;
    char *args = apr_pstrdup(ctx->pool,cargs);
    int tmpcount=1;
-   char delim[2];
-   delim[0] = sep;
-   delim[1] = 0;
-
+   const char *delim = (sdelim)?sdelim:" ,\t\r\n";
+   char sep;
    *numbers_count = 0;
-   for(key=args;*key;key++) {
-      if(*key == sep)
-         tmpcount++;
+   int i=strlen(delim);
+   while(i--) {
+      sep = delim[i];
+      for(key=args;*key;key++) {
+         if(*key == sep)
+            tmpcount++;
+      }
    }
    *numbers = (double*)apr_pcalloc(ctx->pool,tmpcount*sizeof(double));
    for (key = apr_strtok(args, delim, &last); key != NULL;



More information about the mapserver-commits mailing list