create.cpp
Go to the documentation of this file.
00001 #include <megatree/common.h>
00002 #include <megatree/megatree.h>
00003 #include <megatree/storage_factory.h>
00004 #include <megatree/tree_functions.h>
00005 
00006 #include <unistd.h>
00007 #include <iostream>
00008 
00009 using namespace megatree;
00010 
00011 class TempDirectory
00012 {
00013 public:
00014   TempDirectory(const std::string &prefix = "", bool remove = true)
00015     : remove_(remove)
00016   {
00017     std::string tmp_storage = prefix + "XXXXXX";
00018     char *tmp = mkdtemp(&tmp_storage[0]);
00019     assert(tmp);
00020     printf("Temporary directory: %s\n", tmp);
00021 
00022     path_ = tmp;
00023   }
00024 
00025   ~TempDirectory()
00026   {
00027     if (remove_)
00028       boost::filesystem::remove_all(path_);
00029   }
00030 
00031   const boost::filesystem::path &getPath() const
00032   {
00033     return path_;
00034   }
00035 
00036 private:
00037   boost::filesystem::path path_;
00038   bool remove_;
00039 };
00040 
00041 
00042 int main (int argc, char** argv)
00043 {
00044   // create megatree
00045   std::vector<double> tree_center(3, 0);
00046   double tree_size = 2 * (6378000+8850+10000); // radius of the earth + height of Mount Everest + padding
00047 
00048   if(argc != 4)
00049   {
00050     printf("Usage: ./create tree_path  subtree_width subfolder_depth\n");
00051     return -1;
00052   }
00053 
00054   boost::filesystem::path tree_path(argv[1]);
00055   removePath(tree_path);
00056   boost::shared_ptr<Storage> storage(openStorage(tree_path));
00057   MegaTree tree(storage, tree_center, tree_size,
00058                 atoi(argv[2]), atoi(argv[3]),  // subtree_width, subfolder_depth
00059                 1000000);
00060   
00061   return 0;
00062 }


megatree_cpp
Author(s): Stuart Glaser
autogenerated on Thu Nov 28 2013 11:30:34