~ubuntu-branches/ubuntu/trusty/liblas/trusty-proposed

« back to all changes in this revision

Viewing changes to test/unit/transform_test.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2014-01-05 17:00:29 UTC
  • mfrom: (7.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140105170029-ddtp0j63x5jvck2u
Tags: 1.7.0+dfsg-2
Fixed missing linking of system boost component.
(closes: #733282)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// (C) Copyright Mateusz Loskot 2008, mateusz@loskot.net
 
2
// Distributed under the BSD License
 
3
// (See accompanying file LICENSE.txt or copy at
 
4
// http://www.opensource.org/licenses/bsd-license.php)
 
5
//
 
6
#include <liblas/bounds.hpp>
 
7
#include <liblas/guid.hpp>
 
8
#include <tut/tut.hpp>
 
9
#include <string>
 
10
#include <vector>
 
11
#include <stdexcept>
 
12
#include "common.hpp"
 
13
#include "liblas_test.hpp"
 
14
 
 
15
namespace tut
 
16
 
17
    struct lastransform_data
 
18
    {
 
19
        std::string gdal_datasource;
 
20
        std::string lidar_data;
 
21
 
 
22
        lastransform_data()
 
23
            : gdal_datasource(g_test_data_path + "//autzen.jpg")
 
24
            , lidar_data(g_test_data_path + "//autzen.las")
 
25
        {}
 
26
    };
 
27
 
 
28
  
 
29
    typedef test_group<lastransform_data> tg;
 
30
    typedef tg::object to;
 
31
 
 
32
    tg test_group_lastransform("liblas::TransformI");
 
33
 
 
34
 
 
35
#ifdef HAVE_GDAL
 
36
 
 
37
    // Test default constructor
 
38
    template<>
 
39
    template<>
 
40
    void to::test<1>()
 
41
    {
 
42
        liblas::Header header;
 
43
        liblas::TransformPtr color_fetch;
 
44
 
 
45
        {
 
46
            std::ifstream ifs;
 
47
            ifs.open(lidar_data.c_str(), std::ios::in | std::ios::binary);
 
48
            liblas::Reader reader(ifs);
 
49
            header = reader.GetHeader();
 
50
        }
 
51
 
 
52
        {
 
53
            header.SetDataFormatId(liblas::ePointFormat3);
 
54
            header.SetVersionMinor(2);
 
55
        
 
56
            std::vector<boost::uint32_t> bands;
 
57
            bands.resize(3);
 
58
            bands[0] = 1;
 
59
            bands[1] = 2;
 
60
            bands[2] = 3;
 
61
            color_fetch = liblas::TransformPtr(new liblas::ColorFetchingTransform(gdal_datasource, bands, &header));
 
62
        }
 
63
        
 
64
            std::ifstream ifs;
 
65
            ifs.open(lidar_data.c_str(), std::ios::in | std::ios::binary);
 
66
            liblas::Reader reader(ifs);
 
67
            std::vector<liblas::TransformPtr> transforms;
 
68
            transforms.push_back(color_fetch);
 
69
            reader.SetTransforms(transforms);
 
70
            
 
71
            reader.ReadNextPoint();
 
72
            
 
73
            liblas::Point const& p = reader.GetPoint();
 
74
            
 
75
            ensure_equals("Red is incorrect for point", p.GetColor().GetRed(), 210);
 
76
            ensure_equals("Green is incorrect for point", p.GetColor().GetGreen(), 205);
 
77
            ensure_equals("Blue is incorrect for point", p.GetColor().GetBlue(), 185);
 
78
        
 
79
    }
 
80
 
 
81
#endif
 
82
}