Orfeo Toolbox  3.16
LidarReaderExample.cxx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 
19 // Software Guide : BeginCommandLineArgs
20 // INPUTS: {srs.las}
21 // Software Guide : EndCommandLineArgs
22 
23 // Software Guide : BeginLatex
24 //
25 // This example describes how to read a lidar data file and to display the basic
26 // information about it. Here, OTB make use of libLAS.
27 //
28 // The first step toward the use of these filters is to include the proper header files.
29 //
30 // Software Guide : EndLatex
31 
32 // Software Guide : BeginCodeSnippet
33 #include "otbPointSetFileReader.h"
34 #include "itkPointSet.h"
35 #include <fstream>
36 int main(int argc, char * argv[])
37 {
38 // Software Guide : EndCodeSnippet
39 
40 // Software Guide : BeginLatex
41 //
42 // We need now to declare the data types that we will be using and instanciate the
43 // reader (which is a \doxygen{otb}{PointSetFileReader}).
44 //
45 // Software Guide : EndLatex
46 
47 // Software Guide : BeginCodeSnippet
48  typedef itk::PointSet <double, 2> PointSetType;
49  typedef otb::PointSetFileReader<PointSetType> PointSetFileReaderType;
50  PointSetFileReaderType::Pointer reader = PointSetFileReaderType::New();
51 
52  reader->SetFileName(argv[1]);
53  reader->Update();
54 // Software Guide : EndCodeSnippet
55 
56 // Software Guide : BeginLatex
57 //
58 // We can already display some interesting information such as the
59 // data extension and the number of points:
60 //
61 // Software Guide : EndLatex
62 
63  // Software Guide : BeginCodeSnippet
64  std::cout << "*** Data area *** " << std::endl;
65  std::cout << std::setprecision(15);
66  std::cout << " - Easting min: " << reader->GetMinX() << std::endl;
67  std::cout << " - Easting max: " << reader->GetMaxX() << std::endl;
68  std::cout << " - Northing min: " << reader->GetMinY() << std::endl;
69  std::cout << " - Northing max: " << reader->GetMaxY() << std::endl;
70  std::cout << "Data points: " << reader->GetNumberOfPoints() << std::endl;
71  // Software Guide : EndCodeSnippet
72 
73  // Software Guide : BeginLatex
74 //
75 // We can also loop on the point to see each point with its coordinates and
76 // value. Be careful here, data set can have hundred of thousands of points:
77 //
78 // Software Guide : EndLatex
79 
80  // Software Guide : BeginCodeSnippet
81  PointSetType::Pointer data = reader->GetOutput();
82 
83  unsigned long nPoints = data->GetNumberOfPoints();
84 
85  for (unsigned long i = 0; i < nPoints; ++i)
86  {
87  PointSetType::PointType point;
88  data->GetPoint(i, &point);
89  std::cout << point << " : ";
90  PointSetType::PixelType value =
91  itk::NumericTraits<PointSetType::PixelType>::Zero;
92  data->GetPointData(i, &value);
93  std::cout << value << std::endl;
94  }
95 
96  return EXIT_SUCCESS;
97 }
98 // Software Guide : EndCodeSnippet

Generated at Sun Feb 3 2013 00:15:39 for Orfeo Toolbox with doxygen 1.8.1.1