[Liblas-commits] hg-main-tree: Use the new LASzip 2.0 errors when things go wrong...

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Jun 23 09:21:57 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/8a7d89903d4f
changeset: 803:8a7d89903d4f
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Jun 23 08:20:23 2011 -0500
description:
Use the new LASzip 2.0 errors when things go wrong and decrease the level of paranoia
Subject: hg-main-tree: throw an error if the CoordinateTransformation object is not created by GDAL

details:   http://hg.libpc.orghg-main-tree/rev/5fb0926e8a37
changeset: 804:5fb0926e8a37
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Jun 23 08:21:25 2011 -0500
description:
throw an error if the CoordinateTransformation object is not created by GDAL
Subject: hg-main-tree: start using operator== for pdal::SpatialReference comparisons

details:   http://hg.libpc.orghg-main-tree/rev/1912deb7d99c
changeset: 805:1912deb7d99c
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Jun 23 08:21:41 2011 -0500
description:
start using operator== for pdal::SpatialReference comparisons
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/97df63460e54
changeset: 806:97df63460e54
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Jun 23 08:21:50 2011 -0500
description:
merge

diffstat:

 src/XMLSchema.cpp                    |   2 +-
 src/drivers/las/Iterator.cpp         |  69 ++++++++++-------------------------
 src/drivers/las/Reader.cpp           |  15 ++-----
 src/drivers/las/Writer.cpp           |  62 ++++++++++---------------------
 src/drivers/qfit/Reader.cpp          |   4 ++
 src/drivers/terrasolid/Reader.cpp    |   4 +-
 src/filters/ReprojectionFilter.cpp   |  13 +++++-
 test/unit/QFITReaderTest.cpp         |   4 +-
 test/unit/ReprojectionFilterTest.cpp |   7 ++-
 test/unit/TerraSolidTest.cpp         |   2 +-
 10 files changed, 72 insertions(+), 110 deletions(-)

diffs (truncated from 352 to 300 lines):

diff -r c4edb940f08f -r 97df63460e54 src/XMLSchema.cpp
--- a/src/XMLSchema.cpp	Wed Jun 22 10:24:20 2011 -0700
+++ b/src/XMLSchema.cpp	Thu Jun 23 08:21:50 2011 -0500
@@ -617,7 +617,7 @@
 {
     if (!compare_no_case(name.c_str(), "X"))
         return Dimension::Field_X;
-
+    
     if (!compare_no_case(name.c_str(), "Y"))
         return Dimension::Field_Y;
 
diff -r c4edb940f08f -r 97df63460e54 src/drivers/las/Iterator.cpp
--- a/src/drivers/las/Iterator.cpp	Wed Jun 22 10:24:20 2011 -0700
+++ b/src/drivers/las/Iterator.cpp	Thu Jun 23 08:21:50 2011 -0500
@@ -82,17 +82,10 @@
 {
 #ifdef PDAL_HAVE_LASZIP
 
-    try
-    {
-        // Initialize a scoped_ptr and swap it with our member variable 
-        // that will contain it.
-        boost::scoped_ptr<LASzip> s(new LASzip());
-        m_zip.swap(s);
-    }
-    catch(...)
-    {
-        throw pdal_error("Failed to open laszip compression core (1)"); 
-    }
+    // Initialize a scoped_ptr and swap it with our member variable 
+    // that will contain it.
+    boost::scoped_ptr<LASzip> s(new LASzip());
+    m_zip.swap(s);
 
     PointFormat format = m_reader.getPointFormat();
     
@@ -101,58 +94,38 @@
 
 
     bool ok = false;
-    try
-    {
-        ok = m_zip->setup((unsigned char)format, (unsigned short)m_reader.getPointDataOffset());
-    }
-    catch(...)
-    {
-        throw pdal_error("Error opening compression core (3)");
-    }
+    ok = m_zip->setup((unsigned char)format, (unsigned short)m_reader.getPointDataOffset());
+
     if (!ok)
     {
-        throw pdal_error("Error opening compression core (2)");
+        std::ostringstream oss;
+        oss << "Error setting up compression engine: " << std::string(m_zip->get_error());
+        throw pdal_error(oss.str());
     }
 
-    try
-    {
+    ok = m_zip->unpack(m_zipPoint->our_vlr_data, m_zipPoint->our_vlr_num);
 
-        ok = m_zip->unpack(m_zipPoint->our_vlr_data, m_zipPoint->our_vlr_num);
-    }
-    catch(...)
-    {
-        throw pdal_error("Failed to open laszip compression core (2)"); 
-    }
     if (!ok)
     {
-        throw pdal_error("Failed to open laszip compression core (3)"); 
+        std::ostringstream oss;
+        oss << "Error unpacking zip VLR data: " << std::string(m_zip->get_error());
+        throw pdal_error(oss.str());
     }
 
     if (!m_unzipper)
     {
-        try
-        {
-            boost::scoped_ptr<LASunzipper> z(new LASunzipper());
-            m_unzipper.swap(z);
-        }
-        catch(...)
-        {
-            throw pdal_error("Failed to open laszip decompression engine (1)"); 
-        }
+        boost::scoped_ptr<LASunzipper> z(new LASunzipper());
+        m_unzipper.swap(z);
 
         bool stat(false);
-        try
-        {
-            m_istream->seekg(m_reader.getPointDataOffset(), std::ios::beg);
-            stat = m_unzipper->open(*m_istream, m_zip.get());
-        }
-        catch(...)
-        {
-            throw pdal_error("Failed to open laszip decompression engine (2)"); 
-        }
+        m_istream->seekg(m_reader.getPointDataOffset(), std::ios::beg);
+        stat = m_unzipper->open(*m_istream, m_zip.get());
+
         if (!stat)
         {
-            throw pdal_error("Failed to open laszip decompression engine (3)"); 
+            std::ostringstream oss;
+            oss << "Failed to open LASzip stream: " << std::string(m_zip->get_error());
+            throw pdal_error(oss.str());
         }
     }
 #endif
diff -r c4edb940f08f -r 97df63460e54 src/drivers/las/Reader.cpp
--- a/src/drivers/las/Reader.cpp	Wed Jun 22 10:24:20 2011 -0700
+++ b/src/drivers/las/Reader.cpp	Thu Jun 23 08:21:50 2011 -0500
@@ -182,20 +182,15 @@
 #ifdef PDAL_HAVE_LASZIP
         boost::uint8_t* p = buf;
 
+        bool ok = false;
         for (boost::uint32_t i=0; i<numPoints; i++)
         {
-            bool ok = false;
-            try
-            {
-                ok = unzipper->read(zipPoint->m_lz_point);
-            }
-            catch(...)
-            {
-                throw pdal_error("Error reading compressed point data (1)");
-            }
+            ok = unzipper->read(zipPoint->m_lz_point);
             if (!ok)
             {
-                throw pdal_error("Error reading compressed point data (2)");
+                std::ostringstream oss;
+                oss << "Error reading compressed point data: " << std::string(unzipper->get_error());
+                throw pdal_error(oss.str());
             }
 
             memcpy(p, zipPoint->m_lz_point_data, zipPoint->m_lz_point_size);
diff -r c4edb940f08f -r 97df63460e54 src/drivers/las/Writer.cpp
--- a/src/drivers/las/Writer.cpp	Wed Jun 22 10:24:20 2011 -0700
+++ b/src/drivers/las/Writer.cpp	Thu Jun 23 08:21:50 2011 -0500
@@ -171,17 +171,11 @@
 #ifdef PDAL_HAVE_LASZIP
         if (!m_zip)
         {
-            try
-            {
-                // Initialize a scoped_ptr and swap it with our member variable 
-                // that will contain it.
-                boost::scoped_ptr<LASzip> s(new LASzip());
-                m_zip.swap(s);
-            }
-            catch(...)
-            {
-                throw pdal_error("Error opening compression core (1)");
-            }
+            // Initialize a scoped_ptr and swap it with our member variable 
+            // that will contain it.
+            boost::scoped_ptr<LASzip> s(new LASzip());
+            m_zip.swap(s);
+
 
             PointFormat format = m_lasHeader.getPointFormat();
             boost::scoped_ptr<ZipPoint> z(new ZipPoint(format, m_lasHeader.getVLRs().getAll()));
@@ -198,50 +192,34 @@
             }
             if (!ok)
             {
-                throw pdal_error("Error opening compression core (2)");
+                std::ostringstream oss;
+                oss << "Error opening compression core: " << std::string(m_zip->get_error());
+                throw pdal_error(oss.str());
             }
 
-            try
-            {
-                ok = m_zip->pack(m_zipPoint->his_vlr_data, m_zipPoint->his_vlr_num);
-            }
-            catch(...)
-            {
-                throw pdal_error("Error opening compression core (3)");
-            }
+            ok = m_zip->pack(m_zipPoint->his_vlr_data, m_zipPoint->his_vlr_num);
             if (!ok)
             {
-                throw pdal_error("Error opening compression core (2)");
+                std::ostringstream oss;
+                oss << "Error packing VLR data for compression: " << std::string(m_zip->get_error());
+                throw pdal_error(oss.str());
             }
         }
 
         if (!m_zipper)
         {
-            try
-            {
-                boost::scoped_ptr<LASzipper> z(new LASzipper());
-                m_zipper.swap(z);
-            }
-            catch(...)
-            {
-                throw pdal_error("Error opening compression engine (1)");
-            }
+            boost::scoped_ptr<LASzipper> z(new LASzipper());
+            m_zipper.swap(z);
 
-            PointFormat format = m_lasHeader.getPointFormat();
-            boost::scoped_ptr<ZipPoint> z(new ZipPoint(format, m_lasHeader.getVLRs().getAll()));
-            m_zipPoint.swap(z);
+
+
             bool stat(false);
-            try
-            {
-                stat = m_zipper->open(m_ostream, m_zip.get());
-            }
-            catch(...)
-            {
-                throw pdal_error("Error opening compression engine (3)");
-            }
+            stat = m_zipper->open(m_ostream, m_zip.get());
             if (!stat)
             {
-                throw pdal_error("Error opening compression engine (2)");
+                std::ostringstream oss;
+                oss << "Error opening LASzipper: " << std::string(m_zip->get_error());
+                throw pdal_error(oss.str());
             }
         }
 #else
diff -r c4edb940f08f -r 97df63460e54 src/drivers/qfit/Reader.cpp
--- a/src/drivers/qfit/Reader.cpp	Wed Jun 22 10:24:20 2011 -0700
+++ b/src/drivers/qfit/Reader.cpp	Thu Jun 23 08:21:50 2011 -0500
@@ -177,6 +177,10 @@
 #include <iostream>
 #include <map>
 
+#ifdef PDAL_COMPILER_MSVC
+#  pragma warning(disable: 4127)  // conditional expression is constant
+#endif
+
 namespace pdal { namespace drivers { namespace qfit {
 
 PointIndexes::PointIndexes(const Schema& schema, QFIT_Format_Type format)
diff -r c4edb940f08f -r 97df63460e54 src/drivers/terrasolid/Reader.cpp
--- a/src/drivers/terrasolid/Reader.cpp	Wed Jun 22 10:24:20 2011 -0700
+++ b/src/drivers/terrasolid/Reader.cpp	Thu Jun 23 08:21:50 2011 -0500
@@ -110,8 +110,8 @@
 
     setNumPoints(m_header->PntCnt);
 
-    m_haveColor = static_cast<bool>(m_header->Color);
-    m_haveTime = static_cast<bool>(m_header->Time);
+    m_haveColor = (m_header->Color==1);
+    m_haveTime = (m_header->Time==1);
     m_format = static_cast<TERRASOLID_Format_Type>(m_header->HdrVersion);
     
     
diff -r c4edb940f08f -r 97df63460e54 src/filters/ReprojectionFilter.cpp
--- a/src/filters/ReprojectionFilter.cpp	Wed Jun 22 10:24:20 2011 -0700
+++ b/src/filters/ReprojectionFilter.cpp	Thu Jun 23 08:21:50 2011 -0500
@@ -151,7 +151,7 @@
     if (result != OGRERR_NONE) 
     {
         std::ostringstream msg; 
-        msg << "Could not import input spatial reference for ReprojectionTransform:: " 
+        msg << "Could not import input spatial reference for ReprojectionFilter:: " 
             << CPLGetLastErrorMsg() << " code: " << result 
             << "wkt: '" << m_inSRS.getWKT() << "'";
         throw std::runtime_error(msg.str());
@@ -161,13 +161,22 @@
     if (result != OGRERR_NONE) 
     {
         std::ostringstream msg; 
-        msg << "Could not import output spatial reference for ReprojectionTransform:: " 
+        msg << "Could not import output spatial reference for ReprojectionFilter:: " 
             << CPLGetLastErrorMsg() << " code: " << result 
             << "wkt: '" << m_outSRS.getWKT() << "'";
         std::string message(msg.str());
         throw std::runtime_error(message);
     }
     m_transform_ptr = TransformPtr(OCTNewCoordinateTransformation( m_in_ref_ptr.get(), m_out_ref_ptr.get()), OSRTransformDeleter());
+    
+    if (!m_transform_ptr.get())
+    {
+        std::ostringstream msg; 
+        msg << "Could not construct CoordinateTransformation in ReprojectionFilter:: ";
+        std::string message(msg.str());
+        throw std::runtime_error(message);
+    }    
+    
 #endif
     
     setSpatialReference(m_outSRS);
diff -r c4edb940f08f -r 97df63460e54 test/unit/QFITReaderTest.cpp
--- a/test/unit/QFITReaderTest.cpp	Wed Jun 22 10:24:20 2011 -0700


More information about the Liblas-commits mailing list