pktools  2.6.7
Processing Kernel for geospatial data
FileReaderLas.h
1 /**********************************************************************
2 FileReaderLas.h: class to read LAS files using liblas API library
3 Copyright (C) 2008-2012 Pieter Kempeneers
4 
5 This file is part of pktools
6 
7 pktools is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 pktools is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with pktools. If not, see <http://www.gnu.org/licenses/>.
19 ***********************************************************************/
20 #ifndef _IMGREADERLAS_H_
21 #define _IMGREADERLAS_H_
22 
23 #include <string>
24 #include <vector>
25 #include "liblas/liblas.hpp"
26 
27 //--------------------------------------------------------------------------
28 class LastReturnFilter: public liblas::FilterI
29 {
30 public:
32  bool filter(const liblas::Point& point);
33 
34 private:
35  LastReturnFilter(LastReturnFilter const& other);
36  LastReturnFilter& operator=(LastReturnFilter const& rhs);
37 };
38 
40 {
41 public:
42  FileReaderLas(void);
43  FileReaderLas(const std::string& filename);
44  ~FileReaderLas(void);
45  void open(const std::string& filename);
46  void close(void);
47  liblas::Header const& getHeader() const;
48  bool isCompressed() const;
49  unsigned long int getPointCount() const;
50  void las2ascii(const std::string& filename, bool verbose=false) const;
51  template<typename T> liblas::Bounds<T> getExtent() const {return getHeader().GetExtent();};
52  void getExtent(double& ulx, double& uly, double& lrx, double& lry) const;
53  double getMinZ() const;
54  double getMaxZ() const;
55  liblas::Reader* getReader(){return m_reader;};
56  void resetReader(){m_reader->Reset();};
57  void setFilter(std::vector<liblas::FilterPtr> const& filters);
58  bool const& readNextPoint(){return(m_reader->ReadNextPoint());};
59  bool const& readNextPoint(liblas::Point& thePoint);
60  liblas::Point const& getPoint(){return m_reader->GetPoint();};
61  liblas::Point const& readPointAt(std::size_t n){m_reader->ReadPointAt(n);return m_reader->GetPoint();};
62  // void addBoundsFilter(double ulx, double uly, double lrx, double lry);
63  void addReturnsFilter(std::vector<unsigned short> const& returns);
64  void addClassFilter(std::vector<unsigned short> const& classes);
65  void setFilters(const std::vector<liblas::FilterPtr>& filters){m_filters=filters;setFilters();};
66  void setFilters(){m_reader->SetFilters(m_filters);};
67 protected:
68  void setCodec(const std::string& filename);
69  std::string m_filename;
70  std::ifstream *m_ifstream;
71  liblas::Reader* m_reader;
72  std::vector<liblas::FilterPtr> m_filters;
73 };
74 
75 #endif // _IMGREADERLAS_H_
Definition: Filter.h:33