Skip to content

Commit

Permalink
Postproc for windshear is working
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenplieger committed Jun 28, 2023
1 parent 582220f commit 037a670
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 14 deletions.
10 changes: 8 additions & 2 deletions adagucserverEC/CDFObjectStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ CDFObject *CDFObjectStore::getCDFObject(CDataSource *dataSource, const char *fil

CDFObject *CDFObjectStore::getCDFObject(CDataSource *dataSource, CServerParams *srvParams, const char *fileName, bool plain) {
CT::string uniqueIDForFile = fileName;
if (dataSource != NULL && dataSource->layerName.empty() == false) {
uniqueIDForFile.concat(dataSource->layerName);
}
if (srvParams == NULL && dataSource != NULL) {
srvParams = dataSource->srvParams;
}
Expand Down Expand Up @@ -282,7 +285,6 @@ CDFObject *CDFObjectStore::getCDFObject(CDataSource *dataSource, CServerParams *
CDFCache *cdfCache = NULL;

if (srvParams != NULL) {

CT::string cacheDir = srvParams->cfg->TempDir[0]->attr.value.c_str();
// srvParams->getCacheDirectory(&cacheDir);
if (cacheDir.length() > 0) {
Expand All @@ -302,16 +304,20 @@ CDFObject *CDFObjectStore::getCDFObject(CDataSource *dataSource, CServerParams *
CDBError("Exception thrown during opening of %s", fileLocationToOpen);
}

/* Apply NCML file to the datamodel */
if (dataSource) {
if (dataSource->cfgLayer) {
/* Apply NCML file to the datamodel */
if (dataSource->cfgLayer->FilePath.size() == 1) {
CT::string ncmlFileName = dataSource->cfgLayer->FilePath[0]->attr.ncml;
if (!ncmlFileName.empty()) {
CDBDebug("NCML: Applying NCML file %s", ncmlFileName.c_str());
cdfObject->applyNCMLFile(ncmlFileName.c_str());
}
}
if (!dataSource->cfgLayer->Variable[0]->attr.orgname.empty()) {
CDF::Variable *var = cdfObject->getVariable(dataSource->cfgLayer->Variable[0]->attr.orgname);
var->name.copy(dataSource->cfgLayer->Variable[0]->value);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ int CDPPIncludeLayer::execute(CServerConfig::XMLE_DataPostProc *proc, CDataSourc
if ((isApplicable(proc, dataSource, mode) & mode) == false) {
return -1;
}

if (mode == CDATAPOSTPROCESSOR_RUNBEFOREREADING) {

CDBDebug("CDATAPOSTPROCESSOR_RUNBEFOREREADING::Applying include_layer");
Expand Down
15 changes: 15 additions & 0 deletions adagucserverEC/CRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,21 @@ int CRequest::fillDimValuesForDataSource(CDataSource *dataSource, CServerParams
}
}
}
// Check and set value when the value is forced in the layer dimension configuration
for (size_t i = 0; i < dataSource->cfgLayer->Dimension.size(); i++) {
if (!dataSource->cfgLayer->Dimension[i]->attr.forcevalue.empty()) {
CT::string dimName(dataSource->cfgLayer->Dimension[i]->value.c_str());
CT::string forceValue = dataSource->cfgLayer->Dimension[i]->attr.forcevalue;
dimName.toLowerCaseSelf();
for (size_t l = 0; l < dataSource->requiredDims.size(); l++) {
if (dataSource->requiredDims[l]->name.equals(&dimName)) {
CDBDebug("Forcing dimension %s from %s to %s", dimName.c_str(), dataSource->requiredDims[i]->value.c_str(), forceValue.c_str());
dataSource->requiredDims[i]->value = forceValue;
break;
}
}
}
}

// STOP NOW
} catch (int i) {
Expand Down
44 changes: 32 additions & 12 deletions adagucserverEC/CServerConfig_CPPXSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,19 @@ class CServerConfig : public CXMLSerializerInterface {
};
class XMLE_Abstract : public CXMLObjectInterface {};
class XMLE_DataBaseTable : public CXMLObjectInterface {};
class XMLE_Variable : public CXMLObjectInterface {};
class XMLE_Variable : public CXMLObjectInterface {
public:
class Cattr {
public:
CT::string orgname;
} attr;
void addAttribute(const char *name, const char *value) {
if (equals("orgname", 7, name)) {
attr.orgname.copy(value);
return;
}
}
};
class XMLE_DataReader : public CXMLObjectInterface {
public:
class Cattr {
Expand Down Expand Up @@ -1165,30 +1177,38 @@ class CServerConfig : public CXMLSerializerInterface {
public:
class Cattr {
public:
CT::string name, interval, defaultV, units, quantizeperiod, quantizemethod;
CT::string name, interval, defaultV, units, quantizeperiod, quantizemethod, forcevalue;
bool hidden = false;
} attr;
void addAttribute(const char *attrname, const char *attrvalue) {
if (equals("name", 4, attrname)) {
attr.name.copy(attrvalue);
return;
}
if (equals("units", 5, attrname)) {
} else if (equals("units", 5, attrname)) {
attr.units.copy(attrvalue);
return;
}
if (equals("default", 7, attrname)) {
} else if (equals("default", 7, attrname)) {
attr.defaultV.copy(attrvalue);
return;
}
if (equals("interval", 8, attrname)) {
} else if (equals("interval", 8, attrname)) {
attr.interval.copy(attrvalue);
return;
}
if (equals("quantizeperiod", 14, attrname)) {
} else if (equals("quantizeperiod", 14, attrname)) {
attr.quantizeperiod.copy(attrvalue);
return;
}
if (equals("quantizemethod", 14, attrname)) {
} else if (equals("forcevalue", 10, attrname)) {
attr.forcevalue.copy(attrvalue);
return;
} else if (equals("hidden", 6, attrname)) {
if (equals("false", 5, attrvalue)) {
attr.hidden = false;
}
if (equals("true", 4, attrvalue)) {
attr.hidden = true;
}

return;
} else if (equals("quantizemethod", 14, attrname)) {
attr.quantizemethod.copy(attrvalue);
return;
}
Expand Down
15 changes: 15 additions & 0 deletions adagucserverEC/CXMLGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,18 @@ int CXMLGen::getDimsForLayer(WMSLayer *myWMSLayer) {
}
}
}

// Check for forced values
if (!myWMSLayer->dataSource->cfgLayer->Dimension[i]->attr.forcevalue.empty()) {
dim->values = myWMSLayer->dataSource->cfgLayer->Dimension[i]->attr.forcevalue;
dim->defaultValue = myWMSLayer->dataSource->cfgLayer->Dimension[i]->attr.forcevalue;
dim->hasMultipleValues = false;
}

// Check if it should be hidden
if (myWMSLayer->dataSource->cfgLayer->Dimension[i]->attr.hidden == true) {
dim->hidden = true;
}
}
}

Expand Down Expand Up @@ -788,6 +800,7 @@ int CXMLGen::getWMS_1_0_0_Capabilities(CT::string *XMLDoc, std::vector<WMSLayer
// Dims
for (size_t d = 0; d < layer->dimList.size(); d++) {
WMSLayer::Dim *dim = layer->dimList[d];
if (dim->hidden) continue;
XMLDoc->printconcat("<Dimension name=\"%s\" units=\"%s\"/>\n", dim->name.c_str(), dim->units.c_str());
XMLDoc->printconcat("<Extent name=\"%s\" default=\"%s\" multipleValues=\"%d\" nearestValue=\"0\">", dim->name.c_str(), dim->defaultValue.c_str(), 1);
XMLDoc->concat(dim->values.c_str());
Expand Down Expand Up @@ -928,6 +941,7 @@ int CXMLGen::getWMS_1_1_1_Capabilities(CT::string *XMLDoc, std::vector<WMSLayer
// Dims
for (size_t d = 0; d < layer->dimList.size(); d++) {
WMSLayer::Dim *dim = layer->dimList[d];
if (dim->hidden) continue;
XMLDoc->printconcat("<Dimension name=\"%s\" units=\"%s\"/>\n", dim->name.c_str(), dim->units.c_str());
XMLDoc->printconcat("<Extent name=\"%s\" default=\"%s\" multipleValues=\"%d\" nearestValue=\"0\">", dim->name.c_str(), dim->defaultValue.c_str(), 1);
XMLDoc->concat(dim->values.c_str());
Expand Down Expand Up @@ -1347,6 +1361,7 @@ int CXMLGen::getWMS_1_3_0_Capabilities(CT::string *XMLDoc, std::vector<WMSLayer
// Dims
for (size_t d = 0; d < layer->dimList.size(); d++) {
WMSLayer::Dim *dim = layer->dimList[d];
if (dim->hidden) continue;
if (dim->name.indexOf("time") != -1) {
XMLDoc->printconcat("<Dimension name=\"%s\" units=\"%s\" default=\"%s\" multipleValues=\"%d\" nearestValue=\"0\" current=\"1\">", dim->name.c_str(), dim->units.c_str(),
dim->defaultValue.c_str(), 1);
Expand Down
1 change: 1 addition & 0 deletions adagucserverEC/CXMLGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class WMSLayer {
CT::string values;
CT::string defaultValue;
int hasMultipleValues;
bool hidden = false;
};
class Projection {
public:
Expand Down

0 comments on commit 037a670

Please sign in to comment.