mapcache
mapcache copied to clipboard
LMDB support for MVT
I tried to replace my disc cache with a lmdb cache but gets this error in the logs:
mapcache_imageio_decode: unrecognized image format
The format is defined as
<format name="mvt" type="RAW">
<extension>mvt</extension>
<mime_type>application/vnd.mapbox-vector-tile</mime_type>
<compression>fast</compression>
</format>
and the cache section as in the documentation.
I guess this function should implement a case for RAW images?
imageio.c
mapcache_image* mapcache_imageio_decode(mapcache_context *ctx, mapcache_buffer *buffer)
{
mapcache_image_format_type type = mapcache_imageio_header_sniff(ctx,buffer);
if(type == GC_PNG) {
return _mapcache_imageio_png_decode(ctx,buffer);
} else if(type == GC_JPEG) {
return _mapcache_imageio_jpeg_decode(ctx,buffer);
} else {
ctx->set_error(ctx, 500, "mapcache_imageio_decode: unrecognized image format");
return NULL;
}
}
this code is called from cache_lmdb.c :
if(!tile->raw_image) {
tile->raw_image = mapcache_imageio_decode(ctx, tile->encoded_data);
GC_CHECK_ERROR(ctx);
}
if we compare that with, for example cache_rest.c we'll see it's wrapped in another condition:
if(rcache->detect_blank) {
if(tile->nodata) {
return;
}
if(!tile->raw_image) {
tile->raw_image = mapcache_imageio_decode(ctx, tile->encoded_data);
GC_CHECK_ERROR(ctx);
}
if(mapcache_image_blank_color(tile->raw_image) != MAPCACHE_FALSE) {
if(tile->raw_image->data[3] == 0) {
/* We have a blank (uniform) image who's first pixel is fully transparent, thus the whole image is transparent */
tile->nodata = 1;
return;
}
}
}
So I suppose it's best to leave imageio.c alone and implement something similar in cache_lmdb.c