📄 ehapi.c
字号:
| fid int32 HDF-EOS file id || || OUTPUTS: || version char HDF-EOS version string || || NOTES: || || || Date Programmer Description || ====== ============ ================================================= || Mar 97 Joel Gales Original Programmer || || END_PROLOG |-----------------------------------------------------------------------------*/intnEHgetversion(int32 fid, char *version){ intn status = 0; /* routine return status variable */ uint8 access; /* Access code */ int32 dum; /* Dummy variable */ int32 sdInterfaceID; /* HDF SDS interface ID */ int32 attrIndex; /* HDFEOS version attribute index */ int32 count; /* Version string size */ char attrname[16]; /* Attribute name */ /* Get SDS interface ID */ /* -------------------- */ status = EHchkfid(fid, "EHgetversion", &dum, &sdInterfaceID, &access); /* Get attribute index number */ /* -------------------------- */ attrIndex = SDfindattr(sdInterfaceID, "HDFEOSVersion"); /* No such attribute */ /* ----------------- */ if (attrIndex < 0) return (-1); /* Get attribute size */ /* ------------------ */ status = SDattrinfo(sdInterfaceID, attrIndex, attrname, &dum, &count); /* Check return status */ /* ------------------- */ if (status < 0) return (-1); /* Read version attribute */ /* ---------------------- */ status = SDreadattr(sdInterfaceID, attrIndex, (VOIDP) version); /* Place string terminator on version string */ /* ----------------------------------------- */ version[count] = 0; return (status);}/* FORTRAN binding */FCALLSCFUN2(INT, EHgetversion, EHGETVER, ehgetver, INT32, PSTRING)/*----------------------------------------------------------------------------|| BEGIN_PROLOG || || FUNCTION: EHconvAng || || DESCRIPTION: Angle conversion Utility || || || Return Value Type Units Description || ============ ====== ========= ===================================== || outAngle float64 Output Angle value || || INPUTS: || inAngle float64 Input Angle value || code intn Conversion code |! HDFE_RAD_DEG (0) || HDFE_DEG_RAD (1) || HDFE_DMS_DEG (2) || HDFE_DEG_DMS (3) || HDFE_RAD_DMS (4) || HDFE_DMS_RAD (5) || || OUTPUTS: || None || || NOTES: || || || Date Programmer Description || ====== ============ ================================================= || Jun 96 Joel Gales Original Programmer || Feb 97 Joel Gales Correct "60" min & "60" sec in _DMS conversion || || END_PROLOG |-----------------------------------------------------------------------------*/float64EHconvAng(float64 inAngle, intn code){ int32 min; /* Truncated Minutes */ int32 deg; /* Truncated Degrees */ float64 sec; /* Seconds */ float64 outAngle; /* Angle in desired units */ float64 pi = 3.14159265358979324; /* Pi */ float64 r2d = 180 / pi; /* Radians to degrees conversion */ float64 d2r = 1 / r2d; /* Degrees to radians conversion */ switch (code) { /* Convert radians to degrees */ /* -------------------------- */ case HDFE_RAD_DEG: outAngle = inAngle * r2d; break; /* Convert degrees to radians */ /* -------------------------- */ case HDFE_DEG_RAD: outAngle = inAngle * d2r; break; /* Convert packed degrees to degrees */ /* --------------------------------- */ case HDFE_DMS_DEG: deg = inAngle / 1000000; min = (inAngle - deg * 1000000) / 1000; sec = (inAngle - deg * 1000000 - min * 1000); outAngle = deg + min / 60.0 + sec / 3600.0; break; /* Convert degrees to packed degrees */ /* --------------------------------- */ case HDFE_DEG_DMS: deg = inAngle; min = (inAngle - deg) * 60; sec = (inAngle - deg - min / 60.0) * 3600; if ((intn) sec == 60) { sec = sec - 60; min = min + 1; } if (min == 60) { min = min - 60; deg = deg + 1; } outAngle = deg * 1000000 + min * 1000 + sec; break; /* Convert radians to packed degrees */ /* --------------------------------- */ case HDFE_RAD_DMS: inAngle = inAngle * r2d; deg = inAngle; min = (inAngle - deg) * 60; sec = (inAngle - deg - min / 60.0) * 3600; if ((intn) sec == 60) { sec = sec - 60; min = min + 1; } if (min == 60) { min = min - 60; deg = deg + 1; } outAngle = deg * 1000000 + min * 1000 + sec; break; /* Convert packed degrees to radians */ /* --------------------------------- */ case HDFE_DMS_RAD: deg = inAngle / 1000000; min = (inAngle - deg * 1000000) / 1000; sec = (inAngle - deg * 1000000 - min * 1000); outAngle = deg + min / 60.0 + sec / 3600.0; outAngle = outAngle * d2r; break; } return (outAngle);}/* Wrapper to FORTRAN routine *//* -------------------------- */FCALLSCFUN2(DOUBLE, EHconvAng, EHCONVANG, ehconvang, DOUBLE, INT)/*----------------------------------------------------------------------------|| BEGIN_PROLOG || || FUNCTION: EHparsestr || || DESCRIPTION: String Parser Utility || || || Return Value Type Units Description || ============ ====== ========= ===================================== || count int32 Number of string entries || || INPUTS: || instring char Input string || delim char string delimitor || || OUTPUTS: || pntr char * Pointer array to beginning of each || string entry || len int32 Array of string entry lengths || || NOTES: || || || Date Programmer Description || ====== ============ ================================================= || Jun 96 Joel Gales Original Programmer || Aug 96 Joel Gales NULL pointer array returns count only || || END_PROLOG |-----------------------------------------------------------------------------*/int32EHparsestr(char *instring, char delim, char *pntr[], int32 len[]){ int32 i; /* Loop index */ int32 prevDelimPos = 0; /* Previous delimitor position */ int32 count; /* Number of elements in string list */ int32 slen; /* String length */ char *delimitor; /* Pointer to delimitor */ /* Get length of input string list & Point to first delimitor */ /* ---------------------------------------------------------- */ slen = strlen(instring); delimitor = strchr(instring, delim); /* If NULL string set count to zero otherwise set to 1 */ /* --------------------------------------------------- */ count = (slen == 0) ? 0 : 1; /* if string pointers are requested set first one to beginning of string */ /* --------------------------------------------------------------------- */ if (&pntr[0] != NULL) { pntr[0] = instring; } /* If delimitor not found ... */ /* -------------------------- */ if (delimitor == NULL) { /* if string length requested then set to input string length */ /* ---------------------------------------------------------- */ if (len != NULL) { len[0] = slen; } } else /* Delimitors Found */ /* ---------------- */ { /* Loop through all characters in string */ /* ------------------------------------- */ for (i = 1; i < slen; i++) { /* If character is a delimitor ... */ /* ------------------------------- */ if (instring[i] == delim) { /* If string pointer requested */ /* --------------------------- */ if (&pntr[0] != NULL) { /* if requested then compute string length of entry */ /* ------------------------------------------------ */ if (len != NULL) { len[count - 1] = i - prevDelimPos; } /* Point to beginning of string entry */ /* ---------------------------------- */ pntr[count] = instring + i + 1; } /* Reset previous delimitor position and increment counter */ /* ------------------------------------------------------- */ prevDelimPos = i + 1; count++; } } /* Compute string length of last entry */ /* ----------------------------------- */ if (&pntr[0] != NULL && len != NULL) { len[count - 1] = i - prevDelimPos; } } return (count);}/*----------------------------------------------------------------------------|| BEGIN_PROLOG || |
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -