[Liblas-commits] hg-main-tree: add some error checking for the case when findFirs...

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Aug 4 15:02:43 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/51189e85d83b
changeset: 1006:51189e85d83b
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Aug 04 14:00:48 2011 -0500
description:
add some error checking for the case when findFirst returns NULL
Subject: hg-main-tree: remove dead code

details:   http://hg.libpc.orghg-main-tree/rev/9817ea106746
changeset: 1007:9817ea106746
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Aug 04 14:00:58 2011 -0500
description:
remove dead code
Subject: hg-main-tree: add new-style options for Reader

details:   http://hg.libpc.orghg-main-tree/rev/33d6b15f9dd9
changeset: 1008:33d6b15f9dd9
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Aug 04 14:01:23 2011 -0500
description:
add new-style options for Reader

diffstat:

 src/StageFactory.cpp         |   24 ++++++++
 src/drivers/oci/Iterator.cpp |  123 -------------------------------------------
 src/drivers/oci/Reader.cpp   |   14 ++++
 3 files changed, 38 insertions(+), 123 deletions(-)

diffs (220 lines):

diff -r 30b32d488aab -r 33d6b15f9dd9 src/StageFactory.cpp
--- a/src/StageFactory.cpp	Thu Aug 04 11:02:16 2011 -0500
+++ b/src/StageFactory.cpp	Thu Aug 04 14:01:23 2011 -0500
@@ -68,6 +68,7 @@
 
 #include <boost/shared_ptr.hpp>
 
+#include <sstream>
 
 namespace pdal
 {
@@ -127,6 +128,11 @@
 Reader* StageFactory::createReader(const std::string& type, const Options& options)
 {
     ReaderCreator* f = getReaderCreator(type);
+    if (!f) {
+        std::ostringstream oss;
+        oss << "Unable to create reader for type '" << type << "'. Does a driver with this type name exist?";
+        throw pdal_error(oss.str());
+    }
     Reader* stage = f(options);
     return stage;
 }
@@ -135,6 +141,12 @@
 Filter* StageFactory::createFilter(const std::string& type, Stage& prevStage, const Options& options)
 {
     FilterCreator* f = getFilterCreator(type);
+    if (!f) {
+        std::ostringstream oss;
+        oss << "Unable to create filter for type '" << type << "'. Does a driver with this type name exist?";
+        throw pdal_error(oss.str());
+    }
+
     Filter* stage = f(prevStage, options);
     return stage;
 }
@@ -143,6 +155,12 @@
 MultiFilter* StageFactory::createMultiFilter(const std::string& type, const std::vector<Stage*>& prevStages, const Options& options)
 {
     MultiFilterCreator* f = getMultiFilterCreator(type);
+    if (!f) {
+        std::ostringstream oss;
+        oss << "Unable to create multifilter for type '" << type << "'. Does a driver with this type name exist?";
+        throw pdal_error(oss.str());
+    }
+    
     MultiFilter* stage = f(prevStages, options);
     return stage;
 }
@@ -151,6 +169,12 @@
 Writer* StageFactory::createWriter(const std::string& type, Stage& prevStage, const Options& options)
 {
     WriterCreator* f = getWriterCreator(type);
+    if (!f) {
+        std::ostringstream oss;
+        oss << "Unable to create writer for type '" << type << "'. Does a driver with this type name exist?";
+        throw pdal_error(oss.str());
+    }
+
     Writer* stage = f(prevStage, options);
     return stage;
 }
diff -r 30b32d488aab -r 33d6b15f9dd9 src/drivers/oci/Iterator.cpp
--- a/src/drivers/oci/Iterator.cpp	Thu Aug 04 11:02:16 2011 -0500
+++ b/src/drivers/oci/Iterator.cpp	Thu Aug 04 14:01:23 2011 -0500
@@ -84,129 +84,6 @@
     return m_reader;
 }
 
-boost::uint32_t IteratorBase::unpackOracleData(PointBuffer& data)
-{
-    boost::uint32_t capacity = data.getCapacity();
-    boost::uint32_t numPoints = data.getNumPoints();
-    
-    boost::uint32_t space = capacity - numPoints;
-    boost::uint32_t point_position = numPoints;
-    
-    if (m_block->num_points < 0)
-    {
-        std::ostringstream oss;
-        oss << "This oracle block has a num_points that is negative (" << m_block->num_points <<")!";
-        throw pdal_error(oss.str());
-    }
-    
-    if (space < static_cast<boost::uint32_t>(m_block->num_points))
-    {
-        std::ostringstream oss;
-        oss << "Not enough space to store this block!  The space left in the buffer is ";
-        oss << space << ", the Oracle block has " << m_block->num_points << " points ";
-        throw pdal_error(oss.str());
-    }
-
-    std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
-    std::cout.precision(2);
-
-    const Schema& schema = data.getSchema();
-    const int indexX = schema.getDimensionIndex(Dimension::Field_X, Dimension::Int32);
-    const int indexY = schema.getDimensionIndex(Dimension::Field_Y, Dimension::Int32);
-    const int indexZ = schema.getDimensionIndex(Dimension::Field_Z, Dimension::Int32);
-    const int indexTime = schema.getDimensionIndex(Dimension::Field_Time, Dimension::Double);
-    const int indexClassification = schema.getDimensionIndex(Dimension::Field_Classification, Dimension::Uint8);
-    const int indexIntensity = schema.getDimensionIndex(Dimension::Field_Intensity, Dimension::Uint16);
-
-
-    const int indexReturnNumber = schema.getDimensionIndex(Dimension::Field_ReturnNumber, Dimension::Uint8);
-    const int indexNumberOfReturns = schema.getDimensionIndex(Dimension::Field_NumberOfReturns, Dimension::Uint8);
-    const int indexScanDirectionFlag = schema.getDimensionIndex(Dimension::Field_ScanDirectionFlag, Dimension::Uint8);
-    const int indexEdgeOfFlightLine = schema.getDimensionIndex(Dimension::Field_EdgeOfFlightLine, Dimension::Uint8);
-    const int indexScanAngleRank = schema.getDimensionIndex(Dimension::Field_ScanAngleRank, Dimension::Int8);
-    const int indexUserData = schema.getDimensionIndex(Dimension::Field_UserData, Dimension::Uint8);
-    const int indexPointSourceId = schema.getDimensionIndex(Dimension::Field_PointSourceId, Dimension::Uint16);
-
-    const int indexRed = schema.getDimensionIndex(Dimension::Field_Red, Dimension::Uint16);
-    const int indexGreen = schema.getDimensionIndex(Dimension::Field_Green, Dimension::Uint16);
-    const int indexBlue = schema.getDimensionIndex(Dimension::Field_Blue, Dimension::Uint16);
-    
-
-    const Dimension& dimX = schema.getDimension(indexX);
-    const Dimension& dimY = schema.getDimension(indexY);
-    const Dimension& dimZ = schema.getDimension(indexZ);
-    
-    double scalex = dimX.getNumericScale();
-    double scaley = dimY.getNumericScale();
-    double scalez = dimZ.getNumericScale();
-    
-    double offsetx = dimX.getNumericOffset();
-    double offsety = dimY.getNumericOffset();
-    double offsetz = dimZ.getNumericOffset();
-     
-    EightDimensionOCI* d;
-    
-    for (boost::uint32_t i = 0; i < static_cast<boost::uint32_t>(m_block->num_points); i++)
-    {
-        boost::uint32_t byte_position = i*sizeof(EightDimensionOCI);
-        
-        d = (EightDimensionOCI*)(&(*m_block->chunk)[byte_position]);
-        SWAP_BE_TO_LE(d->x);
-        SWAP_BE_TO_LE(d->y);
-        SWAP_BE_TO_LE(d->z);
-        SWAP_BE_TO_LE(d->time);
-        SWAP_BE_TO_LE(d->cls);
-        SWAP_BE_TO_LE(d->intensity);
-
-        SWAP_BE_TO_LE(d->returnNumber);
-        SWAP_BE_TO_LE(d->numberOfReturns);
-        SWAP_BE_TO_LE(d->scanDirFlag);
-        SWAP_BE_TO_LE(d->edgeOfFlightLine);
-        SWAP_BE_TO_LE(d->scanAngleRank);
-        SWAP_BE_TO_LE(d->userData);
-        SWAP_BE_TO_LE(d->pointSourceId);
-
-        SWAP_BE_TO_LE(d->red);
-        SWAP_BE_TO_LE(d->green);
-        SWAP_BE_TO_LE(d->blue);
-        SWAP_BE_TO_LE(d->alpha);
-        
-        SWAP_BE_TO_LE(d->blk_id);
-        SWAP_BE_TO_LE(d->pc_id);
-        
-        boost::int32_t x = static_cast<boost::int32_t>(
-                         Utils::sround((d->x - offsetx) / scalex));
-        boost::int32_t y = static_cast<boost::int32_t>(
-                         Utils::sround((d->y - offsety) / scaley));
-        boost::int32_t z = static_cast<boost::int32_t>(
-                         Utils::sround((d->z - offsetz) / scalez));
-        data.setField(point_position, indexX, x);
-        data.setField(point_position, indexY, y);
-        data.setField(point_position, indexZ, z);
-        
-        data.setField(point_position, indexTime, d->time);
-        data.setField(point_position, indexClassification, static_cast<boost::uint8_t>(d->cls));
-        data.setField<boost::int16_t>(point_position, indexIntensity, static_cast<boost::int16_t>(d->intensity));
-
-        data.setField<boost::int8_t>(point_position, indexReturnNumber, d->returnNumber);
-        data.setField<boost::int8_t>(point_position, indexNumberOfReturns, d->numberOfReturns);
-        data.setField<boost::int8_t>(point_position, indexScanDirectionFlag, d->scanDirFlag);
-        data.setField<boost::int8_t>(point_position, indexEdgeOfFlightLine, d->edgeOfFlightLine);
-        data.setField<boost::int8_t>(point_position, indexScanAngleRank, d->scanAngleRank);
-        data.setField<boost::int8_t>(point_position, indexUserData, d->userData);
-        data.setField<boost::uint16_t>(point_position, indexPointSourceId, d->pointSourceId);
-
-
-        data.setField<boost::uint16_t>(point_position, indexRed, d->red);
-        data.setField<boost::uint16_t>(point_position, indexGreen, d->green);
-        data.setField<boost::uint16_t>(point_position, indexBlue, d->blue);
-                
-        point_position++;
-        data.setNumPoints(point_position);
-    
-    }
-    return 0;
-}
 
 boost::uint32_t IteratorBase::myReadBuffer(PointBuffer& data)
 {
diff -r 30b32d488aab -r 33d6b15f9dd9 src/drivers/oci/Reader.cpp
--- a/src/drivers/oci/Reader.cpp	Thu Aug 04 11:02:16 2011 -0500
+++ b/src/drivers/oci/Reader.cpp	Thu Aug 04 14:01:23 2011 -0500
@@ -126,7 +126,21 @@
 {
     static Options options;
     
+    Option<std::string> connection("connection",
+                                   "",
+                                   "Oracle connection string to connect to database");
+    
+    Option<std::string> query("query",
+                              "",
+                              "SELECT statement that returns an SDO_PC object \
+                              as its first and only queried item.");
 
+    Option<boost::uint32_t> capacity("capacity",
+                                     0,
+                                     "Block capacity");
+
+    Option<bool> debug("debug", false, "Do we output debugging info?");
+    Option<bool> verbose("verbose", false, "Do we output verbose info about what we're doing?");
 
     
     return options;


More information about the Liblas-commits mailing list