[Liblas-commits] hg: 2 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Oct 29 10:12:34 EDT 2010


changeset 5cfe702f59af in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=5cfe702f59af
summary: whoops, use z scale instead of x scale for setting precision

changeset b7880519887b in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=b7880519887b
summary: properly set ostream precision when showing x, y, z values instead of just using x's

diffstat:

 src/lasheader.cpp |  62 ++++++++++++++++++++++++++++++++++++------------------
 src/utility.cpp   |   2 +-
 2 files changed, 42 insertions(+), 22 deletions(-)

diffs (91 lines):

diff -r 1113f11e04c3 -r b7880519887b src/lasheader.cpp
--- a/src/lasheader.cpp	Thu Oct 28 15:23:28 2010 -0500
+++ b/src/lasheader.cpp	Fri Oct 29 09:12:30 2010 -0500
@@ -828,34 +828,54 @@
     os << "  Number of Points by Return:  " << returns_oss.str() << std::endl;
 
     os.setf(std::ios_base::fixed, std::ios_base::floatfield);
-    double scale = tree.get<double>("scale.z");
+    double x_scale = tree.get<double>("scale.x");
+    double y_scale = tree.get<double>("scale.y");
+    double z_scale = tree.get<double>("scale.z");
 
+    boost::uint32_t x_precision = 6;
+    boost::uint32_t y_precision = 6;
+    boost::uint32_t z_precision = 6;
     double frac = 0;
     double integer = 0;
-    frac = std::modf(scale, &integer);
+    
+    frac = std::modf(x_scale, &integer);
+    x_precision = static_cast<boost::uint32_t>(std::fabs(std::floor(std::log10(frac))));
+    frac = std::modf(y_scale, &integer);
+    y_precision = static_cast<boost::uint32_t>(std::fabs(std::floor(std::log10(frac))));
+    frac = std::modf(z_scale, &integer);
+    z_precision = static_cast<boost::uint32_t>(std::fabs(std::floor(std::log10(frac))));
 
-    boost::uint32_t prec = static_cast<boost::uint32_t>(std::fabs(std::floor(std::log10(frac))));
-    os.precision(prec);
+    os << "  Scale Factor X Y Z:          ";
+    os.precision(x_precision);
+    os << tree.get<double>("scale.x") << " "; 
+    os.precision(y_precision);
+    os << tree.get<double>("scale.y") << " "; 
+    os.precision(z_precision);
+    os << tree.get<double>("scale.z") << std::endl;
 
-    os << "  Scale Factor X Y Z:          " 
-     << tree.get<double>("scale.x") << " " 
-     << tree.get<double>("scale.y") << " " 
-     << tree.get<double>("scale.z") << std::endl;
+    os << "  Offset X Y Z:                ";
+    os.precision(x_precision);
+    os << tree.get<double>("offset.x") << " ";
+    os.precision(y_precision);
+    os << tree.get<double>("offset.y") << " ";
+    os.precision(z_precision);
+    os << tree.get<double>("offset.z") << std::endl;
 
-    os << "  Offset X Y Z:                " 
-     << tree.get<double>("offset.x") << " " 
-     << tree.get<double>("offset.y") << " " 
-     << tree.get<double>("offset.z") << std::endl;
+    os << "  Min X Y Z:                   ";
+    os.precision(x_precision);
+    os << tree.get<double>("minimum.x") << " "; 
+    os.precision(y_precision);
+    os << tree.get<double>("minimum.y") << " ";
+    os.precision(z_precision);
+    os << tree.get<double>("minimum.z") << std::endl;
 
-    os << "  Min X Y Z:                   " 
-     << tree.get<double>("minimum.x") << " " 
-     << tree.get<double>("minimum.y") << " " 
-     << tree.get<double>("minimum.z") << std::endl;
-
-    os << "  Max X Y Z:                   " 
-     << tree.get<double>("maximum.x") << " " 
-     << tree.get<double>("maximum.y") << " " 
-     << tree.get<double>("maximum.z") << std::endl;         
+    os << "  Max X Y Z:                   ";
+    os.precision(x_precision);
+    os << tree.get<double>("maximum.x") << " ";
+    os.precision(y_precision);
+    os << tree.get<double>("maximum.y") << " ";
+    os.precision(z_precision);
+    os << tree.get<double>("maximum.z") << std::endl;         
 
     os << "  Spatial Reference:  " << std::endl;
     os << tree.get<std::string>("srs.prettywkt") << std::endl;
diff -r 1113f11e04c3 -r b7880519887b src/utility.cpp
--- a/src/utility.cpp	Thu Oct 28 15:23:28 2010 -0500
+++ b/src/utility.cpp	Fri Oct 29 09:12:30 2010 -0500
@@ -289,7 +289,7 @@
         double integer = 0;
         double x_scale = tree.get<double>("summary.header.scale.x");
         double y_scale = tree.get<double>("summary.header.scale.y");
-        double z_scale = tree.get<double>("summary.header.scale.x");
+        double z_scale = tree.get<double>("summary.header.scale.z");
         frac = std::modf(x_scale, &integer);
         x_precision = static_cast<boost::uint32_t>(std::fabs(std::floor(std::log10(frac))));
         frac = std::modf(y_scale, &integer);


More information about the Liblas-commits mailing list