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

gribapiDefGridLCC(): init x_0, y_0 if missing.

parent d4f86643
......@@ -2030,11 +2030,18 @@ void gribapiDefGridLCC(grib_handle *gh, int editionNumber, int gridID, int uvRel
const long xsize = (long) gridInqXsize(gridID);
const long ysize = (long) gridInqYsize(gridID);
double missval = CDI_grid_missval;
double lon_0, lat_0, lat_1, lat_2, a, rf, xval_0, yval_0, x_0, y_0;
gridInqParamLCC(gridID, CDI_grid_missval, &lon_0, &lat_0, &lat_1, &lat_2, &a, &rf, &xval_0, &yval_0, &x_0, &y_0);
gridInqParamLCC(gridID, missval, &lon_0, &lat_0, &lat_1, &lat_2, &a, &rf, &xval_0, &yval_0, &x_0, &y_0);
if (IS_EQUAL(x_0, missval) && IS_EQUAL(y_0, missval) && (IS_EQUAL(xval_0, missval) || IS_EQUAL(yval_0, missval)))
{
x_0 = gridInqXval(gridID, 0);
y_0 = gridInqYval(gridID, 0);
}
gridVerifyGribParamLCC(CDI_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;
if ( lon_0 < 0 ) lon_0 += 360;
const bool lsouth = (lat_1 < 0);
if ( lsouth ) { lat_1 = -lat_2; lat_2 = -lat_2; }
int projflag = 0;
......@@ -2049,8 +2056,8 @@ void gribapiDefGridLCC(grib_handle *gh, int editionNumber, int gridID, int uvRel
GRIB_CHECK(my_grib_set_long(gh, "Nx", xsize), 0);
GRIB_CHECK(my_grib_set_long(gh, "Ny", ysize), 0);
GRIB_CHECK(my_grib_set_long(gh, "DxInMetres", lround(xinc)), 0);
GRIB_CHECK(my_grib_set_long(gh, "DyInMetres", lround(yinc)), 0);
GRIB_CHECK(my_grib_set_long(gh, "DxInMetres", lround(fabs(xinc))), 0);
GRIB_CHECK(my_grib_set_long(gh, "DyInMetres", lround(fabs(yinc))), 0);
GRIB_CHECK(my_grib_set_double(gh, "longitudeOfFirstGridPointInDegrees", xval_0), 0);
GRIB_CHECK(my_grib_set_double(gh, "latitudeOfFirstGridPointInDegrees", yval_0), 0);
GRIB_CHECK(my_grib_set_double(gh, "LoVInDegrees", lon_0), 0);
......
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