Commit 9f5c5917 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

gribapiGetDiskRepresentation: Wrong result with SZIP compressed GRIB records [Bug #7650].

parent dfd0b4bc
2017-05-?? Uwe Schulzweida
* Version 1.8.2 released
2017-04-21 Uwe Schulzweida
* gribapiGetDiskRepresentation: Wrong result with SZIP compressed GRIB records [Bug #7650]
2017-04-13 Uwe Schulzweida 2017-04-13 Uwe Schulzweida
* Version 1.8.1 released * Version 1.8.1 released
......
...@@ -723,10 +723,26 @@ void ensureBufferSize(size_t requiredSize, size_t *curSize, void **buffer) ...@@ -723,10 +723,26 @@ void ensureBufferSize(size_t requiredSize, size_t *curSize, void **buffer)
static static
grib_handle *gribapiGetDiskRepresentation(size_t recsize, size_t *buffersize, void **gribbuffer, int *outDatatype, int *outCompressionType, size_t *outUnzipsize) grib_handle *gribapiGetDiskRepresentation(size_t recsize, size_t *buffersize, void **gribbuffer, int *outDatatype, int *outCompressionType, size_t *outUnzipsize)
{ {
bool lieee = false; int gribversion = (int)((char*)*gribbuffer)[7];
if ( gribversion <= 1 )
{
if ( gribGetZip(recsize, *gribbuffer, outUnzipsize) > 0 )
{
*outCompressionType = CDI_COMPRESS_SZIP;
ensureBufferSize(*outUnzipsize + 100, buffersize, gribbuffer);
}
else
{
*outCompressionType = CDI_COMPRESS_NONE;
}
}
grib_handle *gh = grib_handle_new_from_message(NULL, *gribbuffer, recsize); grib_handle *gh = grib_handle_new_from_message(NULL, *gribbuffer, recsize);
if(gribEditionNumber(gh) > 1)
bool lieee = false;
if ( gribversion > 1 )
{ {
size_t len = 256; size_t len = 256;
char typeOfPacking[256]; char typeOfPacking[256];
...@@ -739,18 +755,6 @@ grib_handle *gribapiGetDiskRepresentation(size_t recsize, size_t *buffersize, vo ...@@ -739,18 +755,6 @@ grib_handle *gribapiGetDiskRepresentation(size_t recsize, size_t *buffersize, vo
else if ( strncmp(typeOfPacking, "grid_ieee", len) == 0 ) lieee = true; else if ( strncmp(typeOfPacking, "grid_ieee", len) == 0 ) lieee = true;
} }
} }
else
{
if( gribGetZip(recsize, *gribbuffer, outUnzipsize) > 0 )
{
*outCompressionType = CDI_COMPRESS_SZIP;
ensureBufferSize(*outUnzipsize + 100, buffersize, gribbuffer);
}
else
{
*outCompressionType = CDI_COMPRESS_NONE;
}
}
if ( lieee ) if ( lieee )
{ {
...@@ -768,6 +772,7 @@ grib_handle *gribapiGetDiskRepresentation(size_t recsize, size_t *buffersize, vo ...@@ -768,6 +772,7 @@ grib_handle *gribapiGetDiskRepresentation(size_t recsize, size_t *buffersize, vo
if ( bitsPerValue > 0 && bitsPerValue <= 32 ) *outDatatype = (int)bitsPerValue; if ( bitsPerValue > 0 && bitsPerValue <= 32 ) *outDatatype = (int)bitsPerValue;
} }
} }
return gh; return gh;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment