source: geovis/trunk/idatatest.cpp @ 6369

Last change on this file since 6369 was 6216, checked in by ldelgass, 8 years ago

add args for collection, filename to idatatest

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1#include <vector>
2#include <cstdlib>
3#include <iostream>
4#include <sstream>
5#include <fstream>
6
7#include <osgDB/FileNameUtils>
8
9#include "IData.h"
10
11using namespace IData;
12
13int main(int argc, char *argv[])
14{
15    iDataInit(getenv("USER"));
16
17    std::vector<Collection> collections;
18    getCollectionList(collections);
19    std::cout << std::endl << std::endl;
20    for (std::vector<Collection>::iterator itr = collections.begin();
21         itr != collections.end(); ++itr) {
22        std::cout << "id: " << itr->id << " name: " << itr->name << std::endl;
23    }
24
25    int collection = 3;
26    if (argc > 1) {
27        collection = atoi(argv[1]);
28    }
29
30    std::cout << std::endl << std::endl;
31    std::vector<DirectoryItem> dir;
32    getContents(collection, "", dir);
33    std::cout << std::endl << std::endl;
34    for (std::vector<DirectoryItem>::iterator itr = dir.begin();
35         itr != dir.end(); ++itr) {
36        std::cout << " name: " << itr->name;
37        if (!itr->isDir) {
38            std::cout << " size: " << itr->size << " ctime: " << itr->ctime
39                      << " type: " << itr->type << " doi: " << itr->doi;
40        }
41        std::cout << std::endl;
42    }
43
44    std::cout << std::endl << std::endl;
45    const char *filename = NULL;
46    if (argc > 2) {
47        filename = argv[2];
48    } else if (collection == 3) {
49        filename = "station.csv";
50    } else {
51        iDataCleanup();
52        return 0;
53    }
54
55    std::ostringstream oss;
56    oss << "//" << filename;
57    Buffer buff;
58    getFile(collection, oss.str().c_str(), &buff);
59    std::cout << std::endl << std::endl;
60    std::cout << filename << " size: " << buff.size << std::endl;
61    std::ofstream file(filename);
62    file.write((char *)buff.data, buff.size);
63    file.close();
64
65    iDataCleanup();
66    return 0;
67}
Note: See TracBrowser for help on using the repository browser.