-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbag_read.cpp
116 lines (84 loc) · 3.88 KB
/
bag_read.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include "bag_dataset.h"
#include "bag_layer.h"
#include "bag_trackinglist.h"
#include <iomanip>
#include <iostream>
#include <memory>
namespace {
void printLayerDescriptor(
const BAG::LayerDescriptor& descriptor)
{
std::cout << "\t\tchunkSize == " << descriptor.getChunkSize() << '\n';
std::cout << "\t\tcompression level == " << descriptor.getCompressionLevel() << '\n';
std::cout << "\t\tdata type == " << descriptor.getDataType() << '\n';
std::cout << "\t\telement size == " << +descriptor.getElementSize() << '\n';
std::cout << "\t\tinternalPath == " << descriptor.getInternalPath() << '\n';
std::cout << "\t\tlayer type == " << descriptor.getLayerType() << '\n';
const auto minMax = descriptor.getMinMax();
std::cout << "\t\tmin max == (" << std::get<0>(minMax) << ", " <<
std::get<1>(minMax) << ")\n";
}
}
int main(
int argc,
char** argv)
{
if (argc != 2)
{
std::cerr << "Usage is: bag_read <inputBagFile>\n";
return EXIT_FAILURE;
}
using BAG::Dataset;
const std::string bagFileName = argv[1];
auto pDataset = Dataset::open(bagFileName, BAG_OPEN_READONLY);
const auto& descriptor = pDataset->getDescriptor();
std::cout << "Dataset details:\n";
uint64_t numRows = 0, numCols = 0;
std::tie(numRows, numCols) = descriptor.getDims();
std::cout << "\trows, columns == " << numRows << ", " << numCols << '\n';
double minX = 0., minY = 0., maxX = 0., maxY = 0.;
std::tie(minX, minY) = pDataset->gridToGeo(0, 0);
std::tie(maxX, maxY) = pDataset->gridToGeo(numRows - 1, numCols - 1);
std::cout << "\tgrid cover (llx, lly), (urx, ury) == (" <<
std::setprecision(10) << minX << ", " << minY << "), (" << maxX <<
", " << maxY << ")\n";
const auto& dims = descriptor.getDims();
std::cout << "\tdims == (" << std::get<0>(dims) << ", " <<
std::get<1>(dims) << ")\n";
const auto& gridSpacing = descriptor.getGridSpacing();
std::cout << "\tgrid spacing == (" << std::get<0>(gridSpacing) << ", " <<
std::get<1>(gridSpacing) << ")\n";
const auto& origin = descriptor.getOrigin();
std::cout << "\torigin == (" << std::get<0>(origin) << ", "
<< std::get<1>(origin) << ")\n";
const auto& projCover = descriptor.getProjectedCover();
std::cout << "\tprojected cover (llx, lly), (urx, ury) == (" << std::get<0>(projCover) << ", " <<
std::get<1>(projCover) << "), (" << std::get<2>(projCover) << ", " <<
std::get<3>(projCover) << ")\n";
std::cout << "\tversion == " << descriptor.getVersion() << '\n';
std::cout << "\thorizontal reference system ==\n" <<
descriptor.getHorizontalReferenceSystem() << "\n\n";
std::cout << "\tvertical reference system ==\n" << descriptor.getVerticalReferenceSystem() << '\n';
std::cout << "\nLayers:\n";
for (const auto& layer : pDataset->getLayers())
{
auto pDescriptor = layer->getDescriptor();
std::cout << "\t" << pDescriptor->getName() << " Layer .. id(" <<
pDescriptor->getId() << ")\n";
printLayerDescriptor(*pDescriptor);
}
const auto& trackingList = pDataset->getTrackingList();
std::cout << "\nTracking List: (" << trackingList.size() << " items)\n";
size_t itemNum = 0;
for (const auto& item : trackingList)
{
std::cout << "\tTracking list item #" << itemNum++ << '\n';
std::cout << "\t\trow == " << item.row << '\n';
std::cout << "\t\tcol == " << item.col << '\n';
std::cout << "\t\tdepth == " << item.depth << '\n';
std::cout << "\t\tuncertainty == " << item.uncertainty << '\n';
std::cout << "\t\ttrack_code == " << item.track_code << '\n';
std::cout << "\t\tlist_series == " << item.list_series << '\n';
}
return EXIT_SUCCESS;
}