Skip to content

Commit 3e0b391

Browse files
committed
Added a helper function to properly test if a tileset is using the raw format (in response to tbonfort comments).
1 parent 68a9140 commit 3e0b391

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

include/mapcache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,7 @@ struct mapcache_image_format_raw {
14091409
};
14101410

14111411
mapcache_image_format* mapcache_imageio_create_raw_format(apr_pool_t *pool, char *name, char *extension, char *mime_type);
1412+
int mapcache_imageio_is_raw_tileset(mapcache_tileset *tileset);
14121413

14131414
/**\class mapcache_image_format_png_q
14141415
* \brief Quantized PNG format

lib/imageio_raw.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
#include "mapcache.h"
3131
#include <apr_strings.h>
3232

33+
int mapcache_imageio_is_raw_tileset(mapcache_tileset *tileset)
34+
{
35+
if(!tileset || !tileset->format || tileset->format->type != GC_RAW) return MAPCACHE_FALSE;
36+
return MAPCACHE_TRUE;
37+
}
38+
3339
static mapcache_buffer* _mapcache_imageio_raw_create_empty(mapcache_context *ctx, mapcache_image_format *format,
3440
size_t width, size_t height, unsigned int color)
3541
{

lib/service_wms.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void _create_capabilities_wms(mapcache_context *ctx, mapcache_request_get_capabi
198198
int i;
199199
apr_hash_this(tileindex_index,&key,&keylen,(void**)&tileset);
200200

201-
if(tileset->format->type == GC_RAW) {
201+
if(mapcache_imageio_is_raw_tileset(tileset)) {
202202
tileindex_index = apr_hash_next(tileindex_index);
203203
continue; /* WMS is not supported for raw layers */
204204
}
@@ -534,7 +534,7 @@ void _mapcache_service_wms_parse_request(mapcache_context *ctx, mapcache_service
534534
key = apr_strtok(layers, ",", &last); /* extract first layer */
535535
}
536536
main_tileset = mapcache_configuration_get_tileset(config,key);
537-
if(!main_tileset || main_tileset->format->type == GC_RAW) {
537+
if(!main_tileset || mapcache_imageio_is_raw_tileset(main_tileset)) {
538538
errcode = 404;
539539
errmsg = apr_psprintf(ctx->pool,"received wms request with invalid layer %s", key);
540540
goto proxies;
@@ -633,7 +633,7 @@ void _mapcache_service_wms_parse_request(mapcache_context *ctx, mapcache_service
633633
* this step is not done for the first tileset as we have already performed it
634634
*/
635635
tileset = mapcache_configuration_get_tileset(config,key);
636-
if (!tileset || tileset->format->type == GC_RAW) {
636+
if (!tileset || mapcache_imageio_is_raw_tileset(tileset)) {
637637
errcode = 404;
638638
errmsg = apr_psprintf(ctx->pool,"received wms request with invalid layer %s", key);
639639
goto proxies;
@@ -733,7 +733,7 @@ void _mapcache_service_wms_parse_request(mapcache_context *ctx, mapcache_service
733733
goto proxies;
734734
} else {
735735
mapcache_tileset *tileset = mapcache_configuration_get_tileset(config,str);
736-
if(!tileset || tileset->format->type == GC_RAW) {
736+
if(!tileset || mapcache_imageio_is_raw_tileset(tileset)) {
737737
errcode = 404;
738738
errmsg = apr_psprintf(ctx->pool,"received wms getfeatureinfo request with invalid layer %s", str);
739739
goto proxies;

lib/source_wms.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void _mapcache_source_wms_render_map(mapcache_context *ctx, mapcache_map *map)
9393
mapcache_http_do_request(ctx,http,map->encoded_data,NULL,NULL);
9494
GC_CHECK_ERROR(ctx);
9595

96-
if(map->tileset->format->type != GC_RAW && !mapcache_imageio_is_valid_format(ctx,map->encoded_data)) {
96+
if(!mapcache_imageio_is_raw_tileset(map->tileset) && !mapcache_imageio_is_valid_format(ctx,map->encoded_data)) {
9797
char *returned_data = apr_pstrndup(ctx->pool,(char*)map->encoded_data->buf,map->encoded_data->size);
9898
ctx->set_error(ctx, 502, "wms request for tileset %s returned an unsupported format:\n%s",
9999
map->tileset->name, returned_data);

0 commit comments

Comments
 (0)