Skip to content

Commit

Permalink
WCS 1.1 and 2.0: fix support of netCDF output (complementary fix to r…
Browse files Browse the repository at this point in the history
…efs #5968)
  • Loading branch information
github-actions[bot] committed Sep 4, 2020
1 parent 7aba93d commit 4da50ee
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 10 deletions.
18 changes: 13 additions & 5 deletions mapgdal.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "mapserver.h"
#include "mapthread.h"
#include "mapgdal.h"
#include <assert.h>


Expand Down Expand Up @@ -184,11 +185,7 @@ int msSaveImageGDAL( mapObj *map, imageObj *image, const char *filenameIn )
pszExtension = "img.tmp";

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") ) {
msGDALDriverSupportsVirtualIOOutput(hOutputDriver) ) {
msCleanVSIDir( "/vsimem/msout" );
filenameToFree = msTmpFile(map, NULL, "/vsimem/msout/", pszExtension );
}
Expand Down Expand Up @@ -653,4 +650,15 @@ char *msProjectionObj2OGCWKT( projectionObj *projection )
return NULL;
}

/************************************************************************/
/* msGDALDriverSupportsVirtualIOOutput() */
/************************************************************************/

int msGDALDriverSupportsVirtualIOOutput( GDALDriverH hDriver )
{
/* 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. */
return GDALGetMetadataItem( hDriver, GDAL_DCAP_VIRTUALIO, NULL ) != NULL &&
!EQUAL(GDALGetDescription(hDriver), "netCDF");
}
46 changes: 46 additions & 0 deletions mapgdal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/******************************************************************************
* $Id$
*
* Project: MapServer
* Purpose: GDAL interface
* Author: Even Rouault <even.rouault at spatialys.com>
*
******************************************************************************
* Copyright (c) 2020, Even Rouault <even.rouault at spatialys.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies of this Software or works derived from this Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/

#ifndef MAPGDAL_H
#define MAPGDAL_H

#include "mapserver.h"
#include "gdal.h"

#ifdef __cplusplus
extern "C" {
#endif

int msGDALDriverSupportsVirtualIOOutput( GDALDriverH hDriver );

#ifdef __cplusplus
}
#endif

#endif /* MAPGDAL_H */
5 changes: 2 additions & 3 deletions mapwcs11.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "mapthread.h"
#include "mapows.h"
#include "mapwcs.h"

#include "mapgdal.h"


#if defined(USE_WCS_SVR)
Expand Down Expand Up @@ -1188,8 +1188,7 @@ int msWCSReturnCoverage11( wcsParamsObj *params, mapObj *map,
if( pszExtension == NULL )
pszExtension = "img.tmp";

if( GDALGetMetadataItem( hDriver, GDAL_DCAP_VIRTUALIO, NULL )
!= NULL ) {
if( msGDALDriverSupportsVirtualIOOutput(hDriver) ) {
base_dir = msTmpFile(map, map->mappath, "/vsimem/wcsout", NULL);
if( fo_filename )
filename = msStrdup(CPLFormFilename(base_dir,
Expand Down
4 changes: 2 additions & 2 deletions mapwcs20.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "mapthread.h"
#include "mapows.h"
#include "mapwcs.h"
#include "mapgdal.h"
#include <float.h>
#include "gdal.h"
#include "cpl_port.h"
Expand Down Expand Up @@ -2328,8 +2329,7 @@ static int msWCSWriteFile20(mapObj* map, imageObj* image, wcs20ParamsObjPtr para
if( pszExtension == NULL )
pszExtension = "img.tmp";

if( GDALGetMetadataItem( hDriver, GDAL_DCAP_VIRTUALIO, NULL )
!= NULL ) {
if( msGDALDriverSupportsVirtualIOOutput(hDriver) ) {
base_dir = msTmpFile(map, map->mappath, "/vsimem/wcsout", NULL);
if( fo_filename )
filename = msStrdup(CPLFormFilename(base_dir,
Expand Down

0 comments on commit 4da50ee

Please sign in to comment.