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

« back to all changes in this revision

Viewing changes to test/sample/utility.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
#ifndef LIBLAS_SAMPLE_UTILITY_HPP_INCLUDED
 
9
#define LIBLAS_SAMPLE_UTILITY_HPP_INCLUDED
 
10
// std
 
11
#include <iosfwd>
 
12
#include <utility>
 
13
// Forward declarations
 
14
namespace liblas {
 
15
    class LASPoint;
 
16
}
 
17
 
 
18
template <typename T>
 
19
inline std::ostream& operator<<(std::ostream& os, typename std::pair<T, T> const& p)
 
20
{
 
21
    os << p.first << "   " << p.second;
 
22
    return os;
 
23
}
 
24
 
 
25
inline std::ostream& operator<<(std::ostream& os, liblas::LASPoint const& p)
 
26
{
 
27
    os << std::fixed << std::setprecision(6)
 
28
       << "\nx: " << p.GetX()
 
29
       << "\ny: " << p.GetY()
 
30
       << "\nz: " << p.GetZ()
 
31
       << "\nint: " << p.GetIntensity()
 
32
       << "\nrn: " << p.GetReturnNumber()
 
33
       << "\nnor: " << p.GetNumberOfReturns()
 
34
       << "\nsd: " << p.GetScanDirection()
 
35
       << "\neofl: " << p.GetFlightLineEdge()
 
36
       << "\ntime: " << p.GetTime()
 
37
       << std::endl;
 
38
 
 
39
    return os;
 
40
}
 
41
 
 
42
inline void print_point(std::ostream& os, liblas::LASPoint const& p, liblas::uint8_t const& minor)
 
43
{
 
44
    os << std::fixed << std::setprecision(6)
 
45
       << "\nx: " << p.GetX()
 
46
       << "\ny: " << p.GetY()
 
47
       << "\nz: " << p.GetZ()
 
48
       << "\nint: " << p.GetIntensity()
 
49
       << "\nrn: " << p.GetReturnNumber()
 
50
       << "\nnor: " << p.GetNumberOfReturns()
 
51
       << "\nsd: " << p.GetScanDirection()
 
52
       << "\neofl: " << p.GetFlightLineEdge()
 
53
       << "\ntime: " << p.GetTime();
 
54
 
 
55
    if (1 == minor)
 
56
    {
 
57
        const int len = 13;
 
58
        static std::string meaning[len] =
 
59
        {
 
60
            "Created, never classified",
 
61
            "Unclassified",
 
62
            "Ground",
 
63
            "Low Vegetation",
 
64
            "Medium Vegetation",
 
65
            "High Vegetation",
 
66
            "Building",
 
67
            "Low Point (noise)",
 
68
            "Model Key-point (mass point)",
 
69
            "Water",
 
70
            "Reserved for ASPRS Definition",
 
71
            "Reserved for ASPRS Definition",
 
72
            "Overlap Points",
 
73
        };
 
74
 
 
75
        // bit 0:4
 
76
        liblas::uint8_t chClass = p.GetClassification();
 
77
        unsigned int idx = (unsigned int)((chClass >> 3) & 0x1F); 
 
78
        std::cout << "\nClassification: "
 
79
            << ((idx >= 0 && idx < len) ? meaning[idx] : "Reserved for ASPRS Definition");
 
80
        std::cout << "\n- Synthetic: " << ((1 == (short)((chClass >> 2) & 0x1)) ? -1 : 0);
 
81
        std::cout << "\n- Model_Key_Point: " << ((1 == (short)((chClass >> 1) & 0x1)) ? -1 : 0);
 
82
        std::cout << "\n- Withheld: " << ((1 == (short)(chClass & 0x1)) ? -1 : 0);
 
83
    }
 
84
    else
 
85
    {
 
86
       std::cout << "\ncls: " << (int)p.GetClassification();
 
87
    }
 
88
    std::cout << std::endl;
 
89
}
 
90
 
 
91
#endif // LIBLAS_SAMPLE_UTILITY_HPP_INCLUDED