libLAS API Reference  1.8.1
point.hpp
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id$
3  *
4  * Project: libLAS - http://liblas.org - A BSD library for LAS format data.
5  * Purpose: LAS point class
6  * Author: Mateusz Loskot, mateusz@loskot.net
7  *
8  ******************************************************************************
9  * Copyright (c) 2008, Mateusz Loskot
10  *
11  * All rights reserved.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following
15  * conditions are met:
16  *
17  * * Redistributions of source code must retain the above copyright
18  * notice, this list of conditions and the following disclaimer.
19  * * Redistributions in binary form must reproduce the above copyright
20  * notice, this list of conditions and the following disclaimer in
21  * the documentation and/or other materials provided
22  * with the distribution.
23  * * Neither the name of the Martin Isenburg or Iowa Department
24  * of Natural Resources nor the names of its contributors may be
25  * used to endorse or promote products derived from this software
26  * without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
35  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
36  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
37  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
38  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
39  * OF SUCH DAMAGE.
40  ****************************************************************************/
41 
42 #ifndef LIBLAS_LASPOINT_HPP_INCLUDED
43 #define LIBLAS_LASPOINT_HPP_INCLUDED
44 
46 #include <liblas/color.hpp>
47 #include <liblas/schema.hpp>
48 #include <liblas/detail/pointrecord.hpp>
49 #include <liblas/detail/fwd.hpp>
50 #include <liblas/detail/private_utility.hpp>
51 #include <liblas/external/property_tree/ptree.hpp>
52 #include <liblas/export.hpp>
53 
54 // boost
55 #include <boost/array.hpp>
56 #include <boost/shared_ptr.hpp>
57 #include <boost/any.hpp>
58 // std
59 #include <stdexcept> // std::out_of_range
60 #include <cstdlib> // std::size_t
61 #include <vector> // std::vector
62 
63 
64 namespace liblas {
65 
66 
69 {
70 public:
71 
73  {
74  eReturnNumber = 1,
75  eNumberOfReturns = 2,
76  eScanDirection = 4,
77  eFlightLineEdge = 8,
78  eClassification = 16,
79  eScanAngleRank = 32,
80  eTime = 64
81  };
82 
84  {
85  eCreated = 0,
94  eWater = 9,
95  // = 10 // reserved for ASPRS Definition
96  // = 11 // reserved for ASPRS Definition
97  eOverlapPoints = 12
98  // = 13-31 // reserved for ASPRS Definition
99  };
100 
102  {
103  eScanAngleRankMin = -90,
104  eScanAngleRankMax = 90
105  };
106 
107  // Point();
108  ~Point() {}
109  Point(Header const* header);
110  Point(Point const& other);
111  Point& operator=(Point const& rhs);
112 
113  double GetX() const;
114  double GetY() const;
115  double GetZ() const;
116 
117  int32_t GetRawX() const;
118  int32_t GetRawY() const;
119  int32_t GetRawZ() const;
120 
121  void SetCoordinates(double const& x, double const& y, double const& z);
122 
123  void SetX(double const& value);
124  void SetY(double const& value);
125  void SetZ(double const& value);
126 
127  void SetRawX(int32_t const& value);
128  void SetRawY(int32_t const& value);
129  void SetRawZ(int32_t const& value);
130 
131  uint16_t GetIntensity() const;
132  void SetIntensity(uint16_t const& intensity);
133 
140  uint8_t GetScanFlags() const;
141 
144  void SetScanFlags(uint8_t const& flags);
145 
146  uint16_t GetReturnNumber() const;
147  void SetReturnNumber(uint16_t const& num);
148 
149  uint16_t GetNumberOfReturns() const;
150  void SetNumberOfReturns(uint16_t const& num);
151 
152  uint16_t GetScanDirection() const;
153  void SetScanDirection(uint16_t const& dir);
154 
155  uint16_t GetFlightLineEdge() const;
156  void SetFlightLineEdge(uint16_t const& edge);
157 
158  //Classification& GetClassification();
159  Classification GetClassification() const;
160  void SetClassification(Classification const& cls);
161  void SetClassification(Classification::bitset_type const& flags);
162  void SetClassification(uint8_t const& flags);
163 
164  int8_t GetScanAngleRank() const;
165  void SetScanAngleRank(int8_t const& rank);
166 
168  uint8_t GetUserData() const;
169 
171  void SetUserData(uint8_t const& data);
172 
174  uint16_t GetPointSourceID() const;
175 
177  void SetPointSourceID(uint16_t const& id);
178 
180  Color GetColor() const;
181 
183  void SetColor(Color const& value);
184 
185  double GetTime() const;
186  void SetTime(double const& time);
187 
191  double operator[](std::size_t const& index) const;
192 
194  bool equal(Point const& other) const;
195 
196  bool Validate() const;
197  bool IsValid() const;
198 
199 
200  std::vector<uint8_t> const& GetData() const {return m_data; }
201  std::vector<uint8_t> & GetData() {return m_data; }
202  void SetData(std::vector<uint8_t> const& v) { m_data = v;}
203 
204  void SetHeader(Header const* header);
205  Header const* GetHeader() const;
206  property_tree::ptree GetPTree() const;
207  boost::any GetValue(Dimension const& d) const;
208 
209 private:
210 
211  std::vector<uint8_t> m_data;
212 
213  std::vector<uint8_t>::size_type GetDimensionBytePosition(std::size_t dim_pos) const;
214  Header const* m_header;
215  Header const& m_default_header;
216 
217 };
218 
220 inline bool operator==(Point const& lhs, Point const& rhs)
221 {
222  return lhs.equal(rhs);
223 }
224 
226 inline bool operator!=(Point const& lhs, Point const& rhs)
227 {
228  return (!(lhs == rhs));
229 }
230 
231 inline double Point::operator[](std::size_t const& index) const
232 {
233 
234  if (index == 0)
235  return GetX();
236  if (index == 1)
237  return GetY();
238  if (index == 2)
239  return GetZ();
240 
241  throw std::out_of_range("coordinate subscript out of range");
242 
243 }
244 
245 
246 LAS_DLL std::ostream& operator<<(std::ostream& os, liblas::Point const&);
247 
248 
249 } // namespace liblas
250 
251 #endif // LIBLAS_LASPOINT_HPP_INCLUDED
Definition: point.hpp:92
ScanAngleRankRange
Definition: point.hpp:101
bool operator!=(Classification const &lhs, Classification const &rhs)
Not-equal-to operator implemented in terms of Classification::equal.
Definition: classification.hpp:232
Class definition to manipulate properties of point record classification.
Definition: classification.hpp:66
#define LAS_DLL
Definition: export.hpp:58
std::ostream & operator<<(std::ostream &os, Classification const &cls)
The output stream operator is based on std::bitset<N>::operator<<.
Definition: classification.hpp:247
double operator[](std::size_t const &index) const
Const version of index operator providing access to XYZ coordinates of point record.
Definition: point.hpp:231
std::vector< uint8_t > & GetData()
Definition: point.hpp:201
bool equal(Point const &other) const
std::vector< uint8_t > const & GetData() const
Definition: point.hpp:200
void SetData(std::vector< uint8_t > const &v)
Definition: point.hpp:202
Definition: point.hpp:93
Definition: point.hpp:87
Definition: point.hpp:91
std::bitset< 8 > bitset_type
Alias on std::bitset<8> used as collection of flags.
Definition: classification.hpp:71
bool operator==(Classification const &lhs, Classification const &rhs)
Equal-to operator implemented in terms of Classification::equal.
Definition: classification.hpp:226
ClassificationType
Definition: point.hpp:83
Namespace grouping all elements of libLAS public interface.
Definition: bounds.hpp:60
~Point()
Definition: point.hpp:108
Point data record composed with X, Y, Z coordinates and attributes.
Definition: point.hpp:68
Definition: point.hpp:86
Definition: point.hpp:88
DataMemberFlag
Definition: point.hpp:72
Definition: point.hpp:89
Definition: schema.hpp:80
Definition: point.hpp:90
Definition of public header block.
Definition: header.hpp:78
RGB color container.
Definition: color.hpp:55
Dimension definition.
Definition: dimension.hpp:73