Skip to content
Permalink
Browse files

Added a helper function to properly test if a tileset is using the ra…

…w format (in response to tbonfort comments).
  • Loading branch information...
sdlime committed Feb 13, 2019
1 parent 68a9140 commit 3e0b39160d81ca32a73f6f6133c6a7eb6b3d126e
Showing with 12 additions and 5 deletions.
  1. +1 −0 include/mapcache.h
  2. +6 −0 lib/imageio_raw.c
  3. +4 −4 lib/service_wms.c
  4. +1 −1 lib/source_wms.c
@@ -1409,6 +1409,7 @@ struct mapcache_image_format_raw {
};

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

/**\class mapcache_image_format_png_q
* \brief Quantized PNG format
@@ -30,6 +30,12 @@
#include "mapcache.h"
#include <apr_strings.h>

int mapcache_imageio_is_raw_tileset(mapcache_tileset *tileset)
{
if(!tileset || !tileset->format || tileset->format->type != GC_RAW) return MAPCACHE_FALSE;
return MAPCACHE_TRUE;
}

static mapcache_buffer* _mapcache_imageio_raw_create_empty(mapcache_context *ctx, mapcache_image_format *format,
size_t width, size_t height, unsigned int color)
{
@@ -198,7 +198,7 @@ void _create_capabilities_wms(mapcache_context *ctx, mapcache_request_get_capabi
int i;
apr_hash_this(tileindex_index,&key,&keylen,(void**)&tileset);

if(tileset->format->type == GC_RAW) {
if(mapcache_imageio_is_raw_tileset(tileset)) {
tileindex_index = apr_hash_next(tileindex_index);
continue; /* WMS is not supported for raw layers */
}
@@ -534,7 +534,7 @@ void _mapcache_service_wms_parse_request(mapcache_context *ctx, mapcache_service
key = apr_strtok(layers, ",", &last); /* extract first layer */
}
main_tileset = mapcache_configuration_get_tileset(config,key);
if(!main_tileset || main_tileset->format->type == GC_RAW) {
if(!main_tileset || mapcache_imageio_is_raw_tileset(main_tileset)) {
errcode = 404;
errmsg = apr_psprintf(ctx->pool,"received wms request with invalid layer %s", key);
goto proxies;
@@ -633,7 +633,7 @@ void _mapcache_service_wms_parse_request(mapcache_context *ctx, mapcache_service
* this step is not done for the first tileset as we have already performed it
*/
tileset = mapcache_configuration_get_tileset(config,key);
if (!tileset || tileset->format->type == GC_RAW) {
if (!tileset || mapcache_imageio_is_raw_tileset(tileset)) {
errcode = 404;
errmsg = apr_psprintf(ctx->pool,"received wms request with invalid layer %s", key);
goto proxies;
@@ -733,7 +733,7 @@ void _mapcache_service_wms_parse_request(mapcache_context *ctx, mapcache_service
goto proxies;
} else {
mapcache_tileset *tileset = mapcache_configuration_get_tileset(config,str);
if(!tileset || tileset->format->type == GC_RAW) {
if(!tileset || mapcache_imageio_is_raw_tileset(tileset)) {
errcode = 404;
errmsg = apr_psprintf(ctx->pool,"received wms getfeatureinfo request with invalid layer %s", str);
goto proxies;
@@ -93,7 +93,7 @@ void _mapcache_source_wms_render_map(mapcache_context *ctx, mapcache_map *map)
mapcache_http_do_request(ctx,http,map->encoded_data,NULL,NULL);
GC_CHECK_ERROR(ctx);

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

0 comments on commit 3e0b391

Please sign in to comment.
You can’t perform that action at this time.