?? gdapi.c
字號:
} /* Write Dimension to Structural MetaData */ /* -------------------------------------- */ if (status == 0) { Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); status = EHinsertmeta(sdInterfaceID, gridname, "g", 0L, dimname, &dim); } return (status);}/*----------------------------------------------------------------------------|| BEGIN_PROLOG || || FUNCTION: GDdefproj || || DESCRIPTION: Defines projection of grid. || || || Return Value Type Units Description || ============ ====== ========= ===================================== || status intn return status (0) SUCCEED, (-1) FAIL || || INPUTS: || gridID int32 Grid structure ID || projcode int32 GCTP projection code || zonecode int32 UTM zone code || spherecode int32 GCTP spheriod code || projparm float64 Projection parameters || || OUTPUTS: || None || || NOTES: || || || Date Programmer Description || ====== ============ ================================================= || Jun 96 Joel Gales Original Programmer || Jun 00 Abe Taaheri Added support for EASE grid || || END_PROLOG |-----------------------------------------------------------------------------*/intnGDdefproj(int32 gridID, int32 projcode, int32 zonecode, int32 spherecode, float64 projparm[]){ intn i; /* Loop index */ intn projx; /* Projection table index */ intn status = 0; /* routine return status variable */ int32 fid; /* HDF-EOS file ID */ int32 sdInterfaceID; /* HDF SDS interface ID */ int32 gdVgrpID; /* Grid root Vgroup ID */ int32 idOffset = GDIDOFFSET; /* Grid ID offset */ int32 slen; /* String length */ float64 EHconvAng(); char utlbuf[1024]; /* Utility Buffer */ char projparmbuf[512]; /* Projection parameter metadata * string */ char gridname[80]; /* Grid Name */ /* Check for valid grid id */ /* ----------------------- */ status = GDchkgdid(gridID, "GDdefproj", &fid, &sdInterfaceID, &gdVgrpID); if (status == 0) { /* * If projection not GEO, UTM, or State Code build projection * parameter string */ if (projcode != GCTP_GEO && projcode != GCTP_UTM && projcode != GCTP_SPCS) { /* Begin projection parameter list with "(" */ strcpy(projparmbuf, "("); for (i = 0; i < 13; i++) { /* If projparm[i] = 0 ... */ if (projparm[i] == 0.0) { strcpy(utlbuf, "0,"); } else { /* if projparm[i] is integer ... */ if ((int32) projparm[i] == projparm[i]) { sprintf(utlbuf, "%d%s", (int) projparm[i], ","); } /* else projparm[i] is non-zero floating point ... */ else { sprintf(utlbuf, "%lf%s", projparm[i], ","); } } strcat(projparmbuf, utlbuf); } slen = strlen(projparmbuf); /* Add trailing ")" */ projparmbuf[slen - 1] = ')'; } for (projx = 0; Projections[projx].projcode != -1; projx++) { if (projcode == Projections[projx].projcode) { break; } } /* Build metadata string */ /* --------------------- */ if ((projcode == GCTP_GEO)) { sprintf(utlbuf, "%s%s%s", "\t\tProjection=", Projections[projx].projname, "\n"); } else if (projcode == GCTP_UTM || projcode == GCTP_SPCS) { sprintf(utlbuf, "%s%s%s%s%d%s%s%d%s", "\t\tProjection=", Projections[projx].projname, "\n", "\t\tZoneCode=", (int)zonecode, "\n", "\t\tSphereCode=", (int)spherecode, "\n"); } else { sprintf(utlbuf, "%s%s%s%s%s%s%s%d%s", "\t\tProjection=", Projections[projx].projname, "\n", "\t\tProjParams=", projparmbuf, "\n", "\t\tSphereCode=", (int)spherecode, "\n"); } /* Insert in structural metadata */ /* ----------------------------- */ Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); status = EHinsertmeta(sdInterfaceID, gridname, "g", 101L, utlbuf, NULL); } return (status);}/*----------------------------------------------------------------------------|| BEGIN_PROLOG || || FUNCTION: GDblkSOMoffset || || DESCRIPTION: Writes Block SOM offset values || || || Return Value Type Units Description || ============ ====== ========= ===================================== || status intn return status (0) SUCCEED, (-1) FAIL || || INPUTS: || gridID int32 Grid structure ID || offset float32 Offset values || count int32 Number of offset values || code char w/r code (w/r) || || OUTPUTS: || None || || NOTES: || || || Date Programmer Description || ====== ============ ================================================= || Sep 96 Joel Gales Original Programmer || Mar 99 David Wynne Changed data type of offset array from int32 to || float32, NCR 21197 || || END_PROLOG |-----------------------------------------------------------------------------*/intnGDblkSOMoffset(int32 gridID, float32 offset[], int32 count, char *code){ intn status = 0; /* routine return status variable */ int32 fid; /* HDF-EOS file ID */ int32 sdInterfaceID; /* HDF SDS interface ID */ int32 gdVgrpID; /* Grid root Vgroup ID */ int32 idOffset = GDIDOFFSET; /* Grid ID offset */ int32 projcode; /* GCTP projection code */ float64 projparm[13]; /* Projection parameters */ char utlbuf[128];/* Utility Buffer */ char gridname[80]; /* Grid Name */ /* Check for valid grid id */ status = GDchkgdid(gridID, "GDblkSOMoffset", &fid, &sdInterfaceID, &gdVgrpID); if (status == 0) { /* Get projection parameters */ status = GDprojinfo(gridID, &projcode, NULL, NULL, projparm); /* If SOM projection with projparm[11] non-zero ... */ if (projcode == GCTP_SOM && projparm[11] != 0) { Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); sprintf(utlbuf, "%s%s", "_BLKSOM:", gridname); /* Write offset values as attribute */ if (strcmp(code, "w") == 0) { status = GDwriteattr(gridID, utlbuf, DFNT_FLOAT32, count, offset); } /* Read offset values from attribute */ else if (strcmp(code, "r") == 0) { status = GDreadattr(gridID, utlbuf, offset); } } } return (status);}/*----------------------------------------------------------------------------|| BEGIN_PROLOG || || FUNCTION: GDdefcomp || || DESCRIPTION: Defines compression type and parameters || || || Return Value Type Units Description || ============ ====== ========= ===================================== || status intn return status (0) SUCCEED, (-1) FAIL || || INPUTS: || gridID int32 grid structure ID || compcode int32 compression code || compparm intn compression parameters || || OUTPUTS: || None || || NOTES: || || || Date Programmer Description || ====== ============ ================================================= || Sep 96 Joel Gales Original Programmer || || END_PROLOG |-----------------------------------------------------------------------------*/intnGDdefcomp(int32 gridID, int32 compcode, intn compparm[]){ intn status = 0; /* routine return status variable */ int32 fid; /* HDF-EOS file id */ int32 sdInterfaceID; /* HDF SDS interface ID */ int32 gdVgrpID; /* Grid root Vgroup ID */ int32 idOffset = GDIDOFFSET; /* Grid ID offset */ int32 gID; /* gridID - offset */ /* Check for valid grid id */ status = GDchkgdid(gridID, "GDdefcomp", &fid, &sdInterfaceID, &gdVgrpID); if (status == 0) { gID = gridID % idOffset; /* Set compression code in compression exteral array */ GDXGrid[gID].compcode = compcode; switch (compcode) { /* Set NBIT compression parameters in compression external array */ case HDFE_COMP_NBIT: GDXGrid[gID].compparm[0] = compparm[0]; GDXGrid[gID].compparm[1] = compparm[1]; GDXGrid[gID].compparm[2] = compparm[2]; GDXGrid[gID].compparm[3] = compparm[3]; break; /* Set GZIP compression parameter in compression external array */ case HDFE_COMP_DEFLATE: GDXGrid[gID].compparm[0] = compparm[0]; break; } } return (status);}/*----------------------------------------------------------------------------|| BEGIN_PROLOG || || FUNCTION: GDdeftile |
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -