pktools 2.6.7
Processing Kernel for geospatial data
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
FileReaderLas Class Reference
Collaboration diagram for FileReaderLas:
Collaboration graph
[legend]

Public Member Functions

 FileReaderLas (const std::string &filename)
 
void open (const std::string &filename)
 
void close (void)
 
liblas::Header const & getHeader () const
 
bool isCompressed () const
 
unsigned long int getPointCount () const
 
void las2ascii (const std::string &filename, bool verbose=false) const
 
template<typename T >
liblas::Bounds< T > getExtent () const
 
void getExtent (double &ulx, double &uly, double &lrx, double &lry) const
 
double getMinZ () const
 
double getMaxZ () const
 
liblas::Reader * getReader ()
 
void resetReader ()
 
void setFilter (std::vector< liblas::FilterPtr > const &filters)
 
bool const & readNextPoint ()
 
bool const & readNextPoint (liblas::Point &thePoint)
 
liblas::Point const & getPoint ()
 
liblas::Point const & readPointAt (std::size_t n)
 
void addReturnsFilter (std::vector< unsigned short > const &returns)
 
void addClassFilter (std::vector< unsigned short > const &classes)
 
void setFilters (const std::vector< liblas::FilterPtr > &filters)
 
void setFilters ()
 

Protected Member Functions

void setCodec (const std::string &filename)
 

Protected Attributes

std::string m_filename
 
std::ifstream * m_ifstream
 
liblas::Reader * m_reader
 
std::vector< liblas::FilterPtr > m_filters
 

Detailed Description

Definition at line 39 of file FileReaderLas.h.

Constructor & Destructor Documentation

◆ FileReaderLas() [1/2]

FileReaderLas::FileReaderLas ( void  )

Definition at line 49 of file FileReaderLas.cc.

50{
51 m_reader=NULL;
52 m_ifstream=NULL;
53}

◆ FileReaderLas() [2/2]

FileReaderLas::FileReaderLas ( const std::string &  filename)

Definition at line 55 of file FileReaderLas.cc.

56{
57 open(filename);
58}

◆ ~FileReaderLas()

FileReaderLas::~FileReaderLas ( void  )

Definition at line 60 of file FileReaderLas.cc.

61{
62 delete m_ifstream;
63 delete m_reader;
64}

Member Function Documentation

◆ addClassFilter()

void FileReaderLas::addClassFilter ( std::vector< unsigned short > const &  classes)

Definition at line 173 of file FileReaderLas.cc.

173 {
174
175 std::vector<liblas::FilterPtr> filters;
176 std::vector<liblas::Classification> theClasses;
177 for(int iclass=0;iclass<classes.size();++iclass){
178 liblas::Classification aClass(classes[iclass]);
179 theClasses.push_back(aClass);
180 }
181 liblas::FilterPtr class_filter = liblas::FilterPtr(new liblas::ClassificationFilter(theClasses));
182 // eInclusion means to keep the classes that match. eExclusion would
183 // throw out those that matched
184 class_filter->SetType(liblas::FilterI::eInclusion);
185 m_filters.push_back(class_filter);
186}

◆ addReturnsFilter()

void FileReaderLas::addReturnsFilter ( std::vector< unsigned short > const &  returns)

Definition at line 157 of file FileReaderLas.cc.

157 {
158 typedef liblas::ReturnFilter filter;
159 filter* return_filter;
160 std::vector<boost::uint16_t> returns_t;
161 if(returns[0]<0)
162 return_filter=new filter(returns_t,true);
163 else{
164 for(int index=0;index<returns.size();++index){
165 assert(returns[index]>0);
166 returns_t.push_back(returns[index]);
167 }
168 return_filter=new filter(returns_t,false);
169 }
170 m_filters.push_back(liblas::FilterPtr(return_filter));
171}

◆ close()

void FileReaderLas::close ( void  )

Definition at line 75 of file FileReaderLas.cc.

76{
77 m_ifstream->close();
78 m_ifstream=NULL;
79 m_reader=NULL;
80}

◆ getExtent() [1/2]

template<typename T >
liblas::Bounds< T > FileReaderLas::getExtent ( ) const
inline

Definition at line 51 of file FileReaderLas.h.

51{return getHeader().GetExtent();};

◆ getExtent() [2/2]

void FileReaderLas::getExtent ( double &  ulx,
double &  uly,
double &  lrx,
double &  lry 
) const

Definition at line 132 of file FileReaderLas.cc.

132 {
133 const liblas::Header& theHeader=getHeader();
134 ulx=theHeader.GetMinX();
135 uly=theHeader.GetMaxY();
136 lrx=theHeader.GetMaxX();
137 lry=theHeader.GetMinY();
138}

◆ getHeader()

liblas::Header const & FileReaderLas::getHeader ( ) const

Definition at line 94 of file FileReaderLas.cc.

94 {
95 return(m_reader->GetHeader());
96}

◆ getMaxZ()

double FileReaderLas::getMaxZ ( ) const

Definition at line 144 of file FileReaderLas.cc.

144 {
145 return(getHeader().GetMaxZ());
146}

◆ getMinZ()

double FileReaderLas::getMinZ ( ) const

Definition at line 140 of file FileReaderLas.cc.

140 {
141 return(getHeader().GetMinZ());
142}

◆ getPoint()

liblas::Point const & FileReaderLas::getPoint ( )
inline

Definition at line 60 of file FileReaderLas.h.

60{return m_reader->GetPoint();};

◆ getPointCount()

unsigned long int FileReaderLas::getPointCount ( ) const

Definition at line 102 of file FileReaderLas.cc.

102 {
103 return getHeader().GetPointRecordsCount();
104}

◆ getReader()

liblas::Reader * FileReaderLas::getReader ( )
inline

Definition at line 55 of file FileReaderLas.h.

55{return m_reader;};

◆ isCompressed()

bool FileReaderLas::isCompressed ( ) const

Definition at line 98 of file FileReaderLas.cc.

98 {
99 return getHeader().Compressed();
100}

◆ las2ascii()

void FileReaderLas::las2ascii ( const std::string &  filename,
bool  verbose = false 
) const

Definition at line 112 of file FileReaderLas.cc.

112 {
113 std::ofstream fpoints(filename.c_str(),std::ios::out);
114 fpoints << "#";
115 fpoints << "X" << "," << "Y" << "," << "Z" << std::endl;
116 if(verbose)
117 std::cout << "reset reading" << std::endl;
118 m_reader->Reset();
119 if(verbose)
120 std::cout << "going through points" << std::endl;
121 while(m_reader->ReadNextPoint()){
122 liblas::Point const& thePoint=m_reader->GetPoint();
123 double x=thePoint.GetX();
124 double y=thePoint.GetY();
125 double z=thePoint.GetZ();
126 fpoints.precision(12);
127 fpoints << x << "," << y << "," << z << std::endl;
128 }
129 fpoints.close();
130}

◆ open()

void FileReaderLas::open ( const std::string &  filename)

Definition at line 68 of file FileReaderLas.cc.

69{
70 m_filename = filename;
71 setCodec(filename);
72}

◆ readNextPoint() [1/2]

bool const & FileReaderLas::readNextPoint ( )
inline

Definition at line 58 of file FileReaderLas.h.

58{return(m_reader->ReadNextPoint());};

◆ readNextPoint() [2/2]

bool const & FileReaderLas::readNextPoint ( liblas::Point &  thePoint)

Definition at line 106 of file FileReaderLas.cc.

106 {
107 bool returnValue=m_reader->ReadNextPoint();
108 thePoint=m_reader->GetPoint();
109 return(returnValue);
110}

◆ readPointAt()

liblas::Point const & FileReaderLas::readPointAt ( std::size_t  n)
inline

Definition at line 61 of file FileReaderLas.h.

61{m_reader->ReadPointAt(n);return m_reader->GetPoint();};

◆ resetReader()

void FileReaderLas::resetReader ( )
inline

Definition at line 56 of file FileReaderLas.h.

56{m_reader->Reset();};

◆ setCodec()

void FileReaderLas::setCodec ( const std::string &  filename)
protected

Definition at line 83 of file FileReaderLas.cc.

83 {
84 m_ifstream = new(std::ifstream);
85 m_ifstream->open(m_filename.c_str(),std::ios::in|std::ios::binary);
86 liblas::ReaderFactory f;
87 liblas::Reader reader = f.CreateWithStream(*m_ifstream);
88 m_reader=new liblas::Reader(reader);
89 // m_reader = new liblas::Reader(*m_ifstream);
90 //Note: It is possible to use the basic liblas::Reader constructor that takes in a std::istream, but it will not be able to account for the fact that the file might be compressed. Using the ReaderFactory will take care of all of this for you.
91 // m_reader=&rfactory.CreateWithStream(ifs);
92}

◆ setFilters() [1/2]

void FileReaderLas::setFilters ( )
inline

Definition at line 66 of file FileReaderLas.h.

66{m_reader->SetFilters(m_filters);};

◆ setFilters() [2/2]

void FileReaderLas::setFilters ( const std::vector< liblas::FilterPtr > &  filters)
inline

Definition at line 65 of file FileReaderLas.h.

65{m_filters=filters;setFilters();};

Member Data Documentation

◆ m_filename

std::string FileReaderLas::m_filename
protected

Definition at line 69 of file FileReaderLas.h.

◆ m_filters

std::vector<liblas::FilterPtr> FileReaderLas::m_filters
protected

Definition at line 72 of file FileReaderLas.h.

◆ m_ifstream

std::ifstream* FileReaderLas::m_ifstream
protected

Definition at line 70 of file FileReaderLas.h.

◆ m_reader

liblas::Reader* FileReaderLas::m_reader
protected

Definition at line 71 of file FileReaderLas.h.


The documentation for this class was generated from the following files: