[mapserver-commits] r12134 - in trunk/mapserver/mapcache: . src
svn at osgeo.org
svn at osgeo.org
Fri Aug 26 07:00:41 EDT 2011
Author: tbonfort
Date: 2011-08-26 04:00:41 -0700 (Fri, 26 Aug 2011)
New Revision: 12134
Modified:
trunk/mapserver/mapcache/geocache.xml
trunk/mapserver/mapcache/src/services.c
Log:
update header, doh
thomas.bonfort | 2010-10-19 17:44:50 +0200 (Tue, 19 Oct 2010)
Modified: trunk/mapserver/mapcache/geocache.xml
===================================================================
--- trunk/mapserver/mapcache/geocache.xml 2011-08-26 11:00:36 UTC (rev 12133)
+++ trunk/mapserver/mapcache/geocache.xml 2011-08-26 11:00:41 UTC (rev 12134)
@@ -62,5 +62,6 @@
<services>
<wms>true</wms>
+ <tms>true</tms>
</services>
</geocache>
Modified: trunk/mapserver/mapcache/src/services.c
===================================================================
--- trunk/mapserver/mapcache/src/services.c 2011-08-26 11:00:36 UTC (rev 12133)
+++ trunk/mapserver/mapcache/src/services.c 2011-08-26 11:00:41 UTC (rev 12134)
@@ -12,7 +12,7 @@
geocache_request* _geocache_service_wms_parse_request(request_rec *r, apr_table_t *params, geocache_cfg *config) {
char *str = NULL;
double *bbox;
- geocache_request *request;
+ geocache_request *request = NULL;
str = (char*)apr_table_get(params,"REQUEST");
if(!str)
@@ -20,8 +20,8 @@
if(!str || strcasecmp(str,"getmap")) {
return NULL;
}
- request = (geocache_request*)apr_pcalloc(r->pool,sizeof(geocache_request));
+
str = (char*)apr_table_get(params,"BBOX");
if(!str)
str = (char*)apr_table_get(params,"bbox");
@@ -47,6 +47,7 @@
char *last, *key;
int count=1, ret;
char *sep=",";
+ request = (geocache_request*)apr_pcalloc(r->pool,sizeof(geocache_request));
str = apr_pstrdup(r->pool,str);
for(key=str;*key;key++) if(*key == ',') count++;
request->ntiles = 0;
@@ -68,15 +69,78 @@
request->tiles[request->ntiles++] = tile;
}
}
-
+
/* TODO: check the size and srs we've received are compatible */
-
+
return request;
}
geocache_request* _geocache_service_tms_parse_request(request_rec *r, apr_table_t *params, geocache_cfg *config) {
- return NULL;
+ char *pathinfo = apr_pstrdup(r->pool,r->path_info);
+ int index = 0;
+ char *last, *key, *endptr;
+ geocache_tileset *tileset = NULL;
+ geocache_tile *tile = NULL;
+ geocache_request *request = NULL;
+ /* parse a path_info like /1.0.0/global_mosaic/0/0/0.jpg */
+ for (key = apr_strtok(pathinfo, "/", &last); key != NULL;
+ key = apr_strtok(NULL, "/", &last)) {
+ if(!*key) continue; /* skip an empty string, could happen if the url contains // */
+ switch(++index) {
+ case 1: /* version */
+ if(strcmp("1.0.0",key)) {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r,
+ "received tms request with invalid version %s", key);
+ return NULL;
+ }
+ break;
+ case 2: /* layer name */
+ tileset = geocache_configuration_get_tileset(config,key);
+ if(!tileset) {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r,
+ "received tms request with invalid layer %s", key);
+ return NULL;
+ }
+ request = (geocache_request*)apr_pcalloc(r->pool,sizeof(geocache_request));
+ request->ntiles = 1;
+ request->tiles = (geocache_tile**)apr_pcalloc(r->pool,sizeof(geocache_tile*));
+ tile = geocache_tileset_tile_create(tileset,r->pool);
+ request->tiles[0]=tile;
+ break;
+ case 3:
+ tile->z = (int)strtol(key,&endptr,10);
+ if(*endptr != 0) {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "received tms request %s with invalid z %s", r->path_info, key);
+ return NULL;
+ }
+ break;
+ case 4:
+ tile->x = (int)strtol(key,&endptr,10);
+ if(*endptr != 0) {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "received tms request %s with invalid x %s", r->path_info, key);
+ return NULL;
+ }
+ break;
+ case 5:
+ tile->y = (int)strtol(key,&endptr,10);
+ if(*endptr != '.') {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "received tms request %s with invalid y %s", r->path_info, key);
+ return NULL;
+ }
+ break;
+ default:
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "received tms request %s with invalid parameter %s", r->path_info, key);
+ return NULL;
+ }
+ }
+ if(index == 5) {
+ return request;
+ }
+ else {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "received tms request %s with wrong number of arguments", r->path_info);
+ return NULL;
+ }
}
More information about the mapserver-commits
mailing list