Configure CGI script¶
1) Install the POI python script in your application directory¶
hg clone https://dev.knmi.nl/hg/knmi-poi
2) Install the CGI Script for writing POI data to NetCDF files in your cgi directory, named ./cgi-bin/knmi_point_interest.cgi:¶
#!/bin/sh
echo
export KNMI_POI_HOME=<path to knmi-poi dir>
export FILE_DIR=<the directory where the flag file(s) is located, note: must end with a slash / >
export FILE_EXTENSION=".nc" # The extension of the flag set ( default it's NetCDF )
python ${KNMI_POI_HOME}/python/knmi_point_interest.py $QUERY_STRING $FILE_DIR $FILE_EXTENSION
- Put this file in your cgi-bin directory under knmi_point_interest.cgi.
- Configure the URL of this script in adagucviewer/config.js using var knmiFlagURL="http://yourhost.com/cgi-bin/knmi_point_interest.cgi".
- Make sure it is accessible by the apache webserver and that it has execute permissions.
- Check if it works with calling it directly in a browser: http://yourhost.com/cgi-bin/knmi_point_interest.cgi?file=ncpoifile.nc&location=5,52&name=mymarkername .Check apache server loggings (error_log) for errors. Make sure that the python netCDF4 library is required. When you install this in a python virtualenv, first activate that env in the above CGI script. When it fails, a blank page returns and error loggings are available in the apache server logs. When it succeeds, a JSON document is returned in the form:
resultSetFlag({name:'mymarkername',lat:52.0,lon:5.0,action:'added',status:'OK'})
Also a netcdf file in the FILE_DIR should have been created.
The following items need to be configured in the CGI script:
- KNMI_POI_HOME is the location of knmi-poi (get it with command hg clone https://dev.knmi.nl/hg/knmi-poi) Note that this must not be placed in the documentroot but in an application directory, e.g. same dir as adagucserver.
- FILE_DIR is the path to the NetCDF file with the NetCDF flag files, it must end with a / . The same path needs to be configured in adaguc.poi.xml in AutoResource. Make sure it is writable by the apache webserver
- FILE_EXTENSION is the extension of the flagset file. Default it's NetCDF.
3) CGI script for calling adagucserver to visualize NetCDF POI file, named /cgi-bin/poi.cgi:¶
#!/bin/bash
export ADAGUC_PATH=~/adagucserver/ # Replace with the location where you installed ADAGUC
export ADAGUC_TMP=/tmp/
export ADAGUC_CONFIG="${ADAGUC_PATH}/data/config/adaguc.poi.xml"
export ADAGUC_DATARESTRICTION="FALSE"
export ADAGUC_LOGFILE="${ADAGUC_TMP}/adaguc.autoresource.log"
export ADAGUC_ERRORFILE="${ADAGUC_TMP}/adaguc.autoresource.errlog"
export ADAGUC_FONT="${ADAGUC_PATH}/data/fonts/FreeSans.ttf"
export ADAGUC_ONLINERESOURCE="${SERVER}/poi.cgi?"
#export LD_LIBRARY_PATH=:$LD_LIBRARY_PATH # LD_LIBRARY_PATH not needed when netcdf and hdf5 installed through yum.
#export PROJ_LIB=/data/build/share/proj/ # Optional, needed when custom proj.4 library is installed.
${ADAGUC_PATH}/adagucserverEC/adagucserver