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 7389db7 commit f7482add5ef144e1d262eb5380671a397d8a3968
Showing 1 changed file with 9 additions and 4 deletions.
@@ -147,6 +147,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));
@@ -162,11 +163,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;
}

@@ -182,8 +183,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 f7482ad

Please sign in to comment.