diff --git a/Code/IO/otbPointSetFileReader.txx b/Code/IO/otbPointSetFileReader.txx index 709e6d729884875e1624dc998a71ce277055c390..ee8508c242a0434c561df141562b33fa8affb56e 100644 --- a/Code/IO/otbPointSetFileReader.txx +++ b/Code/IO/otbPointSetFileReader.txx @@ -86,6 +86,7 @@ namespace otb m_NumberOfPoints = header.GetPointRecordsCount(); + ifs.close(); } @@ -133,8 +134,38 @@ namespace otb typename TOutputPointSet::Pointer output = this->GetOutput(); + + std::ifstream ifs; + ifs.open(m_FileName.c_str(), std::ios::in | std::ios::binary); + liblas::LASReader reader(ifs); + liblas::LASHeader const& header = reader.GetHeader(); + + std::cout << "Signature: " << header.GetFileSignature() << std::endl; + std::cout << "Points count: " << header.GetPointRecordsCount() << std::endl; + + m_NumberOfPoints = header.GetPointRecordsCount(); + while (reader.ReadNextPoint()) + { + liblas::LASPoint const& p = reader.GetPoint(); + + PointType point; + point[0] = p.GetX(); + point[1] = p.GetY(); + + + unsigned long i = output->GetNumberOfPoints(); + output->SetPoint( i, point ); + + PixelType V; + V = static_cast<PixelType>( p.GetZ() ); + output->SetPointData( i, V ); + + } + + + ifs.close(); } diff --git a/Testing/Code/IO/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt index f838a212fd4d831d1fb58dbf041a22dbf58cb7ba..456003eed3116e827ccc446a0fdc08a183850a70 100755 --- a/Testing/Code/IO/CMakeLists.txt +++ b/Testing/Code/IO/CMakeLists.txt @@ -1589,7 +1589,7 @@ ADD_TEST(ioTvPointSetFileReader ${IO_TESTS16} --compare-ascii ${TOL} ${BASELINE_FILES}/ioPointSetFileReader.txt ${TEMP}/ioPointSetFileReader.txt otbPointSetFileReader - ${INPUTDATA}/lidar.las + ${INPUTDATA}/srs.las ${TEMP}/ioPointSetFileReader.txt) diff --git a/Testing/Code/IO/otbPointSetFileReader.cxx b/Testing/Code/IO/otbPointSetFileReader.cxx index 7dd78d5514728cd6aa865a405aea03e8dbf38d46..56eb8691d6528dba5559b279bac5dd1485760fe3 100644 --- a/Testing/Code/IO/otbPointSetFileReader.cxx +++ b/Testing/Code/IO/otbPointSetFileReader.cxx @@ -31,8 +31,21 @@ int otbPointSetFileReader(int argc, char * argv[]) PointSetType::Pointer data = reader->GetOutput(); + std::ofstream fout (argv[2]); - fout << data <<std::endl; + unsigned long nPoints = data->GetNumberOfPoints(); + fout << std::setprecision(15) << "Number of points: " << nPoints << std::endl; + + for(unsigned long i=0; i < nPoints; ++i) + { + PointSetType::PointType point; + data->GetPoint(i,&point); + fout << point << " : "; + PointSetType::PixelType value; + data->GetPointData(i,&value); + fout << value << std::endl; + } + fout << std::endl; fout.close(); return EXIT_SUCCESS; }