Commit f6bf667e authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added function gridVerifyGribParamLCC().

parent 906a6d08
......@@ -20,7 +20,7 @@
#include "serialize.h"
#include "vlist.h"
double grid_missval = -9999.;
double grid_missval = 9999.;
/* the value in the second pair of brackets must match the length of
* the longest string (including terminating NUL) */
......@@ -3658,13 +3658,13 @@ The function @func{gridInqParamLCC} returns the parameter of a Lambert Conformal
int gridInqParamLCC(int gridID, double missval, double *lon_0, double *lat_0, double *lat_1, double *lat_2,
double *a, double *rf, double *xval_0, double *yval_0, double *x_0, double *y_0)
{
int status = -1;
if ( gridInqType(gridID) != GRID_PROJECTION ) return status;
*a = 0; *rf = 0;
*lon_0 = missval; *lat_0 = missval, *lat_1 = missval, *lat_2 = missval;
*xval_0 = missval; *yval_0 = missval; *x_0 = missval, *y_0 = missval;
int status = -1;
if ( gridInqType(gridID) != GRID_PROJECTION ) return status;
status = -2;
const char *projection = "lambert_conformal_conic";
char mapname[CDI_MAX_NAME]; mapname[0] = 0;
......@@ -3708,6 +3708,26 @@ int gridInqParamLCC(int gridID, double missval, double *lon_0, double *lat_0, do
}
int gridVerifyGribParamLCC(int gridID, double missval, double *lon_0, double *lat_0, double *lat_1, double *lat_2,
double *a, double *rf, double *xval_0, double *yval_0, double *x_0, double *y_0)
{
static bool lwarn = true;
if ( lwarn )
{
lwarn = false;
const char *projection = "lambert_conformal_conic";
if ( IS_EQUAL(*lon_0, missval) ) { Warning("%s mapping parameter %s missing!", projection, "longitude_of_central_meridian"); }
if ( IS_EQUAL(*lat_0, missval) ) { Warning("%s mapping parameter %s missing!", projection, "latitude_of_central_meridian"); }
if ( IS_EQUAL(*lat_1, missval) ) { Warning("%s mapping parameter %s missing!", projection, "standard_parallel"); }
if ( IS_EQUAL(*xval_0, missval) || IS_EQUAL(*yval_0, missval) )
{ Warning("%s mapping parameter %s missing!", projection, "longitudeOfFirstGridPointInDegrees and latitudeOfFirstGridPointInDegrees"); }
}
return 0;
}
void gridDefComplexPacking(int gridID, int lcomplex)
{
grid_t *gridptr = grid_to_pointer(gridID);
......
......@@ -149,6 +149,9 @@ struct addIfNewRes
struct addIfNewRes cdiVlistAddGridIfNew(int vlistID, grid_t *grid, int mode);
int gridVerifyGribParamLCC(int gridID, double missval, double *lon_0, double *lat_0, double *lat_1, double *lat_2,
double *a, double *rf, double *xval_0, double *yval_0, double *x_0, double *y_0);
#endif
/*
* Local Variables:
......
......@@ -1771,6 +1771,7 @@ void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridI
double lon_0, lat_0, lat_1, lat_2, a, rf, xval_0, yval_0, x_0, y_0;
gridInqParamLCC(gridID, grid_missval, &lon_0, &lat_0, &lat_1, &lat_2, &a, &rf, &xval_0, &yval_0, &x_0, &y_0);
gridVerifyGribParamLCC(gridID, grid_missval, &lon_0, &lat_0, &lat_1, &lat_2, &a, &rf, &xval_0, &yval_0, &x_0, &y_0);
bool lsouth = (lat_1 < 0);
if ( lsouth ) { lat_1 = -lat_2; lat_2 = -lat_2; }
......
......@@ -2134,6 +2134,7 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
double lon_0, lat_0, lat_1, lat_2, a, rf, xval_0, yval_0, x_0, y_0;
gridInqParamLCC(gridID, grid_missval, &lon_0, &lat_0, &lat_1, &lat_2, &a, &rf, &xval_0, &yval_0, &x_0, &y_0);
gridVerifyGribParamLCC(gridID, grid_missval, &lon_0, &lat_0, &lat_1, &lat_2, &a, &rf, &xval_0, &yval_0, &x_0, &y_0);
if ( xval_0 < 0 ) xval_0 += 360;
bool lsouth = (lat_1 < 0);
if ( lsouth ) { lat_1 = -lat_2; lat_2 = -lat_2; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment