* Generic function to render a layer object. */
| 662 | * Generic function to render a layer object. |
| 663 | */ |
| 664 | int msDrawLayer(mapObj *map, layerObj *layer, imageObj *image) |
| 665 | { |
| 666 | imageObj *image_draw = image; |
| 667 | outputFormatObj *altFormat=NULL; |
| 668 | int retcode=MS_SUCCESS; |
| 669 | int originalopacity = layer->opacity; |
| 670 | const char *alternativeFomatString = NULL; |
| 671 | |
| 672 | if(!msLayerIsVisible(map, layer)) |
| 673 | return MS_SUCCESS; |
| 674 | |
| 675 | if(layer->opacity == 0) return MS_SUCCESS; /* layer is completely transparent, skip it */ |
| 676 | |
| 677 | /* conditions may have changed since this layer last drawn, so set |
| 678 | layer->project true to recheck projection needs (Bug #673) */ |
| 679 | layer->project = MS_TRUE; |
| 680 | |
| 681 | /* inform the rendering device that layer draw is starting. */ |
| 682 | msImageStartLayer(map, layer, image); |
| 683 | |
| 684 | /*check if an alternative renderer should be used for this layer*/ |
| 685 | alternativeFomatString = msLayerGetProcessingKey( layer, "RENDERER"); |
| 686 | if (MS_RENDERER_PLUGIN(image_draw->format) && alternativeFomatString!=NULL && |
| 687 | (altFormat= msSelectOutputFormat(map, alternativeFomatString))) |
| 688 | { |
| 689 | rendererVTableObj *renderer=NULL; |
| 690 | msInitializeRendererVTable(altFormat); |
| 691 | |
| 692 | image_draw = msImageCreate(image->width, image->height, |
| 693 | altFormat, image->imagepath, image->imageurl, map->resolution, map->defresolution, &map->imagecolor); |
| 694 | renderer = MS_IMAGE_RENDERER(image_draw); |
| 695 | renderer->startLayer(image_draw,map,layer); |
| 696 | } |
| 697 | else if (MS_RENDERER_PLUGIN(image_draw->format)) { |
| 698 | rendererVTableObj *renderer = MS_IMAGE_RENDERER(image_draw); |
| 699 | if (layer->opacity > 0 && layer->opacity < 100) { |
| 700 | if (!renderer->supports_transparent_layers) { |
| 701 | image_draw = msImageCreate(image->width, image->height, |
| 702 | image->format, image->imagepath, image->imageurl, map->resolution, map->defresolution, NULL); |
| 703 | if (!image_draw) { |
| 704 | msSetError(MS_MISCERR, "Unable to initialize temporary transparent image.", |
| 705 | "msDrawLayer()"); |
| 706 | return (MS_FAILURE); |
| 707 | } |
| 708 | /* set opacity to full, as the renderer should be rendering a fully opaque image */ |
| 709 | layer->opacity=100; |
| 710 | renderer->startLayer(image_draw,map,layer); |
| 711 | } |
| 712 | } |
| 713 | } |
| 714 | /* |
| 715 | ** redirect procesing of some layer types. |
| 716 | */ |
| 717 | if(layer->connectiontype == MS_WMS) { |
| 718 | #ifdef USE_WMS_LYR |
| 719 | retcode = msDrawWMSLayer(map, layer, image_draw); |
| 720 | #else |
| 721 | retcode = MS_FAILURE; |
no test coverage detected