libLAS API Reference  1.8.1
dimension.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 Dimension implementation for C++ libLAS
6  * Author: Howard Butler, hobu.inc@gmail.com
7  *
8  ******************************************************************************
9  * Copyright (c) 2010, Howard Butler
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_DIMENSION_HPP_INCLUDED
43 #define LIBLAS_DIMENSION_HPP_INCLUDED
44 
45 #include <liblas/version.hpp>
46 #include <liblas/external/property_tree/ptree.hpp>
48 #include <liblas/version.hpp>
49 #include <liblas/export.hpp>
50 // boost
51 #include <boost/any.hpp>
52 #include <boost/shared_ptr.hpp>
53 #include <boost/foreach.hpp>
54 #include <boost/array.hpp>
55 
56 #include <boost/multi_index_container.hpp>
57 #include <boost/multi_index/member.hpp>
58 #include <boost/multi_index/ordered_index.hpp>
59 #include <boost/multi_index/hashed_index.hpp>
60 #include <boost/multi_index/sequenced_index.hpp>
61 
62 // std
63 #include <iosfwd>
64 #include <limits>
65 #include <string>
66 #include <vector>
67 #include <algorithm>
68 #include <boost/unordered_map.hpp>
69 
70 namespace liblas {
71 
74 {
75 public:
76  Dimension(std::string const& name, std::size_t size_in_bits);
77  Dimension& operator=(Dimension const& rhs);
78  Dimension(Dimension const& other);
79 
80  bool operator==(const Dimension& other) const;
81  bool operator!=(const Dimension& other) const { return !(*this == other); }
82 
83  virtual ~Dimension() {}
84 
85  inline std::string const& GetName() const { return m_name; }
86 
89  inline std::size_t GetBitSize() const
90  {
91  return m_bit_size;
92  }
93 
95  std::size_t GetByteSize() const;
96 
101  inline std::size_t GetByteOffset() const
102  {
103  return m_byte_offset;
104  }
105 
106  inline void SetByteOffset(std::size_t v)
107  {
108  m_byte_offset = v;
109  }
110 
115  inline std::size_t GetBitOffset() const
116  {
117  return m_bit_offset;
118  }
119 
120  inline void SetBitOffset(std::size_t v)
121  {
122  m_bit_offset = v;
123  }
124 
126  inline bool IsRequired() const { return m_required; }
127  inline void IsRequired(bool v) { m_required = v; }
128 
133  inline bool IsActive() const { return m_active; }
134  inline void IsActive(bool v) { m_active = v; }
135 
136  inline std::string GetDescription() const { return m_description; }
137  inline void SetDescription(std::string const& v) { m_description = v; }
138 
141  inline bool IsNumeric() const { return m_numeric ; }
142  inline void IsNumeric(bool v) { m_numeric = v; }
143 
146  inline bool IsSigned() const { return m_signed; }
147  inline void IsSigned(bool v) { m_signed = v; }
148 
151  inline bool IsInteger() const { return m_integer; }
152  inline void IsInteger(bool v) { m_integer = v; }
153 
155  inline double GetMinimum() const { return m_min; }
156  inline void SetMinimum(double min) { m_min = min; }
157 
159  inline double GetMaximum() const { return m_max; }
160  inline void SetMaximum(double max) { m_max = max; }
161 
165  inline uint32_t GetPosition() const { return m_position; }
166  inline void SetPosition(uint32_t v) { m_position = v; }
167 
170  inline double GetScale() const { return m_scale; }
171  inline void SetScale(double v) { m_scale = v; }
172 
176  inline double GetOffset() const { return m_offset; }
177  inline void SetOffset(double v) { m_offset = v; }
178 
180  inline bool IsFinitePrecision() const { return m_precise; }
181  inline void IsFinitePrecision(bool v) { m_precise = v; }
182 
183  inline bool operator < (Dimension const& dim) const
184  {
185  return m_position < dim.m_position;
186  }
187  inline bool operator > (Dimension const& dim) const
188  {
189  return m_position > dim.m_position;
190  }
191 
192  liblas::property_tree::ptree GetPTree() const;
193 private:
194 
195  std::string m_name;
196  std::size_t m_bit_size;
197  bool m_required;
198  bool m_active;
199  std::string m_description;
200  double m_min;
201  double m_max;
202  bool m_numeric;
203  bool m_signed;
204  bool m_integer;
205  uint32_t m_position;
206  double m_scale;
207  bool m_precise;
208  double m_offset;
209  std::size_t m_byte_offset;
210  std::size_t m_bit_offset;
211 
212 
213 };
214 
216 {
217  SetRequired(bool req) : req_(req) {}
218 
220  {
221  e.IsRequired(req_);
222  }
223 
224 private:
225  bool req_;
226 };
227 
228 struct SetActive
229 {
230  SetActive(bool req) : req_(req) {}
231 
233  {
234  e.IsActive(req_);
235  }
236 
237 private:
238  bool req_;
239 };
240 
241 std::ostream& operator<<(std::ostream& os, liblas::Dimension const& d);
242 
243 } // namespace liblas
244 
245 #endif // LIBLAS_DIMENSION_HPP_INCLUDED
bool IsInteger() const
Does this dimension interpret to an integer? Only applicable to dimensions with IsNumeric == true...
Definition: dimension.hpp:151
std::string const & GetName() const
Definition: dimension.hpp:85
uint32_t GetPosition() const
The index position of the index.
Definition: dimension.hpp:165
SetActive(bool req)
Definition: dimension.hpp:230
bool operator!=(const Dimension &other) const
Definition: dimension.hpp:81
void IsFinitePrecision(bool v)
Definition: dimension.hpp:181
#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
void operator()(Dimension &e)
Definition: dimension.hpp:219
double GetMaximum() const
The maximum value of this dimension as a double.
Definition: dimension.hpp:159
bool IsSigned() const
Does this dimension have a sign? Only applicable to dimensions with IsNumeric == true.
Definition: dimension.hpp:146
SetRequired(bool req)
Definition: dimension.hpp:217
void IsRequired(bool v)
Definition: dimension.hpp:127
void SetBitOffset(std::size_t v)
Definition: dimension.hpp:120
void SetPosition(uint32_t v)
Definition: dimension.hpp:166
std::size_t GetByteOffset() const
The byte location to start reading/writing point data from in a composited schema.
Definition: dimension.hpp:101
bool IsNumeric() const
Is this dimension a numeric dimension.
Definition: dimension.hpp:141
void SetMaximum(double max)
Definition: dimension.hpp:160
double GetScale() const
The scaling value for this dimension as a double.
Definition: dimension.hpp:170
std::size_t GetBitSize() const
bits, total logical size of point record, including any custom dimensions
Definition: dimension.hpp:89
virtual ~Dimension()
Definition: dimension.hpp:83
double GetMinimum() const
The minimum value of this dimension as a double.
Definition: dimension.hpp:155
void IsActive(bool v)
Definition: dimension.hpp:134
bool IsFinitePrecision() const
If true, this dimension uses scale/offset values.
Definition: dimension.hpp:180
void IsNumeric(bool v)
Definition: dimension.hpp:142
Definition: dimension.hpp:215
void SetByteOffset(std::size_t v)
Definition: dimension.hpp:106
void SetMinimum(double min)
Definition: dimension.hpp:156
void IsInteger(bool v)
Definition: dimension.hpp:152
bool operator==(Classification const &lhs, Classification const &rhs)
Equal-to operator implemented in terms of Classification::equal.
Definition: classification.hpp:226
void IsSigned(bool v)
Definition: dimension.hpp:147
Namespace grouping all elements of libLAS public interface.
Definition: bounds.hpp:60
bool IsRequired() const
Is this dimension required by PointFormatName.
Definition: dimension.hpp:126
void SetOffset(double v)
Definition: dimension.hpp:177
void SetScale(double v)
Definition: dimension.hpp:171
void operator()(Dimension &e)
Definition: dimension.hpp:232
Definition: dimension.hpp:228
bool IsActive() const
Is this dimension being used.
Definition: dimension.hpp:133
std::string GetDescription() const
Definition: dimension.hpp:136
Definition: schema.hpp:78
double GetOffset() const
The offset value for this dimension.
Definition: dimension.hpp:176
std::size_t GetBitOffset() const
The bit location within the byte to start reading data.
Definition: dimension.hpp:115
void SetDescription(std::string const &v)
Definition: dimension.hpp:137
Dimension definition.
Definition: dimension.hpp:73