WSL/SLF GitLab Repository

Commit 40413ba6 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

A new readDirectory() method has been implemented that directly returns a list...

A new readDirectory() method has been implemented that directly returns a list of strings (slightly more convenient to use). An innacurracy has been fixed in IOUtils: lat_epsilon and lon_epsilon were defined in rad when they should have been in deg. The Coords::toString() method has been slightly improved by allowing more digits for lat/lon. The smet_extract.sh script can now provide a list of available fields if no field has been specified.
parent 10c4be6b
......@@ -148,6 +148,13 @@ bool isAbsolutePath(const std::string& in_path)
#endif
}
std::list<std::string> readDirectory(const std::string& path, const std::string& pattern)
{
std::list<std::string> dirlist;
readDirectory(path, dirlist, pattern);
return dirlist;
}
#if defined _WIN32 || defined __MINGW32__
std::string getCWD()
{
......
......@@ -45,6 +45,8 @@ namespace IOUtils {
* @param pattern optional pattern that must be part of the file names
*/
void readDirectory(const std::string& path, std::list<std::string>& dirlist, const std::string& pattern="");
std::list<std::string> readDirectory(const std::string& path, const std::string& pattern="");
bool validFileName(const std::string& filename);
......
......@@ -72,8 +72,8 @@ namespace IOUtils {
const size_t npos = (size_t)-1; ///<npos is the out-of-range value
const double grid_epsilon = 5.; ///<What is an acceptable small distance on a grid, in meters
const double lon_epsilon = grid_epsilon / Cst::earth_R0; ///<in degrees. Small angle for longitudes, so sin(x)=x
const double lat_epsilon = lon_epsilon/2.; ///<in degrees. Small angle for latitudes. Since for longitudes it is for 360deg, it has to be 180deg for latitudes
const double lon_epsilon = grid_epsilon / Cst::earth_R0 * Cst::to_deg; ///<in degrees. Small angle for longitudes, so sin(x)=x
const double lat_epsilon = lon_epsilon; ///<in degrees. Small angle for latitudes.
/**
* @brief Check whether two values are equal regarding a certain epsilon environment (within certain radius of each other)
......
......@@ -229,8 +229,8 @@ const std::string Coords::toString() const {
os << "<Coords>\n";
os << "Altitude\t" << altitude << "\n";
os << "Lat/Long\t" << printLatLon() << "\n";
os << "Lat/Long\t" << "(" << getLat() << " , " << getLon() << ")" << "\n";
std::streamsize p = os.precision();
os << "Lat/Long\t" <<std::fixed << std::setprecision(6) << "(" << getLat() << " , " << getLon() << ")" << "\n";
os << "X/Y_coords\t" << std::fixed << std::setprecision(0) << "(" << getEasting() << " , " << getNorthing() << ")" << "\n";
os << std::resetiosflags(std::ios_base::fixed|std::ios_base::floatfield);
os.precision(p);
......
......@@ -4,6 +4,10 @@
INPUT=$1
FIELD=$2
if [ $# -eq 1 ]; then
head -20 ${INPUT} | grep "fields" | cut -d'=' -f2 | tr -s ' \t' '\t' | xargs -i echo "Available fields: {}"
fi
#get generic info
stat_id=`head -20 ${INPUT} | grep "station_id" | tr -s '\t' ' ' | cut -d' ' -f 3-`
stat_name=`head -20 ${INPUT} | grep "station_name" | tr -s '\t' ' ' | cut -d' ' -f 3-`
......
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