[Liblas-commits] hg: add SetHeaderPadding/GetHeaderPadding methods

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Jun 30 11:52:17 EDT 2011


details:   http://hg.liblas.orghg/rev/0815afd9db6d
changeset: 3047:0815afd9db6d
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Jun 30 10:47:41 2011 -0500
description:
add SetHeaderPadding/GetHeaderPadding methods
Subject: hg: clean up header when we fetch the new one from the reader/writer

details:   http://hg.liblas.orghg/rev/23daabcc412d
changeset: 3048:23daabcc412d
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Jun 30 10:48:19 2011 -0500
description:
clean up header when we fetch the new one from the reader/writer
Subject: hg: more rigorous header padding preservation testing

details:   http://hg.liblas.orghg/rev/c517b75ce6ae
changeset: 3049:c517b75ce6ae
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Jun 30 10:48:54 2011 -0500
description:
more rigorous header padding preservation testing
Subject: hg: header xml changed for padding

details:   http://hg.liblas.orghg/rev/2dcd55a0960e
changeset: 3050:2dcd55a0960e
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Jun 30 10:49:15 2011 -0500
description:
header xml changed for padding
Subject: hg: clear up 1.0 padding and generic padding

details:   http://hg.liblas.orghg/rev/b3ed606f7878
changeset: 3051:b3ed606f7878
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Jun 30 10:51:34 2011 -0500
description:
clear up 1.0 padding and generic padding
Subject: hg: clean up header padding situation

details:   http://hg.liblas.orghg/rev/09be5ab6978a
changeset: 3052:09be5ab6978a
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Jun 30 10:51:51 2011 -0500
description:
clean up header padding situation
Subject: hg: update for new WKT

details:   http://hg.liblas.orghg/rev/cdf8bcc2bef2
changeset: 3053:cdf8bcc2bef2
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Jun 30 10:52:05 2011 -0500
description:
update for new WKT

diffstat:

 include/liblas/capi/liblas.h |  14 ++++++++
 include/liblas/header.hpp    |  12 +++++++
 python/liblas/core.py        |   8 +++++
 python/liblas/file.py        |   4 +-
 python/liblas/header.py      |  15 +++++++++
 python/tests/File.txt        |  26 +++++++++++++---
 python/tests/Header.txt      |   2 +-
 python/tests/SRS-GDAL.txt    |   6 +-
 src/c_api.cpp                |  20 ++++++++++++
 src/detail/reader/header.cpp |  19 +----------
 src/detail/writer/header.cpp |  70 ++++++++++++++++++++-----------------------
 src/header.cpp               |  43 ++++++++++++++++++--------
 12 files changed, 161 insertions(+), 78 deletions(-)

diffs (truncated from 507 to 300 lines):

diff -r 6ffd597a8ef7 -r cdf8bcc2bef2 include/liblas/capi/liblas.h
--- a/include/liblas/capi/liblas.h	Wed Jun 29 15:13:06 2011 -0500
+++ b/include/liblas/capi/liblas.h	Thu Jun 30 10:52:05 2011 -0500
@@ -712,6 +712,20 @@
 */
  LAS_DLL LASError LASHeader_SetDataOffset(const LASHeaderH hHeader, unsigned int value);
 
+/** Returns the number of bytes between the end of the VLRs on the header to the data offset
+ *  @param hHeader LASHeaderH instance
+ *  @return the number of bytes between the end of the VLRs on the header to the data offset
+*/
+LAS_DLL unsigned int LASHeader_GetHeaderPadding(const LASHeaderH hHeader);
+
+/** Sets the number of bytes between the end of the VLRs on the header to the data offset
+ *  @param hHeader LASHeaderH instance
+ *  @param value the long integer to set for the number of bytes between the end of the VLRs and the data offset
+ *  @return LASError enum
+*/
+ LAS_DLL LASError LASHeader_SetHeaderPadding(const LASHeaderH hHeader, unsigned int value);
+
+
 /** Returns the number of variable length records in the header
  *  @param hHeader LASHeaderH instance
  *  @return the number of variable length records in the header
diff -r 6ffd597a8ef7 -r cdf8bcc2bef2 include/liblas/header.hpp
--- a/include/liblas/header.hpp	Wed Jun 29 15:13:06 2011 -0500
+++ b/include/liblas/header.hpp	Thu Jun 30 10:52:05 2011 -0500
@@ -223,6 +223,15 @@
     /// for the LAS 1.0 format and 227 bytes for the LAS 1.1 format.
     void SetDataOffset(boost::uint32_t v);
 
+    /// Get number of bytes from the end of the VLRs to the GetDataOffset.
+    boost::uint32_t GetHeaderPadding() const;
+
+    /// Set the number of bytes from the end of the VLRs in the header to the 
+    /// beginning of point data.
+    /// \exception std::out_of_range - if given offset is bigger than 227+2 bytes
+    /// for the LAS 1.0 format and 227 bytes for the LAS 1.1 format.
+    void SetHeaderPadding(boost::uint32_t v);
+
     /// Get number of variable-length records.
     boost::uint32_t GetRecordsCount() const;
 
@@ -356,6 +365,8 @@
 
     /// Sets whether or not the points are compressed.
     void SetCompressed(bool b);
+    
+    boost::uint32_t GetVLRBlockSize() const;
 
     void to_rst(std::ostream& os) const;
     void to_xml(std::ostream& os) const;
@@ -414,6 +425,7 @@
     SpatialReference m_srs;
     Schema m_schema;
     bool m_isCompressed;
+    boost::uint32_t m_headerPadding;
 };
 
 LAS_DLL std::ostream& operator<<(std::ostream& os, liblas::Header const&);
diff -r 6ffd597a8ef7 -r cdf8bcc2bef2 python/liblas/core.py
--- a/python/liblas/core.py	Wed Jun 29 15:13:06 2011 -0500
+++ b/python/liblas/core.py	Thu Jun 30 10:52:05 2011 -0500
@@ -450,6 +450,14 @@
 las.LASHeader_SetDataOffset.argtypes = [ctypes.c_void_p, ctypes.c_int]
 las.LASHeader_SetDataOffset.errcheck = check_return
 
+las.LASHeader_GetHeaderPadding.restype = ctypes.c_ulong
+las.LASHeader_GetHeaderPadding.argtypes = [ctypes.c_void_p]
+las.LASHeader_GetHeaderPadding.errcheck = check_value
+
+las.LASHeader_SetHeaderPadding.restype = ctypes.c_int
+las.LASHeader_SetHeaderPadding.argtypes = [ctypes.c_void_p, ctypes.c_int]
+las.LASHeader_SetHeaderPadding.errcheck = check_return
+
 las.LASHeader_GetRecordsCount.restype = ctypes.c_ulong
 las.LASHeader_GetRecordsCount.argtypes = [ctypes.c_void_p]
 las.LASHeader_GetRecordsCount.errcheck = check_value
diff -r 6ffd597a8ef7 -r cdf8bcc2bef2 python/liblas/file.py
--- a/python/liblas/file.py	Wed Jun 29 15:13:06 2011 -0500
+++ b/python/liblas/file.py	Thu Jun 30 10:52:05 2011 -0500
@@ -142,7 +142,8 @@
                 self.handle = \
                 core.las.LASReader_CreateWithHeader(self.filename,
                                                         self._header)
-
+            core.las.LASHeader_Destroy(self._header)
+            self._header = core.las.LASReader_GetHeader(self.handle)
             self.mode = 0
             try:
                 files['read'][self.filename] += 1
@@ -164,6 +165,7 @@
             self.handle = core.las.LASWriter_Create(self.filename,
                                                     self._header,
                                                     1)
+            core.las.LASHeader_Destroy(self._header)
             self._header = core.las.LASWriter_GetHeader(self.handle)
             self.mode = 1
             files['write'].append(self.filename)
diff -r 6ffd597a8ef7 -r cdf8bcc2bef2 python/liblas/header.py
--- a/python/liblas/header.py	Wed Jun 29 15:13:06 2011 -0500
+++ b/python/liblas/header.py	Thu Jun 30 10:52:05 2011 -0500
@@ -388,6 +388,21 @@
     """
     data_offset = property(get_dataoffset, set_dataoffset, None, doc)
 
+    def get_padding(self):
+        """Returns number of bytes between the end of the VLRs and the 
+           beginning of the point data."""
+        return core.las.LASHeader_GetHeaderPadding(self.handle)
+
+    def set_padding(self, value):
+        """Sets the header's padding.
+
+        """
+        return core.las.LASHeader_SetHeaderPadding(self.handle, value)
+    doc = """The number of bytes between the end of the VLRs and the 
+    beginning of the point data.
+    """
+    padding = property(get_padding, set_padding, None, doc)
+
     def get_recordscount(self):
         return core.las.LASHeader_GetRecordsCount(self.handle)
     doc = """Returns the number of user-defined header records in the header.
diff -r 6ffd597a8ef7 -r cdf8bcc2bef2 python/tests/File.txt
--- a/python/tests/File.txt	Wed Jun 29 15:13:06 2011 -0500
+++ b/python/tests/File.txt	Thu Jun 30 10:52:05 2011 -0500
@@ -13,6 +13,8 @@
   8L
   
   >>> h = f.header
+  >>> h.data_offset
+  229L
   >>> p = f.read(0)
   >>> p.x, p.y, p.z
   (630262.30000000005, 4834500.0, 51.530000000000001)
@@ -58,6 +60,8 @@
 Test Reading different locations and proper internal overwriting of the file
 
   >>> f2 = file.File('../test/data/TO_core_last_clip.las')
+  >>> f2.header.data_offset
+  229L  
   >>> p2 = f2.read(6)
   >>> p2.x, p2.y, p2.z
   (630320.95999999996, 4834500.0, 55.009999999999998)
@@ -129,6 +133,8 @@
   >>> del f
   
   >>> f = file.File('junk.las', mode="w", header=h)
+  >>> f.header.data_offset
+  229L    
   >>> sum(h.offset)
   0.0
   >>> h.min
@@ -152,6 +158,8 @@
 
   >>> f2 = file.File('junk.las')
   >>> h = f2.header
+  >>> h.data_offset
+  229L    
   >>> f2.close()
   
   >>> f = file.File('junk.las', mode='w+', header=h)
@@ -172,19 +180,27 @@
   >>> buffered_header = f.header
   >>> del f 
 
-  >>> buffered_header.data_offset = 1024
+  >>> buffered_header.padding = 1024 - buffered_header.data_offset
+  >>> buffered_header.padding
+  795L
+
+  >>> buffered_header.data_offset
+  229L
+
   >>> f3 = file.File('junk2.las',mode='w',header=buffered_header)
 
-  >>> f3.header.data_offset
-  1024L
-
   >>> for i in points:
   ...    f3.write(i)
     
   >>> f3.close()
 
   >>> del f3
- 
+
+  >>> f4 = file.File('junk2.las')
+
+  >>> f4.header.data_offset
+  1024L
+  >>> del f4
 
   
   >>> f = file.File('junk2.las')
diff -r 6ffd597a8ef7 -r cdf8bcc2bef2 python/tests/Header.txt
--- a/python/tests/Header.txt	Wed Jun 29 15:13:06 2011 -0500
+++ b/python/tests/Header.txt	Thu Jun 30 10:52:05 2011 -0500
@@ -120,4 +120,4 @@
   20
   
   >>> h.xml
-  '<?xml version="1.0" encoding="utf-8"?>\n<filesignature>LASF</filesignature><projectdid>00000000-0000-0000-0000-000000000000</projectdid><systemid>Python</systemid><softwareid>hobuhobuhobuhobuhobuhobuhobuhob</softwareid><version>1.2</version><filesourceid>0</filesourceid><reserved>0</reserved><srs><proj4/><prettywkt/><wkt/><compoundwkt/><prettycompoundwkt/><gtiff>Geotiff_Information:\n   Version: 1\n   Key_Revision: 1.0\n   Tagged_Information:\n      End_Of_Tags.\n   Keyed_Information:\n      End_Of_Keys.\n   End_Of_Geotiff.\n</gtiff></srs><date>78/2008</date><size>227</size><dataoffset>742</dataoffset><count>42</count><dataformatid>0</dataformatid><datarecordlength>20</datarecordlength><compressed>false</compressed><returns><return><id>0</id><count>1341235</count></return><return><id>1</id><count>3412341222</count></return><return><id>2</id><count>0</count></return><return><id>3</id><count>0</count></return><return><id>4</id><count>4321</count></return></returns><scale><x
 >0.5</x><y>0.5</y><z>0.001</z></scale><offset><x>32</x><y>32</y><z>256</z></offset><minimum><x>33452344.2333</x><y>523442.344</y><z>-90.99299999999999</z></minimum><maximum><x>33452344.2333</x><y>523442.344</y><z>-90.99299999999999</z></maximum><schema><LASSchema><dimensions><dimension><name>X</name><description>x coordinate as a long integer.  You must use the scale and offset information of the header to determine the double value.</description><position>0</position><active>1</active><size>32</size><integer>1</integer><signed>1</signed><required>1</required><byteoffset>0</byteoffset><bitoffset>0</bitoffset><bytesize>4</bytesize></dimension><dimension><name>Y</name><description>y coordinate as a long integer.  You must use the scale and offset information of the header to determine the double value.</description><position>1</position><active>1</active><size>32</size><integer>1</integer><signed>1</signed><required>1</required><byteoffset>4</byteoffset><bitoffset>0</bitoffset
 ><bytesize>4</bytesize></dimension><dimension><name>Z</name><description>z coordinate as a long integer.  You must use the scale and offset information of the header to determine the double value.</description><position>2</position><active>1</active><size>32</size><integer>1</integer><signed>1</signed><required>1</required><byteoffset>8</byteoffset><bitoffset>0</bitoffset><bytesize>4</bytesize></dimension><dimension><name>Intensity</name><description>The intensity value is the integer representation of the pulse return magnitude. This value is optional and system specific. However, it should always be included if available.</description><position>3</position><active>1</active><size>16</size><integer>1</integer><signed>0</signed><required>1</required><byteoffset>12</byteoffset><bitoffset>0</bitoffset><bytesize>2</bytesize></dimension><dimension><name>Return Number</name><description>Return Number: The Return Number is the pulse return number for a given output pulse. A given 
 output laser pulse can have many returns, and they must be marked in sequence of return. The first return will have a Return Number of one, the second a Return Number of two, and so on up to five returns.</description><position>4</position><active>1</active><size>3</size><integer>1</integer><signed>0</signed><required>1</required><byteoffset>14</byteoffset><bitoffset>3</bitoffset><bytesize>1</bytesize></dimension><dimension><name>Number of Returns</name><description>Number of Returns (for this emitted pulse): The Number of Returns is the total number of returns for a given pulse. For example, a laser data point may be return two (Return Number) within a total number of five returns.</description><position>5</position><active>1</active><size>3</size><integer>1</integer><signed>0</signed><required>1</required><byteoffset>14</byteoffset><bitoffset>6</bitoffset><bytesize>1</bytesize></dimension><dimension><name>Scan Direction</name><description>The Scan Direction Flag denotes th
 e direction at which the scanner mirror was traveling at the time of the output pulse. A bit value of 1 is a positive scan direction, and a bit value of 0 is a negative scan direction (where positive scan direction is a scan moving from the left side of the in-track direction to the right side and negative the opposite). </description><position>6</position><active>1</active><size>1</size><integer>1</integer><signed>0</signed><required>1</required><byteoffset>14</byteoffset><bitoffset>7</bitoffset><bytesize>1</bytesize></dimension><dimension><name>Flightline Edge</name><description>The Edge of Flight Line data bit has a value of 1 only when the point is at the end of a scan. It is the last point on a given scan line before it changes direction.</description><position>7</position><active>1</active><size>1</size><integer>1</integer><signed>0</signed><required>1</required><byteoffset>14</byteoffset><bitoffset>8</bitoffset><bytesize>1</bytesize></dimension><dimension><name>Classi
 fication</name><description>Classification in LAS 1.0 was essentially user defined and optional. LAS 1.1 defines a standard set of ASPRS classifications. In addition, the field is now mandatory. If a point has never been classified, this byte must be set to zero. There are no user defined classes since both point format 0 and point format 1 supply 8 bits per point for user defined operations. Note that the format for classification is a bit encoded field with the lower five bits used for class and the three high bits used for flags.</description><position>8</position><active>1</active><size>8</size><integer>0</integer><signed>0</signed><required>1</required><byteoffset>15</byteoffset><bitoffset>0</bitoffset><bytesize>1</bytesize></dimension><dimension><name>Scan Angle Rank</name><description>The Scan Angle Rank is a signed one-byte number with a valid range from -90 to +90. The Scan Angle Rank is the angle (rounded to the nearest integer in the absolute value sense) at which
  the laser point was output from the laser system including the roll of the aircraft. The scan angle is within 1 degree of accuracy from +90 to -90 degrees. The scan angle is an angle based on 0 degrees being nadir, and -90 degrees to the left side of the aircraft in the direction of flight.</description><position>9</position><active>1</active><size>8</size><integer>1</integer><signed>1</signed><required>1</required><byteoffset>16</byteoffset><bitoffset>0</bitoffset><bytesize>1</bytesize></dimension><dimension><name>User Data</name><description>This field may be used at the user&apos;s discretion</description><position>10</position><active>1</active><size>8</size><integer>0</integer><signed>0</signed><required>1</required><byteoffset>17</byteoffset><bitoffset>0</bitoffset><bytesize>1</bytesize></dimension><dimension><name>Point Source ID</name><description>This value indicates the file from which this point originated. Valid values for this field are 1 to 65,535 inclusive wi
 th zero being used for a special case discussed below. The numerical value corresponds to the File Source ID from which this point originated. Zero is reserved as a convenience to system implementers. A Point Source ID of zero implies that this point originated in this file. This implies that processing software should set the Point Source ID equal to the File Source ID of the file containing this point at some time during processing. </description><position>11</position><active>1</active><size>16</size><integer>1</integer><signed>0</signed><required>1</required><byteoffset>18</byteoffset><bitoffset>0</bitoffset><bytesize>2</bytesize></dimension></dimensions><version>1.0</version><liblas>1.7.0</liblas><formatid>0</formatid></LASSchema></schema>'
\ No newline at end of file
+  '<?xml version="1.0" encoding="utf-8"?>\n<filesignature>LASF</filesignature><projectdid>00000000-0000-0000-0000-000000000000</projectdid><systemid>Python</systemid><softwareid>hobuhobuhobuhobuhobuhobuhobuhob</softwareid><version>1.2</version><filesourceid>0</filesourceid><reserved>0</reserved><srs><proj4/><prettywkt/><wkt/><compoundwkt/><prettycompoundwkt/><gtiff>Geotiff_Information:\n   Version: 1\n   Key_Revision: 1.0\n   Tagged_Information:\n      End_Of_Tags.\n   Keyed_Information:\n      End_Of_Keys.\n   End_Of_Geotiff.\n</gtiff></srs><date>78/2008</date><size>227</size><dataoffset>742</dataoffset><header_padding>0</header_padding><count>42</count><dataformatid>0</dataformatid><datarecordlength>20</datarecordlength><compressed>false</compressed><compression_info>LASzip Version 2.0r0 c2 50000: POINT10 2</compression_info><returns><return><id>0</id><count>1341235</count></return><return><id>1</id><count>3412341222</count></return><return><id>2</id><count>0</count></retu
 rn><return><id>3</id><count>0</count></return><return><id>4</id><count>4321</count></return></returns><scale><x>0.5</x><y>0.5</y><z>0.001</z></scale><offset><x>32</x><y>32</y><z>256</z></offset><minimum><x>33452344.2333</x><y>523442.344</y><z>-90.99299999999999</z></minimum><maximum><x>33452344.2333</x><y>523442.344</y><z>-90.99299999999999</z></maximum><schema><LASSchema><dimensions><dimension><name>X</name><description>x coordinate as a long integer.  You must use the scale and offset information of the header to determine the double value.</description><position>0</position><active>1</active><size>32</size><integer>1</integer><signed>1</signed><required>1</required><byteoffset>0</byteoffset><bitoffset>0</bitoffset><bytesize>4</bytesize></dimension><dimension><name>Y</name><description>y coordinate as a long integer.  You must use the scale and offset information of the header to determine the double value.</description><position>1</position><active>1</active><size>32</siz
 e><integer>1</integer><signed>1</signed><required>1</required><byteoffset>4</byteoffset><bitoffset>0</bitoffset><bytesize>4</bytesize></dimension><dimension><name>Z</name><description>z coordinate as a long integer.  You must use the scale and offset information of the header to determine the double value.</description><position>2</position><active>1</active><size>32</size><integer>1</integer><signed>1</signed><required>1</required><byteoffset>8</byteoffset><bitoffset>0</bitoffset><bytesize>4</bytesize></dimension><dimension><name>Intensity</name><description>The intensity value is the integer representation of the pulse return magnitude. This value is optional and system specific. However, it should always be included if available.</description><position>3</position><active>1</active><size>16</size><integer>1</integer><signed>0</signed><required>1</required><byteoffset>12</byteoffset><bitoffset>0</bitoffset><bytesize>2</bytesize></dimension><dimension><name>Return Number</n
 ame><description>Return Number: The Return Number is the pulse return number for a given output pulse. A given output laser pulse can have many returns, and they must be marked in sequence of return. The first return will have a Return Number of one, the second a Return Number of two, and so on up to five returns.</description><position>4</position><active>1</active><size>3</size><integer>1</integer><signed>0</signed><required>1</required><byteoffset>14</byteoffset><bitoffset>3</bitoffset><bytesize>1</bytesize></dimension><dimension><name>Number of Returns</name><description>Number of Returns (for this emitted pulse): The Number of Returns is the total number of returns for a given pulse. For example, a laser data point may be return two (Return Number) within a total number of five returns.</description><position>5</position><active>1</active><size>3</size><integer>1</integer><signed>0</signed><required>1</required><byteoffset>14</byteoffset><bitoffset>6</bitoffset><bytesiz
 e>1</bytesize></dimension><dimension><name>Scan Direction</name><description>The Scan Direction Flag denotes the direction at which the scanner mirror was traveling at the time of the output pulse. A bit value of 1 is a positive scan direction, and a bit value of 0 is a negative scan direction (where positive scan direction is a scan moving from the left side of the in-track direction to the right side and negative the opposite). </description><position>6</position><active>1</active><size>1</size><integer>1</integer><signed>0</signed><required>1</required><byteoffset>14</byteoffset><bitoffset>7</bitoffset><bytesize>1</bytesize></dimension><dimension><name>Flightline Edge</name><description>The Edge of Flight Line data bit has a value of 1 only when the point is at the end of a scan. It is the last point on a given scan line before it changes direction.</description><position>7</position><active>1</active><size>1</size><integer>1</integer><signed>0</signed><required>1</requir
 ed><byteoffset>14</byteoffset><bitoffset>8</bitoffset><bytesize>1</bytesize></dimension><dimension><name>Classification</name><description>Classification in LAS 1.0 was essentially user defined and optional. LAS 1.1 defines a standard set of ASPRS classifications. In addition, the field is now mandatory. If a point has never been classified, this byte must be set to zero. There are no user defined classes since both point format 0 and point format 1 supply 8 bits per point for user defined operations. Note that the format for classification is a bit encoded field with the lower five bits used for class and the three high bits used for flags.</description><position>8</position><active>1</active><size>8</size><integer>0</integer><signed>0</signed><required>1</required><byteoffset>15</byteoffset><bitoffset>0</bitoffset><bytesize>1</bytesize></dimension><dimension><name>Scan Angle Rank</name><description>The Scan Angle Rank is a signed one-byte number with a valid range from -90
  to +90. The Scan Angle Rank is the angle (rounded to the nearest integer in the absolute value sense) at which the laser point was output from the laser system including the roll of the aircraft. The scan angle is within 1 degree of accuracy from +90 to -90 degrees. The scan angle is an angle based on 0 degrees being nadir, and -90 degrees to the left side of the aircraft in the direction of flight.</description><position>9</position><active>1</active><size>8</size><integer>1</integer><signed>1</signed><required>1</required><byteoffset>16</byteoffset><bitoffset>0</bitoffset><bytesize>1</bytesize></dimension><dimension><name>User Data</name><description>This field may be used at the user&apos;s discretion</description><position>10</position><active>1</active><size>8</size><integer>0</integer><signed>0</signed><required>1</required><byteoffset>17</byteoffset><bitoffset>0</bitoffset><bytesize>1</bytesize></dimension><dimension><name>Point Source ID</name><description>This valu
 e indicates the file from which this point originated. Valid values for this field are 1 to 65,535 inclusive with zero being used for a special case discussed below. The numerical value corresponds to the File Source ID from which this point originated. Zero is reserved as a convenience to system implementers. A Point Source ID of zero implies that this point originated in this file. This implies that processing software should set the Point Source ID equal to the File Source ID of the file containing this point at some time during processing. </description><position>11</position><active>1</active><size>16</size><integer>1</integer><signed>0</signed><required>1</required><byteoffset>18</byteoffset><bitoffset>0</bitoffset><bytesize>2</bytesize></dimension></dimensions><version>1.0</version><liblas>1.7.0b1</liblas><formatid>0</formatid></LASSchema></schema>'
\ No newline at end of file
diff -r 6ffd597a8ef7 -r cdf8bcc2bef2 python/tests/SRS-GDAL.txt
--- a/python/tests/SRS-GDAL.txt	Wed Jun 29 15:13:06 2011 -0500
+++ b/python/tests/SRS-GDAL.txt	Thu Jun 30 10:52:05 2011 -0500
@@ -112,7 +112,7 @@
   >>> del f_project
   >>> f3 = file.File('junk_srs_project.las')
   >>> f3.header.data_offset
-  789L
+  1140L
 
   >>> s_utm = srs.SRS()
   >>> s_utm.wkt = utm_wkt
@@ -129,7 +129,7 @@
 
   >>> f = file.File('../test/data/srs_vertcs.las',mode='r')
   >>> s = f.header.srs
-  >>> s.get_wkt_compoundok() == """COMPD_CS["unknown",PROJCS["WGS 84 / UTM zone 17N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-81],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32617"]],VERT_CS["NAVD88 height",VERT_DATUM["North American Vertical Datum 1988",2005,AUTHORITY["EPSG","5103"],EXTENSION["PROJ4_GRIDS","g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Up",UP],AUTHORITY["EPSG","5703"]]]"""
+  >>> s.get_wkt_compoundok() == """COMPD_CS["unknown",PROJCS["WGS 84 / UTM zone 17N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-81],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32617"]],VERT_CS["NAVD88 height",VERT_DATUM["North American Vertical Datum 1988",2005,AUTHORITY["EPSG","5103"],EXTENSION["PROJ4_GRIDS","g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx"]],AXIS["Up",UP],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","5703"]]]"""
   True
 
   >>> s2 = srs.SRS()
@@ -137,4 +137,4 @@
   >>> s2.set_verticalcs( 5703, 'abc', 5103, 9001 )
   True
   >>> s2.get_wkt_compoundok()
-  'COMPD_CS["unknown",PROJCS["WGS 84 / UTM zone 17N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-81],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32617"]],VERT_CS["NAVD88 height",VERT_DATUM["North American Vertical Datum 1988",2005,AUTHORITY["EPSG","5103"],EXTENSION["PROJ4_GRIDS","g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Up",UP],AUTHORITY["EPSG","5703"]]]'
+  'COMPD_CS["unknown",PROJCS["WGS 84 / UTM zone 17N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-81],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32617"]],VERT_CS["NAVD88 height",VERT_DATUM["North American Vertical Datum 1988",2005,AUTHORITY["EPSG","5103"],EXTENSION["PROJ4_GRIDS","g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx"]],AXIS["Up",UP],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","5703"]]]'
diff -r 6ffd597a8ef7 -r cdf8bcc2bef2 src/c_api.cpp
--- a/src/c_api.cpp	Wed Jun 29 15:13:06 2011 -0500
+++ b/src/c_api.cpp	Thu Jun 30 10:52:05 2011 -0500
@@ -1268,6 +1268,26 @@
     return LE_None;    
 }
 
+LAS_DLL boost::uint32_t LASHeader_GetHeaderPadding(const LASHeaderH hHeader) {
+    VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetHeaderPadding", 0);
+
+    unsigned long value = ((liblas::HeaderPtr*) hHeader)->get()->GetHeaderPadding();
+    return value;
+}
+
+LAS_DLL LASErrorEnum LASHeader_SetHeaderPadding(const LASHeaderH hHeader, boost::uint32_t value) {
+    VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetHeaderPadding", LE_Failure);
+
+    try {
+        ((liblas::HeaderPtr*) hHeader)->get()->SetHeaderPadding(value);    
+    } catch (std::exception const& e)
+    {
+        LASError_PushError(LE_Failure, e.what(), "LASHeader_SetHeaderPadding");
+        return LE_Failure;
+    }
+ 
+    return LE_None;    
+}
 
 LAS_DLL boost::uint32_t LASHeader_GetRecordsCount(const LASHeaderH hHeader) {
     VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetRecordsCount", 0);
diff -r 6ffd597a8ef7 -r cdf8bcc2bef2 src/detail/reader/header.cpp
--- a/src/detail/reader/header.cpp	Wed Jun 29 15:13:06 2011 -0500
+++ b/src/detail/reader/header.cpp	Thu Jun 30 10:52:05 2011 -0500
@@ -265,28 +265,13 @@
 
     m_header->SetMax(x1, y1, z1);
     m_header->SetMin(x2, y2, z2);
-    
-    
 
-    // We're going to check the two bytes off the end of the header to 
-    // see if they're pad bytes anyway.  Some softwares, notably older QTModeler, 
-    // write 1.0-style pad bytes off the end of their header but state that the
-    // offset is actually 2 bytes back.  We need to set the dataoffset 
-    // appropriately in those cases anyway. 
-    m_ifs.seekg(m_header->GetDataOffset());
-    
-
-    if (HasLAS10PadSignature()) {
-        std::streamsize const current_pos = m_ifs.tellg();
-        m_ifs.seekg(current_pos + 2);
-        m_header->SetDataOffset(m_header->GetDataOffset() + 2);
-    }
-     
     // only go read VLRs if we have them.
     if (m_header->GetRecordsCount() > 0)
         ReadVLRs();
 
-
+    boost::uint32_t pad = m_header->GetDataOffset() - (m_header->GetHeaderSize() + m_header->GetVLRBlockSize());
+    m_header->SetHeaderPadding(pad);
 
     // If we're eof, we need to reset the state
     if (m_ifs.eof())
diff -r 6ffd597a8ef7 -r cdf8bcc2bef2 src/detail/writer/header.cpp
--- a/src/detail/writer/header.cpp	Wed Jun 29 15:13:06 2011 -0500


More information about the Liblas-commits mailing list