[Liblas-commits] hg: --debug switch, enable processing

liblas-commits at liblas.org liblas-commits at liblas.org
Sat Aug 14 21:46:17 EDT 2010


changeset 8ea8aeee6173 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=8ea8aeee6173
summary: --debug switch, enable processing

diffstat:

 apps/las2oci.cpp |  680 ++++++++++++++++++++----------------------------------
 1 files changed, 254 insertions(+), 426 deletions(-)

diffs (truncated from 815 to 300 lines):

diff -r 68ff6da9dfc4 -r 8ea8aeee6173 apps/las2oci.cpp
--- a/apps/las2oci.cpp	Sat Aug 14 14:49:33 2010 -0500
+++ b/apps/las2oci.cpp	Sat Aug 14 20:46:07 2010 -0500
@@ -625,6 +625,7 @@
     ("input,i", po::value< string >(), "input LAS file")
     ("connection,c", po::value< string >(), "OCI connection string")
     ("verbose,v", po::value<bool>()->zero_tokens(), "Verbose message output")
+    ("debug", po::value<bool>()->zero_tokens(), "Enable debugging")
     ("base-table-name", po::value< string >()->default_value("HOBU"), "The table name in which to put the point cloud object.  This table must have a column of type SDO_PC, with the name to be specified with --cloud-column-name")
     ("block-table-name", po::value< string >(), "The table name in which to put the block data.  This table must be of type SDO_PC.BLK_TABLE.  This table will be created using the filename of the input LAS file if not specified.  Use -d to delete the table if it already exists.")
     ("cloud-column-name", po::value< string >()->default_value("CLOUD"), "The column name that contains the point cloud object in the base table")
@@ -647,7 +648,6 @@
 
 po::options_description hidden_options("hidden options");
 hidden_options.add_options()
-    ("help,h", "produce help message")
     ("xmin", po::value< double >(), "global-extent minx value")
     ("ymin", po::value< double >(), "global-extent miny value")
     ("zmin", po::value< double >(), "global-extent minz value")
@@ -656,7 +656,23 @@
     ("zmax", po::value< double >(), "global-extent maxz value")
 ;
 
-return file_options.add(hidden_options);
+return file_options;
+}
+
+po::options_description GetHiddenOptions()
+{
+    po::options_description hidden_options("hidden options");
+hidden_options.add_options()
+    ("xmin", po::value< double >(), "global-extent minx value")
+    ("ymin", po::value< double >(), "global-extent miny value")
+    ("zmin", po::value< double >(), "global-extent minz value")
+    ("xmax", po::value< double >(), "global-extent maxx value")
+    ("ymax", po::value< double >(), "global-extent maxy value")
+    ("zmax", po::value< double >(), "global-extent maxz value")
+;
+
+
+return hidden_options;
 }
 // select sdo_pc_pkg.to_geometry(a.points, a.num_points, 3, 4326) from NACHES_BAREEARTH_BLOCK1 a where a.obj_id= 8907
 int main(int argc, char* argv[])
@@ -685,6 +701,7 @@
     bool bUse3d = false;
     bool bInsertHeaderBlob = false;
     
+    
     uint32_t nCapacity = 10000;
 
     int srid = 0;
@@ -698,6 +715,7 @@
     
     
     bool verbose = false;
+    bool debug = false;
     std::vector<liblas::FilterI*> filters;
     std::vector<liblas::TransformI*> transforms;
     
@@ -709,6 +727,7 @@
         po::options_description file_options = GetFileOptions();
         po::options_description filtering_options = GetFilteringOptions();
         po::options_description transform_options = GetTransformationOptions() ;
+        po::options_description hidden_options = GetHiddenOptions();
         po::positional_options_description p;
         p.add("input", 1);
         p.add("connection", 1);
@@ -718,7 +737,7 @@
 
         po::variables_map vm;
         po::options_description options;
-        options.add(file_options).add(transform_options).add(filtering_options);
+        options.add(file_options).add(transform_options).add(filtering_options).add(hidden_options);
         po::store(po::command_line_parser(argc, argv).
         options(options).positional(p).run(), vm);
 
@@ -726,15 +745,26 @@
 
         if (vm.count("help")) 
         {
-            std::cout << GetInvocationHeader()<<file_options;//<<transform_options<<filtering_options<<"\n";
-            return 1;
+            std::cout << GetInvocationHeader()<<file_options<<transform_options<<filtering_options<<"\n";
+            return 0;
         }
 
         if (vm.count("verbose")) 
         {
             verbose = vm["verbose"].as< bool >();
         }
-
+        if (vm.count("debug")) 
+        {
+            debug = vm["debug"].as< bool >();
+            verbose = true; // implies verbose too
+            const char* gdal_debug = getenv("CPL_DEBUG");
+            if (gdal_debug == 0)
+            {
+                char d[20] = "CPL_DEBUG=ON";
+                putenv(d);
+            }
+            
+        }
         if (vm.count("input")) 
         {
             input = vm["input"].as< string >();
@@ -808,14 +838,14 @@
         {
             aux_columns = vm["aux-columns"].as< string >();
             if (verbose)
-                std::cout << "Setting aux-columns to:" << aux_columns << std::endl;
+                std::cout << "Setting aux-columns to: " << aux_columns << std::endl;
 
         }
         if (vm.count("aux-values")) 
         {
             aux_values = vm["aux-values"].as< string >();
             if (verbose)
-                std::cout << "Setting aux-values to:" << aux_columns << std::endl;
+                std::cout << "Setting aux-values to: " << aux_values << std::endl;
 
         }
 
@@ -830,7 +860,7 @@
         {
             precision = vm["precision"].as< uint32_t >();
             if (verbose)
-                std::cout << "Setting precision to:" << precision << std::endl;
+                std::cout << "Setting precision to: " << precision << std::endl;
 
         }
         
@@ -944,48 +974,257 @@
             double xmin = vm["xmin"].as< double >();
             global_extent.min(0, xmin);
             if (verbose)
-                std::cout << "Setting xmin to:" << xmin << std::endl;
+                std::cout << "Setting xmin to: " << xmin << std::endl;
         }
         if (vm.count("ymin")) 
         {
             double ymin = vm["ymin"].as< double >();
             global_extent.min(1, ymin);
             if (verbose)
-                std::cout << "Setting ymin to:" << ymin << std::endl;
+                std::cout << "Setting ymin to: " << ymin << std::endl;
         }
         if (vm.count("zmin")) 
         {
             double zmin = vm["zmin"].as< double >();
             global_extent.min(2, zmin);
             if (verbose)
-                std::cout << "Setting zmin to:" << zmin << std::endl;
+                std::cout << "Setting zmin to: " << zmin << std::endl;
         }
         if (vm.count("xmax")) 
         {
             double xmax = vm["xmax"].as< double >();
             global_extent.max(0, xmax);
             if (verbose)
-                std::cout << "Setting xmax to:" << xmax << std::endl;
+                std::cout << "Setting xmax to: " << xmax << std::endl;
         }
         if (vm.count("ymax")) 
         {
             double ymax = vm["ymax"].as< double >();
             global_extent.max(1, ymax);
             if (verbose)
-                std::cout << "Setting ymax to:" << ymax << std::endl;
+                std::cout << "Setting ymax to: " << ymax << std::endl;
         }
         if (vm.count("zmax")) 
         {
             double zmax = vm["zmax"].as< double >();
             global_extent.max(2, zmax);
             if (verbose)
-                std::cout << "Setting zmax to:" << zmax << std::endl;
+                std::cout << "Setting zmax to: " << zmax << std::endl;
         }
         filters = GetFilters(vm, verbose);
         
         // Transforms alter our header as well.  Setting scales, offsets, etc.
         transforms = GetTransforms(vm, verbose, header);
         
+
+
+
+
+        if (connection.empty() || input.empty()) {
+            if (input.empty())
+                std::cerr << "Input .las file not specified!" << std::endl;
+            if (connection.empty())
+                std::cerr << "Oracle connection string empty!" << std::endl;
+
+            std::cout << GetInvocationHeader()<<file_options<<transform_options<<filtering_options<<"\n";
+            return 1;
+
+        }
+
+        if (block_table_name.size() == 0) {
+            // change filename foo.las -> foo for an appropriate
+            // block tablename for oracle... must be less than 30 characters
+            // and no extraneous characters.
+            string::size_type dot_pos = input.find_first_of(".");
+            block_table_name = input.substr(0,dot_pos);
+        } else {
+            block_table_name = block_table_name;
+        }
+        string::size_type slash_pos = connection.find("/",0);
+        username = connection.substr(0,slash_pos);
+        string::size_type at_pos = connection.find("@",slash_pos);
+    //    std::cout <<"slash_pos: " << slash_pos << " at_pos: " << at_pos<<std::endl;
+        password = connection.substr(slash_pos+1, at_pos-slash_pos-1);
+        instance = connection.substr(at_pos+1);
+        std::cout << "Connecting with username: " << username << " password: "<< password<< " instance: " << instance << std::endl;    
+
+        std::cout << "Base table name " << base_table_name << " cloud column: " << point_cloud_name <<" block table: " << block_table_name << std::endl;
+        // OCI_SUCCESS_WITH_INFO error, which according to google relates to 
+        // a warning related to expired or expiring passwords needs to be 
+        // handled in the oracle wrapper.
+
+        // Create the index before connecting to Oracle.  That way we don't heartbeat
+        // the server while we're cruising through the file(s).
+
+        // OS X RAMDISK configuration
+        // http://www.macosxhints.com/article.php?story=20090222092827145
+
+        // Obj_id is serial for each row in the block table
+        // blk_id is the index leaf node id (this is currently being written incorrectly)
+        OWConnection* con = new OWConnection(username.c_str(),password.c_str(),instance.c_str());
+        if (con->Succeeded()) {
+            std::cout <<"Oracle connection succeded" << std::endl;
+        } else {
+            std::cout <<"Oracle connection failed" << std::endl; exit(1);
+        }
+
+        // std::istream* istrm;
+        // try {
+        //         istrm = OpenInput(input, false);
+        // } catch (std::exception const& e)
+        // {
+        //     std::cout << e.what() << std::endl;
+        //     std::cout << "exiting..." << std::endl;
+        //     exit(-1);
+        // }
+
+
+        con->StartTransaction();
+
+        if (bDropTable) {
+            std::cout << "dropping existing tables..." << std::endl;
+
+            WipeBlockTable(con, block_table_name, base_table_name, point_cloud_name);
+        }
+
+        if (!pre_sql.empty()) {
+            std::cout << "running pre-sql ..." << std::endl;
+            ostringstream oss;
+            oss << pre_sql;
+            OWStatement* statement = 0;
+            statement = RunSQL(con, oss);
+            if (statement != 0) {
+                delete statement; 
+            }
+            else {
+                std::cout << "pre-sql execution failed.." << std::endl;
+                return false;
+            }
+            oss.str("");        
+        }
+        if (!BlockTableExists(con, block_table_name.c_str()))
+            CreateBlockTable(con, block_table_name);
+        else {
+            bUseExistingBlockTable = true;
+            std::cout << "Using existing block table ... " << std::endl;
+
+        }
+
+        KDXIndexSummary* query = 0;
+        if (!KDTreeIndexExists(input)) {
+            std::cout << "KDTree .kdx file does not exist for file, unable to proceed" << std::endl;
+            exit(1);  
+        } else {
+            std::cout << "Using kdtree ... " << std::endl;
+            std::ostringstream os;
+            os << input << ".kdx" ;
+
+            std::istream* kdx = OpenInput(os.str(), false);
+            query = new KDXIndexSummary(*kdx);
+        }
+
+        ResultsVector& results = query->GetResults();
+
+        ResultsVector::iterator i;
+
+        std::istream* istrm2;
+        istrm2 = OpenInput(input, false);
+        liblas::Reader* reader2 = new liblas::Reader(*istrm2);
+


More information about the Liblas-commits mailing list