Skip to content
Permalink
Browse files

Switched 'blob' to 'raw' since it can be used for more than binary da…

…ta (like vector tiles). It can also be used for something like UTFGrid, so...
  • Loading branch information...
sdlime committed Apr 27, 2017
1 parent 8ba4cd8 commit c7c5254b6b505a98c2100402fb3b23135eecf640
Showing with 23 additions and 23 deletions.
  1. +4 −4 include/mapcache.h
  2. +2 −2 lib/cache_disk.c
  3. +2 −2 lib/configuration_xml.c
  4. +2 −2 lib/core.c
  5. +2 −2 lib/image.c
  6. +8 −8 lib/{imageio_blob.c → imageio_raw.c}
  7. +1 −1 lib/source_wms.c
  8. +2 −2 lib/tileset.c
@@ -78,7 +78,7 @@ typedef struct mapcache_image_format_mixed mapcache_image_format_mixed;
typedef struct mapcache_image_format_png mapcache_image_format_png;
typedef struct mapcache_image_format_png_q mapcache_image_format_png_q;
typedef struct mapcache_image_format_jpeg mapcache_image_format_jpeg;
typedef struct mapcache_image_format_blob mapcache_image_format_blob;
typedef struct mapcache_image_format_raw mapcache_image_format_raw;
typedef struct mapcache_cfg mapcache_cfg;
typedef struct mapcache_tileset mapcache_tileset;
typedef struct mapcache_cache mapcache_cache;
@@ -663,7 +663,7 @@ MS_DLL_EXPORT int mapcache_config_services_enabled(mapcache_context *ctx, mapcac
/** @{ */

typedef enum {
GC_UNKNOWN, GC_PNG, GC_JPEG, GC_BLOB
GC_UNKNOWN, GC_PNG, GC_JPEG, GC_RAW
} mapcache_image_format_type;

typedef enum {
@@ -1404,11 +1404,11 @@ mapcache_buffer* mapcache_empty_png_decode(mapcache_context *ctx, int width, int
mapcache_image_format* mapcache_imageio_create_mixed_format(apr_pool_t *pool,
char *name, mapcache_image_format *transparent, mapcache_image_format *opaque, unsigned int alpha_cutoff);

struct mapcache_image_format_blob {
struct mapcache_image_format_raw {
mapcache_image_format format;
};

mapcache_image_format* mapcache_imageio_create_blob_format(apr_pool_t *pool, char *name, char *extension, char *mime_type);
mapcache_image_format* mapcache_imageio_create_raw_format(apr_pool_t *pool, char *name, char *extension, char *mime_type);

/**\class mapcache_image_format_png_q
* \brief Quantized PNG format
@@ -517,11 +517,11 @@ static void _mapcache_cache_disk_set(mapcache_context *ctx, mapcache_cache *pcac

#ifdef HAVE_SYMLINK
if(cache->symlink_blank) {
if(tile->tileset->format->type != GC_BLOB && !tile->raw_image) {
if(tile->tileset->format->type != GC_RAW && !tile->raw_image) {
tile->raw_image = mapcache_imageio_decode(ctx, tile->encoded_data);
GC_CHECK_ERROR(ctx);
}
if(tile->tileset->format->type != GC_BLOB && mapcache_image_blank_color(tile->raw_image) != MAPCACHE_FALSE) {
if(tile->tileset->format->type != GC_RAW && mapcache_image_blank_color(tile->raw_image) != MAPCACHE_FALSE) {
char *blankname;
int retry_count_create_symlink = 0;
char *blankname_rel = NULL;
@@ -480,12 +480,12 @@ void parseFormat(mapcache_context *ctx, ezxml_t node, mapcache_cfg *config)
alpha_cutoff = atoi(cur_node->txt);
}
format = mapcache_imageio_create_mixed_format(ctx->pool,name,transparent, opaque, alpha_cutoff);
} else if(!strcasecmp(type,"BLOB")) {
} else if(!strcasecmp(type,"RAW")) {
char *extension=NULL;
char *mime_type=NULL;
if ((cur_node = ezxml_child(node,"extension")) != NULL) extension = apr_pstrdup(ctx->pool, cur_node->txt);
if ((cur_node = ezxml_child(node,"mime_type")) != NULL) mime_type = apr_pstrdup(ctx->pool, cur_node->txt);
format = mapcache_imageio_create_blob_format(ctx->pool,name,extension,mime_type);
format = mapcache_imageio_create_raw_format(ctx->pool,name,extension,mime_type);
} else {
ctx->set_error(ctx, 400, "unknown format type %s for format \"%s\"", type, name);
return;
@@ -318,7 +318,7 @@ mapcache_http_response *mapcache_core_get_tile(mapcache_context *ctx, mapcache_r
format = mapcache_configuration_get_image_format(ctx->config,"PNG8");
}
} else {
/* set format, not an image type (e.g. GC_BLOB) */
/* set format, not an image type (e.g. GC_RAW) */
if(req_tile->image_request.format) {
format = req_tile->image_request.format;
} else {
@@ -330,7 +330,7 @@ mapcache_http_response *mapcache_core_get_tile(mapcache_context *ctx, mapcache_r
}

/* compute the content-type */
if(format && format->type == GC_BLOB) {
if(format && format->type == GC_RAW) {
apr_table_set(response->headers,"Content-Type",format->mime_type);
} else {
t = mapcache_imageio_header_sniff(ctx,response->data);
@@ -289,9 +289,9 @@ void mapcache_image_metatile_split(mapcache_context *ctx, mapcache_metatile *mt)
int sx,sy;

/*
** No metatile support for blobs...
** No metatile support for raw format types...
*/
if(mt->map.tileset->format->type == GC_BLOB) {
if(mt->map.tileset->format->type == GC_RAW) {
mt->tiles[0].encoded_data = mt->map.encoded_data;
return;
}
@@ -2,7 +2,7 @@
* $Id$
*
* Project: MapServer
* Purpose: MapCache tile caching support file: generic binary (BLOB) format I/O
* Purpose: MapCache tile caching support file: raw (generic) format I/O
* Author: Thomas Bonfort and the MapServer team.
*
******************************************************************************
@@ -30,26 +30,26 @@
#include "mapcache.h"
#include <apr_strings.h>

static mapcache_buffer* _mapcache_imageio_blob_create_empty(mapcache_context *ctx, mapcache_image_format *format,
static mapcache_buffer* _mapcache_imageio_raw_create_empty(mapcache_context *ctx, mapcache_image_format *format,
size_t width, size_t height, unsigned int color)
{
return NULL;
}

mapcache_buffer* _mapcache_imageio_blob_encode(mapcache_context *ctx, mapcache_image *img, mapcache_image_format *format)
mapcache_buffer* _mapcache_imageio_raw_encode(mapcache_context *ctx, mapcache_image *img, mapcache_image_format *format)
{
return NULL;
}

mapcache_image_format* mapcache_imageio_create_blob_format(apr_pool_t *pool, char *name, char *extension, char *mime_type)
mapcache_image_format* mapcache_imageio_create_raw_format(apr_pool_t *pool, char *name, char *extension, char *mime_type)
{
mapcache_image_format_blob *format = apr_pcalloc(pool, sizeof(mapcache_image_format_blob));
mapcache_image_format_raw *format = apr_pcalloc(pool, sizeof(mapcache_image_format_raw));
format->format.name = name;
format->format.extension = apr_pstrdup(pool, extension);
format->format.mime_type = apr_pstrdup(pool, mime_type);
format->format.metadata = apr_table_make(pool,3);
format->format.create_empty_image = _mapcache_imageio_blob_create_empty;
format->format.write = _mapcache_imageio_blob_encode;
format->format.type = GC_BLOB;
format->format.create_empty_image = _mapcache_imageio_raw_create_empty;
format->format.write = _mapcache_imageio_raw_encode;
format->format.type = GC_RAW;
return (mapcache_image_format*)format;
}
@@ -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_BLOB && !mapcache_imageio_is_valid_format(ctx,map->encoded_data)) {
if(map->tileset->format->type != GC_RAW && !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);
@@ -121,9 +121,9 @@ void mapcache_tileset_configuration_check(mapcache_context *ctx, mapcache_tilese
}
}

if(tileset->format && tileset->format->type == GC_BLOB) {
if(tileset->format && tileset->format->type == GC_RAW) {
if(tileset->metasize_x != 1 || tileset->metasize_y != 1 || tileset->metabuffer != 0) {
ctx->set_error(ctx, 400, "tileset \"%s\" references a BLOB format type, metatiling is not supported for the \"%s\" format", tileset->name, tileset->format->name);
ctx->set_error(ctx, 400, "tileset \"%s\" references a RAW format type, metatiling is not supported for the \"%s\" format", tileset->name, tileset->format->name);
}
}
}

0 comments on commit c7c5254

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