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
|
// (C) Copyright Mateusz Loskot 2008, mateusz@loskot.net
// Distributed under the BSD License
// (See accompanying file LICENSE.txt or copy at
// http://www.opensource.org/licenses/bsd-license.php)
//
#include <liblas/bounds.hpp>
#include <tut/tut.hpp>
#include <string>
#include <vector>
#include <stdexcept>
#include "common.hpp"
#include "liblas_test.hpp"
namespace tut
{
struct lastransform_data
{
std::string gdal_datasource;
std::string lidar_data;
lastransform_data()
: gdal_datasource(g_test_data_path + "//autzen.jpg")
, lidar_data(g_test_data_path + "//autzen.las")
{}
};
typedef test_group<lastransform_data> tg;
typedef tg::object to;
tg test_group_lastransform("liblas::TransformI");
#ifdef HAVE_GDAL
// Test default constructor
template<>
template<>
void to::test<1>()
{
liblas::Header header;
liblas::TransformPtr color_fetch;
{
std::ifstream ifs;
ifs.open(lidar_data.c_str(), std::ios::in | std::ios::binary);
liblas::Reader reader(ifs);
header = reader.GetHeader();
}
{
header.SetDataFormatId(liblas::ePointFormat3);
header.SetVersionMinor(2);
std::vector<boost::uint32_t> bands;
bands.resize(3);
bands[0] = 1;
bands[1] = 2;
bands[2] = 3;
color_fetch = liblas::TransformPtr(new liblas::ColorFetchingTransform(gdal_datasource, bands, &header));
}
std::ifstream ifs;
ifs.open(lidar_data.c_str(), std::ios::in | std::ios::binary);
liblas::Reader reader(ifs);
std::vector<liblas::TransformPtr> transforms;
transforms.push_back(color_fetch);
reader.SetTransforms(transforms);
reader.ReadNextPoint();
liblas::Point const& p = reader.GetPoint();
ensure_equals("Red is incorrect for point", p.GetColor().GetRed(), 210);
ensure_equals("Green is incorrect for point", p.GetColor().GetGreen(), 205);
ensure_equals("Blue is incorrect for point", p.GetColor().GetBlue(), 185);
}
#endif
}
|