Commit 5ef70d05 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

grid_read_mapping: set default name for CDI_KEY_GRIDMAP_VARNAME.

parent 24ae64ad
Pipeline #5635 passed with stages
in 14 minutes and 58 seconds
...@@ -256,6 +256,7 @@ grid_read_data(size_t ikv, size_t nkv, KVMap *kvmap, GridDesciption &grid, size_ ...@@ -256,6 +256,7 @@ grid_read_data(size_t ikv, size_t nkv, KVMap *kvmap, GridDesciption &grid, size_
static void static void
grid_read_mapping(size_t igmap, size_t nkv, KVMap *kvmap, int gridID) grid_read_mapping(size_t igmap, size_t nkv, KVMap *kvmap, int gridID)
{ {
bool hasGridmapVarname = false;
for (size_t ik = igmap; ik < nkv; ++ik) for (size_t ik = igmap; ik < nkv; ++ik)
{ {
if (!kvmap[ik].isValid) continue; if (!kvmap[ik].isValid) continue;
...@@ -269,14 +270,25 @@ grid_read_mapping(size_t igmap, size_t nkv, KVMap *kvmap, int gridID) ...@@ -269,14 +270,25 @@ grid_read_mapping(size_t igmap, size_t nkv, KVMap *kvmap, int gridID)
if (key == "grid_mapping") if (key == "grid_mapping")
{ {
hasGridmapVarname = true;
cdiDefKeyString(gridID, CDI_GLOBAL, CDI_KEY_GRIDMAP_VARNAME, value.c_str()); cdiDefKeyString(gridID, CDI_GLOBAL, CDI_KEY_GRIDMAP_VARNAME, value.c_str());
continue; continue;
} }
if (key == "grid_mapping_name") cdiDefKeyString(gridID, CDI_GLOBAL, CDI_KEY_GRIDMAP_NAME, value.c_str()); if (key == "grid_mapping_name")
{
if (!hasGridmapVarname)
{
if (value == "rotated_latitude_longitude")
cdiDefKeyString(gridID, CDI_GLOBAL, CDI_KEY_GRIDMAP_VARNAME, "rotated_pole");
else
cdiDefKeyString(gridID, CDI_GLOBAL, CDI_KEY_GRIDMAP_VARNAME, "crs");
}
const auto dtype = literalsFindDatatype(nvalues, values); cdiDefKeyString(gridID, CDI_GLOBAL, CDI_KEY_GRIDMAP_NAME, value.c_str());
}
const auto dtype = literalsFindDatatype(nvalues, values);
if (dtype == CDI_DATATYPE_INT8 || dtype == CDI_DATATYPE_INT16 || dtype == CDI_DATATYPE_INT32) if (dtype == CDI_DATATYPE_INT8 || dtype == CDI_DATATYPE_INT16 || dtype == CDI_DATATYPE_INT32)
{ {
std::vector<int> ivals(nvalues); std::vector<int> ivals(nvalues);
......
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