1
/***************************************************************************
3
* Project: libLAS -- C/C++ read/write library for LAS LIDAR data
4
* Purpose: LAS information with optional configuration
5
* Author: Howard Butler, hobu.inc at gmail.com
6
***************************************************************************
7
* Copyright (c) 2010, Howard Butler, hobu.inc at gmail.com
9
* See LICENSE.txt in this source distribution for more information.
10
**************************************************************************/
12
#include <liblas/liblas.hpp>
13
#include "laskernel.hpp"
15
#include <boost/cstdint.hpp>
16
#include <boost/foreach.hpp>
21
using namespace liblas;
25
liblas::Summary check_points( liblas::Reader& reader,
26
std::vector<liblas::FilterPtr>& filters,
27
std::vector<liblas::TransformPtr>& transforms,
31
liblas::Summary summary;
32
summary.SetHeader(reader.GetHeader());
34
reader.SetFilters(filters);
35
reader.SetTransforms(transforms);
40
std::cout << "Scanning points:"
45
// Translation of points cloud to features set
47
boost::uint32_t i = 0;
48
boost::uint32_t const size = reader.GetHeader().GetPointRecordsCount();
51
while (reader.ReadNextPoint())
53
liblas::Point const& p = reader.GetPoint();
56
term_progress(std::cout, (i + 1) / static_cast<double>(size));
61
std::cout << std::endl;
67
void OutputHelp( std::ostream & oss, po::options_description const& options)
69
oss << "--------------------------------------------------------------------\n";
70
oss << " lasinfo (" << GetFullVersion() << ")\n";
71
oss << "--------------------------------------------------------------------\n";
75
oss <<"\nFor more information, see the full documentation for lasinfo at:\n";
77
oss << " http://liblas.org/utilities/lasinfo.html\n";
78
oss << "----------------------------------------------------------\n";
82
void PrintVLRs(std::ostream& os, liblas::Header const& header)
84
if (!header.GetRecordsCount())
87
os << "---------------------------------------------------------" << std::endl;
88
os << " VLR Summary" << std::endl;
89
os << "---------------------------------------------------------" << std::endl;
91
typedef std::vector<VariableRecord>::size_type size_type;
92
for(size_type i = 0; i < header.GetRecordsCount(); i++) {
93
liblas::VariableRecord const& v = header.GetVLR(i);
100
int main(int argc, char* argv[])
105
bool verbose = false;
107
bool show_vlrs = true;
108
bool show_schema = true;
109
bool output_xml = false;
110
bool output_json = false;
111
bool show_point = false;
112
bool use_locale = false;
113
boost::uint32_t point = 0;
115
std::vector<liblas::FilterPtr> filters;
116
std::vector<liblas::TransformPtr> transforms;
118
liblas::Header header;
122
po::options_description file_options("lasinfo options");
123
po::options_description filtering_options = GetFilteringOptions();
124
po::options_description header_options = GetHeaderOptions();
126
po::positional_options_description p;
130
file_options.add_options()
131
("help,h", "produce help message")
132
("input,i", po::value< string >(), "input LAS file")
134
("verbose,v", po::value<bool>(&verbose)->zero_tokens(), "Verbose message output")
135
("no-vlrs", po::value<bool>(&show_vlrs)->zero_tokens()->implicit_value(false), "Don't show VLRs")
136
("no-schema", po::value<bool>(&show_schema)->zero_tokens()->implicit_value(false), "Don't show schema")
137
("no-check", po::value<bool>(&check)->zero_tokens()->implicit_value(false), "Don't scan points")
138
("xml", po::value<bool>(&output_xml)->zero_tokens()->implicit_value(true), "Output as XML")
139
("point,p", po::value<boost::uint32_t>(&point), "Display a point with a given id. --point 44")
141
("locale", po::value<bool>(&use_locale)->zero_tokens()->implicit_value(true), "Use the environment's locale for output")
145
// --restructured text output
148
po::variables_map vm;
149
po::options_description options;
150
options.add(file_options).add(filtering_options);
151
po::store(po::command_line_parser(argc, argv).
152
options(options).positional(p).run(), vm);
156
if (vm.count("help"))
158
OutputHelp(std::cout, options);
162
if (vm.count("point"))
167
if (vm.count("input"))
169
input = vm["input"].as< string >();
172
std::cout << "Opening " << input << " to fetch Header" << std::endl;
173
if (!liblas::Open(ifs, input.c_str()))
175
std::cerr << "Cannot open " << input << " for read. Exiting..." << std::endl;
178
liblas::ReaderFactory f;
179
liblas::Reader reader = f.CreateWithStream(ifs);
180
header = reader.GetHeader();
182
std::cerr << "Input LAS file not specified!\n";
183
OutputHelp(std::cout, options);
188
filters = GetFilters(vm, verbose);
191
if (!liblas::Open(ifs, input.c_str()))
193
std::cerr << "Cannot open " << input << " for read. Exiting..." << std::endl;
198
liblas::ReaderFactory f;
199
liblas::Reader reader = f.CreateWithStream(ifs);
204
reader.ReadPointAt(point);
205
liblas::Point const& p = reader.GetPoint();
207
liblas::property_tree::ptree tree;
208
tree.add_child("points.point", p.GetPTree());
209
liblas::property_tree::write_xml(std::cout, tree);
219
std::cout << p << std::endl;
223
} catch (std::out_of_range const& e)
225
std::cerr << "Unable to read point at index " << point << ": " << e.what() << std::endl;
232
liblas::Summary summary;
234
summary = check_points( reader,
242
if (output_xml && output_json) {
243
std::cerr << "both JSON and XML output cannot be chosen";
247
liblas::property_tree::ptree tree;
249
tree = summary.GetPTree();
252
tree.add_child("summary.header", header.GetPTree());
255
liblas::property_tree::write_xml(std::cout, tree);
265
std::cout << header << std::endl;
267
PrintVLRs(std::cout, header);
270
std::cout << header.GetSchema();
273
std::cout << summary << std::endl;
277
catch(std::exception& e) {
278
std::cerr << "error: " << e.what() << "\n";
282
std::cerr << "Exception of unknown type!\n";
290
//las2las2 -i lt_srs_rt.las -o foo.las -c 1,2 -b 2483590,366208,2484000,366612