IExportLAS.hpp
1 #ifndef DM_IO_EXPORT_LAS_HPP_INCLUDED
2 #define DM_IO_EXPORT_LAS_HPP_INCLUDED
3 
4 #ifdef _MSC_VER
5  #pragma once
6 #endif
7 
8 //DM
9 #include "DM/config.hpp"
10 #include "DM/AutoLink.hpp" //enable autolink
11 
12 #include "DM/ColumnTypes.hpp"
13 #include "DM/IO/IExport.hpp"
14 #include "DM/Array.hpp"
15 
16 //boost
17 #include <boost/any.hpp>
18 
19 DM_NAMESPACE_BEGIN
20 
21 class DM_API IExportLAS : public virtual IExport
22 {
23 public:
24  static IExportLAS* New( const char *file, FilterHandle filter = FilterHandle(),
25  unsigned versionMajor = 1, unsigned versionMinor = 1, unsigned pointDataFormat = 0,
26  unsigned extraPointDataLength = 0, ControlObjectHandle control = ControlObjectHandle(),
27  double invalidHeight = DBL_MAX, double coordPrecision = -1.0 );
28 
29 protected:
30  virtual ~IExportLAS() {}
31 
32 public:
33  typedef std::pair<boost::any,boost::any> MinMax;
34  typedef Array<MinMax,2> MinMax2;
35  typedef Array<MinMax,3> MinMax3;
36 
37  typedef Array<double,2> double2;
38  typedef Array<double,3> double3;
39 
40  // functions to retrieve empty defaults
41  static MinMax undefMinMax();
42  static MinMax2 undefMinMax2();
43  static MinMax3 undefMinMax3();
44 
45  static double undefDouble();
46  static double2 undefDouble2();
47  static double3 undefDouble3();
48 
49  /// \name EXTRA_BYTES / LASattributes
50  /// LAS v.1.4+ allows for the definition of the semantic of extra bytes following each point record:
51  /** name, description, data type, number of elements [1 3], NO_DATA value; scale==1.0, offset==0.0. */
52  //@{
53  // By default, no extra bytes are exported.
54  // Calls to exportExtraBytes(.) result in the definition of an EXTRA_BYTES VLR in the header,
55  // and the export of according extra bytes following the bytes defined by the point record format for each point record.
56  // unred = offset + scale * red | unred(uced) = actual value; red(uced) = value stored in LAS file
57  // invalidValue is used as is (i.e. without application of offset/scale) if the attribute for a certain point is undefined or NULL
58  // defaults:
59  // invalidValue is undefined in header; undefined attributes are stored with value T() i.e. default-instantiated lasType
60  // lasName is equal to colName(ngCol)
61  // lasDescription is the NG-attribute-comment, as specified in NG_AddInfoColumns.hpp
62  // lasType is the type of the NG-attribute. If offset and/or scale are used, then lasType defaults to double.
63 
64  // Offset and/or scale are estimated if not given explicitly.
65  // Estimated offset and/or scale are only used if
66  // - necessary to avoid numerical over-/underflows and/or
67  // - helpful to reduce loss of precision.
68  // Passing the actual range of values of the respective attribute via \param minMax (e.g. queried from NG_AddInfoStatistics),
69  // and passing type information of user-defined attributes via \param ngType helps to better determine if offset and/or scale are necessary.
70  // If only ngType is known (which is always the case for predefined attributes), but not minMax, then the range of values is assumed to be the range of representable values of ngType.
71  // If neither ngType, nor minMax are known, then neither offset, nor scale are used. Users then must make sure that the actual range of attribute values to be stored
72  // fits into lasType. Otherwise, a range over-/underflow exception will be thrown.
73 
74  // predefined attributes
75  // with 1 element
76  virtual void exportExtraBytes( ColumnSemantic::Type col,
77  const boost::any &invalidValue = boost::any(),
78  const char* lasName = 0,
79  const char* lasDescription = 0,
80  ColumnType::Type lasType = ColumnType::count,
81  const MinMax &minMax = undefMinMax(),
82  const double &scale = undefDouble(),
83  const double &offset = undefDouble() ) = 0;
84 
85  // with 2 elements
86  virtual void exportExtraBytes( ColumnSemantic::Type col1, ColumnSemantic::Type col2,
87  const boost::any &invalidValue = boost::any(),
88  const char* lasName = 0,
89  const char* lasDescription = 0,
90  ColumnType::Type lasType = ColumnType::count,
91  const MinMax2 &minMax = undefMinMax2(),
92  const double2 &scale = undefDouble2(),
93  const double2 &offset = undefDouble2() ) = 0;
94  // with 3 elements
95  virtual void exportExtraBytes( ColumnSemantic::Type col1, ColumnSemantic::Type col2, ColumnSemantic::Type col3,
96  const boost::any &invalidValue = boost::any(),
97  const char* lasName = 0,
98  const char* lasDescription = 0,
99  ColumnType::Type lasType = ColumnType::count,
100  const MinMax3 &minMax = undefMinMax3(),
101  const double3 &scale = undefDouble3(),
102  const double3 &offset = undefDouble3() ) = 0;
103 
104  // custom attributes, or predefined attributes accessed by their names (not by their enums)
105  // with 1 element
106  virtual void exportExtraBytes( const char* ngName,
107  ColumnType::Type lasType,
108  const boost::any &invalidValue = boost::any(),
109  const char* lasName = 0,
110  const char* lasDescription = 0,
111  ColumnType::Type ngType = ColumnType::count,
112  const MinMax &minMax = undefMinMax(),
113  const double &scale = undefDouble(),
114  const double &offset = undefDouble() ) = 0;
115  // with 2 elements
116  virtual void exportExtraBytes( const char* ngName1, const char* ngName2,
117  ColumnType::Type lasType,
118  const boost::any &invalidValue = boost::any(),
119  const char* lasName = 0,
120  const char* lasDescription = 0,
121  ColumnType::Type ngType = ColumnType::count,
122  const MinMax2 &minMax = undefMinMax2(),
123  const double2 &scale = undefDouble2(),
124  const double2 &offset = undefDouble2() ) = 0;
125  // with 3 elements
126  virtual void exportExtraBytes( const char* ngName1, const char* ngName2, const char* ngName3,
127  ColumnType::Type lasType,
128  const boost::any &invalidValue = boost::any(),
129  const char* lasName = 0,
130  const char* lasDescription = 0,
131  ColumnType::Type ngType = ColumnType::count,
132  const MinMax3 &minMax = undefMinMax3(),
133  const double3 &scale = undefDouble3(),
134  const double3 &offset = undefDouble3() ) = 0;
135 
136  // remove any definitions of extra bytes.
137  // Make sure to call this function before exportExtraBytes(.), if a header is passed in the constructor.
138  virtual void clearExtraBytes() = 0;
139  //}@
140 
141 };
142 
144 
145 DM_NAMESPACE_END
146 
147 #endif //DM_IO_EXPORT_LAS_HPP_INCLUDED