[mapserver-commits] r12487 - in trunk/mapserver/mapcache: . src
svn at osgeo.org
svn at osgeo.org
Fri Aug 26 07:31:04 EDT 2011
Author: tbonfort
Date: 2011-08-26 04:31:04 -0700 (Fri, 26 Aug 2011)
New Revision: 12487
Modified:
trunk/mapserver/mapcache/geocache.xml
trunk/mapserver/mapcache/src/core.c
trunk/mapserver/mapcache/src/imageio_mixed.c
trunk/mapserver/mapcache/src/service_tms.c
trunk/mapserver/mapcache/src/service_wms.c
trunk/mapserver/mapcache/src/service_wmts.c
trunk/mapserver/mapcache/src/tileset.c
Log:
Modified: trunk/mapserver/mapcache/geocache.xml
===================================================================
--- trunk/mapserver/mapcache/geocache.xml 2011-08-26 11:30:56 UTC (rev 12486)
+++ trunk/mapserver/mapcache/geocache.xml 2011-08-26 11:31:04 UTC (rev 12487)
@@ -711,9 +711,7 @@
<metabuffer>30</metabuffer>
</tileset>
<tileset name="natural-earth-1">
- <source>osm</source>
<cache>mbtiles</cache>
- <format>PNG</format>
<grid>g</grid>
</tileset>
<tileset name="osm">
Modified: trunk/mapserver/mapcache/src/core.c
===================================================================
--- trunk/mapserver/mapcache/src/core.c 2011-08-26 11:30:56 UTC (rev 12486)
+++ trunk/mapserver/mapcache/src/core.c 2011-08-26 11:31:04 UTC (rev 12487)
@@ -117,7 +117,14 @@
return basemap;
} else /*if(ctx->config->getmap_strategy == GEOCACHE_GETMAP_FORWARD)*/ {
int i;
- geocache_map *basemap = req_map->maps[0];
+ for(i=0;i<req_map->nmaps;i++) {
+ if(!req_map->maps[i]->tileset->source) {
+ ctx->set_error(ctx,404,"cannot forward request for tileset %s: no source configured",
+ req_map->maps[i]->tileset->name);
+ return NULL;
+ }
+ }
+ geocache_map *basemap = req_map->maps[i];
basemap->tileset->source->render_map(ctx, basemap);
if(GC_HAS_ERROR(ctx)) return NULL;
if(req_map->nmaps>1) {
@@ -156,6 +163,10 @@
geocache_request_get_feature_info *req_fi) {
geocache_feature_info *fi = req_fi->fi;
geocache_tileset *tileset = fi->map.tileset;
+ if(!tileset->source) {
+ ctx->set_error(ctx,404,"cannot query tileset %s: no source defined",tileset->name);
+ return NULL;
+ }
if(tileset->source->info_formats) {
int i;
for(i=0;i<tileset->source->info_formats->nelts;i++) {
Modified: trunk/mapserver/mapcache/src/imageio_mixed.c
===================================================================
--- trunk/mapserver/mapcache/src/imageio_mixed.c 2011-08-26 11:30:56 UTC (rev 12486)
+++ trunk/mapserver/mapcache/src/imageio_mixed.c 2011-08-26 11:31:04 UTC (rev 12487)
@@ -46,7 +46,7 @@
format->transparent = transparent;
format->opaque = opaque;
format->format.extension = apr_pstrdup(pool,"xxx");
- format->format.mime_type = apr_pstrdup(pool,"image/png+jpeg");
+ format->format.mime_type = NULL;
format->format.write = _geocache_imageio_mixed_encode;
format->format.create_empty_image = transparent->create_empty_image;
format->format.metadata = apr_table_make(pool,3);
Modified: trunk/mapserver/mapcache/src/service_tms.c
===================================================================
--- trunk/mapserver/mapcache/src/service_tms.c 2011-08-26 11:30:56 UTC (rev 12486)
+++ trunk/mapserver/mapcache/src/service_tms.c 2011-08-26 11:31:04 UTC (rev 12487)
@@ -107,12 +107,16 @@
ezxml_t tileformat = ezxml_add_child(caps,"TileFormat",0);
ezxml_set_attr(tileformat,"width",apr_psprintf(ctx->pool,"%d",grid->tile_sx));
ezxml_set_attr(tileformat,"height",apr_psprintf(ctx->pool,"%d",grid->tile_sy));
- if(tileset->format->mime_type) {
+ if(tileset->format && tileset->format->mime_type) {
ezxml_set_attr(tileformat,"mime-type",tileset->format->mime_type);
} else {
ezxml_set_attr(tileformat,"mime-type","image/unknown");
}
- ezxml_set_attr(tileformat,"extension",tileset->format->extension);
+ if(tileset->format) {
+ ezxml_set_attr(tileformat,"extension",tileset->format->extension);
+ } else {
+ ezxml_set_attr(tileformat,"extension","xxx");
+ }
ezxml_t tilesets = ezxml_add_child(caps,"TileSets",0);
for(i=0;i<grid->nlevels;i++) {
Modified: trunk/mapserver/mapcache/src/service_wms.c
===================================================================
--- trunk/mapserver/mapcache/src/service_wms.c 2011-08-26 11:30:56 UTC (rev 12486)
+++ trunk/mapserver/mapcache/src/service_wms.c 2011-08-26 11:31:04 UTC (rev 12487)
@@ -171,7 +171,7 @@
ezxml_t layerxml = ezxml_add_child(toplayer,"Layer",0);
ezxml_set_attr(layerxml, "cascaded", "1");
- ezxml_set_attr(layerxml, "queryable", tileset->source->info_formats?"1":"0"),
+ ezxml_set_attr(layerxml, "queryable", (tileset->source && tileset->source->info_formats)?"1":"0"),
ezxml_set_txt(ezxml_add_child(layerxml,"Name",0),tileset->name);
ezxml_t tsxml = ezxml_add_child(vendorxml, "TileSet",0);
@@ -611,7 +611,7 @@
errmsg = apr_psprintf(ctx->pool,"received wms getfeatureinfo request with invalid layer %s", str);
goto proxies;
}
- if(!tileset->source->info_formats) {
+ if(!tileset->source || !tileset->source->info_formats) {
errcode = 404;
errmsg = apr_psprintf(ctx->pool,"received wms getfeatureinfo request for unqueryable layer %s", str);
goto proxies;
Modified: trunk/mapserver/mapcache/src/service_wmts.c
===================================================================
--- trunk/mapserver/mapcache/src/service_wmts.c 2011-08-26 11:30:56 UTC (rev 12486)
+++ trunk/mapserver/mapcache/src/service_wmts.c 2011-08-26 11:31:04 UTC (rev 12487)
@@ -128,7 +128,7 @@
ezxml_set_attr(style,"isDefault","true");
ezxml_set_txt(ezxml_add_child(style,"ows:Identifier",0),"default");
- if(tileset->format->mime_type)
+ if(tileset->format && tileset->format->mime_type)
ezxml_set_txt(ezxml_add_child(layer,"Format",0),tileset->format->mime_type);
else
ezxml_set_txt(ezxml_add_child(layer,"Format",0),"image/unknown");
@@ -154,7 +154,7 @@
dimensionstemplate = apr_pstrcat(ctx->pool,dimensionstemplate,"{",dimension->name,"}/",NULL);
}
}
- if(tileset->source->info_formats) {
+ if(tileset->source && tileset->source->info_formats) {
int i;
for(i=0;i<tileset->source->info_formats->nelts;i++) {
char *iformat = APR_ARRAY_IDX(tileset->source->info_formats,i,char*);
@@ -169,11 +169,15 @@
}
ezxml_t resourceurl = ezxml_add_child(layer,"ResourceURL",0);
- ezxml_set_attr(resourceurl,"format",tileset->format->mime_type);
+ if(tileset->format && tileset->format->mime_type)
+ ezxml_set_attr(resourceurl,"format",tileset->format->mime_type);
+ else
+ ezxml_set_attr(resourceurl,"format","image/unknown");
ezxml_set_attr(resourceurl,"resourceType","tile");
ezxml_set_attr(resourceurl,"template",
apr_pstrcat(ctx->pool,onlineresource,"wmts/1.0.0/",tileset->name,"/default/",
- dimensionstemplate,"{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.",tileset->format->extension,NULL));
+ dimensionstemplate,"{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.",
+ ((tileset->format)?tileset->format->extension:"xxx"),NULL));
if(tileset->wgs84bbox[0] != tileset->wgs84bbox[2]) {
@@ -535,21 +539,26 @@
}
if(!fi_j) { /*we have a getTile request*/
- if(!format && !extension) {
- ctx->set_error(ctx, 404, "received wmts request with no format");
- return;
- } else {
- if(format && strcmp(format,tileset->format->mime_type)) {
- ctx->set_error(ctx, 404, "received wmts request with invalid format \"%s\" (expecting %s)",
- format,tileset->format->mime_type);
+
+#ifdef PEDANTIC_WMTS_FORMAT_CHECK
+ if(tileset->format) {
+ if(!format && !extension) {
+ ctx->set_error(ctx, 404, "received wmts request with no format");
return;
+ } else {
+ if(format && tileset->format && strcmp(format,tileset->format->mime_type)) {
+ ctx->set_error(ctx, 404, "received wmts request with invalid format \"%s\" (expecting %s)",
+ format,tileset->format->mime_type);
+ return;
+ }
+ if(extension && tileset->format && strcmp(extension,tileset->format->extension)) {
+ ctx->set_error(ctx, 404, "received wmts request with invalid extension \"%s\" (expecting %s)",
+ extension,tileset->format->extension);
+ return;
+ }
}
- if(extension && strcmp(extension,tileset->format->extension)) {
- ctx->set_error(ctx, 404, "received wmts request with invalid extension \"%s\" (expecting %s)",
- extension,tileset->format->extension);
- return;
- }
}
+#endif
geocache_request_get_tile *req = (geocache_request_get_tile*)apr_pcalloc(
@@ -593,7 +602,7 @@
}
char *endptr;
- if(!tileset->source->info_formats) {
+ if(!tileset->source || !tileset->source->info_formats) {
ctx->set_error(ctx,400,"tileset %s does not support featureinfo requests", tileset->name);
return;
}
Modified: trunk/mapserver/mapcache/src/tileset.c
===================================================================
--- trunk/mapserver/mapcache/src/tileset.c 2011-08-26 11:30:56 UTC (rev 12486)
+++ trunk/mapserver/mapcache/src/tileset.c 2011-08-26 11:31:04 UTC (rev 12487)
@@ -28,10 +28,6 @@
ctx->set_error(ctx, 400, "tileset \"%s\" has no cache configured.", tileset->name);
return;
}
- if(tileset->source == NULL) {
- ctx->set_error(ctx, 400, "tileset \"%s\" has no source configured.", tileset->name);
- return;
- }
if(apr_is_empty_array(tileset->grid_links)) {
ctx->set_error(ctx, 400, "tileset \"%s\" has no grids configured", tileset->name);
@@ -47,7 +43,7 @@
}
}
#endif
- if(!tileset->format && tileset->source->type == GEOCACHE_SOURCE_GDAL) {
+ if(!tileset->format && tileset->source && tileset->source->type == GEOCACHE_SOURCE_GDAL) {
ctx->set_error(ctx,400, "tileset \"%s\" references a gdal source. <format> tag is missing and mandatory in this case",
tileset->name);
return;
@@ -318,6 +314,12 @@
*/
void _geocache_tileset_render_metatile(geocache_context *ctx, geocache_metatile *mt) {
int i;
+#ifdef DEBUG
+ if(!mt->map.tileset->source) {
+ ctx->set_error(ctx,500,"###BUG### tileset_render_metatile called on tileset with no source");
+ return;
+ }
+#endif
mt->map.tileset->source->render_map(ctx, &mt->map);
GC_CHECK_ERROR(ctx);
geocache_image_metatile_split(ctx, mt);
@@ -431,8 +433,9 @@
ret = tile->tileset->cache->tile_get(ctx, tile);
GC_CHECK_ERROR(ctx);
- if(ret == GEOCACHE_SUCCESS && tile->tileset->auto_expire && tile->mtime) {
- /* the cache is in auto-expire mode, and can return the tile modification date
+ if(ret == GEOCACHE_SUCCESS && tile->tileset->auto_expire && tile->mtime && tile->tileset->source) {
+ /* the cache is in auto-expire mode, and can return the tile modification date,
+ * and there is a source configured so we can possibly update it,
* so we check to see if it is stale */
apr_time_t now = apr_time_now();
apr_time_t stale = tile->mtime + apr_time_from_sec(tile->tileset->auto_expire);
@@ -444,6 +447,13 @@
}
if(ret == GEOCACHE_CACHE_MISS) {
+ /* bail out straight away if the tileset has no source */
+ if(!tile->tileset->source) {
+ ctx->set_error(ctx,404,"tile not in cache, and no source configured for tileset %s",
+ tile->tileset->name);
+ return;
+ }
+
/* the tile does not exist, we must take action before re-asking for it */
/*
More information about the mapserver-commits
mailing list