** msWMSGetMap() */
| 2813 | ** msWMSGetMap() |
| 2814 | */ |
| 2815 | int msWMSGetMap(mapObj *map, int nVersion, char **names, char **values, int numentries, |
| 2816 | char *wms_exception_format, owsRequestObj *ows_request) |
| 2817 | { |
| 2818 | imageObj *img; |
| 2819 | int i = 0; |
| 2820 | int sldrequested = MS_FALSE, sldspatialfilter = MS_FALSE; |
| 2821 | const char *http_max_age; |
| 2822 | |
| 2823 | /* __TODO__ msDrawMap() will try to adjust the extent of the map */ |
| 2824 | /* to match the width/height image ratio. */ |
| 2825 | /* The spec states that this should not happen so that we can deliver */ |
| 2826 | /* maps to devices with non-square pixels. */ |
| 2827 | |
| 2828 | |
| 2829 | /* If there was an SLD in the request, we need to treat it */ |
| 2830 | /* diffrently : some SLD may contain spatial filters requiring */ |
| 2831 | /* to do a query. While parsing the SLD and applying it to the */ |
| 2832 | /* layer, we added a temporary metadata on the layer */ |
| 2833 | /* (tmp_wms_sld_query) for layers with a spatial filter. */ |
| 2834 | |
| 2835 | for (i=0; i<numentries; i++) |
| 2836 | { |
| 2837 | if ((strcasecmp(names[i], "SLD") == 0 && values[i] && strlen(values[i]) > 0) || |
| 2838 | (strcasecmp(names[i], "SLD_BODY") == 0 && values[i] && strlen(values[i]) > 0)) |
| 2839 | { |
| 2840 | sldrequested = MS_TRUE; |
| 2841 | break; |
| 2842 | } |
| 2843 | } |
| 2844 | if (sldrequested) |
| 2845 | { |
| 2846 | for (i=0; i<map->numlayers; i++) |
| 2847 | { |
| 2848 | if (msLookupHashTable(&(GET_LAYER(map, i)->metadata), "tmp_wms_sld_query")) |
| 2849 | { |
| 2850 | sldspatialfilter = MS_TRUE; |
| 2851 | break; |
| 2852 | } |
| 2853 | } |
| 2854 | } |
| 2855 | |
| 2856 | /* turn off layer if WMS GetMap is not enabled */ |
| 2857 | for (i=0; i<map->numlayers; i++) |
| 2858 | if (!msIntegerInArray(GET_LAYER(map, i)->index, ows_request->enabled_layers, ows_request->numlayers)) |
| 2859 | GET_LAYER(map, i)->status = MS_OFF; |
| 2860 | |
| 2861 | if (sldrequested && sldspatialfilter) |
| 2862 | { |
| 2863 | /* set the quermap style so that only selected features will be retruned */ |
| 2864 | map->querymap.status = MS_ON; |
| 2865 | map->querymap.style = MS_SELECTED; |
| 2866 | |
| 2867 | img = msPrepareImage(map, MS_TRUE); |
| 2868 | |
| 2869 | /* compute layer scale factors now */ |
| 2870 | for(i=0;i<map->numlayers; i++) { |
| 2871 | if(GET_LAYER(map, i)->sizeunits != MS_PIXELS) |
| 2872 | GET_LAYER(map, i)->scalefactor = (msInchesPerUnit(GET_LAYER(map, i)->sizeunits,0)/msInchesPerUnit(map->units,0)) / map->cellsize; |
no test coverage detected