3 void MSearch(
const boost::filesystem::path& mpath, std::vector<std::string>& fnames)
7 std::string aux = mpath.leaf().string();
8 unsigned pos = aux.find(
"MOD");
12 fnames.push_back(aux);
17 for (boost::filesystem::directory_iterator it(mpath), itEnd; it !=itEnd; ++it)
23 std::vector<std::string> modis_files;
24 boost::filesystem::path mpath(rootpath);
28 boost::regex efile(
"([[:alnum:]]+)\.A([[:digit:]]{4})([[:digit:]]{3})\.h([[:digit:]]{1,3})v([[:digit:]]{1,3})\.([[:alnum:]]+)\.([[:alnum:]]+)\.hdf");
29 boost::match_results<std::string::const_iterator> presult;
31 BOOST_FOREACH(std::string& mfile, modis_files)
33 boost::filesystem::path fpath(mfile);
34 std::string filename = fpath.leaf().string();
36 if (boost::regex_search(filename, presult, efile))
41 rec.
year = boost::lexical_cast<
unsigned int>(presult[2]);
42 rec.
day = boost::lexical_cast<
unsigned int>(presult[3]);
43 rec.
h = boost::lexical_cast<
unsigned int>(presult[4]);
44 rec.
v = boost::lexical_cast<
unsigned int>(presult[5]);
62 MODISDb::const_iterator it =
m_db.begin();
63 while (it !=
m_db.end())
73 boost::multi_index::nth_index<MODISDb,0>::type::iterator it = boost::multi_index::get<0>(
m_db).find(filename);
74 if (it == boost::multi_index::get<0>(
m_db).end())
83 std::vector<MODISRecord> result;
85 boost::multi_index::nth_index<MODISDb,1>::type::iterator it_l = boost::multi_index::get<1>(
m_db).lower_bound(product);
86 boost::multi_index::nth_index<MODISDb,1>::type::iterator it_u = boost::multi_index::get<1>(
m_db).upper_bound(product);
89 result.push_back(*it_l);
98 std::vector<MODISRecord> result;
100 boost::multi_index::nth_index<MODISDb,2>::type::iterator it_l = boost::multi_index::get<2>(
m_db).lower_bound(year);
101 boost::multi_index::nth_index<MODISDb,2>::type::iterator it_u = boost::multi_index::get<2>(
m_db).upper_bound(year);
104 result.push_back(*it_l);
113 std::vector<MODISRecord> result;
115 boost::multi_index::nth_index<MODISDb,3>::type::iterator it_l = boost::multi_index::get<3>(
m_db).lower_bound(day);
116 boost::multi_index::nth_index<MODISDb,3>::type::iterator it_u = boost::multi_index::get<3>(
m_db).upper_bound(day);
119 result.push_back(*it_l);
std::vector< MODISRecord > findByDay(unsigned int day) const
void MSearch(const boost::filesystem::path &mpath, std::vector< std::string > &fnames)
MODISRecord findByFile(const std::string &filename) const
MODISDatabase(std::string rootpath)
std::vector< MODISRecord > findByYear(unsigned int year) const
std::vector< MODISRecord > findByProduct(const std::string &product) const
static bool isRegularFile(const std::string &path)
Checks if a given path in UTF-8 is a regular file.