[mapserver-commits] r12201 - in trunk/mapserver/mapcache: include
src
svn at osgeo.org
svn at osgeo.org
Fri Aug 26 07:06:40 EDT 2011
Author: tbonfort
Date: 2011-08-26 04:06:40 -0700 (Fri, 26 Aug 2011)
New Revision: 12201
Modified:
trunk/mapserver/mapcache/include/geocache.h
trunk/mapserver/mapcache/src/fastcgi_geocache.c
trunk/mapserver/mapcache/src/mod_geocache.c
trunk/mapserver/mapcache/src/services.c
Log:
stop using epsg:900913 for google grid, use the official 3857
use grid resolutions from wmts spec for preconfigured grids
thomas.bonfort | 2011-01-05 18:56:53 +0100 (Wed, 05 Jan 2011)
Modified: trunk/mapserver/mapcache/include/geocache.h
===================================================================
--- trunk/mapserver/mapcache/include/geocache.h 2011-08-26 11:06:34 UTC (rev 12200)
+++ trunk/mapserver/mapcache/include/geocache.h 2011-08-26 11:06:40 UTC (rev 12201)
@@ -332,7 +332,7 @@
* \returns a geocache_request corresponding to the parameters received
* \returns NULL if the request does not correspond the the service
*/
- geocache_request * (*parse_request)(geocache_context *ctx, char *path_info, apr_table_t *params, geocache_cfg * config);
+ geocache_request * (*parse_request)(geocache_context *ctx, char *uri, char *path_info, apr_table_t *params, geocache_cfg * config);
};
/**\class geocache_service_wms
Modified: trunk/mapserver/mapcache/src/fastcgi_geocache.c
===================================================================
--- trunk/mapserver/mapcache/src/fastcgi_geocache.c 2011-08-26 11:06:34 UTC (rev 12200)
+++ trunk/mapserver/mapcache/src/fastcgi_geocache.c 2011-08-26 11:06:40 UTC (rev 12201)
@@ -151,6 +151,13 @@
return 200;
}
+static int geocache_write_capabilities(geocache_context_fcgi_request *ctx, geocache_request *request) {
+ FCGX_FPrintF(ctx->out,"Content-type: text/xml\r\n\r\n");
+ FCGX_PutStr(request->capabilities, strlen(request->capabilities),ctx->out);
+
+ return 200;
+}
+
int main(int argc, char **argv) {
apr_pool_initialize();
@@ -179,7 +186,27 @@
geocache_context *ctx = (geocache_context*) fcgi_context_request_create(globalctx,out,err);
geocache_tile *tile;
geocache_request *request = NULL;
+ char *host = FCGX_GetParam("SERVER_NAME",envp);
+ char *port = FCGX_GetParam("SERVER_PORT",envp);
+ char *fullhost;
+ if(FCGX_GetParam("HTTPS",envp)) {
+ if(!port || !strcmp(port,"443")) {
+ fullhost = apr_psprintf(ctx->pool,"https://%s",host);
+ } else {
+ fullhost = apr_psprintf(ctx->pool,"https://%s:%s",host,port);
+ }
+ } else {
+ if(!port || !strcmp(port,"80")) {
+ fullhost = apr_psprintf(ctx->pool,"http://%s",host);
+ } else {
+ fullhost = apr_psprintf(ctx->pool,"http://%s:%s",host,port);
+ }
+ }
char *pathInfo = FCGX_GetParam("PATH_INFO",envp);
+ char *uri = apr_psprintf(ctx->pool,"%s%s",
+ fullhost,
+ FCGX_GetParam("SCRIPT_NAME",envp)
+ );
int i;
@@ -189,41 +216,48 @@
for(i=0;i<GEOCACHE_SERVICES_COUNT;i++) {
geocache_service *service = cfg->services[i];
if(!service) continue;
- request = service->parse_request(ctx,pathInfo,params,cfg);
+ request = service->parse_request(ctx,uri,pathInfo,params,cfg);
if(request)
break;
}
- if(!request || !request->ntiles) {
+ if(!request || GC_HAS_ERROR(ctx)) {
FCGX_FPrintF(out,"Status: 404 Not Found\r\n\r\n");
goto cleanup;
}
-
- for(i=0;i<request->ntiles;i++) {
- geocache_tile *tile = request->tiles[i];
- geocache_tileset_tile_get(ctx,tile);
- if(GC_HAS_ERROR(ctx)) {
- ctx->log(ctx,GEOCACHE_DEBUG,ctx->get_error_message(ctx));
- FCGX_FPrintF(out,"Status: 500 Internal Server Error\r\n\r\n");
+ if(request->type == GEOCACHE_REQUEST_GET_CAPABILITIES) {
+ geocache_write_capabilities((geocache_context_fcgi_request*)ctx,request);
+ } else {
+ if(!request->ntiles) {
+ FCGX_FPrintF(out,"Status: 404 Not Found\r\n\r\n");
goto cleanup;
}
- }
- if(request->ntiles == 1) {
- tile = request->tiles[0];
- } else {
- tile = geocache_image_merge_tiles(ctx,cfg->merge_format,request->tiles,request->ntiles);
- if(!tile) {
- ctx->log(ctx,GEOCACHE_ERROR, "tile merging failed to return data");
- if(ctx->get_error(ctx)) {
- ctx->log(ctx,GEOCACHE_ERROR,c->get_error_message(ctx));
+ for(i=0;i<request->ntiles;i++) {
+ geocache_tile *tile = request->tiles[i];
+ geocache_tileset_tile_get(ctx,tile);
+ if(GC_HAS_ERROR(ctx)) {
+ ctx->log(ctx,GEOCACHE_DEBUG,ctx->get_error_message(ctx));
FCGX_FPrintF(out,"Status: 500 Internal Server Error\r\n\r\n");
goto cleanup;
}
- FCGX_FPrintF(out,"Status: 500 Internal Server Error\r\n\r\n");
- goto cleanup;
}
- tile->tileset = request->tiles[0]->tileset;
+ if(request->ntiles == 1) {
+ tile = request->tiles[0];
+ } else {
+ tile = geocache_image_merge_tiles(ctx,cfg->merge_format,request->tiles,request->ntiles);
+ if(!tile) {
+ ctx->log(ctx,GEOCACHE_ERROR, "tile merging failed to return data");
+ if(ctx->get_error(ctx)) {
+ ctx->log(ctx,GEOCACHE_ERROR,c->get_error_message(ctx));
+ FCGX_FPrintF(out,"Status: 500 Internal Server Error\r\n\r\n");
+ goto cleanup;
+ }
+ FCGX_FPrintF(out,"Status: 500 Internal Server Error\r\n\r\n");
+ goto cleanup;
+ }
+ tile->tileset = request->tiles[0]->tileset;
+ }
+ geocache_write_tile((geocache_context_fcgi_request*)ctx,tile);
}
- geocache_write_tile((geocache_context_fcgi_request*)ctx,tile);
cleanup:
apr_pool_destroy(ctx->pool);
}
Modified: trunk/mapserver/mapcache/src/mod_geocache.c
===================================================================
--- trunk/mapserver/mapcache/src/mod_geocache.c 2011-08-26 11:06:34 UTC (rev 12200)
+++ trunk/mapserver/mapcache/src/mod_geocache.c 2011-08-26 11:06:40 UTC (rev 12201)
@@ -18,6 +18,7 @@
* Include the core server components.
*/
#include <httpd.h>
+#include <http_core.h>
#include <http_config.h>
#include <http_protocol.h>
#include <http_request.h>
@@ -205,7 +206,9 @@
geocache_context_apache_request *apache_ctx = apache_request_context_create(r);
geocache_context *global_ctx = (geocache_context*)apache_ctx;
geocache_tile *tile;
+ request_rec *original;
int i,ret;
+ char *uri;
if (!r->handler || strcmp(r->handler, "geocache")) {
return DECLINED;
@@ -216,12 +219,16 @@
params = geocache_http_parse_param_string(global_ctx, r->args);
config = ap_get_module_config(r->per_dir_config, &geocache_module);
-
+ if(r->main)
+ original = r->main;
+ else
+ original = r;
+ uri = ap_construct_url(r->pool,original->parsed_uri.path,original);
for(i=0;i<GEOCACHE_SERVICES_COUNT;i++) {
/* loop through the services that have been configured */
geocache_service *service = config->services[i];
if(!service) continue;
- request = service->parse_request(global_ctx,r->path_info,params,config);
+ request = service->parse_request(global_ctx,uri,original->path_info,params,config);
/* the service has recognized the request if it returns a non NULL value */
if(request || GC_HAS_ERROR(global_ctx))
break;
Modified: trunk/mapserver/mapcache/src/services.c
===================================================================
--- trunk/mapserver/mapcache/src/services.c 2011-08-26 11:06:34 UTC (rev 12200)
+++ trunk/mapserver/mapcache/src/services.c 2011-08-26 11:06:40 UTC (rev 12201)
@@ -80,10 +80,10 @@
"<BoundingBox srs=\"%s\" minx=\"%f\" miny=\"%f\" maxx=\"%f\" maxy=\"%f\" />\n"
"</Layer>\n";
-geocache_request* _geocache_service_wms_capabilities(geocache_context *ctx, geocache_cfg *cfg) {
+geocache_request* _geocache_service_wms_capabilities(geocache_context *ctx, char *uri, geocache_cfg *cfg) {
geocache_request *request = (geocache_request*)apr_pcalloc(ctx->pool,sizeof(geocache_request));
request->type = GEOCACHE_REQUEST_GET_CAPABILITIES;
- char *host = "http://foo?";
+ char *host = uri;
char *caps = apr_psprintf(ctx->pool,wms_capabilities_preamble,host,host,host);
apr_hash_index_t *tileindex_index = apr_hash_first(ctx->pool,cfg->tilesets);
@@ -145,7 +145,7 @@
* \private \memberof geocache_service_wms
* \sa geocache_service::parse_request()
*/
-geocache_request* _geocache_service_wms_parse_request(geocache_context *ctx, char *pathinfo, apr_table_t *params, geocache_cfg *config) {
+geocache_request* _geocache_service_wms_parse_request(geocache_context *ctx, char *uri, char *pathinfo, apr_table_t *params, geocache_cfg *config) {
char *str = NULL, *srs=NULL;
int width=0, height=0;
double *bbox;
@@ -166,7 +166,7 @@
return NULL;
}
if( ! strcasecmp(str,"getcapabilities") ) {
- return _geocache_service_wms_capabilities(ctx, config);
+ return _geocache_service_wms_capabilities(ctx, uri, config);
} else if( strcasecmp(str,"getmap")) {
ctx->set_error(ctx, GEOCACHE_REQUEST_ERROR, "received wms with invalid request %s",str);
return NULL;
@@ -290,7 +290,7 @@
* \private \memberof geocache_service_tms
* \sa geocache_service::parse_request()
*/
-geocache_request* _geocache_service_tms_parse_request(geocache_context *ctx, char *pathinfo, apr_table_t *params, geocache_cfg *config) {
+geocache_request* _geocache_service_tms_parse_request(geocache_context *ctx, char *uri, char *pathinfo, apr_table_t *params, geocache_cfg *config) {
int index = 0;
char *last, *key, *endptr;
geocache_tileset *tileset = NULL;
More information about the mapserver-commits
mailing list