Skip to content
Permalink
Browse files
WCS output / msSaveImageGDAL(): fix support of netCDF output (#5968)
Fixes #5968
Derived from suggestion by @constantinius
  • Loading branch information
rouault committed Jan 17, 2020
1 parent 006d4ba commit a3166a82f76878b15bc4fb1c855f894039c2a583
Showing 1 changed file with 9 additions and 4 deletions.
@@ -155,6 +155,7 @@ int msSaveImageGDAL( mapObj *map, imageObj *image, const char *filenameIn )
int bUseXmp = MS_FALSE;
const char *filename = NULL;
char *filenameToFree = NULL;
const char *gdal_driver_shortname = format->driver+5;

msGDALInitialize();
memset(&rb,0,sizeof(rasterBufferObj));
@@ -170,11 +171,11 @@ int msSaveImageGDAL( mapObj *map, imageObj *image, const char *filenameIn )
/* Identify the proposed output driver. */
/* -------------------------------------------------------------------- */
msAcquireLock( TLOCK_GDAL );
hOutputDriver = GDALGetDriverByName( format->driver+5 );
hOutputDriver = GDALGetDriverByName( gdal_driver_shortname );
if( hOutputDriver == NULL ) {
msReleaseLock( TLOCK_GDAL );
msSetError( MS_MISCERR, "Failed to find %s driver.",
"msSaveImageGDAL()", format->driver+5 );
"msSaveImageGDAL()", gdal_driver_shortname );
return MS_FAILURE;
}

@@ -190,8 +191,12 @@ int msSaveImageGDAL( mapObj *map, imageObj *image, const char *filenameIn )
if( pszExtension == NULL )
pszExtension = "img.tmp";

if( bUseXmp == MS_FALSE && GDALGetMetadataItem( hOutputDriver, GDAL_DCAP_VIRTUALIO, NULL )
!= NULL ) {
if( bUseXmp == MS_FALSE &&
GDALGetMetadataItem( hOutputDriver, GDAL_DCAP_VIRTUALIO, NULL ) != NULL &&
/* We need special testing here for the netCDF driver, since recent */
/* GDAL versions advertize VirtualIO support, but this is only for the */
/* read-side of the driver, not the write-side. */
!EQUAL(gdal_driver_shortname, "netCDF") ) {
msCleanVSIDir( "/vsimem/msout" );
filenameToFree = msTmpFile(map, NULL, "/vsimem/msout/", pszExtension );
}

0 comments on commit a3166a8

Please sign in to comment.