[Liblas-commits] r1035 - in trunk: python/liblas src
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Feb 17 02:02:29 EST 2009
Author: hobu
Date: Tue Feb 17 02:02:29 2009
New Revision: 1035
URL: http://liblas.org/changeset/1035
Log:
default to using 1.2 for LASHeader and fix SetVersionMinor interaction with the data offset that likely prevented us from ever correctly writing 1.0 data
Modified:
trunk/python/liblas/color.py
trunk/python/liblas/header.py
trunk/src/lasheader.cpp
Modified: trunk/python/liblas/color.py
==============================================================================
--- trunk/python/liblas/color.py (original)
+++ trunk/python/liblas/color.py Tue Feb 17 02:02:29 2009
@@ -44,7 +44,7 @@
import ctypes
class Color(object):
- def __init__(self, owned=True, handle=None):
+ def __init__(self, red=0, green=0, blue=0, owned=True, handle=None):
if handle:
self.handle = handle
else:
Modified: trunk/python/liblas/header.py
==============================================================================
--- trunk/python/liblas/header.py (original)
+++ trunk/python/liblas/header.py Tue Feb 17 02:02:29 2009
@@ -97,7 +97,7 @@
major_version = property(get_majorversion, set_majorversion)
def get_minorversion(self):
- """Returns the minor version of the file. Expect this value to always be 0 or 1"""
+ """Returns the minor version of the file. Expect this value to always be 0, 1, or 2"""
return core.las.LASHeader_GetVersionMinor(self.handle)
def set_minorversion(self, value):
"""Sets the minor version of the file. The value should be 0 for 1.0 LAS files and 1 for 1.1 LAS files"""
@@ -195,19 +195,19 @@
records_count = property(get_recordscount)
def get_dataformatid(self):
- """Returns the data format id.
+ """Gets the point format value
A value of 1 means the format is 1.1 compatible and includes a time
value on the points. A value of 0 means the format is 1.0 compatible.
"""
return core.las.LASHeader_GetDataFormatId(self.handle)
def set_dataformatid(self, value):
- """Sets the data format id for the file.
+ """Sets the point format value
- It can only be 1 (for 1.1 compatible) or 0 (for 1.0 compatible).
+ It can only be 1 (for 1.1 compatible) or 0 (for 1.0 compatible).
"""
- if value not in [1,0]:
- raise core.LASException("Format ID must be 1 or 0")
+ if value not in [3, 2,1,0]:
+ raise core.LASException("Format ID must be 3, 2, 1, or 0")
return core.las.LASHeader_SetDataFormatId(self.handle, value)
dataformat_id = property(get_dataformatid, set_dataformatid)
Modified: trunk/src/lasheader.cpp
==============================================================================
--- trunk/src/lasheader.cpp (original)
+++ trunk/src/lasheader.cpp Tue Feb 17 02:02:29 2009
@@ -263,8 +263,19 @@
{
if (v > eVersionMinorMax)
throw std::out_of_range("version minor out of range");
-
+
m_versionMinor = v;
+
+ uint32_t size = 0;
+ uint32_t const dataSignatureSize = 2;
+
+ // Add the signature if we're a 1.0 file
+ if (eVersionMinorMin == m_versionMinor) {
+ size = dataSignatureSize;
+ }
+
+ SetDataOffset(GetHeaderSize()+size);
+
}
std::string LASHeader::GetSystemId(bool pad /*= false*/) const
@@ -359,8 +370,9 @@
uint32_t const dataSignatureSize = 2;
uint16_t const hsize = GetHeaderSize();
- if ((eVersionMinorMin == m_versionMinor && v < hsize + dataSignatureSize)
- || (eVersionMinorMax == m_versionMinor && v < hsize))
+ if ( (m_versionMinor == 0 && v < hsize + dataSignatureSize) ||
+ (m_versionMinor == 1 && v < hsize) ||
+ (m_versionMinor == 2 && v < hsize) )
{
throw std::out_of_range("data offset out of range");
}
@@ -608,10 +620,10 @@
void LASHeader::Init()
{
// Initialize public header block with default
- // values according to LAS 1.1
+ // values according to LAS 1.2
m_versionMajor = 1;
- m_versionMinor = 1;
+ m_versionMinor = 2;
m_dataFormatId = ePointFormat0;
m_dataRecordLen = ePointSize0;
More information about the Liblas-commits
mailing list