3
// (C) Copyright Mateusz Loskot 2008, mateusz@loskot.net
4
// Distributed under the BSD License
5
// (See accompanying file LICENSE.txt or copy at
6
// http://www.opensource.org/licenses/bsd-license.php)
9
#include <liblas/liblas.hpp>
10
#include <tut/tut.hpp>
13
#include "liblas_test.hpp"
24
: file10_(g_test_data_path + "//TO_core_last_clip.las")
25
, file12_(g_test_data_path + "//certainty3d-color-utm-feet-navd88.las")
29
typedef test_group<lasreader_data> tg;
30
typedef tg::object to;
32
tg test_group_lasreader("liblas::Reader");
34
// Test user-declared constructor
40
ifs.open(file10_.c_str(), std::ios::in | std::ios::binary);
41
liblas::Reader reader(ifs);
43
ensure_equals(reader.GetHeader().GetVersionMinor(), 0);
46
// Test reading header
52
ifs.open(file10_.c_str(), std::ios::in | std::ios::binary);
53
liblas::Reader reader(ifs);
54
liblas::Header const& hdr = reader.GetHeader();
56
test_file10_header(hdr);
59
// Test GetPoint method
65
ifs.open(file10_.c_str(), std::ios::in | std::ios::binary);
66
liblas::Reader reader(ifs);
68
// uninitialized point object, a null-point
69
liblas::Point const& p = reader.GetPoint();
70
ensure(p == liblas::Point());
73
// Test ReadPoint and GetPoint pair
79
ifs.open(file10_.c_str(), std::ios::in | std::ios::binary);
80
liblas::Reader reader(ifs);
83
reader.ReadNextPoint();
84
test_file10_point1(reader.GetPoint());
87
reader.ReadNextPoint();
88
test_file10_point2(reader.GetPoint());
90
// read and skip 3rd point
91
reader.ReadNextPoint();
94
reader.ReadNextPoint();
95
test_file10_point4(reader.GetPoint());
97
// read and count remaining points from 5 to 8
99
while (reader.ReadNextPoint())
106
// Test ReadPointAt and GetPoint pair
112
ifs.open(file10_.c_str(), std::ios::in | std::ios::binary);
113
liblas::Reader reader(ifs);
116
reader.ReadPointAt(0);
117
test_file10_point1(reader.GetPoint());
120
reader.ReadPointAt(3);
121
test_file10_point4(reader.GetPoint());
123
// read back to 2nd point
124
reader.ReadPointAt(1);
125
test_file10_point2(reader.GetPoint());
128
// Test operator[] and GetPoint pair
134
ifs.open(file10_.c_str(), std::ios::in | std::ios::binary);
135
liblas::Reader reader(ifs);
138
test_file10_point1(reader[0]);
141
test_file10_point4(reader[3]);
143
// read back to 2nd point
144
test_file10_point2(reader[1]);
147
// Test seek and GetPoint pair
153
ifs.open(file10_.c_str(), std::ios::in | std::ios::binary);
154
liblas::Reader reader(ifs);
157
reader.ReadNextPoint();
158
test_file10_point1(reader.GetPoint());
164
test_file10_point4(reader[3]);
168
// Test summarization and valid values
174
ifs.open(file12_.c_str(), std::ios::in | std::ios::binary);
175
liblas::Reader reader(ifs);
177
liblas::Summary summary;
178
liblas::CoordinateSummary coord_summary;
180
bool read = reader.ReadNextPoint();
183
summary.AddPoint(reader.GetPoint());
184
coord_summary.AddPoint(reader.GetPoint());
185
read = reader.ReadNextPoint();
188
liblas::property_tree::ptree tree = summary.GetPTree();
190
ensure_equals("Point count not correct",
191
tree.get<boost::uint32_t>("summary.points.count"),
192
static_cast<boost::uint32_t>(10126));
194
ensure_distance("Min X does not match",
195
tree.get<double>("summary.points.minimum.x"),
199
ensure_distance("Min Y does not match",
200
tree.get<double>("summary.points.minimum.y"),
204
ensure_distance("Min Z does not match",
205
tree.get<double>("summary.points.minimum.z"),
210
ensure_distance("Max X does not match",
211
tree.get<double>("summary.points.maximum.x"),
215
ensure_distance("Max Y does not match",
216
tree.get<double>("summary.points.maximum.y"),
220
ensure_distance("Max Z does not match",
221
tree.get<double>("summary.points.maximum.z"),
225
ensure_equals("Min red not correct",
226
tree.get<boost::uint16_t>("summary.points.minimum.color.red"),
227
static_cast<boost::uint16_t>(4096));
228
ensure_equals("Min green not correct",
229
tree.get<boost::uint16_t>("summary.points.minimum.color.green"),
230
static_cast<boost::uint16_t>(2304));
231
ensure_equals("Min blue not correct",
232
tree.get<boost::uint16_t>("summary.points.minimum.color.blue"),
233
static_cast<boost::uint16_t>(0));
235
ensure_equals("Max red not correct",
236
tree.get<boost::uint16_t>("summary.points.maximum.color.red"),
237
static_cast<boost::uint16_t>(65280));
238
ensure_equals("Max green not correct",
239
tree.get<boost::uint16_t>("summary.points.maximum.color.green"),
240
static_cast<boost::uint16_t>(64512));
241
ensure_equals("Max blue not correct",
242
tree.get<boost::uint16_t>("summary.points.maximum.color.blue"),
243
static_cast<boost::uint16_t>(56320));
245
tree = coord_summary.GetPTree();
246
ensure_distance("Coordinate Summary Min X does not match",
247
tree.get<double>("summary.points.minimum.x"),
251
ensure_distance("Coordinate Summary Min Y does not match",
252
tree.get<double>("summary.points.minimum.y"),
256
ensure_distance("Coordinate Summary Min Z does not match",
257
tree.get<double>("summary.points.minimum.z"),
262
ensure_distance("Coordinate Summary Max X does not match",
263
tree.get<double>("summary.points.maximum.x"),
267
ensure_distance("Coordinate Summary Max Y does not match",
268
tree.get<double>("summary.points.maximum.y"),
272
ensure_distance("Coordinate Summary Max Z does not match",
273
tree.get<double>("summary.points.maximum.z"),