Permalink
Browse files

Fix for embedding legend and scalebar if pixel buffer is not supporte…

…d with the selected output format (#4618)
  • Loading branch information...
1 parent 551d5f4 commit bd86c2c34befdb510827879f81dfbec18b5254b9 @szekerest szekerest committed Mar 28, 2013
Showing with 37 additions and 11 deletions.
  1. +17 −6 maplegend.c
  2. +20 −5 mapscale.c
View
@@ -632,15 +632,10 @@ int msEmbedLegend(mapObj *map, imageObj *img)
pointObj point;
imageObj *image = NULL;
symbolObj *legendSymbol;
+ char* imageType = NULL;
rendererVTableObj *renderer;
- if(!MS_RENDERER_PLUGIN(map->outputformat) || !MS_MAP_RENDERER(map)->supports_pixel_buffer) {
- msSetError(MS_MISCERR, "unsupported output format", "msEmbedLegend()");
- return MS_FAILURE;
- }
- renderer = MS_MAP_RENDERER(map);
-
s = msGetSymbolIndex(&(map->symbolset), "legend", MS_FALSE);
if(s != -1)
msRemoveSymbol(&(map->symbolset), s); /* solves some caching issues in AGG with long-running processes */
@@ -652,10 +647,26 @@ int msEmbedLegend(mapObj *map, imageObj *img)
map->symbolset.numsymbols++;
initSymbol(legendSymbol);
+ if(!MS_RENDERER_PLUGIN(map->outputformat) || !MS_MAP_RENDERER(map)->supports_pixel_buffer) {
+ imageType = msStrdup(map->imagetype); /* save format */
+ if MS_DRIVER_CAIRO(map->outputformat)
+ map->outputformat = msSelectOutputFormat( map, "cairopng" );
+ else
+ map->outputformat = msSelectOutputFormat( map, "png" );
+
+ msInitializeRendererVTable(map->outputformat);
+ }
+ renderer = MS_MAP_RENDERER(map);
+
/* render the legend. */
image = msDrawLegend(map, MS_FALSE);
if( image == NULL ) return -1;
+ if (imageType) {
+ map->outputformat = msSelectOutputFormat( map, imageType ); /* restore format */
+ msFree(imageType);
+ }
+
/* copy renderered legend image into symbol */
legendSymbol->pixmap_buffer = calloc(1,sizeof(rasterBufferObj));
MS_CHECK_ALLOC(legendSymbol->pixmap_buffer, sizeof(rasterBufferObj), MS_FAILURE);
View
@@ -339,24 +339,39 @@ int msEmbedScalebar(mapObj *map, imageObj *img)
int l,index,s;
pointObj point;
imageObj *image = NULL;
- rendererVTableObj *renderer = MS_MAP_RENDERER(map);
+ rendererVTableObj *renderer;
symbolObj *embededSymbol;
+ char* imageType = NULL;
- if( ! renderer ) {
- msSetError(MS_MISCERR,"unsupported outputformat","msEmbedScalebar()");
- return MS_FAILURE;
- }
index = msGetSymbolIndex(&(map->symbolset), "scalebar", MS_FALSE);
if(index != -1)
msRemoveSymbol(&(map->symbolset), index); /* remove cached symbol in case the function is called multiple
times with different zoom levels */
if((embededSymbol=msGrowSymbolSet(&map->symbolset)) == NULL)
return MS_FAILURE;
+
s = map->symbolset.numsymbols;
map->symbolset.numsymbols++;
+ if(!MS_RENDERER_PLUGIN(map->outputformat) || !MS_MAP_RENDERER(map)->supports_pixel_buffer) {
+ imageType = msStrdup(map->imagetype); /* save format */
+ if MS_DRIVER_CAIRO(map->outputformat)
+ map->outputformat = msSelectOutputFormat( map, "cairopng" );
+ else
+ map->outputformat = msSelectOutputFormat( map, "png" );
+
+ msInitializeRendererVTable(map->outputformat);
+ }
+ renderer = MS_MAP_RENDERER(map);
+
image = msDrawScalebar(map);
+
+ if (imageType) {
+ map->outputformat = msSelectOutputFormat( map, imageType ); /* restore format */
+ msFree(imageType);
+ }
+
if(!image) {
return MS_FAILURE;
}

0 comments on commit bd86c2c

Please sign in to comment.