Skip to content

Commit

Permalink
WCS output / msSaveImageGDAL(): fix support of netCDF output (#5968)
Browse files Browse the repository at this point in the history
Fixes #5968
Derived from suggestion by @constantinius
  • Loading branch information
rouault committed Jan 17, 2020
1 parent 7389db7 commit f7482ad
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions mapgdal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;
}

Expand All @@ -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 );
}
Expand Down

0 comments on commit f7482ad

Please sign in to comment.