libLAS API Reference (svn-trunk)
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
64namespace liblas {
65
66
69{
70public:
71
82
84 {
94 eWater = 9,
95 // = 10 // reserved for ASPRS Definition
96 // = 11 // reserved for ASPRS Definition
98 // = 13-31 // reserved for ASPRS Definition
99 };
100
106
107 // 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();
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
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
209private:
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
220inline bool operator==(Point const& lhs, Point const& rhs)
221{
222 return lhs.equal(rhs);
223}
224
226inline bool operator!=(Point const& lhs, Point const& rhs)
227{
228 return (!(lhs == rhs));
229}
230
231inline 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
246LAS_DLL std::ostream& operator<<(std::ostream& os, liblas::Point const&);
247
248
249} // namespace liblas
250
251#endif // LIBLAS_LASPOINT_HPP_INCLUDED
Class definition to manipulate properties of point record classification.
Definition classification.hpp:67
std::bitset< 8 > bitset_type
Alias on std::bitset<8> used as collection of flags.
Definition classification.hpp:71
RGB color container.
Definition color.hpp:56
Dimension definition.
Definition dimension.hpp:74
Definition of public header block.
Definition header.hpp:79
Point data record composed with X, Y, Z coordinates and attributes.
Definition point.hpp:69
double GetZ() const
void SetCoordinates(double const &x, double const &y, double const &z)
void SetRawZ(int32_t const &value)
ClassificationType
Definition point.hpp:84
@ eCreated
Definition point.hpp:85
@ eBuilding
Definition point.hpp:91
@ eModelKeyPoint
Definition point.hpp:93
@ eLowPoint
Definition point.hpp:92
@ eOverlapPoints
Definition point.hpp:97
@ eUnclassified
Definition point.hpp:86
@ eHighVegetation
Definition point.hpp:90
@ eLowVegetation
Definition point.hpp:88
@ eGround
Definition point.hpp:87
@ eWater
Definition point.hpp:94
@ eMediumVegetation
Definition point.hpp:89
void SetFlightLineEdge(uint16_t const &edge)
void SetX(double const &value)
uint8_t GetScanFlags() const
Gets all scanning flags encoded as single byte.
bool Validate() const
double GetY() const
uint16_t GetFlightLineEdge() const
int32_t GetRawY() const
Point(Point const &other)
Color GetColor() const
Fetch color value associated with this point (LAS 1.2)
void SetData(std::vector< uint8_t > const &v)
Definition point.hpp:202
void SetRawY(int32_t const &value)
Point(Header const *header)
bool IsValid() const
void SetPointSourceID(uint16_t const &id)
Set value of User Bit Field (LAS 1.0) or Point Source ID (LAS 1.1).
uint16_t GetReturnNumber() const
Point & operator=(Point const &rhs)
uint16_t GetNumberOfReturns() const
property_tree::ptree GetPTree() const
void SetIntensity(uint16_t const &intensity)
void SetRawX(int32_t const &value)
int8_t GetScanAngleRank() const
Header const * GetHeader() const
~Point()
Definition point.hpp:108
double GetTime() const
std::vector< uint8_t > & GetData()
Definition point.hpp:201
ScanAngleRankRange
Definition point.hpp:102
@ eScanAngleRankMin
Definition point.hpp:103
@ eScanAngleRankMax
Definition point.hpp:104
void SetTime(double const &time)
uint16_t GetPointSourceID() const
Fetch value of User Bit Field (LAS 1.0) or Point Source ID (LAS 1.1).
void SetClassification(Classification const &cls)
int32_t GetRawZ() const
void SetZ(double const &value)
void SetUserData(uint8_t const &data)
Set value of File Marker (LAS 1.0) or User Data (LAS 1.1).
void SetScanAngleRank(int8_t const &rank)
uint16_t GetIntensity() const
void SetReturnNumber(uint16_t const &num)
void SetScanFlags(uint8_t const &flags)
Sets all scanning flags passed as a single byte.
void SetY(double const &value)
bool equal(Point const &other) const
void SetNumberOfReturns(uint16_t const &num)
void SetClassification(uint8_t const &flags)
double GetX() const
void SetClassification(Classification::bitset_type const &flags)
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
boost::any GetValue(Dimension const &d) const
void SetScanDirection(uint16_t const &dir)
DataMemberFlag
Definition point.hpp:73
@ eFlightLineEdge
Definition point.hpp:77
@ eScanDirection
Definition point.hpp:76
@ eReturnNumber
Definition point.hpp:74
@ eScanAngleRank
Definition point.hpp:79
@ eNumberOfReturns
Definition point.hpp:75
@ eClassification
Definition point.hpp:78
@ eTime
Definition point.hpp:80
uint8_t GetUserData() const
Fetch value of File Marker (LAS 1.0) or User Data (LAS 1.1).
void SetHeader(Header const *header)
uint16_t GetScanDirection() const
int32_t GetRawX() const
Classification GetClassification() const
std::vector< uint8_t > const & GetData() const
Definition point.hpp:200
void SetColor(Color const &value)
Set color value associated with this point (LAS 1.2)
#define LAS_DLL
Definition export.hpp:58
Namespace grouping all elements of libLAS public interface.
Definition bounds.hpp:60
bool operator!=(Classification const &lhs, Classification const &rhs)
Not-equal-to operator implemented in terms of Classification::equal.
Definition classification.hpp:232
std::ostream & operator<<(std::ostream &os, Classification const &cls)
The output stream operator is based on std::bitset<N>::operator<<.
Definition classification.hpp:247
bool operator==(Classification const &lhs, Classification const &rhs)
Equal-to operator implemented in terms of Classification::equal.
Definition classification.hpp:226
Definition schema.hpp:80