mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
Merge pull request #1317 from Unidata/fillhack.dmh
Add hack to deal with DAP2 signed byte conversion.
This commit is contained in:
commit
29d2643f8e
@ -780,11 +780,45 @@ fprintf(stderr,"\n");
|
||||
}
|
||||
var->ncid = varid;
|
||||
if(var->attributes != NULL) {
|
||||
NCattribute* unsignedatt = NULL;
|
||||
int unsignedval = 0;
|
||||
/* See if variable has _Unsigned attribute */
|
||||
for(j=0;j<nclistlength(var->attributes);j++) {
|
||||
NCattribute* att = (NCattribute*)nclistget(var->attributes,j);
|
||||
if(strcmp(att->name,"_Unsigned") == 0) {
|
||||
char* value = nclistget(att->values,0);
|
||||
unsignedatt = att;
|
||||
if(value != NULL) {
|
||||
if(strcasecmp(value,"false")==0
|
||||
|| strcmp(value,"0")==0)
|
||||
unsignedval = 0;
|
||||
else
|
||||
unsignedval = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(j=0;j<nclistlength(var->attributes);j++) {
|
||||
NCattribute* att = (NCattribute*)nclistget(var->attributes,j);
|
||||
char* val = NULL;
|
||||
/* Check for _FillValue/Variable mismatch */
|
||||
if(strcmp(att->name,"_FillValue")==0) {
|
||||
if(att->etype != var->etype) {
|
||||
/* Special case var is byte, fillvalue is int16 and
|
||||
unsignedattr == 0;
|
||||
This exception is needed because DAP2 byte type
|
||||
is equivalent to netcdf ubyte type. So passing
|
||||
a signed byte thru DAP2 requires some type and
|
||||
signedness hacking that we have to undo.
|
||||
*/
|
||||
if(var->etype == NC_UBYTE
|
||||
&& att->etype == NC_SHORT
|
||||
&& unsignedatt != NULL && unsignedval == 0) {
|
||||
/* Forcibly change the attribute type and signedness */
|
||||
att->etype = NC_BYTE;
|
||||
val = nclistremove(unsignedatt->values,0);
|
||||
if(val) free(val);
|
||||
nclistpush(unsignedatt->values,strdup("false"));
|
||||
} else if(att->etype != var->etype) {/* other mismatches */
|
||||
/* Log a message */
|
||||
nclog(NCLOGERR,"_FillValue/Variable type mismatch: variable=%s",var->ncbasename);
|
||||
/* See if mismatch is allowed */
|
||||
|
@ -138,6 +138,7 @@ ocfetchurl(CURL* curl, const char* url, NCbytes* buf, long* filetime)
|
||||
fail:
|
||||
nclog(NCLOGERR, "curl error: %s", curl_easy_strerror(cstat));
|
||||
switch (httpcode) {
|
||||
case 400: stat = OC_EBADURL; break;
|
||||
case 401: stat = OC_EAUTH; break;
|
||||
case 404: stat = OC_ENOFILE; break;
|
||||
case 500: stat = OC_EDAPSVC; break;
|
||||
|
Loading…
Reference in New Issue
Block a user