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

« back to all changes in this revision

Viewing changes to test/unit/common.hpp

  • 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
// $Id$
 
2
//
 
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)
 
7
//
 
8
#include <liblas/liblas.hpp>
 
9
 
 
10
#include <iostream>
 
11
 
 
12
namespace tut
 
13
{
 
14
 
 
15
// Predicate testing LASPoint against given XY coordinates
 
16
// and tolerance.
 
17
struct is_xy
 
18
{
 
19
    is_xy(double x, double y, double tolerance)
 
20
        : x(x), y(y), t(tolerance)
 
21
    {}
 
22
 
 
23
    bool operator()(liblas::Point const& p)
 
24
    {
 
25
        double const dx = x - p.GetX();
 
26
        double const dy = y - p.GetY();
 
27
 
 
28
        return ((dx <= t && dx >= -t) && (dy <= t && dy >= -t));
 
29
    }
 
30
 
 
31
    double x;
 
32
    double y;
 
33
    double t;
 
34
};
 
35
 
 
36
// Functor to calculate bounding box of a set of points
 
37
struct bbox_calculator
 
38
{
 
39
    bbox_calculator(liblas::Bounds<double>& bbox) : bbox(&bbox), empty(true) {}
 
40
 
 
41
    void operator()(liblas::Point const& p)
 
42
    {
 
43
        if (0 == bbox)
 
44
            throw std::invalid_argument("bbox is null");
 
45
 
 
46
        // Box initialization during first iteration only
 
47
        if (empty)
 
48
        {
 
49
            (bbox->min)(0, p.GetX());
 
50
            (bbox->max)(0, p.GetX());
 
51
            (bbox->min)(1, p.GetY());
 
52
            (bbox->max)(1, p.GetY());
 
53
            (bbox->min)(2, p.GetZ());
 
54
            (bbox->max)(2, p.GetZ());
 
55
            empty = false;
 
56
        }
 
57
 
 
58
        // Expand bounding box to include given point
 
59
        (bbox->min)(0, (std::min)((bbox->min)(0), p.GetX()));
 
60
        (bbox->min)(1, (std::min)((bbox->min)(1), p.GetY()));
 
61
        (bbox->min)(2, (std::min)((bbox->min)(2), p.GetZ()));
 
62
        (bbox->max)(0, (std::max)((bbox->max)(0), p.GetX()));
 
63
        (bbox->max)(1, (std::max)((bbox->max)(1), p.GetY()));
 
64
        (bbox->max)(2, (std::max)((bbox->max)(2), p.GetZ()));
 
65
    }
 
66
 
 
67
private:
 
68
    liblas::Bounds<double>* bbox;
 
69
    bool empty;
 
70
};
 
71
 
 
72
// Common test procedure for default constructed point data.
 
73
void test_default_point(liblas::Point const& p);
 
74
 
 
75
// Common test procedure for default constructed header data.
 
76
void test_default_header(liblas::Header const& h);
 
77
 
 
78
// Test of header data in trunk/test/data/TO_core_last_clip.las file
 
79
void test_file10_header(liblas::Header const& h);
 
80
 
 
81
// Test of 1st point record in trunk/test/data/TO_core_last_clip.las file
 
82
void test_file10_point1(liblas::Point const& p);
 
83
 
 
84
// Test of 2nd point record in trunk/test/data/TO_core_last_clip.las file
 
85
void test_file10_point2(liblas::Point const& p);
 
86
 
 
87
// Test of 4th point record in trunk/test/data/TO_core_last_clip.las file
 
88
void test_file10_point4(liblas::Point const& p);
 
89
 
 
90
// Test of 1st, 2nd, 3rd point record in trunk/test/data/1.2-with-color.laz file
 
91
void test_file_12Color_point0(liblas::Point const& p);
 
92
void test_file_12Color_point1(liblas::Point const& p);
 
93
void test_file_12Color_point2(liblas::Point const& p);
 
94
 
 
95
// make sure we have a valid laszip VLR block
 
96
void test_laszip_vlr(liblas::Header const& header);
 
97
 
 
98
} // namespace tut
 
99