IImportLAS.hpp
1 #ifndef DM_IO_IMPORT_LAS_HPP_INCLUDED
2 #define DM_IO_IMPORT_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/IImport.hpp"
14 
15 
16 DM_NAMESPACE_BEGIN
17 
18 class DM_API IImportLAS : public virtual IImport
19 {
20 public:
21  static IImportLAS* New( const char *file, FilterHandle filter = FilterHandle(),
23  bool collectHdrContents = false, unsigned maxBulkPoints = 1000,
24  AddInfoLayoutHandle defaultLayout = AddInfoLayoutHandle() );
25 
26  struct ExtraBytes {
27  union AnyType {
28  unsigned long long ul;
29  signed long long sl;
30  double d;
31  };
32  ColumnType::Type type; // The quantity's data type. Note that unsigned long long is supported by LAS, but (currently) not by NG-attributes, which is thus mapped to signed long long.
33  int nElements; // [1 3]; 1->scalar
34  char name[32]; // max. length: 32
35  char description[32]; // max. length: 32
36  // Left variable specifies if right variable is meaningful.
37  // consider nElements of right variable!
38  // LAS 1.4 does not specify if right variables refer to raw values or transformed values. We use: raw values.
39  bool hasNoData; AnyType noData[3]; // These raw values should be considered as invalid.
40  bool hasMin; AnyType minima[3]; // Minimum valid, raw value.
41  bool hasMax; AnyType maxima[3]; // Maximum valid, raw value.
42 
43  // Transform raw values to external values.
44  // If scale and/or offset are in use, then the external values may need to be represented as real numbers, although the raw values are integrals (maybe even unsigned ones).
45  // LAS 1.4 does not specify how the transformation is defined.
46  // We use: externalVal = rawVal * scale + offset, in accordance with the transformation of raw point coordinates
47  bool hasOffset; double offset[3];
48  bool hasScale; double scale[3];
49  };
50 
51 
52 protected:
53  virtual ~IImportLAS() {}
54 
55 public:
56 
57  /// get number of extra byte records (available after header was read)
58  virtual unsigned getExtraByteRecordCount() const = 0;
59  /// get corresponding extra byte record (available after header was read)
60  virtual void getExtraByteRecord(unsigned idx, ExtraBytes &record) const = 0;
61 
62  // Specify a predefined NG-attribute by its enum. The LASattribute's type will be converted to that of the predefined attribute
63  virtual void importExtraBytes( int lasAttrIndex, ColumnSemantic::Type ngCol ) = 0;
64  // Specify the NG-attribute by name. By default, use the name and type of the LASattribute
65  virtual void importExtraBytes( int lasAttrIndex, const char* ngName = 0, ColumnType::Type ngType = ColumnType::count ) = 0;
66  // Map an arbitrary element of a multi-element LAS attribute. Indexing starts at zero.
67  virtual void importExtraBytes( int lasAttrIndex, int lasElemIndex, ColumnSemantic::Type ngCol ) = 0;
68  virtual void importExtraBytes( int lasAttrIndex, int lasElemIndex, const char* ngName = 0, ColumnType::Type ngType = ColumnType::count ) = 0;
69  //}@
70 };
71 
72 typedef Handle<IImportLAS> ImportLASHandle;
73 
74 
75 DM_NAMESPACE_END
76 
77 #endif //DM_IO_IMPORT_LAS_HPP_INCLUDED