@@ -77,7 +77,6 @@ mapcache_http_response *mapcache_http_response_create(apr_pool_t *pool)
7777
7878void mapcache_prefetch_tiles (mapcache_context * ctx , mapcache_tile * * tiles , int ntiles )
7979{
80-
8180 apr_thread_t * * threads ;
8281 apr_threadattr_t * thread_attrs ;
8382 int nthreads ;
@@ -99,7 +98,6 @@ void mapcache_prefetch_tiles(mapcache_context *ctx, mapcache_tile **tiles, int n
9998 return ;
10099 }
101100
102-
103101 /* allocate a thread struct for each tile. Not all will be used */
104102 thread_tiles = (_thread_tile * )apr_pcalloc (ctx -> pool ,ntiles * sizeof (_thread_tile ));
105103#if 1 || !USE_THREADPOOL
@@ -205,7 +203,7 @@ mapcache_http_response *mapcache_core_get_tile(mapcache_context *ctx, mapcache_r
205203 format = NULL ;
206204
207205#ifdef DEBUG
208- if (req_tile -> ntiles == 0 ) {
206+ if (req_tile -> ntiles == 0 ) {
209207 ctx -> set_error (ctx ,500 ,"BUG: get_tile called with 0 tiles" );
210208 return NULL ;
211209 }
@@ -216,7 +214,6 @@ mapcache_http_response *mapcache_core_get_tile(mapcache_context *ctx, mapcache_r
216214 req_tile -> tiles [0 ]-> allow_redirect = 1 ;
217215 }
218216
219-
220217 mapcache_prefetch_tiles (ctx ,req_tile -> tiles ,req_tile -> ntiles );
221218 if (GC_HAS_ERROR (ctx ))
222219 return NULL ;
@@ -295,7 +292,7 @@ mapcache_http_response *mapcache_core_get_tile(mapcache_context *ctx, mapcache_r
295292 }
296293
297294 if (!response -> data ) {
298- /* we need to encode the raw image data*/
295+ /* we need to encode the raw image data */
299296 if (base ) {
300297 if (req_tile -> image_request .format ) {
301298 format = req_tile -> image_request .format ;
@@ -320,14 +317,28 @@ mapcache_http_response *mapcache_core_get_tile(mapcache_context *ctx, mapcache_r
320317 response -> data = mapcache_empty_png_decode (ctx ,req_tile -> tiles [0 ]-> grid_link -> grid -> tile_sx , req_tile -> tiles [0 ]-> grid_link -> grid -> tile_sy , empty ,& is_empty ); /* is_empty is unchanged and left to 1 */
321318 format = mapcache_configuration_get_image_format (ctx -> config ,"PNG8" );
322319 }
320+ } else {
321+ /* set format, not an image type (e.g. GC_RAW) */
322+ if (req_tile -> image_request .format ) {
323+ format = req_tile -> image_request .format ;
324+ } else {
325+ format = req_tile -> tiles [0 ]-> tileset -> format ;
326+ if (!format ) {
327+ format = ctx -> config -> default_image_format ; /* this one is always defined */
328+ }
329+ }
323330 }
324331
325332 /* compute the content-type */
326- t = mapcache_imageio_header_sniff (ctx ,response -> data );
327- if (t == GC_PNG )
328- apr_table_set (response -> headers ,"Content-Type" ,"image/png" );
329- else if (t == GC_JPEG )
330- apr_table_set (response -> headers ,"Content-Type" ,"image/jpeg" );
333+ if (format && format -> type == GC_RAW ) {
334+ apr_table_set (response -> headers ,"Content-Type" ,format -> mime_type );
335+ } else {
336+ t = mapcache_imageio_header_sniff (ctx ,response -> data );
337+ if (t == GC_PNG )
338+ apr_table_set (response -> headers ,"Content-Type" ,"image/png" );
339+ else if (t == GC_JPEG )
340+ apr_table_set (response -> headers ,"Content-Type" ,"image/jpeg" );
341+ }
331342
332343 /* compute expiry headers */
333344 if (expires ) {
@@ -428,14 +439,14 @@ mapcache_http_response *mapcache_core_get_map(mapcache_context *ctx, mapcache_re
428439 mapcache_http_response * response ;
429440 mapcache_map * basemap = NULL ;
430441 char * timestr ;
442+
431443#ifdef DEBUG
432444 if (req_map -> nmaps == 0 ) {
433445 ctx -> set_error (ctx ,500 ,"BUG: get_map called with 0 maps" );
434446 return NULL ;
435447 }
436448#endif
437449
438-
439450 if (req_map -> getmap_strategy == MAPCACHE_GETMAP_ERROR ) {
440451 ctx -> set_error (ctx , 404 , "full wms support disabled" );
441452 return NULL ;
@@ -444,7 +455,6 @@ mapcache_http_response *mapcache_core_get_map(mapcache_context *ctx, mapcache_re
444455 format = NULL ;
445456 response = mapcache_http_response_create (ctx -> pool );
446457
447-
448458 if (req_map -> getmap_strategy == MAPCACHE_GETMAP_ASSEMBLE ) {
449459 basemap = mapcache_assemble_maps (ctx , req_map -> maps , req_map -> nmaps , req_map -> resample_mode );
450460 if (GC_HAS_ERROR (ctx )) return NULL ;
0 commit comments