82 #define MIN_LAT (-90.0*(1.0-1.0/(double)ROWS))
83 #define MAX_LON (180.0*(1.0-1.0/(double)COLS))
86 static geoid_height_t *geoid_height =
NULL;
88 geoid_height = calloc(
ROWS,
sizeof(geoid_height_t));
91 int lat_lo, lat_hi, lon_lo, lon_hi;
93 char msgbuf[128] =
"";
94 static char filefunc[] = __FILE__
", GEO_get_geoid";
114 else if(lon_hi >
COLS-1)
123 dlat = lat_lo = lat_hi = 0;
124 else if(lat_hi >
ROWS-1)
126 lat_lo = lat_hi =
ROWS-1;
132 PGSt_integer numPixVertical;
133 PGSt_integer numPixHorizontal;
134 PGSt_integer sizeDataType;
135 PGSt_double longitude_arry[2] = { -180.0,
MAX_LON};
136 PGSt_double latitude_arry[2] = {90.0,
MIN_LAT};
138 if( PGS_DEM_GetSize(PGSd_DEM_30ARC, PGSd_DEM_GEOID, PGSd_DEM_DEGREE,
139 latitude_arry, longitude_arry, &numPixVertical, &numPixHorizontal,
140 &sizeDataType ) != PGS_S_SUCCESS )
148 if( (numPixVertical !=
ROWS) || (numPixHorizontal !=
COLS) ||
149 ((
size_t)sizeDataType !=
sizeof(geoid_height[0][0])) )
152 "\nnumPixVertical= %ld numPixHorizontal= %ld sizeDataType= %ld",
153 (
long)numPixVertical,(
long)numPixHorizontal,(
long)sizeDataType);
160 if( PGS_DEM_GetQualityData(PGSd_DEM_30ARC, PGSd_DEM_GEOID,
161 PGSd_DEM_DEGREE, latitude_arry, longitude_arry,
162 (
void *)geoid_height) != PGS_S_SUCCESS )
164 modsmf(
MODIS_E_GEO,
"PGS_DEM_GetQualityData", filefunc);
169 return (
int)floor( (1-dlon)*((1.0-dlat)*geoid_height[lat_lo][lon_lo] +
170 dlat*geoid_height[lat_hi][lon_lo]) +
171 dlon*((1.0-dlat)*geoid_height[lat_lo][lon_hi] +
172 dlat*geoid_height[lat_hi][lon_hi]) + 0.5);