WSL/SLF GitLab Repository

Commit 51703c49 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Grid namming scheme has been changed: this now uses a slightly modified ISO...

Grid namming scheme has been changed: this now uses a slightly modified ISO format: YYYY-MM-DDTHH.MM (because ':' is invalid for filenames under Windows)
parent 0921ea6c
......@@ -18,6 +18,7 @@
#include "ARCIO.h"
#include <errno.h>
#include <string.h>
#include <algorithm>
using namespace std;
......@@ -33,7 +34,7 @@ namespace mio {
*
* These specifications should reflect commonly accepted practise.
*
* Finally, the naming scheme for meteo grids should be: YYYYMMDDHHmm_{MeteoGrids::Parameters}.asc
* Finally, the naming scheme for meteo grids should be: YYYY-MM-DDTHH.mm_{MeteoGrids::Parameters}.asc
*
* @section lus_format Land Use Format
* The landuse codes are coming from PREVAH and have the format 1LLDC where:
......@@ -255,8 +256,11 @@ void ARCIO::read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& par
IOUtils::toLower(ext);
}
read2DGrid_internal(grid_out, grid2dpath_in + "/" + date.toString(Date::NUM)+"."+ext );
} else
read2DGrid_internal(grid_out, grid2dpath_in + "/" + date.toString(Date::NUM) + "_" + MeteoGrids::getParameterName(parameter) + ".asc");
} else {
std::string date_str = date.toString(Date::ISO);
std::replace( date_str.begin(), date_str.end(), ':', '.');
read2DGrid_internal(grid_out, grid2dpath_in + "/" + date_str + "_" + MeteoGrids::getParameterName(parameter) + ".asc");
}
}
void ARCIO::readDEM(DEMObject& dem_out)
......@@ -364,8 +368,11 @@ void ARCIO::write2DGrid(const Grid2DObject& grid_in, const MeteoGrids::Parameter
IOUtils::toLower(ext);
}
write2DGrid(grid_in, date.toString(Date::NUM)+"."+ext );
} else
write2DGrid(grid_in, date.toString(Date::NUM) + "_" + MeteoGrids::getParameterName(parameter) + ".asc");
} else {
std::string date_str = date.toString(Date::ISO);
std::replace( date_str.begin(), date_str.end(), ':', '.');
write2DGrid(grid_in, date_str + "_" + MeteoGrids::getParameterName(parameter) + ".asc");
}
}
#ifndef _METEOIO_JNI
......
......@@ -17,6 +17,7 @@
#include "PGMIO.h"
#include <errno.h>
#include <string.h>
#include <algorithm>
using namespace std;
......@@ -25,7 +26,7 @@ namespace mio {
* @page pgmio PGMIO
* @section pgmio_format Format
* This reads a grid file in PGM format (see http://www.fileformat.info/format/pbm/egff.htm). This is a graphic format that is supported by a wide range of graphics programs (Gimp, Irfanview, Paint Shop Pro, gqview, etc). This allows to write a grid as an image (one pixel equals one cell), read an image as a grid (useful for creating synthetic DEMs). Since there is no geolocalization information in this format, such data is either encoded as a comment (when writing a file) or read from io.ini (for reading).
* Finally, the naming scheme for meteo grids should be: YYYYMMDDHHmm_{MeteoGrids::Parameters}.pgm
* Finally, the naming scheme for meteo grids should be: YYYY-MM-DDTHH.mm_{MeteoGrids::Parameters}.pgm
*
* Please keep in mind that only a finite number of greyscales are used, making a discretization of the data. Moreover, we consider that a color of "0" is NODATA.
*
......@@ -190,7 +191,9 @@ void PGMIO::read2DGrid(Grid2DObject& grid_out, const std::string& filename) {
void PGMIO::read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date)
{
read2DGrid_internal(grid_out, grid2dpath_in+"/"+date.toString(Date::NUM)+"_"+MeteoGrids::getParameterName(parameter)+".pgm");
std::string date_str = date.toString(Date::ISO);
std::replace( date_str.begin(), date_str.end(), ':', '.');
read2DGrid_internal(grid_out, grid2dpath_in+"/"+date_str+"_"+MeteoGrids::getParameterName(parameter)+".pgm");
}
void PGMIO::readDEM(DEMObject& dem_out)
......@@ -298,9 +301,9 @@ void PGMIO::write2DGrid(const Grid2DObject& grid_in, const std::string& name)
void PGMIO::write2DGrid(const Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date)
{
//path will be added by calling write2Dgrid
std::stringstream ss;
ss << date.toString(Date::NUM) << "_" << MeteoGrids::getParameterName(parameter) << ".pgm";
write2DGrid(grid_out, ss.str());
std::string date_str = date.toString(Date::ISO);
std::replace( date_str.begin(), date_str.end(), ':', '.');
write2DGrid(grid_out, date_str+"_"+MeteoGrids::getParameterName(parameter)+".pgm");
}
void PGMIO::cleanup() throw()
......
......@@ -33,7 +33,7 @@ namespace mio {
* No data read has been implemented, because reading an existing file would require the exact knowlege of the color gradient that has been used
* to create it. When writing grids, various color gradients will be used depending on the parameter that the data represents. Nodata values
* are represented by transparent pixels (transparency is acheived through a transparent color instead of a true alpha channel for size and performance).
* Finally, the naming scheme for meteo grids should be: YYYYMMDDHHmm_{MeteoGrids::Parameters}.png
* Finally, the naming scheme for meteo grids should be: YYYY-MM-DDTHH.mm_{MeteoGrids::Parameters}.png
*
* @section template_units Units
* All units are MKSA except temperatures that are expressed in celcius.
......@@ -461,8 +461,11 @@ void PNGIO::write2DGrid(const Grid2DObject& grid_in, const MeteoGrids::Parameter
std::string filename;
if(parameter==MeteoGrids::DEM || parameter==MeteoGrids::SLOPE || parameter==MeteoGrids::AZI)
filename = grid2dpath + "/" + MeteoGrids::getParameterName(parameter) + ".png";
else
filename = grid2dpath + "/" + date.toString(Date::NUM) + "_" + 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";
}
fp=NULL;
png_color *palette=NULL;
......
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