[mapserver-commits] r12385 - in trunk/mapserver/mapcache: . include
src
svn at osgeo.org
svn at osgeo.org
Fri Aug 26 07:21:24 EDT 2011
Author: tbonfort
Date: 2011-08-26 04:21:24 -0700 (Fri, 26 Aug 2011)
New Revision: 12385
Modified:
trunk/mapserver/mapcache/geocache.xml
trunk/mapserver/mapcache/include/geocache.h
trunk/mapserver/mapcache/src/configuration.c
trunk/mapserver/mapcache/src/core.c
trunk/mapserver/mapcache/src/http.c
trunk/mapserver/mapcache/src/mod_geocache.c
trunk/mapserver/mapcache/src/service_demo.c
trunk/mapserver/mapcache/src/service_kml.c
trunk/mapserver/mapcache/src/service_tms.c
trunk/mapserver/mapcache/src/service_ve.c
trunk/mapserver/mapcache/src/service_wms.c
trunk/mapserver/mapcache/src/service_wmts.c
trunk/mapserver/mapcache/src/services.c
trunk/mapserver/mapcache/src/source_wms.c
Log:
add title and boundingbox on tilematrixset capabilities doc
thomas.bonfort | 2011-06-09 13:03:27 +0200 (Thu, 09 Jun 2011)
Modified: trunk/mapserver/mapcache/geocache.xml
===================================================================
--- trunk/mapserver/mapcache/geocache.xml 2011-08-26 11:21:15 UTC (rev 12384)
+++ trunk/mapserver/mapcache/geocache.xml 2011-08-26 11:21:24 UTC (rev 12385)
@@ -214,11 +214,6 @@
for now, type can only be "wms"
-->
<source name="vmap0" type="wms">
- <!-- url
-
- url of the wms service, without any parameters
- -->
- <url>http://vmap0.tiles.osgeo.org/wms/vmap0</url>
<!-- getmap
@@ -237,10 +232,16 @@
<!-- http
- custom http parameters that will be used when making WMS requests
+ http url and parameters that will be used when making WMS requests
-->
<http>
+ <!-- url
+
+ url of the wms service, without any parameters
+ -->
+ <url>http://vmap0.tiles.osgeo.org/wms/vmap0</url>
+
<!-- headers
http headers added to request. make sure you know what you are
@@ -269,17 +270,21 @@
</http>
</source>
<source name="osm" type="wms">
- <url>http://localhost/cgi-bin/mapserv?</url>
+ <http>
+ <url>http://localhost/cgi-bin/mapserv?</url>
+ </http>
<getmap>
<params>
<FORMAT>image/png</FORMAT>
<LAYERS>default</LAYERS>
- <MAP>/Users/tbonfort/dev/mapserver-utils/osm-mapserver.map</MAP>
+ <MAP>/gro1/mapserver-utils/osm.map</MAP>
</params>
</getmap>
</source>
<source name="nexrad" type="wms">
- <url>http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi</url>
+ <http>
+ <url>http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi</url>
+ </http>
<getmap>
<params>
<FORMAT>image/png</FORMAT>
@@ -289,7 +294,9 @@
</getmap>
</source>
<source name="basic" type="wms">
- <url>http://geoservices.brgm.fr/geologie?</url>
+ <http>
+ <url>http://geoservices.brgm.fr/geologie?</url>
+ </http>
<getmap>
<params>
<FORMAT>image/png</FORMAT>
@@ -463,6 +470,7 @@
<grid>WGS84</grid>
<grid>g</grid>
<metatile>5 5</metatile>
+ <expires>1</expires>
<metabuffer>10</metabuffer>
</tileset>
@@ -492,6 +500,13 @@
each service is accessible at the url http://host/path/to/geocache/{service},
eg http://myhost/geocache/wms for OGC WMS.
-->
+ <service type="wms" enabled="true"/>
+ <service type="wmts" enabled="true"/>
+ <service type="tms" enabled="true"/>
+ <service type="kml" enabled="true"/>
+ <service type="gmaps" enabled="true"/>
+ <service type="ve" enabled="true"/>
+ <service type="demo" enabled="true"/>
<services>
<!-- OGC WMS -->
<wms>true</wms>
Modified: trunk/mapserver/mapcache/include/geocache.h
===================================================================
--- trunk/mapserver/mapcache/include/geocache.h 2011-08-26 11:21:15 UTC (rev 12384)
+++ trunk/mapserver/mapcache/include/geocache.h 2011-08-26 11:21:24 UTC (rev 12385)
@@ -77,10 +77,13 @@
typedef struct geocache_feature_info geocache_feature_info;
typedef struct geocache_request_get_feature_info geocache_request_get_feature_info;
typedef struct geocache_map geocache_map;
+typedef struct geocache_proxied_response geocache_proxied_response;
typedef struct geocache_source_wms geocache_source_wms;
typedef struct geocache_source_gdal geocache_source_gdal;
typedef struct geocache_cache_disk geocache_cache_disk;
+typedef struct geocache_http geocache_http;
typedef struct geocache_request geocache_request;
+typedef struct geocache_request_proxy geocache_request_proxy;
typedef struct geocache_request_get_capabilities geocache_request_get_capabilities;
typedef struct geocache_request_get_capabilities_demo geocache_request_get_capabilities_demo;
typedef struct geocache_request_get_capabilities_wms geocache_request_get_capabilities_wms;
@@ -263,17 +266,24 @@
void (*configuration_check)(geocache_context *ctx, geocache_source * source);
};
+geocache_http* geocache_http_configuration_parse(geocache_context *ctx,ezxml_t node);
+
+struct geocache_http {
+ char *url; /**< the base url to request */
+ apr_table_t *headers; /**< additional headers to add to the http request, eg, Referer */
+ /* TODO: authentication */
+};
+
/**\class geocache_source_wms
* \brief WMS geocache_source
* \implements geocache_source
*/
struct geocache_source_wms {
geocache_source source;
- char *url; /**< the base WMS url */
apr_table_t *wms_default_params; /**< default WMS parameters (SERVICE,REQUEST,STYLES,VERSION) */
apr_table_t *getmap_params; /**< WMS parameters specified in configuration */
apr_table_t *getfeatureinfo_params; /**< WMS parameters specified in configuration */
- apr_table_t *http_headers;
+ geocache_http *http;
};
#ifdef USE_GDAL
@@ -374,7 +384,8 @@
GEOCACHE_REQUEST_GET_TILE,
GEOCACHE_REQUEST_GET_MAP,
GEOCACHE_REQUEST_GET_CAPABILITIES,
- GEOCACHE_REQUEST_GET_FEATUREINFO
+ GEOCACHE_REQUEST_GET_FEATUREINFO,
+ GEOCACHE_REQUEST_PROXY
} geocache_request_type;
/**
* \brief a request sent by a client
@@ -403,6 +414,10 @@
};
+struct geocache_proxied_response {
+ geocache_buffer *data;
+ apr_table_t *headers;
+};
struct geocache_map {
geocache_tileset *tileset;
@@ -473,8 +488,14 @@
geocache_service *service;
};
+struct geocache_request_proxy {
+ geocache_request request;
+ geocache_http *http;
+ apr_table_t *params;
+};
+
/** \defgroup services Services*/
/** @{ */
@@ -498,6 +519,7 @@
* \brief a standard service (eg WMS, TMS)
*/
struct geocache_service {
+ char *name;
geocache_service_type type;
/**
@@ -517,6 +539,11 @@
* \param url the full url at which the service is available
*/
void (*create_capabilities_response)(geocache_context *ctx, geocache_request_get_capabilities *request, char *url, char *path_info, geocache_cfg *config);
+
+ /**
+ * parse advanced configuration options for the selected service
+ */
+ void (*configuration_parse)(geocache_context *ctx, ezxml_t xml, geocache_service * service);
};
/**\class geocache_service_wms
@@ -707,8 +734,9 @@
/** \defgroup http HTTP Request handling*/
/** @{ */
-void geocache_http_request_url(geocache_context *ctx, char *url, apr_table_t *headers, geocache_buffer *data);
-void geocache_http_request_url_with_params(geocache_context *ctx, char *url, apr_table_t *params, apr_table_t *headers, geocache_buffer *data);
+void geocache_http_do_request(geocache_context *ctx, geocache_http *req, geocache_buffer *data, apr_table_t *headers);
+void geocache_http_do_request_with_params(geocache_context *ctx, geocache_http *req, apr_table_t *params,
+ geocache_buffer *data, apr_table_t *headers);
char* geocache_http_build_url(geocache_context *ctx, char *base, apr_table_t *params);
apr_table_t *geocache_http_parse_param_string(geocache_context *ctx, char *args);
/** @} */
@@ -1087,7 +1115,9 @@
geocache_feature_info *geocache_core_get_featureinfo(geocache_context *ctx, geocache_request_get_feature_info *req_fi);
+geocache_proxied_response *geocache_core_proxy_request(geocache_context *ctx, geocache_request_proxy *req_proxy);
+
/* in grid.c */
geocache_grid* geocache_grid_create(apr_pool_t *pool);
Modified: trunk/mapserver/mapcache/src/configuration.c
===================================================================
--- trunk/mapserver/mapcache/src/configuration.c 2011-08-26 11:21:15 UTC (rev 12384)
+++ trunk/mapserver/mapcache/src/configuration.c 2011-08-26 11:21:24 UTC (rev 12385)
@@ -976,7 +976,69 @@
if(GC_HAS_ERROR(ctx)) goto cleanup;
}
- if ((node = ezxml_child(doc,"services")) != NULL) {
+ if ((node = ezxml_child(doc,"service")) != NULL) {
+ ezxml_t service_node;
+ for(service_node = node; service_node; service_node = service_node->next) {
+ char *enabled = (char*)ezxml_attr(service_node,"enabled");
+ char *type = (char*)ezxml_attr(service_node,"type");
+ if(!strcasecmp(enabled,"true")) {
+ if (!strcasecmp(type,"wms")) {
+ geocache_service *new_service = geocache_service_wms_create(ctx);
+ if(new_service->configuration_parse) {
+ new_service->configuration_parse(ctx,service_node,new_service);
+ }
+ config->services[GEOCACHE_SERVICE_WMS] = new_service;
+ }
+ else if (!strcasecmp(type,"tms")) {
+ geocache_service *new_service = geocache_service_tms_create(ctx);
+ if(new_service->configuration_parse) {
+ new_service->configuration_parse(ctx,service_node,new_service);
+ }
+ config->services[GEOCACHE_SERVICE_TMS] = new_service;
+ }
+ else if (!strcasecmp(type,"wmts")) {
+ geocache_service *new_service = geocache_service_wmts_create(ctx);
+ if(new_service->configuration_parse) {
+ new_service->configuration_parse(ctx,service_node,new_service);
+ }
+ config->services[GEOCACHE_SERVICE_WMTS] = new_service;
+ }
+ else if (!strcasecmp(type,"kml")) {
+ geocache_service *new_service = geocache_service_kml_create(ctx);
+ if(new_service->configuration_parse) {
+ new_service->configuration_parse(ctx,service_node,new_service);
+ }
+ config->services[GEOCACHE_SERVICE_KML] = new_service;
+ }
+ else if (!strcasecmp(type,"gmaps")) {
+ geocache_service *new_service = geocache_service_gmaps_create(ctx);
+ if(new_service->configuration_parse) {
+ new_service->configuration_parse(ctx,service_node,new_service);
+ }
+ config->services[GEOCACHE_SERVICE_GMAPS] = new_service;
+ }
+ else if (!strcasecmp(type,"ve")) {
+ geocache_service *new_service = geocache_service_ve_create(ctx);
+ if(new_service->configuration_parse) {
+ new_service->configuration_parse(ctx,service_node,new_service);
+ }
+ config->services[GEOCACHE_SERVICE_VE] = new_service;
+ }
+ else if (!strcasecmp(type,"demo")) {
+ geocache_service *new_service = geocache_service_demo_create(ctx);
+ if(new_service->configuration_parse) {
+ new_service->configuration_parse(ctx,service_node,new_service);
+ }
+ config->services[GEOCACHE_SERVICE_DEMO] = new_service;
+ } else {
+ ctx->set_error(ctx,400,"unknown <service> type %s",type);
+ }
+ if(GC_HAS_ERROR(ctx)) goto cleanup;
+ }
+ }
+ }
+ else if ((node = ezxml_child(doc,"services")) != NULL) {
+ ctx->log(ctx,GEOCACHE_WARNING,"<services> tag is deprecated, use <service type=\"wms\" enabled=\"true|false\">");
parseServices(ctx, node, config);
} else {
ctx->set_error(ctx, 400, "no <services> configured");
Modified: trunk/mapserver/mapcache/src/core.c
===================================================================
--- trunk/mapserver/mapcache/src/core.c 2011-08-26 11:21:15 UTC (rev 12384)
+++ trunk/mapserver/mapcache/src/core.c 2011-08-26 11:21:24 UTC (rev 12385)
@@ -113,6 +113,17 @@
}
}
+
+geocache_proxied_response *geocache_core_proxy_request(geocache_context *ctx, geocache_request_proxy *req_proxy) {
+ geocache_proxied_response *response = (geocache_proxied_response*) apr_pcalloc(ctx->pool,
+ sizeof(geocache_proxied_response));
+
+ response->data = geocache_buffer_create(30000,ctx->pool);
+ response->headers = apr_table_make(ctx->pool,1);
+ geocache_http_do_request_with_params(ctx,req_proxy->http,req_proxy->params,response->data,response->headers);
+ return response;
+}
+
geocache_feature_info *geocache_core_get_featureinfo(geocache_context *ctx,
geocache_request_get_feature_info *req_fi) {
geocache_feature_info *fi = req_fi->fi;
Modified: trunk/mapserver/mapcache/src/http.c
===================================================================
--- trunk/mapserver/mapcache/src/http.c 2011-08-26 11:21:15 UTC (rev 12384)
+++ trunk/mapserver/mapcache/src/http.c 2011-08-26 11:21:24 UTC (rev 12385)
@@ -22,21 +22,59 @@
#define MAX_STRING_LEN 10000
+static const int n_headers_to_extract = 2;
+static char* headers_to_extract[] = {
+ "Content-Type",
+ "Foo-Header"
+};
+
+struct _header_struct {
+ apr_table_t *headers;
+ geocache_context *ctx;
+};
+
size_t _geocache_curl_memory_callback(void *ptr, size_t size, size_t nmemb, void *data) {
geocache_buffer *buffer = (geocache_buffer*)data;
size_t realsize = size * nmemb;
return geocache_buffer_append(buffer, realsize, ptr);
}
-void geocache_http_request_url(geocache_context *ctx, char *url, apr_table_t *headers, geocache_buffer *data) {
+size_t _geocache_curl_header_callback( void *ptr, size_t size, size_t nmemb, void *userdata) {
+ struct _header_struct *h = (struct _header_struct*)userdata;
+ int i;
+ char *header = apr_pstrndup(h->ctx->pool,ptr,size*nmemb);
+ char *endptr = strstr(header,"\r\n");
+ if(!endptr) {
+ /* invalid header ? */
+#ifdef DEBUG
+ h->ctx->log(h->ctx,GEOCACHE_DEBUG,"received header %s with no trailing \\r\\n",header);
+#endif
+ return size*nmemb;
+ }
+ for(i=0;i<n_headers_to_extract;i++) {
+ int keylen = strlen(headers_to_extract[i]);
+ char *startptr;
+ if(size*nmemb<=keylen+4) /* +4 is for the ": " after the key, and terminating "\r\n" */
+ continue;
+ if(!strstr(ptr,headers_to_extract[i])) continue;
+ /* the header contains our key */
+ startptr = header+keylen+2;
+ *endptr = '\0';
+ apr_table_setn(h->headers,headers_to_extract[i],startptr);
+ //h->ctx->log(h->ctx,GEOCACHE_DEBUG,"%s:%s",headers_to_extract[i],startptr);
+ }
+ return size*nmemb;
+}
+
+void geocache_http_do_request(geocache_context *ctx, geocache_http *req, geocache_buffer *data, apr_table_t *headers) {
CURL *curl_handle;
curl_handle = curl_easy_init();
int ret;
char error_msg[CURL_ERROR_SIZE];
/* specify URL to get */
- curl_easy_setopt(curl_handle, CURLOPT_URL, url);
+ curl_easy_setopt(curl_handle, CURLOPT_URL, req->url);
#ifdef DEBUG
- ctx->log(ctx, GEOCACHE_DEBUG, "##### START #####\ncurl requesting url %s",url);
+ ctx->log(ctx, GEOCACHE_DEBUG, "curl requesting url %s",req->url);
#endif
/* send all data to this function */
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, _geocache_curl_memory_callback);
@@ -44,6 +82,15 @@
/* we pass our geocache_buffer struct to the callback function */
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)data);
+ if(headers != NULL) {
+ /* intercept headers */
+ struct _header_struct h;
+ h.headers = headers;
+ h.ctx=ctx;
+ curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, _geocache_curl_header_callback);
+ curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER, (void*)(&h));
+ }
+
curl_easy_setopt(curl_handle, CURLOPT_ERRORBUFFER, error_msg);
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, 10);
@@ -52,30 +99,34 @@
struct curl_slist *curl_headers=NULL;
- if(headers) {
- const apr_array_header_t *array = apr_table_elts(headers);
+ if(req->headers) {
+ const apr_array_header_t *array = apr_table_elts(req->headers);
apr_table_entry_t *elts = (apr_table_entry_t *) array->elts;
int i;
for (i = 0; i < array->nelts; i++) {
curl_headers = curl_slist_append(curl_headers, apr_pstrcat(ctx->pool,elts[i].key,": ",elts[i].val,NULL));
}
}
- if(!headers || !apr_table_get(headers,"User-Agent")) {
+ if(!req->headers || !apr_table_get(req->headers,"User-Agent")) {
curl_headers = curl_slist_append(curl_headers, "User-Agent: "GEOCACHE_USERAGENT);
}
curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, curl_headers);
/* get it! */
ret = curl_easy_perform(curl_handle);
if(ret != CURLE_OK) {
- ctx->set_error(ctx, 502, "curl failed to request url %s : %s", url, error_msg);
+ ctx->set_error(ctx, 502, "curl failed to request url %s : %s", req->url, error_msg);
}
/* cleanup curl stuff */
curl_easy_cleanup(curl_handle);
}
-void geocache_http_request_url_with_params(geocache_context *ctx, char *url, apr_table_t *params, apr_table_t *headers, geocache_buffer *data) {
- char *fullUrl = geocache_http_build_url(ctx,url,params);
- geocache_http_request_url(ctx,fullUrl,headers,data);
+void geocache_http_do_request_with_params(geocache_context *ctx, geocache_http *req, apr_table_t *params,
+ geocache_buffer *data, apr_table_t *headers) {
+ char *fullUrl = geocache_http_build_url(ctx,req->url,params);
+ char *oldurl = req->url;
+ req->url = fullUrl;
+ geocache_http_do_request(ctx,req,data,headers);
+ req->url = oldurl;
}
/* calculate the length of the string formed by key=value&, and add it to cnt */
@@ -229,6 +280,28 @@
return params;
}
+geocache_http* geocache_http_configuration_parse(geocache_context *ctx, ezxml_t node) {
+ ezxml_t http_node;
+ geocache_http *req = (geocache_http*)apr_pcalloc(ctx->pool,
+ sizeof(geocache_http));
+ if ((http_node = ezxml_child(node,"url")) != NULL) {
+ req->url = apr_pstrdup(ctx->pool,http_node->txt);
+ }
+ if(!req->url) {
+ ctx->set_error(ctx,400,"got an <http> object with no <url>");
+ return NULL;
+ }
+ req->headers = apr_table_make(ctx->pool,1);
+ if((http_node = ezxml_child(node,"headers")) != NULL) {
+ ezxml_t header_node;
+ for(header_node = http_node->child; header_node; header_node = header_node->sibling) {
+ apr_table_set(req->headers, header_node->name, header_node->txt);
+ }
+ }
+ return req;
+ /* TODO: parse <proxy> and <auth> elements */
+}
+
/* vim: ai ts=3 sts=3 et sw=3
*/
Modified: trunk/mapserver/mapcache/src/mod_geocache.c
===================================================================
--- trunk/mapserver/mapcache/src/mod_geocache.c 2011-08-26 11:21:15 UTC (rev 12384)
+++ trunk/mapserver/mapcache/src/mod_geocache.c 2011-08-26 11:21:24 UTC (rev 12385)
@@ -204,7 +204,7 @@
apr_time_t now = apr_time_now();
apr_time_t additional = apr_time_from_sec(tile->expires);
apr_time_t expires = now + additional;
- apr_table_mergen(r->headers_out, "Cache-Control",apr_psprintf(r->pool, "max-age=%d", tile->expires));
+ apr_table_set(r->headers_out, "Cache-Control",apr_psprintf(r->pool, "max-age=%d", tile->expires));
char *timestr = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
apr_rfc822_date(timestr, expires);
apr_table_set(r->headers_out, "Expires", timestr);
@@ -230,6 +230,25 @@
return OK;
}
+static int geocache_write_proxied_response(geocache_context_apache_request *ctx, geocache_proxied_response *response) {
+ request_rec *r = ctx->request;
+
+ ap_set_content_length(r,response->data->size);
+ if(response->headers && !apr_is_empty_table(response->headers)) {
+ const apr_array_header_t *elts = apr_table_elts(response->headers);
+ int i;
+ for(i=0;i<elts->nelts;i++) {
+ apr_table_entry_t entry = APR_ARRAY_IDX(elts,i,apr_table_entry_t);
+ apr_table_set(r->headers_out, entry.key, entry.val);
+ }
+
+ }
+ ap_rwrite((void*)response->data->buf, response->data->size, r);
+
+ return OK;
+
+}
+
static int mod_geocache_request_handler(request_rec *r) {
apr_table_t *params;
geocache_cfg *config = NULL;
@@ -293,6 +312,14 @@
ret = geocache_write_tile(apache_ctx,tile);
return ret;
+ } else if( request->type == GEOCACHE_REQUEST_PROXY ) {
+ geocache_request_proxy *req_proxy = (geocache_request_proxy*)request;
+ geocache_proxied_response *response = geocache_core_proxy_request(global_ctx, req_proxy);
+ if(GC_HAS_ERROR(global_ctx)) {
+ return report_error(apache_ctx);
+ }
+ return geocache_write_proxied_response(apache_ctx, response);
+
} else if( request->type == GEOCACHE_REQUEST_GET_MAP) {
geocache_request_get_map *req_map = (geocache_request_get_map*)request;
geocache_map *map = geocache_core_get_map(global_ctx,req_map);
Modified: trunk/mapserver/mapcache/src/service_demo.c
===================================================================
--- trunk/mapserver/mapcache/src/service_demo.c 2011-08-26 11:21:15 UTC (rev 12384)
+++ trunk/mapserver/mapcache/src/service_demo.c 2011-08-26 11:21:24 UTC (rev 12385)
@@ -369,8 +369,8 @@
geocache_service *service = NULL;
service = config->services[i];
if(!service) continue; /* skip an unconfigured service */
- prefixlen = strlen(service->url_prefix);
- if(strncmp(service->url_prefix,cpathinfo, prefixlen)) continue; /*skip a service who's prefix does not correspond */
+ prefixlen = strlen(service->name);
+ if(strncmp(service->name,cpathinfo, prefixlen)) continue; /*skip a service who's prefix does not correspond */
if(*(cpathinfo+prefixlen)!='/' && *(cpathinfo+prefixlen)!='\0') continue; /*we matched the prefix but there are trailing characters*/
drequest->service = service;
return;
@@ -388,8 +388,8 @@
for(i=0;i<GEOCACHE_SERVICES_COUNT;i++) {
geocache_service *service = ctx->config->services[i];
if(!service || service->type == GEOCACHE_SERVICE_DEMO) continue; /* skip an unconfigured service, and the demo one */
- caps = apr_pstrcat(ctx->pool,caps,"<a href=\"",urlprefix,"/demo/",service->url_prefix,"\">",
- service->url_prefix,"</a><br/>",NULL);
+ caps = apr_pstrcat(ctx->pool,caps,"<a href=\"",urlprefix,"/demo/",service->name,"\">",
+ service->name,"</a><br/>",NULL);
}
caps = apr_pstrcat(ctx->pool,caps,"</body></html>",NULL);
@@ -436,7 +436,7 @@
ol_layer_name,
tileset->name,
grid->name,
- apr_pstrcat(ctx->pool,url_prefix,"/wms?",NULL),
+ apr_pstrcat(ctx->pool,url_prefix,"?",NULL),
tileset->name,
resolutions,
unit,
@@ -454,7 +454,7 @@
ol_layer_name,
tileset->name,
grid->name,
- apr_pstrcat(ctx->pool,url_prefix,"/wms?",NULL),
+ apr_pstrcat(ctx->pool,url_prefix,"?",NULL),
tileset->name,resolutions,unit,
grid->extent[0],
grid->extent[1],
@@ -787,6 +787,7 @@
return NULL;
}
service->service.url_prefix = apr_pstrdup(ctx->pool,"demo");
+ service->service.name = apr_pstrdup(ctx->pool,"demo");
service->service.type = GEOCACHE_SERVICE_DEMO;
service->service.parse_request = _geocache_service_demo_parse_request;
service->service.create_capabilities_response = _create_capabilities_demo;
Modified: trunk/mapserver/mapcache/src/service_kml.c
===================================================================
--- trunk/mapserver/mapcache/src/service_kml.c 2011-08-26 11:21:15 UTC (rev 12384)
+++ trunk/mapserver/mapcache/src/service_kml.c 2011-08-26 11:21:24 UTC (rev 12385)
@@ -227,6 +227,7 @@
return NULL;
}
service->service.url_prefix = apr_pstrdup(ctx->pool,"kml");
+ service->service.name = apr_pstrdup(ctx->pool,"kml");
service->service.type = GEOCACHE_SERVICE_KML;
service->service.parse_request = _geocache_service_kml_parse_request;
service->service.create_capabilities_response = _create_capabilities_kml;
Modified: trunk/mapserver/mapcache/src/service_tms.c
===================================================================
--- trunk/mapserver/mapcache/src/service_tms.c 2011-08-26 11:21:15 UTC (rev 12384)
+++ trunk/mapserver/mapcache/src/service_tms.c 2011-08-26 11:21:24 UTC (rev 12385)
@@ -276,6 +276,7 @@
return NULL;
}
service->service.url_prefix = apr_pstrdup(ctx->pool,"tms");
+ service->service.name = apr_pstrdup(ctx->pool,"tms");
service->service.type = GEOCACHE_SERVICE_TMS;
service->reverse_y = 0;
service->service.parse_request = _geocache_service_tms_parse_request;
@@ -294,6 +295,7 @@
return NULL;
}
service->service.url_prefix = apr_pstrdup(ctx->pool,"gmaps");
+ service->service.name = apr_pstrdup(ctx->pool,"gmaps");
service->reverse_y = 1;
service->service.type = GEOCACHE_SERVICE_GMAPS;
service->service.parse_request = _geocache_service_tms_parse_request;
Modified: trunk/mapserver/mapcache/src/service_ve.c
===================================================================
--- trunk/mapserver/mapcache/src/service_ve.c 2011-08-26 11:21:15 UTC (rev 12384)
+++ trunk/mapserver/mapcache/src/service_ve.c 2011-08-26 11:21:24 UTC (rev 12385)
@@ -131,6 +131,7 @@
return NULL;
}
service->service.url_prefix = apr_pstrdup(ctx->pool,"ve");
+ service->service.name = apr_pstrdup(ctx->pool,"ve");
service->service.type = GEOCACHE_SERVICE_VE;
service->service.parse_request = _geocache_service_ve_parse_request;
service->service.create_capabilities_response = _create_capabilities_ve;
Modified: trunk/mapserver/mapcache/src/service_wms.c
===================================================================
--- trunk/mapserver/mapcache/src/service_wms.c 2011-08-26 11:21:15 UTC (rev 12384)
+++ trunk/mapserver/mapcache/src/service_wms.c 2011-08-26 11:21:24 UTC (rev 12385)
@@ -36,7 +36,7 @@
if(!url) {
url = guessed_url;
}
- url = apr_pstrcat(ctx->pool,url,"/wms?",NULL);
+ url = apr_pstrcat(ctx->pool,url,"/",req->request.service->url_prefix,"?",NULL);
caps = ezxml_new("WMT_MS_Capabilities");
ezxml_set_attr(caps,"version","1.1.1");
/*
@@ -625,16 +625,23 @@
#endif
}
+void _configuration_parse_wms(geocache_context *ctx, ezxml_t node, geocache_service *gservice) {
+ assert(gservice->type == GEOCACHE_SERVICE_WMS);
+
+}
+
geocache_service* geocache_service_wms_create(geocache_context *ctx) {
geocache_service_wms* service = (geocache_service_wms*)apr_pcalloc(ctx->pool, sizeof(geocache_service_wms));
if(!service) {
ctx->set_error(ctx, 500, "failed to allocate wms service");
return NULL;
}
- service->service.url_prefix = apr_pstrdup(ctx->pool,"wms");
+ service->service.url_prefix = apr_pstrdup(ctx->pool,"");
+ service->service.name = apr_pstrdup(ctx->pool,"wms");
service->service.type = GEOCACHE_SERVICE_WMS;
service->service.parse_request = _geocache_service_wms_parse_request;
service->service.create_capabilities_response = _create_capabilities_wms;
+ service->service.configuration_parse = _configuration_parse_wms;
return (geocache_service*)service;
}
Modified: trunk/mapserver/mapcache/src/service_wmts.c
===================================================================
--- trunk/mapserver/mapcache/src/service_wmts.c 2011-08-26 11:21:15 UTC (rev 12384)
+++ trunk/mapserver/mapcache/src/service_wmts.c 2011-08-26 11:21:24 UTC (rev 12385)
@@ -629,6 +629,7 @@
return NULL;
}
service->service.url_prefix = apr_pstrdup(ctx->pool,"wmts");
+ service->service.name = apr_pstrdup(ctx->pool,"wmts");
service->service.type = GEOCACHE_SERVICE_WMTS;
service->service.parse_request = _geocache_service_wmts_parse_request;
service->service.create_capabilities_response = _create_capabilities_wmts;
Modified: trunk/mapserver/mapcache/src/services.c
===================================================================
--- trunk/mapserver/mapcache/src/services.c 2011-08-26 11:21:15 UTC (rev 12384)
+++ trunk/mapserver/mapcache/src/services.c 2011-08-26 11:21:24 UTC (rev 12385)
@@ -35,11 +35,6 @@
while((*pathinfo) == '/')
++pathinfo;
- if(!(*pathinfo)) {
- ctx->set_error(ctx,404,"missing a service");
- return;
- }
-
for(i=0;i<GEOCACHE_SERVICES_COUNT;i++) {
/* loop through the services that have been configured */
int prefixlen;
Modified: trunk/mapserver/mapcache/src/source_wms.c
===================================================================
--- trunk/mapserver/mapcache/src/source_wms.c 2011-08-26 11:21:15 UTC (rev 12384)
+++ trunk/mapserver/mapcache/src/source_wms.c 2011-08-26 11:21:24 UTC (rev 12385)
@@ -44,7 +44,7 @@
}
map->data = geocache_buffer_create(30000,ctx->pool);
- geocache_http_request_url_with_params(ctx,wms->url,params,wms->http_headers,map->data);
+ geocache_http_do_request_with_params(ctx,wms->http,params,map->data,NULL);
GC_CHECK_ERROR(ctx);
if(!geocache_imageio_is_valid_format(ctx,map->data)) {
@@ -82,7 +82,7 @@
}
map->data = geocache_buffer_create(30000,ctx->pool);
- geocache_http_request_url_with_params(ctx,wms->url,params,wms->http_headers,map->data);
+ geocache_http_do_request_with_params(ctx,wms->http,params,map->data,NULL);
GC_CHECK_ERROR(ctx);
}
@@ -96,9 +96,6 @@
geocache_source_wms *src = (geocache_source_wms*)source;
- if ((cur_node = ezxml_child(node,"url")) != NULL) {
- src->url = apr_pstrdup(ctx->pool,cur_node->txt);
- }
if ((cur_node = ezxml_child(node,"getmap")) != NULL){
ezxml_t gm_node;
if ((gm_node = ezxml_child(cur_node,"params")) != NULL) {
@@ -137,14 +134,7 @@
}
}
if ((cur_node = ezxml_child(node,"http")) != NULL) {
- ezxml_t http_node;
- if((http_node = ezxml_child(cur_node,"headers")) != NULL) {
- ezxml_t header_node;
- for(header_node = http_node->child; header_node; header_node = header_node->sibling) {
- apr_table_set(src->http_headers, header_node->name, header_node->txt);
- }
- }
- /* TODO: parse <proxy> and <auth> elements */
+ src->http = geocache_http_configuration_parse(ctx,cur_node);
}
}
@@ -155,8 +145,8 @@
void _geocache_source_wms_configuration_check(geocache_context *ctx, geocache_source *source) {
geocache_source_wms *src = (geocache_source_wms*)source;
/* check all required parameters are configured */
- if(!strlen(src->url)) {
- ctx->set_error(ctx, 400, "wms source %s has no url",source->name);
+ if(!src->http) {
+ ctx->set_error(ctx, 400, "wms source %s has no <http> request configured",source->name);
}
if(!apr_table_get(src->getmap_params,"LAYERS")) {
ctx->set_error(ctx, 400, "wms source %s has no LAYERS", source->name);
@@ -183,7 +173,6 @@
source->wms_default_params = apr_table_make(ctx->pool,4);;
source->getmap_params = apr_table_make(ctx->pool,4);
source->getfeatureinfo_params = apr_table_make(ctx->pool,4);
- source->http_headers = apr_table_make(ctx->pool,1);
apr_table_add(source->wms_default_params,"VERSION","1.1.1");
apr_table_add(source->wms_default_params,"REQUEST","GetMap");
apr_table_add(source->wms_default_params,"SERVICE","WMS");
More information about the mapserver-commits
mailing list