[Liblas-commits] hg: fix #181,
round instead of truncate integers when scaling
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Jun 17 21:57:49 EDT 2010
changeset 14da39665f17 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=14da39665f17
summary: fix #181, round instead of truncate integers when scaling
diffstat:
python/tests/File.txt | 26 +++++++++++++-------------
src/detail/writer/point.cpp | 19 +++++++++++--------
2 files changed, 24 insertions(+), 21 deletions(-)
diffs (84 lines):
diff -r 0fa044ad02f9 -r 14da39665f17 python/tests/File.txt
--- a/python/tests/File.txt Thu Jun 17 20:47:50 2010 -0500
+++ b/python/tests/File.txt Thu Jun 17 20:57:42 2010 -0500
@@ -184,13 +184,13 @@
>>> for g in points:
... print round(g.x, 6)
- 630262.3
+ 630262.3
630282.45
- 630300.07
- 630346.82
- 630327.58
+ 630300.08
+ 630346.83
+ 630327.59
630323.57
- 630320.95
+ 630320.96
630280.89
Now try writing a 1.2 version of the junk2.las file above to ensure that
@@ -231,11 +231,11 @@
... print round(g.x, 6)
630262.3
630282.45
- 630300.07
- 630346.82
- 630327.57
+ 630300.08
+ 630346.83
+ 630327.59
630323.57
- 630320.95
+ 630320.96
630280.89
@@ -280,11 +280,11 @@
... print round(g.x, 6)
630262.3
630282.45
- 630300.07
- 630346.82
- 630327.57
+ 630300.08
+ 630346.83
+ 630327.59
630323.57
- 630320.95
+ 630320.96
630280.89
diff -r 0fa044ad02f9 -r 14da39665f17 src/detail/writer/point.cpp
--- a/src/detail/writer/point.cpp Thu Jun 17 20:47:50 2010 -0500
+++ b/src/detail/writer/point.cpp Thu Jun 17 20:57:42 2010 -0500
@@ -222,15 +222,18 @@
if (m_transform) {
project();
- m_record.x = static_cast<int32_t>((p.GetX() - m_header.GetOffsetX()) / m_header.GetScaleX());
- m_record.y = static_cast<int32_t>((p.GetY() - m_header.GetOffsetY()) / m_header.GetScaleY());
- m_record.z = static_cast<int32_t>((p.GetZ() - m_header.GetOffsetZ()) / m_header.GetScaleZ());
- } else {
- m_record.x = static_cast<int32_t>((p.GetX() - m_header.GetOffsetX()) / m_header.GetScaleX());
- m_record.y = static_cast<int32_t>((p.GetY() - m_header.GetOffsetY()) / m_header.GetScaleY());
- m_record.z = static_cast<int32_t>((p.GetZ() - m_header.GetOffsetZ()) / m_header.GetScaleZ());
- }
+ // m_record.y = static_cast<int32_t>((p.GetY() - m_header.GetOffsetY()) / m_header.GetScaleY());
+ // m_record.z = static_cast<int32_t>((p.GetZ() - m_header.GetOffsetZ()) / m_header.GetScaleZ());
+ } // else {
+ // m_record.x = static_cast<int32_t>((p.GetX() - m_header.GetOffsetX()) / m_header.GetScaleX());
+ // m_record.y = static_cast<int32_t>((p.GetY() - m_header.GetOffsetY()) / m_header.GetScaleY());
+ // m_record.z = static_cast<int32_t>((p.GetZ() - m_header.GetOffsetZ()) / m_header.GetScaleZ());
+ // }
+ m_record.x = static_cast<int32_t>(round(((p.GetX() - m_header.GetOffsetX()) / m_header.GetScaleX())));
+ m_record.y = static_cast<int32_t>(round(((p.GetY() - m_header.GetOffsetY()) / m_header.GetScaleY())));
+ m_record.z = static_cast<int32_t>(round(((p.GetZ() - m_header.GetOffsetZ()) / m_header.GetScaleZ())));
+
Classification::bitset_type clsflags(p.GetClassification());
m_record.classification = static_cast<uint8_t>(clsflags.to_ulong());
More information about the Liblas-commits
mailing list