| 228 | } |
| 229 | |
| 230 | int msReturnTemplateQuery(mapservObj *mapserv, char *queryFormat, char **papszBuffer) |
| 231 | { |
| 232 | imageObj *img = NULL; |
| 233 | int i, status; |
| 234 | |
| 235 | outputFormatObj *outputFormat=NULL; |
| 236 | mapObj *map = mapserv->map; |
| 237 | |
| 238 | if(!queryFormat) { |
| 239 | msSetError(MS_WEBERR, "Return format/mime-type not specified.", "msReturnTemplateQuery()"); |
| 240 | return MS_FAILURE; |
| 241 | } |
| 242 | |
| 243 | msApplyDefaultOutputFormats(map); |
| 244 | |
| 245 | i = msGetOutputFormatIndex(map, queryFormat); /* queryFormat can be a mime-type or name */ |
| 246 | if(i >= 0) outputFormat = map->outputformatlist[i]; |
| 247 | |
| 248 | if(outputFormat) { |
| 249 | if( MS_RENDERER_PLUGIN(outputFormat) ) { |
| 250 | msInitializeRendererVTable(outputFormat); |
| 251 | } |
| 252 | |
| 253 | if( MS_RENDERER_OGR(outputFormat) ) |
| 254 | { |
| 255 | if( mapserv != NULL ) |
| 256 | checkWebScale(mapserv); |
| 257 | |
| 258 | status = msOGRWriteFromQuery(map, outputFormat, mapserv->sendheaders); |
| 259 | |
| 260 | return status; |
| 261 | } |
| 262 | |
| 263 | if( !MS_RENDERER_TEMPLATE(outputFormat) ) { /* got an image format, return the query results that way */ |
| 264 | outputFormatObj *tempOutputFormat = map->outputformat; /* save format */ |
| 265 | |
| 266 | if( mapserv != NULL ) |
| 267 | checkWebScale(mapserv); |
| 268 | |
| 269 | map->outputformat = outputFormat; /* override what was given for IMAGETYPE */ |
| 270 | img = msDrawMap(map, MS_TRUE); |
| 271 | if(!img) return MS_FAILURE; |
| 272 | map->outputformat = tempOutputFormat; /* restore format */ |
| 273 | |
| 274 | if(mapserv == NULL || mapserv->sendheaders) |
| 275 | msIO_printf("Content-type: %s%c%c", MS_IMAGE_MIME_TYPE(outputFormat), 10,10); |
| 276 | status = msSaveImage(map, img, NULL); |
| 277 | msFreeImage(img); |
| 278 | |
| 279 | return status; |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | /* |
| 284 | ** At this point we know we have a template of some sort, either the new style that references a or the old |
| 285 | ** style made up of external files slammed together. Either way we may have to compute a query map and other |
| 286 | ** images. We only create support images IF the querymap has status=MS_ON. |
| 287 | */ |
no test coverage detected