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
  • Loading branch information
rouault committed Sep 4, 2020
1 parent 5707957 commit 6bd9301
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 10 deletions.
20 changes: 15 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 @@ -192,11 +193,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 @@ -651,4 +648,17 @@ char *msProjectionObj2OGCWKT( projectionObj *projection )
#endif /* defined USE_GDAL or USE_OGR */
}

#ifdef USE_GDAL
/************************************************************************/
/* 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");
}
#endif
50 changes: 50 additions & 0 deletions mapgdal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/******************************************************************************
* $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

#ifdef USE_GDAL

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

#ifdef __cplusplus
extern "C" {
#endif

int msGDALDriverSupportsVirtualIOOutput( GDALDriverH hDriver );

#ifdef __cplusplus
}
#endif

#endif /* USE_GDAL */

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



#if defined(USE_WCS_SVR)
#include "mapwcs.h"
#include "gdal.h"
#include "cpl_string.h" /* GDAL string handling */
#include "mapgdal.h"
#endif

#if defined(USE_LIBXML2)
Expand Down Expand Up @@ -1187,8 +1187,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 @@ -2329,8 +2330,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 6bd9301

Please sign in to comment.