[Liblas-commits] hg: add GetPTree methods to liblas::Header and
liblas::Point
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Aug 19 15:12:35 EDT 2010
changeset 5721a1944d54 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=5721a1944d54
summary: add GetPTree methods to liblas::Header and liblas::Point
diffstat:
apps/las2las2.cpp | 19 +++---
apps/laskernel.cpp | 128 ++----------------------------------------
apps/laskernel.hpp | 2 +-
include/liblas/lasheader.hpp | 5 +
include/liblas/laspoint.hpp | 8 ++-
src/lasheader.cpp | 79 ++++++++++++++++++++++++++
src/laspoint.cpp | 48 ++++++++++++++++
7 files changed, 155 insertions(+), 134 deletions(-)
diffs (truncated from 426 to 300 lines):
diff -r c7b737060ffb -r 5721a1944d54 apps/las2las2.cpp
--- a/apps/las2las2.cpp Thu Aug 19 11:49:06 2010 -0500
+++ b/apps/las2las2.cpp Thu Aug 19 14:12:27 2010 -0500
@@ -99,7 +99,7 @@
liblas::Header const& header,
std::vector<liblas::FilterI*>& filters,
std::vector<liblas::TransformI*>& transforms,
- boost::uint32_t split_size,
+ uint32_t split_size,
bool verbose)
{
@@ -172,13 +172,12 @@
if (verbose)
std::cout << std::endl;
- // reader.Reset();
- // boost::property_tree::ptree pts = SummarizePoints(reader);
- // boost::property_tree::ptree hdr = SummarizeHeader(reader.GetHeader());
- // boost::property_tree::ptree top;
- // top.add_child("summary.header",hdr);
- // top.add_child("summary.points",pts);
- // boost::property_tree::write_xml("junk.xml", top);
+ reader.Reset();
+ boost::property_tree::ptree pts = SummarizePoints(reader);
+ boost::property_tree::ptree top;
+ top.add_child("summary.header",reader.GetHeader().GetPTree());
+ top.add_child("summary.points",pts);
+ boost::property_tree::write_xml("junk.xml", top);
delete writer;
delete ofs;
@@ -203,7 +202,7 @@
int main(int argc, char* argv[])
{
- boost::uint32_t split_size;
+ uint32_t split_size;
std::string input;
std::string output;
@@ -225,7 +224,7 @@
file_options.add_options()
("help,h", "produce help message")
- ("split,s", po::value<boost::uint32_t>(&split_size)->default_value(0), "Split file into multiple files with each being this size in MB or less. If this value is 0, no splitting is done")
+ ("split,s", po::value<uint32_t>(&split_size)->default_value(0), "Split file into multiple files with each being this size in MB or less. If this value is 0, no splitting is done")
("input,i", po::value< string >(), "input LAS file")
("output,o", po::value< string >(&output)->default_value("output.las"), "output LAS file")
("verbose,v", po::value<bool>(&verbose)->zero_tokens(), "Verbose message output")
diff -r c7b737060ffb -r 5721a1944d54 apps/laskernel.cpp
--- a/apps/laskernel.cpp Thu Aug 19 11:49:06 2010 -0500
+++ b/apps/laskernel.cpp Thu Aug 19 14:12:27 2010 -0500
@@ -678,51 +678,13 @@
read = reader.ReadNextPoint();
}
- pt.put("bounds.minx", min.GetX());
- pt.put("bounds.miny", min.GetY());
- pt.put("bounds.minz", min.GetZ());
- pt.put("bounds.maxx", max.GetX());
- pt.put("bounds.maxy", max.GetY());
- pt.put("bounds.maxz", max.GetZ());
+ ptree pmin = min.GetPTree();
+ ptree pmax = max.GetPTree();
- pt.put("time.min", min.GetTime());
- pt.put("time.max", max.GetTime());
-
- pt.put("intensity.min", min.GetIntensity());
- pt.put("intensity.max", max.GetIntensity());
-
- pt.put("returnnumber.min", min.GetReturnNumber());
- pt.put("returnnumber.max", max.GetReturnNumber());
-
- pt.put("numberofreturns.min", min.GetNumberOfReturns());
- pt.put("numberofreturns.max", max.GetNumberOfReturns());
-
- pt.put("scandirection.min", min.GetScanDirection());
- pt.put("scandirection.max", max.GetScanDirection());
-
- pt.put("scanangle.min", min.GetScanAngleRank());
- pt.put("scanangle.max", max.GetScanAngleRank());
-
- pt.put("flightlineedge.min", min.GetFlightLineEdge());
- pt.put("flightlineedge.max", max.GetFlightLineEdge());
-
- pt.put("userdata.min", min.GetUserData());
- pt.put("userdata.max", max.GetUserData());
-
- pt.put("pointsourceid.min", min.GetPointSourceID());
- pt.put("pointsourceid.max", max.GetPointSourceID());
-
- ptree colors;
- liblas::Color const& c = min.GetColor();
- colors.put("min.red", c.GetRed());
- colors.put("min.green", c.GetGreen());
- colors.put("min.blue", c.GetBlue());
- liblas::Color const& d = max.GetColor();
- colors.put("max.red", d.GetRed());
- if (d.GetGreen() == 57) std::cout << "hey it's 57!" << std::endl;
- colors.put("max.green", d.GetGreen());
- colors.put("max.blue", d.GetBlue());
- pt.add_child("color", colors);
+
+
+ pt.add_child("minimum", pmin);
+ pt.add_child("maximum", pmax);
ptree klasses;
@@ -769,83 +731,5 @@
return pt;
}
-boost::property_tree::ptree SummarizeHeader(liblas::Header const& header )
-{
- using boost::property_tree::ptree;
- ptree pt;
-
- pt.put("filesignature", header.GetFileSignature());
- pt.put("projectdid", header.GetProjectId());
- pt.put("systemid", header.GetSystemId());
- pt.put("softwareid", header.GetSoftwareId());
-
-
- ostringstream version;
- version << static_cast<int>(header.GetVersionMajor());
- version <<".";
- version << static_cast<int>(header.GetVersionMinor());
- pt.put("version", version.str());
-
- pt.put("filesourceid", header.GetFileSourceId());
- pt.put("reserved", header.GetReserved());
-#ifdef HAVE_GDAL
- pt.put("srs", header.GetSRS().GetWKT());
-#else
-#ifdef HAVE_LIBGEOTIFF
- pt.put("proj4", header.GetSRS().GetProj4());
-#endif
-#endif
-
- ostringstream date;
- date << header.GetCreationDOY() << "/" << header.GetCreationYear();
- pt.put("date", date.str());
-
- pt.put("size", header.GetHeaderSize());
- pt.put("offset", header.GetDataOffset());
-
- pt.put("count", header.GetPointRecordsCount());
- pt.put("dataformatid", header.GetDataFormatId());
- pt.put("datarecordlength", header.GetDataRecordLength());
-
- ptree return_count;
- liblas::Header::RecordsByReturnArray returns = header.GetPointRecordsByReturnCount();
- for (boost::uint32_t i=0; i< 5; i++){
- ptree r;
- r.put("id", i);
- r.put("count", returns[i]);
- return_count.add_child("return", r);
- }
- pt.add_child("returns", return_count);
-
- pt.put("scale.x", header.GetScaleX());
- pt.put("scale.y", header.GetScaleY());
- pt.put("scale.z", header.GetScaleZ());
-
- pt.put("offset.x", header.GetOffsetX());
- pt.put("offset.y", header.GetOffsetY());
- pt.put("offset.z", header.GetOffsetZ());
-
- pt.put("min.x", header.GetMinX());
- pt.put("min.y", header.GetMinY());
- pt.put("min.z", header.GetMinZ());
-
- pt.put("max.x", header.GetMaxX());
- pt.put("max.y", header.GetMaxY());
- pt.put("max.z", header.GetMaxZ());
-
-
- ptree vlr;
- for (boost::uint32_t i=0; i< header.GetRecordsCount(); i++) {
- liblas::VariableRecord const& r = header.GetVLR(i);
- vlr.put("userid", r.GetUserId(false));
- vlr.put("description", r.GetDescription(false));
- vlr.put("length", r.GetRecordLength());
- vlr.put("id", r.GetRecordId());
- pt.add_child("vlr", vlr);
- }
-
- return pt;
-}
-
diff -r c7b737060ffb -r 5721a1944d54 apps/laskernel.hpp
--- a/apps/laskernel.hpp Thu Aug 19 11:49:06 2010 -0500
+++ b/apps/laskernel.hpp Thu Aug 19 14:12:27 2010 -0500
@@ -85,6 +85,6 @@
std::vector<liblas::TransformI*> GetTransforms(po::variables_map vm, bool verbose, liblas::Header& header);
boost::property_tree::ptree SummarizePoints(liblas::Reader& reader );
-boost::property_tree::ptree SummarizeHeader(liblas::Header const& header );
+// boost::property_tree::ptree SummarizeHeader(liblas::Header const& header );
#endif // LIBLAS_ITERATOR_HPP_INCLUDED
diff -r c7b737060ffb -r 5721a1944d54 include/liblas/lasheader.hpp
--- a/include/liblas/lasheader.hpp Thu Aug 19 11:49:06 2010 -0500
+++ b/include/liblas/lasheader.hpp Thu Aug 19 14:12:27 2010 -0500
@@ -52,10 +52,13 @@
#include <liblas/lasversion.hpp>
// boost
#include <boost/cstdint.hpp>
+#include <boost/property_tree/ptree.hpp>
+
//std
#include <cstddef>
#include <string>
#include <vector>
+#include <sstream>
namespace liblas {
@@ -327,6 +330,8 @@
const Bounds<double>& GetExtent() const;
void SetExtent(Bounds<double> const& extent);
+ boost::property_tree::ptree GetPTree() const;
+
private:
typedef detail::Point<double> PointScales;
diff -r c7b737060ffb -r 5721a1944d54 include/liblas/laspoint.hpp
--- a/include/liblas/laspoint.hpp Thu Aug 19 11:49:06 2010 -0500
+++ b/include/liblas/laspoint.hpp Thu Aug 19 14:12:27 2010 -0500
@@ -50,11 +50,14 @@
#include <boost/array.hpp>
#include <boost/cstdint.hpp>
#include <boost/shared_ptr.hpp>
+#include <boost/property_tree/ptree.hpp>
+
// std
#include <stdexcept> // std::out_of_range
#include <cstdlib> // std::size_t
#include <vector> // std::vector
+
namespace liblas {
/// Point data record composed with X, Y, Z coordinates and attributes.
@@ -192,7 +195,8 @@
void SetHeader(HeaderPtr header);
HeaderPtr GetHeaderPtr() const;
-
+
+ boost::property_tree::ptree GetPTree() const;
private:
detail::PointRecord m_record;
@@ -362,6 +366,8 @@
return m_coords[index];
}
+
+
} // namespace liblas
#endif // LIBLAS_LASPOINT_HPP_INCLUDED
diff -r c7b737060ffb -r 5721a1944d54 src/lasheader.cpp
--- a/src/lasheader.cpp Thu Aug 19 11:49:06 2010 -0500
+++ b/src/lasheader.cpp Thu Aug 19 14:12:27 2010 -0500
@@ -759,6 +759,85 @@
m_format = format;
}
+
+boost::property_tree::ptree Header::GetPTree( ) const
+{
+ using boost::property_tree::ptree;
+ ptree pt;
+ pt.put("filesignature", GetFileSignature());
+ pt.put("projectdid", GetProjectId());
+ pt.put("systemid", GetSystemId());
+ pt.put("softwareid", GetSoftwareId());
+
+
+ std::ostringstream version;
+ version << static_cast<int>(GetVersionMajor());
+ version <<".";
+ version << static_cast<int>(GetVersionMinor());
+ pt.put("version", version.str());
+
+ pt.put("filesourceid", GetFileSourceId());
+ pt.put("reserved", GetReserved());
+
+#ifdef HAVE_GDAL
+ pt.put("srs", GetSRS().GetWKT());
+#else
More information about the Liblas-commits
mailing list