WSL/SLF GitLab Repository

Commit 4c53e6b4 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Fixed a serious bug introduced a few commits ago in PNGIO.

Introduced the basic structure that will be required to build a new plugin to read Matlab files prepared by the OSHD project/service. This is not usable yet but should come quite soon.
parent 176e31a5
......@@ -180,6 +180,7 @@ SET(PLUGIN_GRIBIO OFF CACHE BOOL "Compilation GRIBIO ON or OFF")
SET(PLUGIN_GSNIO OFF CACHE BOOL "Compilation GSNIO ON or OFF")
SET(PLUGIN_IMISIO OFF CACHE BOOL "Compilation IMISIO ON or OFF")
SET(PLUGIN_NETCDFIO OFF CACHE BOOL "Compilation NETCDFIO ON or OFF")
SET(PLUGIN_OSHDIO OFF CACHE BOOL "Compilation OshdIO ON or OFF")
SET(PLUGIN_PGMIO ON CACHE BOOL "Compilation PGMIO ON or OFF")
SET(PLUGIN_PNGIO OFF CACHE BOOL "Compilation PNGIO ON or OFF")
SET(PLUGIN_PSQLIO OFF CACHE BOOL "Compilation PSQLIO ON or OFF")
......
......@@ -30,6 +30,7 @@
#cmakedefine PLUGIN_SNIO
#cmakedefine PLUGIN_PGMIO
#cmakedefine PLUGIN_IMISIO
#cmakedefine PLUGIN_OSHDIO
#cmakedefine PLUGIN_GRIBIO
#cmakedefine PLUGIN_PNGIO
#cmakedefine PLUGIN_BORMAIO
......@@ -65,6 +66,10 @@
#include <meteoio/plugins/ImisIO.h>
#endif
#ifdef PLUGIN_OSHDIO
#include <meteoio/plugins/OshdIO.h>
#endif
#ifdef PLUGIN_GRIBIO
#include <meteoio/plugins/GRIBIO.h>
#endif
......@@ -245,6 +250,9 @@ IOInterface* IOHandler::getPlugin(const std::string& plugin_name) const
#ifdef PLUGIN_IMISIO
if (plugin_name == "IMIS") return new ImisIO(cfg);
#endif
#ifdef PLUGIN_OSHDIO
if (plugin_name == "OSHD") return new OshdIO(cfg);
#endif
#ifdef PLUGIN_GRIBIO
if (plugin_name == "GRIB") return new GRIBIO(cfg);
#endif
......
......@@ -249,8 +249,8 @@ void TimeSeriesManager::fill_filtered_cache()
if ((IOUtils::filtered & processing_level) == IOUtils::filtered){
filtered_cache.clear(); //HACK until we get true ringbuffers, to prevent eating up all memory
meteoprocessor.process(raw_buffer.getBuffer(), filtered_cache.getBuffer());
filtered_cache.setBufferStart(raw_buffer.getBufferStart()); //HACK
filtered_cache.setBufferEnd(raw_buffer.getBufferEnd()); //HACK
filtered_cache.setBufferStart( raw_buffer.getBufferStart() );
filtered_cache.setBufferEnd( raw_buffer.getBufferEnd() );
}
}
......
......@@ -62,6 +62,13 @@ IF(PLUGIN_IMISIO)
SET(plugins_sources ${plugins_sources} plugins/ImisIO.cc)
ENDIF(PLUGIN_IMISIO)
IF(PLUGIN_OSHDIO)
FIND_PACKAGE(Matio REQUIRED)
INCLUDE_DIRECTORIES(SYSTEM ${Matio_INCLUDE_DIR})
SET(plugin_libs ${plugin_libs} ${Matio_LIBRARY})
SET(plugins_sources ${plugins_sources} plugins/OshdIO.cc)
ENDIF(PLUGIN_OSHDIO)
IF(PLUGIN_PGMIO)
SET(plugins_sources ${plugins_sources} plugins/PGMIO.cc)
ENDIF(PLUGIN_PGMIO)
......
......@@ -262,14 +262,10 @@ void PNGIO::setFile(const std::string& filename, png_structp& png_ptr, png_infop
{
// Open file for writing (binary mode)
if (!IOUtils::validFileAndPath(filename)) throw InvalidNameException(filename, AT);
if (!IOUtils::fileExists(filename)) throw NotFoundException(filename, AT);
errno=0;
fp = fopen(filename.c_str(), "wb");
if (fp == NULL) {
ostringstream ss;
ss << "Error opening file \"" << filename << "\", possible reason: " << strerror(errno);
throw AccessException(ss.str(), AT);
}
if (fp == NULL)
throw AccessException("Error opening file \""+filename+"\", possible reason: "+std::string(strerror(errno)), AT);
// Initialize write structure
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
......@@ -468,14 +464,10 @@ void PNGIO::write2DGrid(const Grid2DObject& grid_in, const std::string& filename
void PNGIO::write2DGrid(const Grid2DObject& grid_in, const MeteoGrids::Parameters& parameter, const Date& date)
{
std::string filename;
if (parameter==MeteoGrids::DEM || parameter==MeteoGrids::SLOPE || parameter==MeteoGrids::AZI)
filename = grid2dpath + "/" + MeteoGrids::getParameterName(parameter) + ".png";
else {
std::string date_str = date.toString(Date::ISO);
std::replace( date_str.begin(), date_str.end(), ':', '.');
filename = grid2dpath + "/" + date_str + "_" + MeteoGrids::getParameterName(parameter) + ".png";
}
const bool isNormalParam = (parameter!=MeteoGrids::DEM && parameter!=MeteoGrids::SLOPE && parameter!=MeteoGrids::AZI);
std::string date_str = (isNormalParam)? date.toString(Date::ISO)+"_" : "";
std::replace( date_str.begin(), date_str.end(), ':', '.');
const std::string filename = grid2dpath + "/" + date_str + MeteoGrids::getParameterName(parameter) + ".png";
fp=NULL;
png_color *palette=NULL;
......
INCLUDE(LibFindMacros)
FIND_PROGRAM(POPCC_EXECUTABLE popcc)
MARK_AS_ADVANCED(FORCE POPCC_EXECUTABLE)
#build POPC_ROOT so we can provide a hint for searching for the header file
GET_FILENAME_COMPONENT(popc_exe_root ${POPCC_EXECUTABLE} PATH)
SET(POPC_ROOT "${popc_exe_root}/../")
#get POPC_LOCATION env. variable to provide as a hint
SET(POPC_LOCATION $ENV{POPC_LOCATION})
# Finally the library itself
FIND_LIBRARY(Popc_LIBRARY
NAMES libparoc_common.a
FIND_LIBRARY(Matio_LIBRARY
NAMES libmatio.so
PATHS
"${POPC_LOCATION}/lib"
"${POPC_ROOT}/lib"
"${POPC_ROOT}/popc/lib"
ENV LD_LIBRARY_PATH
"~/usr/lib"
"/usr/local/lib"
"/usr/lib"
"/opt/lib"
DOC "Location of the libparoc_common, like /usr/lib/libparoc_common.a"
DOC "Location of the libmatio, like /usr/lib/libmatio.so"
)
#build POPC_ROOT so we can provide a hint for searching for the header file
IF("${Popc_LIBRARY}" MATCHES "^(.+)lib[\\/]libparoc_common\\.(.+)$")
SET(POPC_ROOT "${CMAKE_MATCH_1}")
ENDIF("${Popc_LIBRARY}" MATCHES "^(.+)lib[\\/]libparoc_common\\.(.+)$")
IF("${Matio_LIBRARY}" MATCHES "^(.+)lib[\\/]libmatio\\.(.+)$")
SET(MATIO_ROOT "${CMAKE_MATCH_1}")
ENDIF("${Matio_LIBRARY}" MATCHES "^(.+)lib[\\/]libmatio\\.(.+)$")
# locate main header file
FIND_PATH(Popc_INCLUDE_DIR
NAMES paroc_base.h
#HINTS ${POPC_ROOT}/include
FIND_PATH(Matio_INCLUDE_DIR
NAMES matio.h
PATHS
"${POPC_LOCATION}/lib"
"${POPC_ROOT}/include"
"${POPC_ROOT}/popc/include"
"${MATIO_ROOT}/include"
"~/usr/include"
"/usr/local/include"
"/usr/include"
"/opt/include"
DOC "Location of the popc headers, like /usr/include"
DOC "Location of the matio headers, like /usr/include"
)
# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
SET(Popc_PROCESS_INCLUDES Popc_INCLUDE_DIR)
SET(Popc_PROCESS_LIBS Popc_LIBRARY)
libfind_process(Popc)
SET(Matio_PROCESS_INCLUDES Matio_INCLUDE_DIR)
SET(Matio_PROCESS_LIBS Matio_LIBRARY)
libfind_process(Matio)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment