⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swapi.c

📁 GIS系统支持库Geospatial Data Abstraction Library代码.GDAL is a translator library for raster geospatial dat
💻 C
📖 第 1 页 / 共 5 页
字号:
/*----------------------------------------------------------------------------||  BEGIN_PROLOG                                                               ||                                                                             ||  FUNCTION: SWmapinfo                                                        ||                                                                             ||  DESCRIPTION: Returns dimension mapping information                         ||                                                                             ||                                                                             ||  Return Value    Type     Units     Description                             ||  ============   ======  =========   =====================================   ||  status         intn                return status (0) SUCCEED, (-1) FAIL    ||                                                                             ||  INPUTS:                                                                    ||  swathID        int32               swath structure id                      ||  geodim         char                geolocation dimension name              ||  datadim        char                data dimension name                     ||                                                                             ||  OUTPUTS:                                                                   ||  offset         int32               mapping offset                          ||  increment      int32               mapping increment                       ||                                                                             ||  NOTES:                                                                     ||                                                                             ||                                                                             ||   Date     Programmer   Description                                         ||  ======   ============  =================================================   ||  Jun 96   Joel Gales    Original Programmer                                 ||  Aug 96   Joel Gales    Make metadata ODL compliant                         ||  Jan 97   Joel Gales    Check for metadata error status from EHgetmetavalue ||                                                                             ||  END_PROLOG                                                                 |-----------------------------------------------------------------------------*/intnSWmapinfo(int32 swathID, char *geodim, char *datadim, int32 * offset,	  int32 * increment){    intn            status;	/* routine return status variable */    intn            statmeta = 0;	/* EHgetmetavalue return status */    int32           fid;	/* HDF-EOS file ID */    int32           sdInterfaceID;	/* HDF SDS interface ID */    int32           swVgrpID;	/* Swath root Vgroup ID */    int32           idOffset = SWIDOFFSET;	/* Swath ID offset */    char           *metabuf;	/* Pointer to structural metadata (SM) */    char           *metaptrs[2];/* Pointers to begin and end of SM section */    char            swathname[80];	/* Swath Name */    char           *utlstr;	/* Utility string */    /* Allocate space for utility string */    /* --------------------------------- */    utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char));    if(utlstr == NULL)    { 	HEpush(DFE_NOSPACE,"SWmapinfo", __FILE__, __LINE__);	return(-1);    }    /* Initialize return values */    *offset = -1;    *increment = -1;    /* Check Swath ID */    status = SWchkswid(swathID, "SWmapinfo", &fid, &sdInterfaceID, &swVgrpID);    if (status == 0)    {	/* Get swath name */	Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname);	/* Get pointers to "DimensionMap" section within SM */	metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s",				       "DimensionMap", metaptrs);	if(metabuf == NULL)	{	    free(utlstr);	    return(-1);	}	/* Search for mapping - GeoDim/DataDim (surrounded by quotes) */	sprintf(utlstr, "%s%s%s%s%s", "\t\t\t\tGeoDimension=\"", geodim,		"\"\n\t\t\t\tDataDimension=\"", datadim, "\"\n");	metaptrs[0] = strstr(metaptrs[0], utlstr);	/*	 * If mapping found within swath structure then get offset and	 * increment value	 */	if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL)	{	    /* Get Offset */	    statmeta = EHgetmetavalue(metaptrs, "Offset", utlstr);	    if (statmeta == 0)	    {		*offset = atol(utlstr);	    }	    else	    {		status = -1;		HEpush(DFE_GENAPP, "SWmapinfo", __FILE__, __LINE__);		HEreport("\"Offset\" string not found in metadata.\n");	    }	    /* Get Increment */	    statmeta = EHgetmetavalue(metaptrs, "Increment", utlstr);	    if (statmeta == 0)	    {		*increment = atol(utlstr);	    }	    else	    {		status = -1;		HEpush(DFE_GENAPP, "SWmapinfo", __FILE__, __LINE__);		HEreport("\"Increment\" string not found in metadata.\n");	    }	}	else	{	    status = -1;	    HEpush(DFE_GENAPP, "SWmapinfo", __FILE__, __LINE__);	    HEreport("Mapping \"%s/%s\" not found.\n", geodim, datadim);	}	free(metabuf);    }    free(utlstr);    return (status);}/*----------------------------------------------------------------------------||  BEGIN_PROLOG                                                               ||                                                                             ||  FUNCTION: SWidxmapinfo                                                     ||                                                                             ||  DESCRIPTION: Returns indexed mapping information                           ||                                                                             ||                                                                             ||  Return Value    Type     Units     Description                             ||  ============   ======  =========   =====================================   ||  gsize          int32               Number of index values (sz of geo dim)  ||                                                                             ||  INPUTS:                                                                    ||  swathID        int32               swath structure id                      ||  geodim         char                geolocation dimension name              ||  datadim        char                data dimension name                     ||                                                                             ||                                                                             ||  OUTPUTS:                                                                   ||  index          int32               array of index values                   ||                                                                             ||  NOTES:                                                                     ||                                                                             ||                                                                             ||   Date     Programmer   Description                                         ||  ======   ============  =================================================   ||  Jun 96   Joel Gales    Original Programmer                                 ||                                                                             ||  END_PROLOG                                                                 |-----------------------------------------------------------------------------*/int32SWidxmapinfo(int32 swathID, char *geodim, char *datadim, int32 index[]){    intn            status;	/* routine return status variable */    int32           fid;	/* HDF-EOS file ID */    int32           sdInterfaceID;	/* HDF SDS interface ID */    int32           swVgrpID;	/* Swath root Vgroup ID */    int32           idOffset = SWIDOFFSET;	/* Swath ID offset */    int32           vgid;	/* Swath Attributes Vgroup ID */    int32           vdataID;	/* Index Mapping Vdata ID */    int32           gsize = -1;	/* Size of geo dim */    char            utlbuf[256];/* Utility buffer */    /* Check Swath ID */    status = SWchkswid(swathID, "SWidxmapinfo",		       &fid, &sdInterfaceID, &swVgrpID);    if (status == 0)    {	/* Find Index Mapping Vdata with Swath Attributes Vgroup */	sprintf(utlbuf, "%s%s%s%s", "INDXMAP:", geodim, "/", datadim);	vgid = SWXSwath[swathID % idOffset].VIDTable[2];	vdataID = EHgetid(fid, vgid, utlbuf, 1, "r");	/* If found then get geodim size & read index mapping values */	if (vdataID != -1)	{	    gsize = SWdiminfo(swathID, geodim);	    VSsetfields(vdataID, "Index");	    VSread(vdataID, (uint8 *) index, 1, FULL_INTERLACE);	    VSdetach(vdataID);	}	else	{	    status = -1;	    HEpush(DFE_GENAPP, "SWidxmapinfo", __FILE__, __LINE__);	    HEreport("Index Mapping \"%s\" not found.\n", utlbuf);	}    }    return (gsize);}/*----------------------------------------------------------------------------||  BEGIN_PROLOG                                                               ||                                                                             ||  FUNCTION: SWcompinfo                                                       ||                                                                             ||  DESCRIPTION:                                                               ||                                                                             ||                                                                             ||  Return Value    Type     Units     Description                             ||  ============   ======  =========   =====================================   ||  status         intn                                                        ||                                                                             ||  INPUTS:                                                                    ||  swathID        int32                                                       ||  compcode       int32                                                       ||  compparm       intn                                                        ||                                                                             ||                                                                             ||  OUTPUTS:                                                                   ||             None                                                            ||                                                                             ||  NOTES:                                                                     ||                                                                             ||                                                                             ||   Date     Programmer   Description                                         ||  ======   ============  =================================================   ||  Oct 96   Joel Gales    Original Programmer                                 ||  Jan 97   Joel Gales    Check for metadata error status from EHgetmetavalue ||                                                                             ||  END_PROLOG                                                                 |-----------------------------------------------------------------------------*/intnSWcompinfo(int32 swathID, char *fieldname, int32 * compcode, intn compparm[]){    intn            i;		/* Loop Index */    intn            status;	/* routine return status variable */    intn            statmeta = 0;	/* EHgetmetavalue return status */    int32           fid;	/* HDF-EOS file ID */    int32           sdInterfaceID;	/* HDF SDS interface ID */    int32           swVgrpID;	/* Swath root Vgroup ID */    int32           idOffset = SWIDOFFSET;	/* Swath ID offset */    char           *metabuf;	/* Pointer to structural metadata (SM) */    char           *metaptrs[2];/* Pointers to begin and end of SM section */    char            swathname[80];	/* Swath Name */    char           *utlstr;     /* Utility string */    char           *HDFcomp[5] = {"HDFE_COMP_NONE", "HDFE_COMP_RLE",	"HDFE_COMP_NBIT", "HDFE_COMP_SKPHUFF",    "HDFE_COMP_DEFLATE"};	/* Compression Codes */    /* Allocate space for utility string */    /* --------------------------------- */    utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char));    if(utlstr == NULL)    { 	HEpush(DFE_NOSPACE,"SWcompinfo", __FILE__, __LINE__);	return(-1);    }    /* Check Swath ID */    status = SWchkswid(swathID, "SWcompinfo",		       &fid, &sdInterfaceID, &swVgrpID);    if (status == 0)    {	/* Get swath name */	Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname);	/* Get pointers to "DataField" section within SM */	metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s",				       "DataField", metaptrs);	if(metabuf == NULL)	{	    free(utlstr);	    return(-1);	}	/* Search for field */	sprintf(utlstr, "%s%s%s", "\"", fieldname, "\"\n");	metaptrs[0] = strstr(metaptrs[0], utlstr);	/* If not found then search in "GeoField" section */	if (metaptrs[0] > metaptrs[1] || metaptrs[0] == NULL)	{	    free(metabuf);	    /* Get pointers to "GeoField" section within SM */	    metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s",					   "GeoField", metaptrs);	    if(metabuf == NULL)	    {		free(utlstr);		return(-1);	    }	    /* Search for field */	    sprintf(utlstr, "%s%s%s", "\"", fieldname, "\"\n");	    metaptrs[0] = strstr(metaptrs[0], utlstr);	}	/* If field found and user wants compression code ... */	if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL)	{	    if (compcode != NULL)	    {		/* Set endptr at end of field's definition entry */		metaptrs[1] = strstr(metaptrs[0], "\t\t\tEND_OBJECT");		/* Get compression type */		statmeta = EHgetmetavalue(metaptrs, "CompressionType", utlstr);		/*		 * Default is no compression if "CompressionType" string not		 * in metadata		 */		*compcode = HDFE_COMP_NONE;		/* If compression code is found ... */		if (statmeta == 0)		{		    /* Loop through compression types until match */		    for (i = 0; i < 5; i++)		    {			if (strcmp(utlstr, HDFcomp[i]) == 0)			{			    *compcode = i;			    break;			}		    }		}	    }	    /* If user wants compression parameters ... */	    if (compparm != NULL && compcode != NULL)	    {		/* Initialize to zero */		for (i = 0; i < 4; i++)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -