[Liblas-commits] hg-main-tree: pcinfo work, now dumping stats
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Aug 18 20:18:37 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/acc2c512e52c
changeset: 1143:acc2c512e52c
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Aug 18 17:06:52 2011 -0700
description:
pcinfo work, now dumping stats
diffstat:
apps/pcinfo.cpp | 32 ++++---
test/data/apps/pcinfo_point.txt | 20 +++++
test/data/apps/pcinfo_schema.txt | 146 +++++++++++++++++++++++++++++++++++++++
test/data/apps/pcinfo_stage.txt | 3 +
test/data/apps/pcinfo_stats.txt | 23 ++++++
test/unit/pcinfoTest.cpp | 6 +-
6 files changed, 215 insertions(+), 15 deletions(-)
diffs (truncated from 331 to 300 lines):
diff -r 017ef48bc1bd -r acc2c512e52c apps/pcinfo.cpp
--- a/apps/pcinfo.cpp Thu Aug 18 17:06:27 2011 -0700
+++ b/apps/pcinfo.cpp Thu Aug 18 17:06:52 2011 -0700
@@ -63,18 +63,17 @@
void validateSwitches(); // overrride
void dumpOnePoint(const Stage&) const;
- void dumpPointsSummary(const Stage&) const;
+ void dumpStats(pdal::filters::StatsFilter& filter) const;
void dumpSchema(const Stage&) const;
void dumpStage(const Stage&) const;
std::string m_inputFile;
std::string m_outputFile;
bool m_useLiblas;
- bool m_summarizePoints;
+ bool m_showStats;
bool m_showSchema;
bool m_showStage;
boost::uint64_t m_pointNumber;
- boost::scoped_ptr<filters::StatsFilter> m_filter;
std::ostream* m_outputStream;
};
@@ -84,7 +83,7 @@
, m_inputFile("")
, m_outputFile("")
, m_useLiblas(false)
- , m_summarizePoints(false)
+ , m_showStats(false)
, m_showSchema(false)
, m_showStage(false)
, m_pointNumber((std::numeric_limits<boost::uint64_t>::max)())
@@ -123,7 +122,7 @@
processing_options->add_options()
("point,p", po::value<boost::uint64_t>(&m_pointNumber)->implicit_value((std::numeric_limits<boost::uint64_t>::max)()), "point to dump")
- ("points,a", po::value<bool>(&m_summarizePoints)->zero_tokens()->implicit_value(true), "dump stats on all points (read entire dataset)")
+ ("stats,a", po::value<bool>(&m_showStats)->zero_tokens()->implicit_value(true), "dump stats on all points (reads entire dataset)")
("schema,s", po::value<bool>(&m_showSchema)->zero_tokens()->implicit_value(true), "dump the schema")
("stage,r", po::value<bool>(&m_showStage)->zero_tokens()->implicit_value(true), "dump the stage info")
;
@@ -164,12 +163,13 @@
}
-void PcInfo::dumpPointsSummary(const Stage& stage) const
+void PcInfo::dumpStats(pdal::filters::StatsFilter& filter) const
{
- const Schema& schema = stage.getSchema();
+
+ const Schema& schema = filter.getSchema();
SchemaLayout layout(schema);
- boost::scoped_ptr<StageSequentialIterator> iter(stage.createSequentialIterator());
+ boost::scoped_ptr<StageSequentialIterator> iter(filter.createSequentialIterator());
boost::uint64_t totRead = 0;
while (!iter->atEnd())
@@ -180,9 +180,11 @@
totRead += numRead;
}
+ boost::property_tree::ptree tree = filter.toStatsPTree();
+
std::ostream& ostr = m_outputStream ? *m_outputStream : std::cout;
- ostr << "Read " << totRead << " points\n";
+ write_json(ostr, tree);
return;
}
@@ -238,16 +240,18 @@
Stage& reader = AppSupport::makeReader(readerOptions);
- reader.initialize();
-
+ pdal::filters::StatsFilter filter(reader);
+
+ filter.initialize();
+
if (m_pointNumber != (std::numeric_limits<boost::uint64_t>::max)())
{
- dumpOnePoint(reader);
+ dumpOnePoint(filter);
}
- if (m_summarizePoints)
+ if (m_showStats)
{
- dumpPointsSummary(reader);
+ dumpStats(filter);
}
if (m_showSchema)
diff -r 017ef48bc1bd -r acc2c512e52c test/data/apps/pcinfo_point.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/apps/pcinfo_point.txt Thu Aug 18 17:06:52 2011 -0700
@@ -0,0 +1,20 @@
+Point 1:
+{
+ "X": "63689633",
+ "Y": "84908770",
+ "Z": "44639",
+ "Intensity": "18",
+ "ReturnNumber": "1",
+ "NumberOfReturns": "2",
+ "ScanDirectionFlag": "1",
+ "EdgeOfFlightLine": "0",
+ "Classification": "1",
+ "ScanAngleRank": "-11",
+ "UserData": "128",
+ "PointSourceId": "7326",
+ "Time": "245381.45279923646",
+ "Red": "54",
+ "Green": "66",
+ "Blue": "68"
+}
+
diff -r 017ef48bc1bd -r acc2c512e52c test/data/apps/pcinfo_schema.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/apps/pcinfo_schema.txt Thu Aug 18 17:06:52 2011 -0700
@@ -0,0 +1,146 @@
+{
+ "dimension":
+ {
+ "name": "X",
+ "datatype": "Int32",
+ "description": "x coordinate as a long integer. You must use the scale and offset information of the header to determine the double value.",
+ "bytesize": "4",
+ "endianness": "little",
+ "scale": "0.01"
+ },
+ "dimension":
+ {
+ "name": "Y",
+ "datatype": "Int32",
+ "description": "y coordinate as a long integer. You must use the scale and offset information of the header to determine the double value.",
+ "bytesize": "4",
+ "endianness": "little",
+ "scale": "0.01"
+ },
+ "dimension":
+ {
+ "name": "Z",
+ "datatype": "Int32",
+ "description": "z coordinate as a long integer. You must use the scale and offset information of the header to determine the double value.",
+ "bytesize": "4",
+ "endianness": "little",
+ "scale": "0.01"
+ },
+ "dimension":
+ {
+ "name": "Intensity",
+ "datatype": "Uint16",
+ "description": "The intensity value is the integer representation of the pulse return magnitude. This value is optional and system specific. However, it should always be included if available.",
+ "bytesize": "2",
+ "endianness": "little",
+ "scale": "0"
+ },
+ "dimension":
+ {
+ "name": "ReturnNumber",
+ "datatype": "Uint8",
+ "description": "Return Number: The Return Number is the pulse return number for a given output pulse. A given output laser pulse can have many returns, and they must be marked in sequence of return. The first return will have a Return Number of one, the second a Return Number of two, and so on up to five returns.",
+ "bytesize": "1",
+ "endianness": "little",
+ "scale": "0"
+ },
+ "dimension":
+ {
+ "name": "NumberOfReturns",
+ "datatype": "Uint8",
+ "description": "Number of Returns (for this emitted pulse): The Number of Returns is the total number of returns for a given pulse. For example, a laser data point may be return two (Return Number) within a total number of five returns.",
+ "bytesize": "1",
+ "endianness": "little",
+ "scale": "0"
+ },
+ "dimension":
+ {
+ "name": "ScanDirectionFlag",
+ "datatype": "Uint8",
+ "description": "The Scan Direction Flag denotes the direction at which the scanner mirror was traveling at the time of the output pulse. A bit value of 1 is a positive scan direction, and a bit value of 0 is a negative scan direction (where positive scan direction is a scan moving from the left side of the in-track direction to the right side and negative the opposite). ",
+ "bytesize": "1",
+ "endianness": "little",
+ "scale": "0"
+ },
+ "dimension":
+ {
+ "name": "EdgeOfFlightLine",
+ "datatype": "Uint8",
+ "description": "The Edge of Flight Line data bit has a value of 1 only when the point is at the end of a scan. It is the last point on a given scan line before it changes direction.",
+ "bytesize": "1",
+ "endianness": "little",
+ "scale": "0"
+ },
+ "dimension":
+ {
+ "name": "Classification",
+ "datatype": "Uint8",
+ "description": "Classification in LAS 1.0 was essentially user defined and optional. LAS 1.1 defines a standard set of ASPRS classifications. In addition, the field is now mandatory. If a point has never been classified, this byte must be set to zero. There are no user defined classes since both point format 0 and point format 1 supply 8 bits per point for user defined operations. Note that the format for classification is a bit encoded field with the lower five bits used for class and the three high bits used for flags.",
+ "bytesize": "1",
+ "endianness": "little",
+ "scale": "0"
+ },
+ "dimension":
+ {
+ "name": "ScanAngleRank",
+ "datatype": "Int8",
+ "description": "The Scan Angle Rank is a signed one-byte number with a valid range from -90 to +90. The Scan Angle Rank is the angle (rounded to the nearest integer in the absolute value sense) at which the laser point was output from the laser system including the roll of the aircraft. The scan angle is within 1 degree of accuracy from +90 to \u009690 degrees. The scan angle is an angle based on 0 degrees being nadir, and \u009690 degrees to the left side of the aircraft in the direction of flight.",
+ "bytesize": "1",
+ "endianness": "little",
+ "scale": "0"
+ },
+ "dimension":
+ {
+ "name": "UserData",
+ "datatype": "Uint8",
+ "description": "This field may be used at the user\u0092s discretion",
+ "bytesize": "1",
+ "endianness": "little",
+ "scale": "0"
+ },
+ "dimension":
+ {
+ "name": "PointSourceId",
+ "datatype": "Uint16",
+ "description": "This value indicates the file from which this point originated. Valid values for this field are 1 to 65,535 inclusive with zero being used for a special case discussed below. The numerical value corresponds to the File Source ID from which this point originated. Zero is reserved as a convenience to system implementers. A Point Source ID of zero implies that this point originated in this file. This implies that processing software should set the Point Source ID equal to the File Source ID of the file containing this point at some time during processing. ",
+ "bytesize": "2",
+ "endianness": "little",
+ "scale": "0"
+ },
+ "dimension":
+ {
+ "name": "Time",
+ "datatype": "Double",
+ "description": "The GPS Time is the double floating point time tag value at which the point was acquired. It is GPS Week Time if the Global Encoding low bit is clear and Adjusted Standard GPS Time if the Global Encoding low bit is set (see Global Encoding in the Public Header Block description).",
+ "bytesize": "8",
+ "endianness": "little",
+ "scale": "0"
+ },
+ "dimension":
+ {
+ "name": "Red",
+ "datatype": "Uint16",
+ "description": "The red image channel value associated with this point",
+ "bytesize": "2",
+ "endianness": "little",
+ "scale": "0"
+ },
+ "dimension":
+ {
+ "name": "Green",
+ "datatype": "Uint16",
+ "description": "The green image channel value associated with this point",
+ "bytesize": "2",
+ "endianness": "little",
+ "scale": "0"
+ },
+ "dimension":
+ {
+ "name": "Blue",
+ "datatype": "Uint16",
+ "description": "The blue image channel value associated with this point",
+ "bytesize": "2",
+ "endianness": "little",
+ "scale": "0"
+ }
+}
diff -r 017ef48bc1bd -r acc2c512e52c test/data/apps/pcinfo_stage.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/apps/pcinfo_stage.txt Thu Aug 18 17:06:52 2011 -0700
@@ -0,0 +1,3 @@
+driver type: drivers.las.reader
+1065 points
+WKT:
diff -r 017ef48bc1bd -r acc2c512e52c test/data/apps/pcinfo_stats.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/apps/pcinfo_stats.txt Thu Aug 18 17:06:52 2011 -0700
@@ -0,0 +1,23 @@
+{
+ "X":
+ {
+ "count": "1065",
+ "minimum": "63561985",
+ "maximum": "63898255",
+ "average": "63729673.51830986"
+ },
+ "Y":
+ {
+ "count": "1065",
+ "minimum": "84889970",
+ "maximum": "85353543",
+ "average": "85124953.84882629"
+ },
+ "Z":
+ {
+ "count": "1065",
+ "minimum": "40659",
More information about the Liblas-commits
mailing list