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

Set default mapping name to Projection.

parent 22f46e00
......@@ -299,10 +299,7 @@ void cdf_get_gmapvarname(int gridID, char *gmapvarname)
}
if ( mapping[0] )
{
cdiGridInqKeyStr(pgridID, CDI_KEY_MAPNAME, CDI_MAX_NAME, gmapvarname);
if ( !gmapvarname[0] ) strcpy(gmapvarname, "dummy");
}
cdiGridInqKeyStr(pgridID, CDI_KEY_MAPNAME, CDI_MAX_NAME, gmapvarname);
}
static
......
......@@ -142,9 +142,9 @@ extern "C" {
#define GRID_SINUSOIDAL 14 /* Sinusoidal */
#define GRID_PROJECTION 15 /* Projected coordinates */
#define CDI_PROJ_RLL 11 /* Rotated Latitude Longitude */
#define CDI_PROJ_LCC 12 /* Lambert Conformal Conic */
#define CDI_PROJ_LAEA 13 /* Lambert Azimuthal Equal Area */
#define CDI_PROJ_RLL 21 /* Rotated Latitude Longitude */
#define CDI_PROJ_LCC 22 /* Lambert Conformal Conic */
#define CDI_PROJ_LAEA 23 /* Lambert Azimuthal Equal Area */
/* ZAXIS types */
......
......@@ -339,11 +339,15 @@ cdiGridTypeInit(grid_t *gridptr, int gridtype, int size)
break;
}
case GRID_GENERIC:
case GRID_PROJECTION:
{
/* gridptr->x.size = size; */
if ( gridptr->x.name[0] == 0 ) gridSetName(gridptr->x.name, "x");
if ( gridptr->y.name[0] == 0 ) gridSetName(gridptr->y.name, "y");
if ( gridtype == GRID_PROJECTION )
{
gridSetName(gridptr->mapname, "Projection");
}
/*
strcpy(gridptr->x.stdname, "grid_longitude");
strcpy(gridptr->y.stdname, "grid_latitude");
......@@ -1829,10 +1833,17 @@ void gridInqProjParamRLL(int gridID, double *xpole, double *ypole, double *angle
void gridDefProjParamRLL(int gridID, double xpole, double ypole, double angle)
{
cdiGridDefKeyStr(gridID, CDI_KEY_MAPPING, CDI_MAX_NAME, "rotated_latitude_longitude");
cdiGridDefKeyStr(gridID, CDI_KEY_MAPNAME, CDI_MAX_NAME, "rotated_pole");
const char *mapping = "rotated_latitude_longitude";
cdiGridDefKeyStr(gridID, CDI_KEY_MAPPING, CDI_MAX_NAME, mapping);
vlistDefAttTxt(gridID, CDI_GLOBAL, "grid_mapping_name", strlen(mapping)+1, mapping);
vlistDefAttFlt(gridID, CDI_GLOBAL, "grid_north_pole_longitude", DATATYPE_FLT64, 1, &xpole);
vlistDefAttFlt(gridID, CDI_GLOBAL, "grid_north_pole_latitude", DATATYPE_FLT64, 1, &ypole);
if ( IS_NOT_EQUAL(angle, 0) ) vlistDefAttFlt(gridID, CDI_GLOBAL, "north_pole_grid_longitude", DATATYPE_FLT64, 1, &angle);
grid_t *gridptr = gridID2Ptr(gridID);
gridptr->projtype = CDI_PROJ_RLL;
}
/*
......@@ -2689,10 +2700,10 @@ void gridComplete(grid_t *grid)
*/
}
if ( grid->isRotated )
if ( grid->isRotated || grid->projtype == CDI_PROJ_RLL )
{
if ( grid->x.name[0] == 0 ) gridDefXname(gridID, "rlon");
if ( grid->y.name[0] == 0 ) gridDefYname(gridID, "rlat");
if ( grid->x.name[0] == 0 || grid->x.name[0] == 'x' ) gridDefXname(gridID, "rlon");
if ( grid->y.name[0] == 0 || grid->y.name[0] == 'y' ) gridDefYname(gridID, "rlat");
if ( grid->x.longname[0] == 0 ) gridDefXlongname(gridID, "longitude in rotated pole grid");
if ( grid->y.longname[0] == 0 ) gridDefYlongname(gridID, "latitude in rotated pole grid");
grid->x.stdname = xystdname_tab[grid_xystdname_grid_latlon][0];
......@@ -2700,9 +2711,12 @@ void gridComplete(grid_t *grid)
if ( grid->x.units[0] == 0 ) gridDefXunits(gridID, "degrees");
if ( grid->y.units[0] == 0 ) gridDefYunits(gridID, "degrees");
gridDefXpole(gridID, grid->rll.xpole);
gridDefYpole(gridID, grid->rll.ypole);
gridDefAngle(gridID, grid->rll.angle);
if ( grid->isRotated )
{
gridDefXpole(gridID, grid->rll.xpole);
gridDefYpole(gridID, grid->rll.ypole);
gridDefAngle(gridID, grid->rll.angle);
}
}
switch (gridtype)
......
......@@ -811,8 +811,8 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int gridindex, int ndims,
ncgrid[gridindex].ydimID = dimID;
}
static void
finishCyclicXBounds(double *pbounds, size_t dimlen, const double *pvals)
static
void finishCyclicXBounds(double *pbounds, size_t dimlen, const double *pvals)
{
pbounds[0] = (pvals[0] + pvals[dimlen-1]-360)*0.5;
pbounds[2*dimlen-1] = (pvals[dimlen-1] + pvals[0]+360)*0.5;
......@@ -825,8 +825,8 @@ void cdfDefXaxis(stream_t *streamptr, int gridID, int gridindex, int ndims)
CDI_KEY_XDIMNAME, 'X', finishCyclicXBounds);
}
static void
finishCyclicYBounds(double *pbounds, size_t dimlen, const double *pvals)
static
void finishCyclicYBounds(double *pbounds, size_t dimlen, const double *pvals)
{
pbounds[0] = copysign(90.0, pvals[0]);
pbounds[2*dimlen-1] = copysign(90.0, pvals[dimlen-1]);
......@@ -1940,13 +1940,12 @@ void cdf_def_mapping(stream_t *streamptr, int gridID)
{
char gmapvarname[CDI_MAX_NAME]; gmapvarname[0] = 0;
cdiGridInqKeyStr(gridID, CDI_KEY_MAPNAME, CDI_MAX_NAME, gmapvarname);
if ( !gmapvarname[0] ) strcpy(gmapvarname, "dummy");
int fileID = streamptr->fileID;
cdf_redef(fileID);
int ncvarid;
int ncerrcode = nc_def_var(fileID, gmapvarname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
int ncerrcode = nc_def_var(fileID, gmapvarname, (nc_type) NC_INT, 0, NULL, &ncvarid);
if ( ncerrcode == NC_NOERR )
cdfDefineAttributes(gridID, CDI_GLOBAL, fileID, ncvarid);
......
......@@ -665,6 +665,8 @@ void iegAddRecord(stream_t *streamptr, int param, int *pdb, int *gdb, double *vc
grid->rll.ypole = ypole;
grid->rll.angle = 0;
}
else
grid->projtype = CDI_PROJ_RLL;
}
struct addIfNewRes gridAdded = cdiVlistAddGridIfNew(vlistID, grid, 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