Skip to content
Snippets Groups Projects
Commit d2dba72f authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

grid_define: added support for GRID_PROJECTION without coordinates.

parent 09055b66
No related branches found
No related tags found
No related merge requests found
Pipeline #22684 passed
......@@ -24,17 +24,15 @@
int
getoptname(char *optname, const char *optstring, int nopt)
{
int nerr = 0;
int nerr = 1;
auto pname = optstring;
auto pend = optstring;
for (int i = 0; i < nopt; ++i)
{
pend = strchr(pname, ',');
if (pend == nullptr)
break;
else
pname = pend + 1;
if (pend == nullptr) break;
pname = pend + 1;
}
if (pend)
......@@ -43,9 +41,8 @@ getoptname(char *optname, const char *optstring, int nopt)
const size_t namelen = (pend == nullptr) ? strlen(pname) : pend - pname;
memcpy(optname, pname, namelen);
optname[namelen] = '\0';
nerr = 0;
}
else
nerr = 1;
return nerr;
}
......@@ -122,13 +119,13 @@ grid_define(GridDesciption &grid)
{
if (grid.size != 1)
{
if (grid.xsize == 0 && grid.type != GRID_GAUSSIAN_REDUCED) cdo_abort("xsize undefined!");
if (grid.ysize == 0) cdo_abort("ysize undefined!");
if (grid.xsize == 0 && grid.type != GRID_PROJECTION && grid.type != GRID_GAUSSIAN_REDUCED) cdo_abort("xsize undefined!");
if (grid.ysize == 0 && grid.type != GRID_PROJECTION) cdo_abort("ysize undefined!");
}
if (grid.size == 0) grid.size = grid.xsize * grid.ysize;
if (grid.type != GRID_GAUSSIAN_REDUCED && grid.xsize && grid.size != grid.xsize * grid.ysize)
if (grid.type != GRID_PROJECTION && grid.type != GRID_GAUSSIAN_REDUCED && grid.xsize && grid.size != grid.xsize * grid.ysize)
cdo_abort("Inconsistent grid declaration: xsize*ysize!=gridsize (xsize=%zu ysize=%zu gridsize=%zu)", grid.xsize,
grid.ysize, grid.size);
......@@ -142,12 +139,12 @@ grid_define(GridDesciption &grid)
if (grid.nvertex) gridDefNvertex(gridID, grid.nvertex);
const auto def_xfirst = IS_NOT_EQUAL(grid.xfirst, undef_grid_value);
const auto def_yfirst = IS_NOT_EQUAL(grid.yfirst, undef_grid_value);
const auto def_xlast = IS_NOT_EQUAL(grid.xlast, undef_grid_value);
const auto def_ylast = IS_NOT_EQUAL(grid.ylast, undef_grid_value);
const auto def_xinc = IS_NOT_EQUAL(grid.xinc, undef_grid_value);
const auto def_yinc = IS_NOT_EQUAL(grid.yinc, undef_grid_value);
const auto def_xfirst = IS_NOT_EQUAL(grid.xfirst, undefGridValue);
const auto def_yfirst = IS_NOT_EQUAL(grid.yfirst, undefGridValue);
const auto def_xlast = IS_NOT_EQUAL(grid.xlast, undefGridValue);
const auto def_ylast = IS_NOT_EQUAL(grid.ylast, undefGridValue);
const auto def_xinc = IS_NOT_EQUAL(grid.xinc, undefGridValue);
const auto def_yinc = IS_NOT_EQUAL(grid.yinc, undefGridValue);
if ((def_xfirst || def_xlast || def_xinc) && grid.xvals.size() == 0)
{
const auto xfirst = def_xfirst ? grid.xfirst : 0.0;
......
......@@ -11,7 +11,7 @@
#include <string>
#include <cdi.h>
constexpr double undef_grid_value = 9.e20;
constexpr double undefGridValue = 9.e20;
struct // GridDesciption
#ifdef WARN_UNUSED
......@@ -26,9 +26,9 @@ GridDesciption
std::vector<double> ybounds;
std::vector<double> area;
std::vector<int> reducedPoints;
double xfirst = undef_grid_value, yfirst = undef_grid_value;
double xlast = undef_grid_value, ylast = undef_grid_value;
double xinc = undef_grid_value, yinc = undef_grid_value;
double xfirst = undefGridValue, yfirst = undefGridValue;
double xlast = undefGridValue, ylast = undefGridValue;
double xinc = undefGridValue, yinc = undefGridValue;
double xpole = 0.0, ypole = 0.0, angle = 0.0; // rotated north pole
int scanningMode = 64;
/*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment