[Liblas-commits] hg: more PointFormat fixes
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Apr 8 09:55:58 EDT 2010
changeset 490a89e5e964 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=490a89e5e964
summary: more PointFormat fixes
diffstat:
python/tests/Format.txt | 14 +++++++-------
python/tests/Header.txt | 8 +++++++-
src/lasformat.cpp | 27 ++++++++-------------------
src/lasheader.cpp | 4 +++-
4 files changed, 25 insertions(+), 28 deletions(-)
diffs (140 lines):
diff -r 5d81f6a34091 -r 490a89e5e964 python/tests/Format.txt
--- a/python/tests/Format.txt Thu Apr 08 08:02:16 2010 -0500
+++ b/python/tests/Format.txt Thu Apr 08 08:55:23 2010 -0500
@@ -7,7 +7,7 @@
>>> f = format.Format()
>>> f.size
- 20L
+ 20
>>> f.color
False
>>> f.time
@@ -17,24 +17,24 @@
>>> f.size = 40
>>> f.size
- 40L
+ 40
>>> f.color = True
>>> f.size
- 46L
+ 46
>>> f.size = 14
>>> f.size
- 26L
+ 26
>>> h = f2.header
>>> f = h.format
>>> f.major, f.minor
- (1, 2)
+ (1, 0)
>>> f.size
- 28L
+ 28
>>> f.color
False
@@ -47,7 +47,7 @@
>>> f.size
- 20L
+ 20
>>> f.major
1
diff -r 5d81f6a34091 -r 490a89e5e964 python/tests/Header.txt
--- a/python/tests/Header.txt Thu Apr 08 08:02:16 2010 -0500
+++ b/python/tests/Header.txt Thu Apr 08 08:55:23 2010 -0500
@@ -119,6 +119,12 @@
>>> h.data_record_length
34
+Can't be smaller than the dataformat needs
+
>>> h.data_record_length = 24
>>> h.data_record_length
- 24
+ 34
+
+ >>> h.data_record_length = 40
+ >>> h.data_record_length
+ 40
\ No newline at end of file
diff -r 5d81f6a34091 -r 490a89e5e964 src/lasformat.cpp
--- a/src/lasformat.cpp Thu Apr 08 08:02:16 2010 -0500
+++ b/src/lasformat.cpp Thu Apr 08 08:55:23 2010 -0500
@@ -45,24 +45,16 @@
namespace liblas {
void PointFormat::updatesize(liblas::uint16_t new_size) {
-
-
- long base_difference = new_size - m_size;
- // printf("updatesize() %d\n", base_difference);
- if (base_difference == 0) {
+ // if the difference between the new size we're given
+ // and our existing size is 0, do nothing.
+ if ((new_size - m_size) == 0) {
return;
}
- else if (base_difference > 0) {
- // Expand m_size to include new_base_size
- // printf("we're now here! %d %d %d %d\n", m_size, base_difference, new_size, m_base_size);
-
- m_size = new_size;
- }
- else {
- // printf("we're here! %d %d %d\n", m_size, base_difference, m_base_size);
- m_size = std::max(new_size, m_base_size);
- }
+
+ // Use the larger of either our base size (accounting for
+ // color, time, etc) and the size we were given.
+ m_size = std::max(new_size, m_base_size);
}
@@ -100,13 +92,10 @@
// Expand m_size to include new_base_size
m_size = m_size + base_difference;
m_base_size = new_base_size;
- printf("base difference > 0: %d %d %d %d\n", m_size, base_difference, m_base_size, new_base_size);
}
else {
- printf("base difference < 0: %d %d %d %d\n", m_size, base_difference, m_base_size, new_base_size);
- m_size = m_size + base_difference;
+ m_size = m_size - base_difference;
m_base_size = new_base_size;
- printf("new: %d %d %d %d\n", m_size, base_difference, m_base_size, new_base_size);
}
}
diff -r 5d81f6a34091 -r 490a89e5e964 src/lasheader.cpp
--- a/src/lasheader.cpp Thu Apr 08 08:02:16 2010 -0500
+++ b/src/lasheader.cpp Thu Apr 08 08:55:23 2010 -0500
@@ -390,6 +390,8 @@
{
m_dataFormatId = static_cast<uint8_t>(v);
+ UpdatePointFormat();
+
if (ePointFormat0 == m_dataFormatId)
SetDataRecordLength(ePointSize0);
else if (ePointFormat1 == m_dataFormatId)
@@ -401,7 +403,7 @@
else
SetDataRecordLength(ePointSize3);
- UpdatePointFormat();
+
}
uint16_t Header::GetDataRecordLength() const
More information about the Liblas-commits
mailing list