Skip to content

Commit

Permalink
Merge pull request #144 from KNMI/runadagucfromcmd
Browse files Browse the repository at this point in the history
ADAGUC can now be runned from python
  • Loading branch information
maartenplieger authored Nov 18, 2020
2 parents 546ab6f + c938685 commit 623efec
Show file tree
Hide file tree
Showing 59 changed files with 2,739 additions and 143 deletions.
17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ bin/*
#Python pyc files
*.pyc

#Sqlite files
*db
*result.png*

#Test results
tests/log
tests/tmp
Expand Down Expand Up @@ -86,8 +90,19 @@ Docker/keystore.jks
adaguc-services
adaguc-services.log


data/python/adaguc.egg-info/
data/python/adaguc_knmi.nl.egg-info/
data/python/adaguc_server.egg-info/
data/python/adagucserver.egg-info/
data/python/env/
data/python/dist/

.cmake
*/.cmake
*CMakeFiles*

build
build
adaguc.egg-info
env
dist
71 changes: 32 additions & 39 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"/usr/include/cairo/",
"/usr/include/freetype2/",
"/usr/include/freetype2/",
"/usr/include/hdf5/serial/",
"./hclasses/",
"./CCDFDataModel/",
"./adagucserverEC/",
"${default}"
],
"defines": [
"${default}"
],
"macFrameworkPath": [
"${default}"
],
"forcedInclude": [
"${default}"
],
"compileCommands": "${default}",
"browse": {
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": "${default}",
"path": [
"${default}"
]
},
"intelliSenseMode": "${default}",
"cStandard": "${default}",
"cppStandard": "${default}",
"compilerPath": "${default}",
"configurationProvider": "go2sh.cmake-integration"
}
],
"version": 4
}
"configurations": [
{
"name": "ADAGUC",
"includePath": [
"/usr/include/cairo/",
"/usr/include/freetype2/",
"/usr/include/freetype2/",
"/usr/include/hdf5/serial/",
"./hclasses/",
"./CCDFDataModel/",
"./adagucserverEC/",
"${default}",
"${workspaceRoot}"
],
"defines": ["${default}"],
"macFrameworkPath": ["${default}"],
"forcedInclude": ["${default}"],
"compileCommands": "${default}",
"browse": {
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": "${default}",
"path": ["${default}"]
},
// "intelliSenseMode": "${default}",
"cStandard": "${default}",
"cppStandard": "${default}",
"compilerPath": "${default}"
// "configurationProvider": "go2sh.cmake-integration"
}
],
"version": 4
}
20 changes: 20 additions & 0 deletions .vscode/cmake_configurations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "Debug",
"buildType": "Debug"
},
{
"name": "Release",
"buildType": "Release"
},
{
"name": "RelWithDebInfo",
"buildType": "RelWithDebInfo"
},
{
"name": "MinSizeRel",
"buildType": "MinSizeRel"
}
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files.associations": {
"random": "cpp"
},
"cmake.buildDirectory": "${workspaceFolder}/bin"
}
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.15)
project(adaguc-server VERSION 3.0.0)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Expand Down
3 changes: 3 additions & 0 deletions Docker/adaguc-services-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<queuesize>32</queuesize>
<adagucexecutable>/adaguc/adaguc-server-master/bin/adagucserver</adagucexecutable>
<export>ADAGUC_PATH=/adaguc/adaguc-server-master/</export>
<export>ADAGUC_DATASET_DIR={ENV.ADAGUC_DATASET_DIR}</export>
<export>ADAGUC_DATA_DIR={ENV.ADAGUC_DATA_DIR}</export>
<export>ADAGUC_AUTOWMS_DIR={ENV.ADAGUC_AUTOWMS_DIR}</export>
<export>ADAGUC_CONFIG=/adaguc/adaguc-server-config.xml</export>
<export>ADAGUC_DATARESTRICTION=FALSE</export>
<export>ADAGUC_ENABLELOGBUFFER=FALSE</export>
Expand Down
2 changes: 1 addition & 1 deletion Docker/docker-compose-generate-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


ADAGUC_PORT=443
ADAGUC_DATA_DIR=/data/adaguc-autowms
ADAGUC_DATA_DIR=/data/adaguc-data
ADAGUC_AUTOWMS_DIR=/data/adaguc-autowms
ADAGUC_DATASET_DIR=/data/adaguc-datasets

Expand Down
2 changes: 1 addition & 1 deletion Docker/env-example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
EXTERNALADDRESS=https://bhw485.knmi.nl/
ADAGUC_HOME=/nobackup/users/plieger/pliegerhome
ADAGUC_DATA_DIR=/data/adaguc-autowms
ADAGUC_DATA_DIR=/data/adaguc-data
ADAGUC_AUTOWMS_DIR=/data/adaguc-autowms
ADAGUC_DATASET_DIR=/data/adaguc-datasets
ADAGUC_PORT=443
10 changes: 9 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ USER root
LABEL maintainer="adaguc@knmi.nl"

# Version should be same as in Definitions.h
LABEL version="2.5.1"
LABEL version="2.5.2"

######### First stage (build) ############

Expand Down Expand Up @@ -61,6 +61,7 @@ RUN cp -r /usr/include/udunits2/* /usr/include/

RUN bash compile.sh


######### Second stage (production) ############
FROM centos:7
USER root
Expand Down Expand Up @@ -133,6 +134,13 @@ RUN chmod +x /adaguc/adaguc-server-*.sh && \
RUN cp /etc/pki/java/cacerts /adaguc/security/truststore.ts

ENV ADAGUC_SERVICES_CONFIG=/adaguc/adaguc-services-config.xml
ENV ADAGUC_PATH=/adaguc/adaguc-server-master

# Build and test adaguc python support
WORKDIR /adaguc/adaguc-server-master/data/python/
RUN python3 setup.py install
RUN bash -c "python3 /adaguc/adaguc-server-master/data/python/examples/runautowms/run.py && ls result.png"
WORKDIR /adaguc/adaguc-server-master

USER adaguc

Expand Down
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Version 2.5.2 2020-11-13
- Support to run Adaguc-server from python3.

Version 2.5.1 2020-11-13
- Support for 32 contourline definitions (previousely 8)
Expand Down
2 changes: 2 additions & 0 deletions adagucserverEC/CAreaMapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "CDebugger.h"
#include "CDataSource.h"
#include "CDrawImage.h"
#include <stdio.h>

class CAreaMapper{
private:
DEF_ERRORFUNCTION();
Expand Down
9 changes: 7 additions & 2 deletions adagucserverEC/CRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1964,15 +1964,15 @@ int CRequest::process_all_layers(){
int textY=16;
//int prevTextY=0;
if(srvParam->mapTitle.length()>0){
if(srvParam->cfg->WMS[0]->TitleFont.size()==1){
if(srvParam->cfg->WMS[0]->TitleFont.size()>0){
float fontSize=parseFloat(srvParam->cfg->WMS[0]->TitleFont[0]->attr.size.c_str());
textY+=int(fontSize);
textY+=imageDataWriter.drawImage.drawTextArea(16,textY,srvParam->cfg->WMS[0]->TitleFont[0]->attr.location.c_str(),fontSize,0,srvParam->mapTitle.c_str(),CColor(0,0,0,255),CColor(255,255,255,100));
//textY+=12;
}
}
if(srvParam->mapSubTitle.length()>0){
if(srvParam->cfg->WMS[0]->SubTitleFont.size()==1){
if(srvParam->cfg->WMS[0]->SubTitleFont.size()>0){
float fontSize=parseFloat(srvParam->cfg->WMS[0]->SubTitleFont[0]->attr.size.c_str());
textY+=int(fontSize)/2;
textY+=imageDataWriter.drawImage.drawTextArea(16,textY,srvParam->cfg->WMS[0]->SubTitleFont[0]->attr.location.c_str(),fontSize,0,srvParam->mapSubTitle.c_str(),CColor(0,0,0,255),CColor(255,255,255,100));
Expand Down Expand Up @@ -2027,6 +2027,11 @@ int CRequest::process_all_layers(){
if(legendWidth<minimumLegendWidth)legendWidth=minimumLegendWidth;
imageDataWriter.drawImage.enableTransparency(true);
legendImage.createImage(&imageDataWriter.drawImage,legendWidth,(imageDataWriter.drawImage.Geo->dHeight / 2)-padding*2+2);

CStyleConfiguration *styleConfiguration = dataSources[d]->getStyle();
if (styleConfiguration!=NULL && styleConfiguration->legendIndex != -1) {
legendImage.createGDPalette(srvParam->cfg->Legend[styleConfiguration->legendIndex]);
}
status = imageDataWriter.createLegend(dataSources[d],&legendImage);if(status != 0)throw(__LINE__);
int posX=imageDataWriter.drawImage.Geo->dWidth-(legendImage.Geo->dWidth+padding) - legendOffsetX;
int posY=imageDataWriter.drawImage.Geo->dHeight-(legendImage.Geo->dHeight+padding);
Expand Down
18 changes: 18 additions & 0 deletions adagucserverEC/CServerParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,16 +569,34 @@ int CServerParams::parseConfigFile(CT::string &pszConfigFile){
CDBError("Unable to open configuration file [%s], error %d", pszConfigFile.c_str(), e);
return 1;
}

/* Substitute ADAGUC_PATH */
const char *pszADAGUC_PATH=getenv("ADAGUC_PATH");
if(pszADAGUC_PATH!=NULL){
CT::string adagucPath = CDirReader::makeCleanPath(pszADAGUC_PATH);
adagucPath = adagucPath + "/";
configFileData.replaceSelf("{ADAGUC_PATH}",adagucPath.c_str());
}

/* Substitute ADAGUC_TMP */
const char *pszADAGUC_TMP=getenv("ADAGUC_TMP");
if(pszADAGUC_TMP!=NULL)configFileData.replaceSelf("{ADAGUC_TMP}",pszADAGUC_TMP);

/* Substitute ADAGUC_DB */
const char *pszADAGUC_DB=getenv("ADAGUC_DB");
if(pszADAGUC_DB!=NULL)configFileData.replaceSelf("{ADAGUC_DB}",pszADAGUC_DB);

/* Substitute ADAGUC_DATASET_DIR */
const char *pszADAGUC_DATASET_DIR=getenv("ADAGUC_DATASET_DIR");
if(pszADAGUC_DATASET_DIR!=NULL)configFileData.replaceSelf("{ADAGUC_DATASET_DIR}",pszADAGUC_DATASET_DIR);

/* Substitute ADAGUC_DATA_DIR */
const char *pszADAGUC_DATA_DIR=getenv("ADAGUC_DATA_DIR");
if(pszADAGUC_DATA_DIR!=NULL)configFileData.replaceSelf("{ADAGUC_DATA_DIR}",pszADAGUC_DATA_DIR);

/* Substitute ADAGUC_AUTOWMS_DIR */
const char *pszADAGUC_AUTOWMS_DIR=getenv("ADAGUC_AUTOWMS_DIR");
if(pszADAGUC_AUTOWMS_DIR!=NULL)configFileData.replaceSelf("{ADAGUC_AUTOWMS_DIR}",pszADAGUC_AUTOWMS_DIR);
}catch(int e){
CDBError("Exception %d in substituting", e);
}
Expand Down
2 changes: 1 addition & 1 deletion adagucserverEC/Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef Definitions_H
#define Definitions_H

#define ADAGUCSERVER_VERSION "2.5.1"
#define ADAGUCSERVER_VERSION "2.5.2"

//CConfigReaderLayerType
#define CConfigReaderLayerTypeUnknown 0
Expand Down
6 changes: 3 additions & 3 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ function clean {
cd $CURRENTDIR/hclasses
rm -f *.o
rm -f *.a
rm -rf CMakeFiles
rm -rf CMakeFiles CMakeCache.txt

cd $CURRENTDIR/CCDFDataModel
rm -f *.o
rm -f *.a
rm -rf CMakeFiles
rm -rf CMakeFiles CMakeCache.txt

cd $CURRENTDIR/adagucserverEC
rm -f *.o
rm -f adagucserver
rm -f h5ncdump
rm -f aggregate_time
rm -f geojsondump
rm -rf CMakeFiles
rm -rf CMakeFiles CMakeCache.txt

test -d $CURRENTDIR/bin || mkdir $CURRENTDIR/bin/
rm -f $CURRENTDIR/bin/adagucserver
Expand Down
Loading

0 comments on commit 623efec

Please sign in to comment.