libLAS API Reference  1.8.1
transform.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 transform class
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_LASTRANSFORM_HPP_INCLUDED
43 #define LIBLAS_LASTRANSFORM_HPP_INCLUDED
44 
45 #include <liblas/version.hpp>
46 #include <liblas/point.hpp>
48 #include <liblas/export.hpp>
49 // boost
50 #include <boost/shared_ptr.hpp>
51 #include <boost/array.hpp>
52 // std
53 #include <vector>
54 #include <string>
55 
56 namespace liblas {
57 
60 {
61 public:
62 
63  virtual bool transform(Point& point) = 0;
64  virtual bool ModifiesHeader() = 0;
65  virtual ~TransformI() {}
66 };
67 
68 typedef boost::shared_ptr<liblas::TransformI> TransformPtr;
69 
71 {
72 public:
73 
74  ReprojectionTransform(const SpatialReference& inSRS, const SpatialReference& outSRS);
75  ReprojectionTransform(const SpatialReference& inSRS, const SpatialReference& outSRS, Header const* new_header);
77 
78  bool transform(Point& point);
79  void SetHeader(Header* header) {m_new_header = header;}
80  bool ModifiesHeader() { return true; }
81 
82 private:
83 
84  Header const* m_new_header;
85 
86  typedef boost::shared_ptr<void> ReferencePtr;
87  typedef boost::shared_ptr<void> TransformPtr;
88  ReferencePtr m_in_ref_ptr;
89  ReferencePtr m_out_ref_ptr;
90  TransformPtr m_transform_ptr;
91 
92 
93 
95  ReprojectionTransform& operator=(ReprojectionTransform const& rhs);
96 
97  void Initialize(SpatialReference const& inSRS, SpatialReference const& outSRS);
98 };
99 
101 {
102 public:
103 
104  TranslationTransform(std::string const& expression);
106 
107  bool transform(Point& point);
108  bool ModifiesHeader() { return false; }
109 
111  {
112  eOPER_MULTIPLY = 0,
113  eOPER_DIVIDE = 1,
114  eOPER_SUBTRACT = 2,
115  eOPER_ADD = 3,
116  eOPER_NONE = -99
117  };
118 
119  // Yes, Mateusz, I'm embarassed by this :)
120  struct operation{
122  std::string dimension;
123  double value;
124  std::string expression;
125 
126  operation(std::string name) : oper(eOPER_NONE), dimension(name), value(0.0)
127  {
128  }
129  };
130 
131 private:
132 
134  TranslationTransform& operator=(TranslationTransform const& rhs);
135 
136  operation GetOperation(std::string const& expression);
137 
138  std::vector<operation> operations;
139 
140  std::string m_expression;
141 };
142 
143 
145 {
146 public:
147 
148  ColorFetchingTransform( std::string const& datasource,
149  std::vector<uint32_t> bands
150  );
151  ColorFetchingTransform( std::string const& datasource,
152  std::vector<uint32_t> bands,
153  Header const* header);
154 
155  void SetScaleFactor(uint32_t v) {m_scale = v; }
157 
158  bool transform(Point& point);
159  bool ModifiesHeader() { return true; }
160 
161 
162 private:
163 
164  Header const* m_new_header;
165 
166  typedef boost::shared_ptr<void> DataSourcePtr;
167 
168  DataSourcePtr m_ds;
169  std::string m_datasource;
170  std::vector<uint32_t> m_bands;
171  boost::array<double, 6> m_forward_transform;
172  boost::array<double, 6> m_inverse_transform;
173  boost::uint32_t m_scale;
174 
176  ColorFetchingTransform& operator=(ColorFetchingTransform const& rhs);
177 
178  void Initialize();
179 };
180 } // namespace liblas
181 
182 #endif // ndef LIBLAS_LASTRANSFORM_HPP_INCLUDED
Definition: transform.hpp:70
bool ModifiesHeader()
Definition: transform.hpp:108
#define LAS_DLL
Definition: export.hpp:58
Definition: transform.hpp:144
double value
Definition: transform.hpp:123
std::string expression
Definition: transform.hpp:124
OPER_TYPE
Definition: transform.hpp:110
std::string dimension
Definition: transform.hpp:122
operation(std::string name)
Definition: transform.hpp:126
boost::shared_ptr< liblas::TransformI > TransformPtr
Definition: transform.hpp:68
bool ModifiesHeader()
Definition: transform.hpp:159
Spatial Reference System container for libLAS.
Definition: spatialreference.hpp:69
Namespace grouping all elements of libLAS public interface.
Definition: bounds.hpp:60
Point data record composed with X, Y, Z coordinates and attributes.
Definition: point.hpp:68
bool ModifiesHeader()
Definition: transform.hpp:80
Definition: transform.hpp:120
Defines public interface to LAS transform implementation.
Definition: transform.hpp:59
void SetHeader(Header *header)
Definition: transform.hpp:79
Definition: schema.hpp:78
virtual ~TransformI()
Definition: transform.hpp:65
Definition: transform.hpp:100
OPER_TYPE oper
Definition: transform.hpp:121
Definition of public header block.
Definition: header.hpp:78
void SetScaleFactor(uint32_t v)
Definition: transform.hpp:155