[mapserver-commits] r12664 - in trunk/mapserver/mapcache: include
src
svn at osgeo.org
svn at osgeo.org
Fri Oct 14 11:33:26 EDT 2011
Author: tbonfort
Date: 2011-10-14 08:33:26 -0700 (Fri, 14 Oct 2011)
New Revision: 12664
Modified:
trunk/mapserver/mapcache/include/mapcache.h
trunk/mapserver/mapcache/src/cache_disk.c
trunk/mapserver/mapcache/src/cache_memcache.c
trunk/mapserver/mapcache/src/cache_sqlite.c
trunk/mapserver/mapcache/src/cache_tiff.c
trunk/mapserver/mapcache/src/configuration_xml.c
trunk/mapserver/mapcache/src/imageio_jpeg.c
trunk/mapserver/mapcache/src/imageio_png.c
Log:
make the tiff cache reference a jpeg format so that compression quality can be configured
Modified: trunk/mapserver/mapcache/include/mapcache.h
===================================================================
--- trunk/mapserver/mapcache/include/mapcache.h 2011-10-14 13:17:39 UTC (rev 12663)
+++ trunk/mapserver/mapcache/include/mapcache.h 2011-10-14 15:33:26 UTC (rev 12664)
@@ -390,7 +390,7 @@
*/
void (*tile_set)(mapcache_context *ctx, mapcache_tile * tile);
- void (*configuration_parse_xml)(mapcache_context *ctx, ezxml_t xml, mapcache_cache * cache);
+ void (*configuration_parse_xml)(mapcache_context *ctx, ezxml_t xml, mapcache_cache * cache, mapcache_cfg *config);
void (*configuration_post_config)(mapcache_context *ctx, mapcache_cache * cache, mapcache_cfg *config);
};
@@ -1357,6 +1357,7 @@
mapcache_buffer* (*create_empty_image)(mapcache_context *ctx, mapcache_image_format *format,
size_t width, size_t height, unsigned int color);
apr_table_t *metadata;
+ mapcache_image_format_type type;
};
/**\defgroup imageio_png PNG Image IO
Modified: trunk/mapserver/mapcache/src/cache_disk.c
===================================================================
--- trunk/mapserver/mapcache/src/cache_disk.c 2011-10-14 13:17:39 UTC (rev 12663)
+++ trunk/mapserver/mapcache/src/cache_disk.c 2011-10-14 15:33:26 UTC (rev 12664)
@@ -421,7 +421,7 @@
/**
* \private \memberof mapcache_cache_disk
*/
-static void _mapcache_cache_disk_configuration_parse_xml(mapcache_context *ctx, ezxml_t node, mapcache_cache *cache) {
+static void _mapcache_cache_disk_configuration_parse_xml(mapcache_context *ctx, ezxml_t node, mapcache_cache *cache, mapcache_cfg *config) {
ezxml_t cur_node;
mapcache_cache_disk *dcache = (mapcache_cache_disk*)cache;
Modified: trunk/mapserver/mapcache/src/cache_memcache.c
===================================================================
--- trunk/mapserver/mapcache/src/cache_memcache.c 2011-10-14 13:17:39 UTC (rev 12663)
+++ trunk/mapserver/mapcache/src/cache_memcache.c 2011-10-14 15:33:26 UTC (rev 12664)
@@ -68,6 +68,10 @@
if(!*path) {
ctx->set_error(ctx,500, "failed to allocate tile key");
}
+#ifdef DEBUG
+ ctx->log(ctx,MAPCACHE_DEBUG,"memcache key is %s (length:%d)",
+ *path,strlen(*path));
+#endif
}
@@ -178,7 +182,7 @@
/**
* \private \memberof mapcache_cache_memcache
*/
-static void _mapcache_cache_memcache_configuration_parse_xml(mapcache_context *ctx, ezxml_t node, mapcache_cache *cache) {
+static void _mapcache_cache_memcache_configuration_parse_xml(mapcache_context *ctx, ezxml_t node, mapcache_cache *cache, mapcache_cfg *config) {
ezxml_t cur_node;
mapcache_cache_memcache *dcache = (mapcache_cache_memcache*)cache;
int servercount = 0;
Modified: trunk/mapserver/mapcache/src/cache_sqlite.c
===================================================================
--- trunk/mapserver/mapcache/src/cache_sqlite.c 2011-10-14 13:17:39 UTC (rev 12663)
+++ trunk/mapserver/mapcache/src/cache_sqlite.c 2011-10-14 15:33:26 UTC (rev 12664)
@@ -256,7 +256,7 @@
}
-static void _mapcache_cache_sqlite_configuration_parse_xml(mapcache_context *ctx, ezxml_t node, mapcache_cache *cache) {
+static void _mapcache_cache_sqlite_configuration_parse_xml(mapcache_context *ctx, ezxml_t node, mapcache_cache *cache, mapcache_cfg *config) {
ezxml_t cur_node;
sqlite3_initialize();
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
Modified: trunk/mapserver/mapcache/src/cache_tiff.c
===================================================================
--- trunk/mapserver/mapcache/src/cache_tiff.c 2011-10-14 13:17:39 UTC (rev 12663)
+++ trunk/mapserver/mapcache/src/cache_tiff.c 2011-10-14 15:33:26 UTC (rev 12664)
@@ -640,6 +640,9 @@
GTIFFree( psGTIF );
#endif
}
+ mapcache_image_format_jpeg *format = (mapcache_image_format_jpeg*) dcache->format;
+ TIFFSetField(hTIFF, TIFFTAG_JPEGQUALITY, format->quality);
+
int tiff_offx, tiff_offy; /* the x and y offset of the tile inside the tiff image */
int tiff_off; /* the index of the tile inside the list of tiles of the tiff image */
@@ -698,7 +701,7 @@
/**
* \private \memberof mapcache_cache_tiff
*/
-static void _mapcache_cache_tiff_configuration_parse_xml(mapcache_context *ctx, ezxml_t node, mapcache_cache *cache) {
+static void _mapcache_cache_tiff_configuration_parse_xml(mapcache_context *ctx, ezxml_t node, mapcache_cache *cache, mapcache_cfg *config) {
ezxml_t cur_node;
mapcache_cache_tiff *dcache = (mapcache_cache_tiff*)cache;
@@ -723,24 +726,27 @@
return;
}
}
-}
-
-/**
- * \private \memberof mapcache_cache_tiff
- */
-static void _mapcache_cache_tiff_configuration_post_config(mapcache_context *ctx, mapcache_cache *cache,
- mapcache_cfg *cfg) {
- mapcache_cache_tiff *dcache = (mapcache_cache_tiff*)cache;
- /* check all required parameters are configured */
- if((!dcache->filename_template || !strlen(dcache->filename_template))) {
- ctx->set_error(ctx, 400, "tiff cache %s has no template pattern",dcache->cache.name);
+ ezxml_t xformat = ezxml_child(node,"format");
+ char * format_name;
+ if(xformat && xformat->txt && *xformat->txt) {
+ format_name = xformat->txt;
+ } else {
+ format_name = "JPEG";
+ }
+ mapcache_image_format *pformat = mapcache_configuration_get_image_format(
+ config,format_name);
+ if(!pformat) {
+ ctx->set_error(ctx,500,"TIFF cache %s references unknown image format %s",
+ cache->name, format_name);
return;
}
- if(dcache->count_x <= 0 || dcache->count_y <= 0) {
- ctx->set_error(ctx, 400, "tiff cache %s has invalid count (%d,%d)",dcache->count_x,dcache->count_y);
+ if(pformat->type != GC_JPEG) {
+ ctx->set_error(ctx,500,"TIFF cache %s can only reference a JPEG image format",
+ cache->name);
return;
}
-
+ dcache->format = (mapcache_image_format_jpeg*)pformat;
+
#ifdef USE_TIFF_WRITE
#if APR_HAS_THREADS
if(ctx->has_threads) {
@@ -757,6 +763,23 @@
}
/**
+ * \private \memberof mapcache_cache_tiff
+ */
+static void _mapcache_cache_tiff_configuration_post_config(mapcache_context *ctx, mapcache_cache *cache,
+ mapcache_cfg *cfg) {
+ mapcache_cache_tiff *dcache = (mapcache_cache_tiff*)cache;
+ /* check all required parameters are configured */
+ if((!dcache->filename_template || !strlen(dcache->filename_template))) {
+ ctx->set_error(ctx, 400, "tiff cache %s has no template pattern",dcache->cache.name);
+ return;
+ }
+ if(dcache->count_x <= 0 || dcache->count_y <= 0) {
+ ctx->set_error(ctx, 400, "tiff cache %s has invalid count (%d,%d)",dcache->count_x,dcache->count_y);
+ return;
+ }
+}
+
+/**
* \brief creates and initializes a mapcache_tiff_cache
*/
mapcache_cache* mapcache_cache_tiff_create(mapcache_context *ctx) {
Modified: trunk/mapserver/mapcache/src/configuration_xml.c
===================================================================
--- trunk/mapserver/mapcache/src/configuration_xml.c 2011-10-14 13:17:39 UTC (rev 12663)
+++ trunk/mapserver/mapcache/src/configuration_xml.c 2011-10-14 15:33:26 UTC (rev 12664)
@@ -450,7 +450,7 @@
}
cache->name = name;
- cache->configuration_parse_xml(ctx,node,cache);
+ cache->configuration_parse_xml(ctx,node,cache,config);
GC_CHECK_ERROR(ctx);
mapcache_configuration_add_cache(config,cache,name);
return;
Modified: trunk/mapserver/mapcache/src/imageio_jpeg.c
===================================================================
--- trunk/mapserver/mapcache/src/imageio_jpeg.c 2011-10-14 13:17:39 UTC (rev 12663)
+++ trunk/mapserver/mapcache/src/imageio_jpeg.c 2011-10-14 15:33:26 UTC (rev 12664)
@@ -313,6 +313,7 @@
format->format.create_empty_image = _mapcache_imageio_jpg_create_empty;
format->format.write = _mapcache_imageio_jpeg_encode;
format->quality = quality;
+ format->format.type = GC_JPEG;
return (mapcache_image_format*)format;
}
Modified: trunk/mapserver/mapcache/src/imageio_png.c
===================================================================
--- trunk/mapserver/mapcache/src/imageio_png.c 2011-10-14 13:17:39 UTC (rev 12663)
+++ trunk/mapserver/mapcache/src/imageio_png.c 2011-10-14 15:33:26 UTC (rev 12664)
@@ -1233,6 +1233,7 @@
format->format.metadata = apr_table_make(pool,3);
format->format.write = _mapcache_imageio_png_encode;
format->format.create_empty_image = _mapcache_imageio_png_create_empty;
+ format->format.type = GC_PNG;
return (mapcache_image_format*)format;
}
@@ -1246,6 +1247,7 @@
format->format.format.create_empty_image = _mapcache_imageio_png_create_empty;
format->format.format.metadata = apr_table_make(pool,3);
format->ncolors = ncolors;
+ format->format.format.type = GC_PNG;
return (mapcache_image_format*)format;
}
More information about the mapserver-commits
mailing list