pktools  2.6.3
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  void resetReader(){m_reader->Reset();};
56  void setFilter(std::vector<liblas::FilterPtr> const& filters);
57  bool const& readNextPoint(liblas::Point& thePoint){bool returnValue=m_reader->ReadNextPoint();thePoint=m_reader->GetPoint();return(returnValue);};
58  liblas::Point const& readPointAt(std::size_t n){m_reader->ReadPointAt(n);return m_reader->GetPoint();};
59  // void addBoundsFilter(double ulx, double uly, double lrx, double lry);
60  void addReturnsFilter(std::vector<unsigned short> const& returns);
61  void addClassFilter(std::vector<unsigned short> const& classes);
62  void setFilters(const std::vector<liblas::FilterPtr>& filters){m_filters=filters;setFilters();};
63  void setFilters(){m_reader->SetFilters(m_filters);};
64 protected:
65  void setCodec(const std::string& filename);
66  std::string m_filename;
67  std::ifstream *m_ifstream;
68  liblas::Reader* m_reader;
69  std::vector<liblas::FilterPtr> m_filters;
70 };
71 
72 #endif // _IMGREADERLAS_H_