[Liblas-commits] hg: crlf fix

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Jan 20 13:57:22 EST 2011


details:   http://hg.liblas.orghg/rev/f1f3ee82101e
changeset: 2798:f1f3ee82101e
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Jan 20 10:56:43 2011 -0800
description:
crlf fix
Subject: hg: merge

details:   http://hg.liblas.orghg/rev/e5eba3f4447c
changeset: 2799:e5eba3f4447c
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Jan 20 10:56:56 2011 -0800
description:
merge

diffstat:

 include/liblas/capi/liblas.h |   37 +-
 include/liblas/writer.hpp    |    5 +-
 src/c_api.cpp                |  136 +++++-
 src/detail/reader/header.cpp |  958 +++++++++++++++++++++---------------------
 src/writer.cpp               |    8 +-
 test/unit/writer_test.cpp    |    3 +-
 6 files changed, 654 insertions(+), 493 deletions(-)

diffs (truncated from 1304 to 300 lines):

diff -r 5f9b5354c170 -r e5eba3f4447c include/liblas/capi/liblas.h
--- a/include/liblas/capi/liblas.h	Wed Jan 19 08:44:39 2011 -0800
+++ b/include/liblas/capi/liblas.h	Thu Jan 20 10:56:56 2011 -0800
@@ -194,6 +194,7 @@
 */
 LAS_DLL LASHeaderH LASReader_GetHeader(const LASReaderH hReader);
 
+LAS_DLL void LASReader_SetHeader(  LASReaderH hReader, const LASHeaderH hHeader);
 
 LAS_DLL LASError LASReader_SetSRS(LASReaderH hReader, const LASSRSH hSRS);
 LAS_DLL LASError LASReader_SetInputSRS(LASReaderH hReader, const LASSRSH hSRS);
@@ -502,8 +503,28 @@
 /** Returns a LASHeaderH representing the header for the point
  *  @param hPoint the LASPointH instance
  *  @return a LASHeaderH representing the header for the point
+*/ 
+LAS_DLL LASHeaderH LASPoint_GetHeader(const LASPointH hPoint);
+
+LAS_DLL void LASPoint_SetHeader( LASPointH hPoint, const LASHeaderH hHeader);
+
+/** Gets the data stream for the VLR as an array of bytes.  The length of this 
+ *  array should be the same as LASVLR_GetRecordLength.  You must allocate it on 
+ *  the heap and you are responsible for its destruction.
+ *  @param hPoint the LASPointH instance
+ *  @param data a pointer to your array where you want the data copied
+ *  @return LASErrorEnum
 */
- LAS_DLL LASHeaderH LASPoint_GetHeader(const LASPointH hPoint);
+LAS_DLL LASError LASPoint_GetData(const LASPointH hPoint, unsigned char* data);
+
+/** Sets the data stream for the Point as an array of bytes.  The length of this 
+ *  array should be the same as LASPoint_GetHeader(LASHeader_GetDataRecordLength()).  The data are copied into 
+ *  the Point .
+ *  @param hPoint the LASPointH instance
+ *  @param data a pointer to your array.  It must be LASPoint_GetHeader(LASHeader_GetDataRecordLength()) in size
+ *  @return LASErrorEnum
+*/
+LAS_DLL LASError LASPoint_SetData(LASPointH hPoint, unsigned char* data);
 
 /****************************************************************************/
 /* Header operations                                                        */
@@ -906,7 +927,9 @@
 LAS_DLL LASError LASWriter_WritePoint(const LASWriterH hWriter, const LASPointH hPoint);
 
 /** Overwrites the header for the file represented by the LASWriterH.  It does 
- *  not matter if the file is opened for append or for write.
+ *  not matter if the file is opened for append or for write.  This function is 
+ *  equivalent to calling LASWriter_SetHeader and LASWriter_WriteOwnedHeader
+ *  simultaneously.
  *  @param hWriter opaque pointer to the LASWriterH instance
  *  @param hHeader LASHeaderH instance to write into the file
  *  @return LE_None if no error occurred during the operation.
@@ -914,6 +937,15 @@
 
 LAS_DLL LASError LASWriter_WriteHeader(const LASWriterH hWriter, const LASHeaderH hHeader);
 
+/** Overwrites the header for the file represented by the LASWriterH that was 
+ *  set using LASWriter_SetHeader or flushes the existing header that is on the
+ *  the writer to the file and resets the file for writing.
+ *  @param hWriter opaque pointer to the LASWriterH instance
+ *  @return LE_None if no error occurred during the operation.
+*/
+
+LAS_DLL LASError LASWriter_WriteOwnedHeader(const LASWriterH hWriter);
+
 /** Destroys the LASWriterH instance, effectively closing the file and performing 
  *  housekeeping operations.
  *  @param hWriter LASWriterH instance to close
@@ -927,6 +959,7 @@
  *  in the event of a NULL return.
 */
 LAS_DLL LASHeaderH LASWriter_GetHeader(const LASWriterH hWriter);
+LAS_DLL void LASWriter_SetHeader(  LASWriterH hWriter, const LASHeaderH hHeader) ;
 
 LAS_DLL LASError LASWriter_SetSRS(LASWriterH hWriter, const LASSRSH hSRS);
 LAS_DLL LASError LASWriter_SetInputSRS(LASWriterH hWriter, const LASSRSH hSRS);
diff -r 5f9b5354c170 -r e5eba3f4447c include/liblas/writer.hpp
--- a/include/liblas/writer.hpp	Wed Jan 19 08:44:39 2011 -0800
+++ b/include/liblas/writer.hpp	Thu Jan 20 10:56:56 2011 -0800
@@ -82,13 +82,16 @@
     
     /// Provides access to header structure.
     Header const& GetHeader() const;
+    
+    void SetHeader(Header const& header);
+    
 
     /// \todo TODO: Move point record composition deep into writer implementation.
     /// \todo TODO: How to handle point_source_id in portable way, for LAS 1.0 and 1.1
     bool WritePoint(Point const& point);
 
     /// Allow in-place writing of header
-    void WriteHeader(Header& header);
+    void WriteHeader();
 
     /// Sets filters that are used to determine wither or not to 
     /// keep a point that before we write it
diff -r 5f9b5354c170 -r e5eba3f4447c src/c_api.cpp
--- a/src/c_api.cpp	Wed Jan 19 08:44:39 2011 -0800
+++ b/src/c_api.cpp	Thu Jan 20 10:56:56 2011 -0800
@@ -269,6 +269,17 @@
 
 }
 
+LAS_DLL void LASReader_SetHeader(  LASReaderH hReader, const LASHeaderH hHeader) 
+
+{
+    VALIDATE_LAS_POINTER0(hReader, "LASReader_SetHeader");
+    VALIDATE_LAS_POINTER0(hHeader, "LASReader_SetHeader");
+
+    liblas::Reader* reader = (liblas::Reader*)hReader;
+    liblas::Header* header = (liblas::Header*)hHeader;
+    reader->SetHeader(*header);
+}
+
 LAS_DLL void LASReader_Destroy(LASReaderH hReader)
 {
     VALIDATE_LAS_POINTER0(hReader, "LASReader_Destroy");
@@ -458,6 +469,87 @@
         
 }
 
+LAS_DLL void LASPoint_SetHeader( LASPointH hPoint, const LASHeaderH hHeader) 
+
+{
+    VALIDATE_LAS_POINTER0(hPoint, "LASPoint_SetHeader");
+    VALIDATE_LAS_POINTER0(hHeader, "LASPoint_SetHeader");
+
+    liblas::Point* point = (liblas::Point*)hPoint;
+    liblas::Header* header = (liblas::Header*)hHeader;
+    liblas::HeaderPtr h = liblas::HeaderPtr(new liblas::Header(*header));
+    point->SetHeaderPtr(h);
+}
+
+LAS_DLL LASErrorEnum LASPoint_SetData(LASPointH hPoint, unsigned char* data) {
+    
+    VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetData", LE_Failure);
+    VALIDATE_LAS_POINTER1(data, "LASPoint_SetData", LE_Failure);
+    
+    try {
+        liblas::Point* p = ((liblas::Point*) hPoint);
+        boost::uint16_t size = 0;
+
+        liblas::HeaderPtr h = p->GetHeaderPtr();
+        if (h.get())
+        {
+            size = h->GetDataRecordLength();
+        } else
+        {
+            size = liblas::DefaultHeader::get().GetDataRecordLength();
+        }
+        
+        std::vector<boost::uint8_t> & d = p->GetData();
+        if (d.size() != size)
+        {
+            d.resize(size);
+            d.assign(0, size);
+        }
+                
+        for (boost::uint16_t i=0; i < size; i++) {
+            d[i] = data[i];
+        }
+    }
+    catch (std::exception const& e) {
+        LASError_PushError(LE_Failure, e.what(), "LASPoint_SetData");
+        return LE_Failure;
+    }
+
+
+    return LE_None;
+}
+
+LAS_DLL LASErrorEnum LASPoint_GetData( const LASPointH hPoint, boost::uint8_t* data) {
+    
+    VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetData", LE_Failure);
+    VALIDATE_LAS_POINTER1(data, "LASPoint_GetData", LE_Failure);
+    
+    try {
+        liblas::Point* p = ((liblas::Point*) hPoint);
+        boost::uint16_t size = 0;
+        std::vector<boost::uint8_t> const& d = p->GetData();
+
+        liblas::HeaderPtr h = p->GetHeaderPtr();
+        if (h.get())
+        {
+            size = h->GetDataRecordLength();
+        } else
+        {
+            size = liblas::DefaultHeader::get().GetDataRecordLength();
+        }        
+        for (boost::uint16_t i=0; i < size; i++) {
+            data[i] = d[i];
+        }
+    }
+    catch (std::exception const& e) {
+        LASError_PushError(LE_Failure, e.what(), "LASPoint_GetData");
+        return LE_Failure;
+    }
+
+
+    return LE_None;
+}
+
 
 LAS_DLL void LASPoint_Destroy(LASPointH hPoint) {
     VALIDATE_LAS_POINTER0(hPoint, "LASPoint_Destroy");
@@ -491,9 +583,9 @@
 
 LAS_DLL boost::int32_t LASPoint_GetRawX(const LASPointH hPoint) {
 
-    VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetRawX", 0.0);
+    VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetRawX", 0);
     
-    boost::int32_t value = ((liblas::Point*) hPoint)->GetRawX();
+    long value = static_cast<long>(((liblas::Point*) hPoint)->GetRawX());
     return value;
 }
 
@@ -539,9 +631,9 @@
 
 LAS_DLL boost::int32_t LASPoint_GetRawY(const LASPointH hPoint) {
 
-    VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetRawY", 0.0);
+    VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetRawY", 0);
     
-    boost::int32_t value = ((liblas::Point*) hPoint)->GetRawY();
+    long value = static_cast<long>(((liblas::Point*) hPoint)->GetRawY());
     return value;
 }
 
@@ -586,9 +678,9 @@
 
 LAS_DLL boost::int32_t LASPoint_GetRawZ(const LASPointH hPoint) {
 
-    VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetRawZ", 0.0);
+    VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetRawZ", 0);
     
-    boost::int32_t value = ((liblas::Point*) hPoint)->GetRawZ();
+    long value = static_cast<long>(((liblas::Point*) hPoint)->GetRawZ());
     return value;
 }
 
@@ -1518,7 +1610,8 @@
     VALIDATE_LAS_POINTER1(hWriter, "LASWriter_WriteHeader", LE_Failure);
     
     try {
-            ((liblas::Writer*) hWriter)->WriteHeader(*((liblas::Header*) hHeader));
+        ((liblas::Writer*) hWriter)->SetHeader(*((liblas::Header*) hHeader));
+        ((liblas::Writer*) hWriter)->WriteHeader();
     } catch (std::exception const& e)
     {
         LASError_PushError(LE_Failure, e.what(), "LASWriter_WriteHeader");
@@ -1528,6 +1621,33 @@
     return LE_None;    
 }
 
+LAS_DLL LASErrorEnum LASWriter_WriteOwnedHeader(const LASWriterH hWriter)
+{
+    VALIDATE_LAS_POINTER1(hWriter, "LASWriter_WriteOwnedHeader", LE_Failure);
+
+    try {
+        ((liblas::Writer*) hWriter)->WriteHeader();
+    } catch (std::exception const& e)
+    {
+        LASError_PushError(LE_Failure, e.what(), "LASWriter_WriteOwnedHeader");
+        return LE_Failure;
+    }
+
+    return LE_None;    
+}
+
+
+LAS_DLL void LASWriter_SetHeader(  LASWriterH hWriter, const LASHeaderH hHeader) 
+
+{
+    VALIDATE_LAS_POINTER0(hWriter, "LASWriter_SetHeader");
+    VALIDATE_LAS_POINTER0(hHeader, "LASWriter_SetHeader");
+
+    liblas::Writer* writer = (liblas::Writer*)hWriter;
+    liblas::Header* header = (liblas::Header*)hHeader;
+    writer->SetHeader(*header);
+}
+
 LAS_DLL void LASWriter_Destroy(LASWriterH hWriter)
 {
     VALIDATE_LAS_POINTER0(hWriter, "LASWriter_Destroy");
@@ -1758,7 +1878,7 @@
 
     try {
         liblas::VariableRecord* vlr = ((liblas::VariableRecord*) hVLR);
-        std::vector<boost::uint8_t> d = vlr->GetData();
+        std::vector<boost::uint8_t> const& d = vlr->GetData();
         boost::uint16_t length = vlr->GetRecordLength();
         for (boost::uint16_t i=0; i < length; i++) {
             data[i] = d[i];
diff -r 5f9b5354c170 -r e5eba3f4447c src/detail/reader/header.cpp
--- a/src/detail/reader/header.cpp	Wed Jan 19 08:44:39 2011 -0800
+++ b/src/detail/reader/header.cpp	Thu Jan 20 10:56:56 2011 -0800
@@ -1,478 +1,478 @@
-/******************************************************************************


More information about the Liblas-commits mailing list