Skip to content

Commit

Permalink
Added --updatelayermetadata option to update layermetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenplieger committed Sep 13, 2024
1 parent 52b2fa9 commit a48c9d2
Show file tree
Hide file tree
Showing 11 changed files with 191 additions and 232 deletions.
36 changes: 31 additions & 5 deletions adagucserverEC/CDBFileScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "CCreateTiles.h"
#include <set>
#include "utils/LayerMetadataStore.h"
#include "utils/ConfigurationUtils.h"
const char *CDBFileScanner::className = "CDBFileScanner";
std::vector<CT::string> CDBFileScanner::tableNamesDone;
// #define CDBFILESCANNER_DEBUG
Expand Down Expand Up @@ -951,7 +952,34 @@ int CDBFileScanner::updatedb(CDataSource *dataSource, CT::string *_tailPath, CT:
if (fileToUpdate.length() == 0) {
// No file specified, just scan the directory for matching filenames.
try {
fileList = searchFileNames(dataSource->cfgLayer->FilePath[0]->value.c_str(), filter.c_str(), tailPath.c_str());
if (scanFlags & CDBFILESCANNER_UPDATEDB_ONLYFILEFROMDEFAULTQUERY) {
if (checkIfPathIsFile(dataSource->cfgLayer->FilePath[0]->value.c_str())) {
fileList.push_back(dataSource->cfgLayer->FilePath[0]->value.c_str());
CDBDebug("Obtained filename from layer configuration [%s]", dataSource->cfgLayer->FilePath[0]->value.c_str());
} else {
CDBDebug("CDBFILESCANNER_UPDATEDB_ONLYFILEFROMDEFAULTQUERY");
int status = CRequest::setDimValuesForDataSource(dataSource, dataSource->srvParams);
if (status != 0) {
CDBError("setDimValuesForDataSource");
return 1;
}
status = CRequest::fillDimValuesForDataSource(dataSource, dataSource->srvParams);
if (status != 0) {
CDBError("fillDimValuesForDataSource");
return 1;
}
status = CRequest::queryDimValuesForDataSource(dataSource, dataSource->srvParams);
if (status != 0) {
CDBError("queryDimValuesForDataSource");
return 1;
}
fileList.push_back(dataSource->getFileName());
CDBDebug("Queried file from database with filename [%s]", dataSource->getFileName());
}
} else {
fileList = searchFileNames(dataSource->cfgLayer->FilePath[0]->value.c_str(), filter.c_str(), tailPath.c_str());
}

} catch (int linenr) {
CDBDebug("Exception in searchFileNames [%s] [%s]", dataSource->cfgLayer->FilePath[0]->value.c_str(), filter.c_str(), tailPath.c_str());
return 0;
Expand Down Expand Up @@ -1089,10 +1117,8 @@ std::vector<std::string> CDBFileScanner::searchFileNames(const char *path, CT::s
}
}
}
// CDBDebug("Checking if this is a file: [%s]", filePath.c_str());
if (filePath.endsWith(".nc") || filePath.endsWith(".h5") || filePath.endsWith(".hdf5") || filePath.endsWith(".he5") || filePath.endsWith(".png") || filePath.endsWith(".csv") ||
filePath.endsWith(".geojson") || filePath.endsWith(".json") || filePath.startsWith("http://") || filePath.startsWith("https://") || filePath.startsWith("dodsc://")) {
// Add single file or opendap URL.

if (checkIfPathIsFile(filePath)) {
std::vector<std::string> fileList;
fileList.push_back(filePath.c_str());
// CDBDebug("%s is a file",filePath.c_str());
Expand Down
2 changes: 2 additions & 0 deletions adagucserverEC/CDBFileScanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#define CDBFILESCANNER_RECREATETABLES 32
#define CDBFILESCANNER_CLEANFILES 64
#define CDBFILESCANNER_DONOTTILE 128
#define CDBUPDATE_LAYER_METADATA 256
#define CDBFILESCANNER_UPDATEDB_ONLYFILEFROMDEFAULTQUERY 512

// Return type to indicate nothing was found.
#define CDBFILESCANNER_RETURN_FILEDOESNOTMATCH 100
Expand Down
4 changes: 4 additions & 0 deletions adagucserverEC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ add_library(
utils/LayerUtils.cpp
utils/LayerMetadataToJson.h
utils/LayerMetadataToJson.cpp
utils/UpdateLayerMetadata.h
utils/UpdateLayerMetadata.cpp
utils/ConfigurationUtils.h
utils/ConfigurationUtils.cpp
Types/LayerMetadataType.h
CDataPostProcessors/CDataPostProcessor_AddFeatures.cpp
CDataPostProcessors/CDataPostProcessor_AddFeatures.h
Expand Down
154 changes: 0 additions & 154 deletions adagucserverEC/CRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,151 +414,6 @@ int CRequest::generateGetReferenceTimesDoc(CT::string *result, CDataSource *data
return 0;
}

int CRequest::process_wms_getstyles_request() {
// int status;
// if(srvParam->serviceType==SERVICE_WMS){
// if(srvParam->Geo->dWidth>MAX_IMAGE_WIDTH){
// CDBError("Parameter WIDTH must be smaller than %d",MAX_IMAGE_WIDTH);
// return 1;
// }
// if(srvParam->Geo->dHeight>MAX_IMAGE_HEIGHT){
// CDBError("Parameter HEIGHT must be smaller than %d",MAX_IMAGE_HEIGHT);
// return 1;
// }
// }
// CDrawImage plotCanvas;
// plotCanvas.setTrueColor(true);
// plotCanvas.createImage(int(srvParam->Geo->dWidth),int(srvParam->Geo->dHeight));
// plotCanvas.create685Palette();
//
// CImageDataWriter imageDataWriter;
//
// CDataSource * dataSource = new CDataSource();
// //dataSource->setCFGLayer(srvParam,srvParam->configObj->Configuration[0],srvParam->cfg->Layer[0],"prediction",0);
// dataSource->addStep("",NULL);
// dataSource->getCDFDims()->addDimension("time","0",0);
// dataSource->setTimeStep(0);
// dataSource->srvParams=srvParam;
// dataSource->cfg=srvParam->configObj->Configuration[0];
// dataSource->cfgLayer=srvParam->cfg->Layer[0];
// CDataSource::DataObject *newDataObject = new CDataSource::DataObject();
// newDataObject->variableName.copy("test");
// dataSource->getDataObjectsVector()->push_back(newDataObject);
// dataSource->dLayerType=CConfigReaderLayerTypeStyled;
//
//
//
//
// plotCanvas.rectangle(0,0,plotCanvas.Geo->dWidth,plotCanvas.Geo->dHeight,CColor(255,255,255,255),CColor(255,255,255,255));
//
// int legendWidth = 200;
// int legendHeight = 600;
//
//
//
//
//
//
// int posX=0;
// int posY=0;
//
// bool errorOccured = false;
//
// bool legendOnlyMode = true;
// try{
//
// for(size_t j=0;j<srvParam->cfg->Style.size();j++){
// CServerConfig::XMLE_Style* style = srvParam->cfg->Style[j];
// CDBDebug("style %s",style->attr.name.c_str());
//
// CT::PointerList<CT::string*> *legendList = NULL;
//
// if(legendOnlyMode == false){
// legendList = CServerParams::getLegendNames(style->Legend);
// }else{
// legendList = new CT::PointerList<CT::string*>();
// for(size_t j=0;j<srvParam->cfg->Legend.size();j++){
//
// legendList->push_back(new CT::string(srvParam->cfg->Legend[j]->attr.name.c_str()));
//
// }
// }
//
// CDBDebug("Found %d legends",legendList->size());
// for(size_t i=0;i<legendList->size();i++){
// CDBDebug("legend %s",(*legendList)[i]->c_str());
//
// int legendIndex =
// CImageDataWriter::getServerLegendIndexByName((*legendList)[i]->c_str(),srvParam->cfg->Legend);
// if(legendIndex == -1){
// CDBError("Legend %s is not configured");
// delete legendList;
// throw (__LINE__);
// }
// CDBDebug("Found legend index %d",legendIndex);
//
// CT::PointerList<CT::string*> *renderMethodList =
// CImageDataWriter::getRenderMethodListForDataSource(dataSource,style);
//
// CDBDebug("Found %d rendermethods",renderMethodList->size());
// // for(size_t r=0;r<renderMethodList->size();r++){
// // CDBDebug("Using
// %s->%s->%s",style->attr.name.c_str(),(*legendList)[i]->c_str(),(*renderMethodList)[r]->c_str());
// // CT::string styleName;
// // styleName.print("%s/%s",style->attr.name.c_str(),(*renderMethodList)[r]->c_str());
// // if(legendOnlyMode){
// // styleName.print("%s",(*legendList)[i]->c_str());
// // }
// //
// //
// //
// CImageDataWriter::makeStyleConfig(dataSource->styleConfiguration,dataSource);//,style->attr.name.c_str(),(*legendList)[i]->c_str(),(*renderMethodList)[r]->c_str());
// //
// // CDrawImage legendImage;
// // legendImage.enableTransparency(true);
// // legendImage.createImage(&plotCanvas,legendWidth,legendHeight);
// // status = legendImage.createGDPalette(srvParam->cfg->Legend[legendIndex]);if(status !=
// 0)throw(__LINE__);
// //
// //
// //
// legendImage.rectangle(0,0,legendImage.Geo->dWidth-1,legendImage.Geo->dHeight-1,CColor(255,255,255,255),CColor(0,0,255,255));
// // status = imageDataWriter.createLegend(dataSource,&legendImage);if(status != 0)throw(__LINE__);
// // //posX = (legendNr++)*legendWidth;
// //
// // plotCanvas.draw(posX,posY,0,0,&legendImage);
// //
// plotCanvas.drawText(posX+4,posY+legendHeight-4,srvParam->cfg->WMS[0]->SubTitleFont[0]->attr.location.c_str(),8,0,styleName.c_str(),CColor(0,0,0,255),textBGColor);
// //
// // posX+=legendWidth;
// // if(posX>plotCanvas.Geo->dWidth){
// // posX=0;
// // posY+=legendHeight;
// // }
// // if(legendOnlyMode)break;
// // }
// delete renderMethodList;
// }
// delete legendList;
// if(legendOnlyMode)break;
// }
// }catch(int e){
// errorOccured = true;
// }
//
//
//
//
// delete dataSource;
//
// if(errorOccured){
// return 1;
// }
// printf("%s%c%c\n","Content-Type:image/png",13,10);
// plotCanvas.printImagePng();
return 0;
}

int CRequest::process_wms_getlegendgraphic_request() {
if (srvParam->WMSLayers != NULL)
for (size_t j = 0; j < srvParam->WMSLayers->count; j++) {
Expand Down Expand Up @@ -2935,8 +2790,6 @@ int CRequest::process_querystring() {
srvParam->requestType = REQUEST_WMS_GETLEGENDGRAPHIC;
else if (REQUEST.equals("GETMETADATA"))
srvParam->requestType = REQUEST_WMS_GETMETADATA;
else if (REQUEST.equals("GETSTYLES"))
srvParam->requestType = REQUEST_WMS_GETSTYLES;
else if (REQUEST.equals("GETREFERENCETIMES"))
srvParam->requestType = REQUEST_WMS_GETREFERENCETIMES;
else {
Expand Down Expand Up @@ -3061,13 +2914,6 @@ int CRequest::process_querystring() {
// WMS Service
if (dErrorOccured == 0 && srvParam->serviceType == SERVICE_WMS) {
// CDBDebug("Entering WMS service");

if (srvParam->requestType == REQUEST_WMS_GETSTYLES) {

if (process_wms_getstyles_request() != 0) return 1;
return 0;
}

if (srvParam->requestType == REQUEST_WMS_GETREFERENCETIMES) {
int status = process_wms_getreferencetimes_request();
if (status != 0) {
Expand Down
1 change: 0 additions & 1 deletion adagucserverEC/CRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ class CRequest {
int process_wms_getmap_request();
int process_wms_getmetadata_request();
int process_wms_getfeatureinfo_request();
int process_wms_getstyles_request();
int process_wms_getlegendgraphic_request();
int process_wcs_getcap_request();
int process_wcs_describecov_request();
Expand Down
1 change: 0 additions & 1 deletion adagucserverEC/Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
#define REQUEST_WCS_DESCRIBECOVERAGE 6
#define REQUEST_WCS_GETCOVERAGE 7
#define REQUEST_WMS_GETMETADATA 8
#define REQUEST_WMS_GETSTYLES 9
#define REQUEST_WMS_GETPOINTVALUE 10
#define REQUEST_WMS_GETREFERENCETIMES 11
#define REQUEST_WMS_GETHISTOGRAM 12
Expand Down
Loading

0 comments on commit a48c9d2

Please sign in to comment.