[mapserver-commits] r13188 - sandbox/tb-labels/mapcache/lib

svn at osgeo.org svn at osgeo.org
Thu Mar 1 04:04:35 EST 2012


Author: tbonfort
Date: 2012-03-01 01:04:34 -0800 (Thu, 01 Mar 2012)
New Revision: 13188

Modified:
   sandbox/tb-labels/mapcache/lib/core.c
   sandbox/tb-labels/mapcache/lib/service_tms.c
Log:
fix parsing of incorrect gmaps service, be less verbose on tms errors


Modified: sandbox/tb-labels/mapcache/lib/core.c
===================================================================
--- sandbox/tb-labels/mapcache/lib/core.c	2012-03-01 08:34:14 UTC (rev 13187)
+++ sandbox/tb-labels/mapcache/lib/core.c	2012-03-01 09:04:34 UTC (rev 13188)
@@ -506,6 +506,9 @@
       mapcache_request_get_capabilities *req_caps, char *url, char *path_info, mapcache_cfg *config) {
   mapcache_http_response *response;
    service->create_capabilities_response(ctx,req_caps,url,path_info,config);
+   if(GC_HAS_ERROR(ctx)) {
+      return NULL;
+   }
    response = mapcache_http_response_create(ctx->pool);
    response->data = mapcache_buffer_create(0,ctx->pool);
    response->data->size = strlen(req_caps->capabilities);

Modified: sandbox/tb-labels/mapcache/lib/service_tms.c
===================================================================
--- sandbox/tb-labels/mapcache/lib/service_tms.c	2012-03-01 08:34:14 UTC (rev 13187)
+++ sandbox/tb-labels/mapcache/lib/service_tms.c	2012-03-01 09:04:34 UTC (rev 13188)
@@ -54,8 +54,8 @@
 
    request->request.mime_type = apr_pstrdup(ctx->pool,"text/xml");
    if(!request->version) {
-     ezxml_t TileMapService;
-     char* serviceurl;
+      ezxml_t TileMapService;
+      char* serviceurl;
       caps = ezxml_new("Services");
       TileMapService = ezxml_add_child(caps,"TileMapService",0);
       ezxml_set_attr(TileMapService,"version","1.0");
@@ -63,25 +63,25 @@
       ezxml_set_attr(TileMapService,"href",serviceurl);
    } else {
       if(!request->tileset) {
-	apr_hash_index_t *tileindex_index;
-	ezxml_t tilemaps;
+         apr_hash_index_t *tileindex_index;
+         ezxml_t tilemaps;
          caps = ezxml_new("TileMapService");
          ezxml_set_attr(caps,"version",request->version);
          tileindex_index = apr_hash_first(ctx->pool,cfg->tilesets);
-	 tilemaps = ezxml_add_child(caps,"TileMaps",0);
+         tilemaps = ezxml_add_child(caps,"TileMaps",0);
          while(tileindex_index) {
             mapcache_tileset *tileset;
             int j;
             const void *key; apr_ssize_t keylen;
-	    const char *title;
+            const char *title;
             apr_hash_this(tileindex_index,&key,&keylen,(void**)&tileset);
             title = apr_table_get(tileset->metadata,"title");
             if(!title) {
                title = "no title set, add some in metadata";
             }
             for(j=0;j<tileset->grid_links->nelts;j++) {
-	      ezxml_t tilemap;
-	      char *href;
+               ezxml_t tilemap;
+               char *href;
                mapcache_grid *grid = APR_ARRAY_IDX(tileset->grid_links,j,mapcache_grid_link*)->grid;
                const char *profile = apr_table_get(grid->metadata,"profile");
                if(!profile) profile = "none";
@@ -96,12 +96,12 @@
             tileindex_index = apr_hash_next(tileindex_index);
          }
       } else {
-	const char *title;
-	const char *abstract;
-	ezxml_t origin;
-	ezxml_t bbox;
-	ezxml_t tileformat;
-	ezxml_t tilesets;
+         const char *title;
+         const char *abstract;
+         ezxml_t origin;
+         ezxml_t bbox;
+         ezxml_t tileformat;
+         ezxml_t tilesets;
          mapcache_tileset *tileset = request->tileset;
          mapcache_grid_link *grid_link = request->grid_link;
          mapcache_grid *grid = grid_link->grid;
@@ -207,21 +207,21 @@
          case 3:
             z = (int)strtol(key,&endptr,10);
             if(*endptr != 0) {
-               ctx->set_error(ctx,404, "received tms request %s with invalid z %s", pathinfo, key);
+               ctx->set_error(ctx,404, "failed to parse z");
                return;
             }
             break;
          case 4:
             x = (int)strtol(key,&endptr,10);
             if(*endptr != 0) {
-               ctx->set_error(ctx,404, "received tms request %s with invalid x %s", pathinfo, key);
+               ctx->set_error(ctx,404, "failed to parse x");
                return;
             }
             break;
          case 5:
             y = (int)strtol(key,&endptr,10);
             if(*endptr != '.') {
-               ctx->set_error(ctx,404, "received tms request %s with invalid y %s", pathinfo, key);
+               ctx->set_error(ctx,404, "failed to parse y");
                return;
             }
             break;
@@ -309,7 +309,7 @@
       }
       *request = (mapcache_request*)req;
       return;
-   } else if(index<3) {
+   } else if(index<3 && this->type == MAPCACHE_SERVICE_TMS) {
       mapcache_request_get_capabilities_tms *req = (mapcache_request_get_capabilities_tms*)apr_pcalloc(
             ctx->pool,sizeof(mapcache_request_get_capabilities_tms));
       req->request.request.type = MAPCACHE_REQUEST_GET_CAPABILITIES;
@@ -324,7 +324,7 @@
       return;
    }
    else {
-      ctx->set_error(ctx,404, "received tms request %s with wrong number of arguments", pathinfo);
+      ctx->set_error(ctx,404, "received request with wrong number of arguments", pathinfo);
       return;
    }
 }
@@ -345,7 +345,7 @@
 }
 
 void _create_capabilities_gmaps(mapcache_context *ctx, mapcache_request_get_capabilities *req, char *url, char *path_info, mapcache_cfg *cfg) {
-   ctx->set_error(ctx,501,"gmaps service does not support capapbilities");
+   ctx->set_error(ctx,404,"gmaps service does not support capabilities");
 }
 
 mapcache_service* mapcache_service_gmaps_create(mapcache_context *ctx) {



More information about the mapserver-commits mailing list