6 #include <boost/algorithm/string/case_conv.hpp> 7 #include <boost/filesystem.hpp> 8 #include <boost/lexical_cast.hpp> 9 #include <boost/tokenizer.hpp> 11 void msearch(
const boost::filesystem::path& mpath, std::string product, std::string hv,
ProdHVDate& fnames)
17 std::string filename = mpath.leaf().string();
18 std::string::size_type pos = filename.find(
"MOD");
22 boost::char_separator<char> sep(
".");
23 boost::tokenizer<boost::char_separator<char> > tokens(filename, sep);
24 boost::tokenizer<boost::char_separator<char> >::iterator beg;
26 std::string mproduct(*beg);
27 ++beg;
if (beg == tokens.end())
return;
28 std::string mdate(*beg);
29 ++beg;
if (beg == tokens.end())
return;
30 std::string mhv(*beg);
32 if (!product.empty() && product != mproduct)
return;
33 if (!hv.empty() && hv != mhv)
return;
39 sscanf(mdate.c_str(),
"%1c%4d%3d",&a,&year,&jday);
41 boost::gregorian::date
d(year,boost::gregorian::Jan,1);
42 boost::gregorian::date_duration dd(jday-1);
43 boost::gregorian::date bdate = d + dd;
44 mdate = to_iso_extended_string(bdate);
46 fnames[mproduct][mhv][mdate] = mpath.string();
50 for (boost::filesystem::directory_iterator it(mpath), itEnd; it !=itEnd; ++it)
55 const std::vector<boost::gregorian::date>*
times)
57 std::size_t nvals = times->size();
59 for(std::size_t i = 0; i != nvals; ++i)
61 std::cout <<
"date: " << boost::gregorian::to_simple_string((*times)[i])
62 <<
", value: " << *((boost::int16_t*)(values)) << std::endl;
64 values +=
sizeof(boost::int16_t);
std::map< std::string, std::map< std::string, std::map< std::string, std::string > > > ProdHVDate
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
std::complex< double > times(std::complex< double > lhs, std::complex< double > rhs)
void modis_print(const unsigned char *values, const std::vector< boost::gregorian::date > *times)
static bool isRegularFile(const std::string &path)
Checks if a given path in UTF-8 is a regular file.
void msearch(const boost::filesystem::path &mpath, std::string product, std::string hv, ProdHVDate &fnames)