| 446 | /************************************************************************/ |
| 447 | |
| 448 | int msOGRWriteFromQuery( mapObj *map, outputFormatObj *format, int sendheaders ) |
| 449 | |
| 450 | { |
| 451 | #ifndef USE_OGR |
| 452 | msSetError(MS_OGRERR, "OGR support is not available.", |
| 453 | "msOGRWriteFromQuery()"); |
| 454 | return MS_FAILURE; |
| 455 | #else |
| 456 | /* -------------------------------------------------------------------- */ |
| 457 | /* Variable declarations. */ |
| 458 | /* -------------------------------------------------------------------- */ |
| 459 | OGRSFDriverH hDriver; |
| 460 | OGRDataSourceH hDS; |
| 461 | const char *storage; |
| 462 | const char *fo_filename; |
| 463 | const char *form; |
| 464 | char datasource_name[MS_MAXPATHLEN]; |
| 465 | char base_dir[MS_MAXPATHLEN]; |
| 466 | char *request_dir = NULL; |
| 467 | char **ds_options = NULL; |
| 468 | char **layer_options = NULL; |
| 469 | char **file_list = NULL; |
| 470 | int iLayer, i; |
| 471 | |
| 472 | /* -------------------------------------------------------------------- */ |
| 473 | /* Fetch the output format driver. */ |
| 474 | /* -------------------------------------------------------------------- */ |
| 475 | msOGRInitialize(); |
| 476 | |
| 477 | hDriver = OGRGetDriverByName( format->driver+4 ); |
| 478 | if( hDriver == NULL ) |
| 479 | { |
| 480 | msSetError( MS_MISCERR, "No OGR driver named `%s' available.", |
| 481 | "msOGRWriteFromQuery()", format->driver+4 ); |
| 482 | return MS_FAILURE; |
| 483 | } |
| 484 | |
| 485 | /* -------------------------------------------------------------------- */ |
| 486 | /* Capture datasource and layer creation options. */ |
| 487 | /* -------------------------------------------------------------------- */ |
| 488 | for( i=0; i < format->numformatoptions; i++ ) |
| 489 | { |
| 490 | if( strncasecmp(format->formatoptions[i],"LCO:",4) == 0 ) |
| 491 | layer_options = CSLAddString( layer_options, |
| 492 | format->formatoptions[i] + 4 ); |
| 493 | if( strncasecmp(format->formatoptions[i],"DSCO:",5) == 0 ) |
| 494 | ds_options = CSLAddString( ds_options, |
| 495 | format->formatoptions[i] + 5 ); |
| 496 | } |
| 497 | |
| 498 | /* ==================================================================== */ |
| 499 | /* Determine the output datasource name to use. */ |
| 500 | /* ==================================================================== */ |
| 501 | storage = msGetOutputFormatOption( format, "STORAGE", "filesystem" ); |
| 502 | |
| 503 | /* -------------------------------------------------------------------- */ |
| 504 | /* Where are we putting stuff? */ |
| 505 | /* -------------------------------------------------------------------- */ |
no test coverage detected