Skip to content

Commit

Permalink
Merge pull request #217 from KNMI/innov-profiles
Browse files Browse the repository at this point in the history
Support profiles with time/height data
  • Loading branch information
maartenplieger authored Feb 1, 2024
2 parents 4acdbbc + 3ca2c2a commit d592192
Show file tree
Hide file tree
Showing 24 changed files with 729 additions and 203 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ USER root
LABEL maintainer="adaguc@knmi.nl"

# Version should be same as in Definitions.h
LABEL version="2.15.0"
LABEL version="2.15.1"

# Try to update image packages
RUN apt-get -q -y update \
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
**Version 2.15.1 2024-01-22**
- Support time/height profile data from https://dataplatform.knmi.nl/dataset/ceilonet-chm15k-backsct-la1-t12s-v1-0

**Version 2.15.0 2024-01-29**
- PostgreSQL queries have been optimized

Expand Down
12 changes: 6 additions & 6 deletions adagucserverEC/CDataSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,18 +357,15 @@ int CDataSource::setCFGLayer(CServerParams *_srvParams, CServerConfig::XMLE_Conf
srvParams = _srvParams;
cfg = _cfg;
cfgLayer = _cfgLayer;
// numVariables = cfgLayer->Variable.size();
// CDBDebug("Configure layer ");
datasourceIndex = layerIndex;

// Make DataObjects for each Variable defined in the Layer.
for (size_t j = 0; j < cfgLayer->Variable.size(); j++) {
DataObject *newDataObject = new DataObject();
newDataObject->variableName.copy(cfgLayer->Variable[j]->value.c_str());
if (!cfgLayer->Variable[j]->attr.orgname.empty()) {
newDataObject->variableName = cfgLayer->Variable[j]->value.c_str();
}

getDataObjectsVector()->push_back(newDataObject);
}

// Set the layername
CT::string layerUniqueName;
if (_layerName == NULL) {
Expand All @@ -383,6 +380,8 @@ int CDataSource::setCFGLayer(CServerParams *_srvParams, CServerConfig::XMLE_Conf
layerName = "";
layerName.concat(_layerName);

layerTitle = cfgLayer->Title.size() > 0 && !cfgLayer->Title[0]->value.empty() ? cfgLayer->Title[0]->value.c_str() : layerName.c_str();

#ifdef CDATASOURCE_DEBUG
CDBDebug("LayerName=\"%s\"", layerName.c_str());
#endif
Expand Down Expand Up @@ -466,6 +465,7 @@ CT::string CDataSource::getDimensionValue(int i) { return timeSteps[currentAnima
int CDataSource::getNumTimeSteps() { return (int)timeSteps.size(); }

const char *CDataSource::getLayerName() { return layerName.c_str(); }
const char *CDataSource::getLayerTitle() { return layerTitle.c_str(); }

CCDFDims *CDataSource::getCDFDims() {
if (currentAnimationStep >= int(timeSteps.size())) {
Expand Down
2 changes: 2 additions & 0 deletions adagucserverEC/CDataSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ class CDataSource {
int dNetCDFNumDims;
int dLayerType;
CT::string layerName;
CT::string layerTitle;

//
bool queryBBOX; // True: query on viewport
Expand Down Expand Up @@ -327,6 +328,7 @@ class CDataSource {
CCDFDims *getCDFDims();
int getNumTimeSteps();
const char *getLayerName();
const char *getLayerTitle();

int attachCDFObject(CDFObject *cdfObject);
void detachCDFObject();
Expand Down
35 changes: 16 additions & 19 deletions adagucserverEC/CImageDataWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ int CImageDataWriter::getFeatureInfo(std::vector<CDataSource *> dataSources, int
bool openAll = false;

bool everythingIsInBBOX = true;

CDataReader reader;
reader.open(dataSources[d], CNETCDFREADER_MODE_OPEN_HEADER);
if (dataSources[d]->getNumDataObjects() > 0) {
Expand All @@ -717,9 +718,7 @@ int CImageDataWriter::getFeatureInfo(std::vector<CDataSource *> dataSources, int
openAll = true;
}
if (dataSources[d]->getDataObject(0)->cdfVariable->getAttributeNE("ADAGUC_PROFILE") != NULL) {
if (!srvParam->InfoFormat.equals("application/json")) {
isProfileData = true;
}
isProfileData = true;
}
if (dataSources[d]->getDataObject(0)->cdfObject->getAttributeNE("ADAGUC_GEOJSON") != NULL) {
openAll = true;
Expand Down Expand Up @@ -747,17 +746,10 @@ int CImageDataWriter::getFeatureInfo(std::vector<CDataSource *> dataSources, int
CDBDebug("isProfileData:[%d] openAll:[%d] sameHeaderForAll:[%d] infoFormat:[%s]", isProfileData, openAll, sameHeaderForAll, srvParam->InfoFormat.c_str());

if (isProfileData) {
if (srvParam->InfoFormat.equals("image/png")) {
int status = CMakeEProfile::MakeEProfile(&drawImage, &imageWarper, dataSources, d, dX, dY);
if (status != 0) {
CDBError("CMakeEProfile::MakeEProfile failed");
return status;
}
CDBDebug("CMakeEProfile::MakeEProfile done");
} else {
printf("%s%c%c\n", "Content-Type:text/plain", 13, 10);
printf("Not supported yet");
return 0;
int status = CMakeEProfile::MakeEProfile(&drawImage, &imageWarper, dataSources, d, dX, dY, &eProfileJson);
if (status != 0) {
CDBError("CMakeEProfile::MakeEProfile failed");
return status;
}
} else if (sameHeaderForAll == false && openAll == false && srvParam->InfoFormat.equals("application/json")) {
int status = CMakeJSONTimeSeries::MakeJSONTimeSeries(&drawImage, &imageWarper, dataSources, d, dX, dY, &gfiStructure);
Expand Down Expand Up @@ -2402,8 +2394,13 @@ int CImageDataWriter::end() {
if (isProfileData) {
resultFormat = imagepng_eprofile;

printf("%s%c%c\n", "Content-Type:image/png", 13, 10);
drawImage.printImagePng8(true);
if (srvParam->InfoFormat.equals("image/png")) {
printf("%s%s%c%c\n", "Content-Type:image/png", srvParam->getCacheControlHeader(CSERVERPARAMS_CACHE_CONTROL_OPTION_SHORTCACHE).c_str(), 13, 10);
drawImage.printImagePng8(true);
} else {
printf("%s%s%c%c\n", "Content-Type:application/json", srvParam->getCacheControlHeader(CSERVERPARAMS_CACHE_CONTROL_OPTION_SHORTCACHE).c_str(), 13, 10);
printf("%s", eProfileJson.c_str());
}

return 0;
}
Expand Down Expand Up @@ -3697,8 +3694,8 @@ void rotateUvNorth(double &u, double &v, double rlo, double rla, float deltaX, f
xpntNorthSph -= xpnt0Sph, ypntNorthSph -= ypnt0Sph;
zpntNorthSph -= zpnt0Sph;

NormVector(xpntEastSph, ypntEastSph, zpntEastSph); // vecx
NormVector(xpntNorthSph, ypntNorthSph, zpntNorthSph); // vecy
NormVector(xpntEastSph, ypntEastSph, zpntEastSph); // vecx
NormVector(xpntNorthSph, ypntNorthSph, zpntNorthSph); // vecy

CrossProd(xpntEastSph, ypntEastSph, zpntEastSph, xpntNorthSph, ypntNorthSph, zpntNorthSph, xnormSph, ynormSph, znormSph); // vec z
xpntNorthSphRot = -znormSph * xnormSph; // xpntNorthSphRot = 0.0 - Dist*xnormSph;
Expand All @@ -3719,7 +3716,7 @@ void rotateUvNorth(double &u, double &v, double rlo, double rla, float deltaX, f

xpntNorthSph = sin(vecAngle); // Rotate the point/vector (0,1) around Z-axis with vecAngle
ypntNorthSph = cos(vecAngle);
xpntEastSph = ypntNorthSph; // Rotate the same point/vector around Z-axis with 90 degrees
xpntEastSph = ypntNorthSph; // Rotate the same point/vector around Z-axis with 90 degrees
ypntEastSph = -xpntNorthSph;

// zpntNorthSph = 0; zpntEastSph = 0; // not needed in 2D
Expand Down
1 change: 1 addition & 0 deletions adagucserverEC/CImageDataWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class CImageDataWriter : public CBaseDataWriterInterface {
// int status;
int animation;
int nrImagesAdded;
CT::string eProfileJson;

public:
public:
Expand Down
Loading

0 comments on commit d592192

Please sign in to comment.