[Liblas-commits] hg: add option to provide a schema document to the pc_other_attr...

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Apr 22 13:26:50 EDT 2011


details:   http://hg.liblas.orghg/rev/55ba3cb6ba0e
changeset: 2928:55ba3cb6ba0e
user:      Howard Butler <hobu.inc at gmail.com>
date:      Fri Apr 22 12:26:41 2011 -0500
description:
add option to provide a schema document to the pc_other_attrs column of the point cloud

diffstat:

 apps/las2oci.cpp |  69 ++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 55 insertions(+), 14 deletions(-)

diffs (174 lines):

diff -r 5385bcbdfc4d -r 55ba3cb6ba0e apps/las2oci.cpp
--- a/apps/las2oci.cpp	Thu Apr 21 14:26:48 2011 -0600
+++ b/apps/las2oci.cpp	Fri Apr 22 12:26:41 2011 -0500
@@ -387,7 +387,8 @@
                     std::string const& header_blob_column,
                     std::vector<boost::uint8_t> const& header_data,
                     std::string const& boundary_column,
-                    std::string const& boundary_wkt)
+                    std::string const& boundary_wkt,
+                    std::string const& point_schema_override)
 {
     ostringstream oss;
 
@@ -405,7 +406,12 @@
     
     ostringstream columns;
     ostringstream values;
+    bool bHaveSchemaOverride;
     
+    if (point_schema_override.size() > 0)
+        bHaveSchemaOverride = true;
+
+
     if (!aux_columns_u.empty() ) {
         columns << cloudColumnName_u << "," << aux_columns_u;
     
@@ -414,8 +420,13 @@
         columns << cloudColumnName_u;
         values << "pc";
     }
-
-    int nPos = 2; // Bind column position    
+    
+    int nPCPos = 1;
+    int nSchemaPos = 1;
+    if (bHaveSchemaOverride)
+        nSchemaPos++; // PC ID is now bound second
+        
+    int nPos = nSchemaPos+1; // Bind column position    
     if (!header_blob_column_u.empty()){
         columns << "," << header_blob_column_u;
         values <<", :" << nPos;
@@ -435,7 +446,7 @@
     ostringstream s_gtype;
     ostringstream s_eleminfo;
     ostringstream s_geom;
-
+    ostringstream s_schema;
 
     IsGeographic(connection, srid);
 
@@ -472,6 +483,13 @@
         }
     }
     
+    if (bHaveSchemaOverride)
+    {
+        s_schema << "xmltype(:"<<nSchemaPos<<")";
+    } else
+    {
+        s_schema << "NULL";
+    }
 
     // extent* e = GetExtent(  *(query->bounds.get()), bUse3d );
     liblas::Bounds<double> e =  *(query->bounds.get());
@@ -497,22 +515,24 @@
     
     
 oss << "declare\n"
-"  pc_id NUMBER := :1;\n"
+"  pc_id NUMBER := :"<<nPCPos<<";\n"
 "  pc sdo_pc;\n"
 
 "begin\n"
 "  -- Initialize the Point Cloud object.\n"
 "  pc := sdo_pc_pkg.init( \n"
-"          '"<< pcTableName_u<<"', -- Table that has the SDO_POINT_CLOUD column defined\n"
-"          '"<< cloudColumnName_u<<"',   -- Column name of the SDO_POINT_CLOUD object\n"
-"          '"<<blkTableName_u<<"', -- Table to store blocks of the point cloud\n"
+"          '"<< pcTableName_u <<"', -- Table that has the SDO_POINT_CLOUD column defined\n"
+"          '"<< cloudColumnName_u <<"',   -- Column name of the SDO_POINT_CLOUD object\n"
+"          '"<< blkTableName_u <<"', -- Table to store blocks of the point cloud\n"
 "           'blk_capacity="<<blk_capacity<<"', -- max # of points per block\n"
 << s_geom.str() <<
 ",  -- Extent\n"
 "     0.5, -- Tolerance for point cloud\n"
 "           "<<nDimension<<", -- Total number of dimensions\n"
-"           null);\n"
-"  :1 := pc.pc_id;\n"
+"           NULL,"
+"            NULL,"
+"            "<< s_schema.str() <<");\n"
+"  :"<<nPCPos<<" := pc.pc_id;\n"
 
 "  -- Insert the Point Cloud object  into the \"base\" table.\n"
 "  insert into " << pcTableName_u << " ( ID, "<< columns.str() <<
@@ -526,6 +546,15 @@
     long output = 0;
     statement = connection->CreateStatement(oss.str().c_str());
     statement->Bind(&pc_id);
+    OCILobLocator* schema_locator ; 
+    OCILobLocator* boundary_locator ; 
+    if (bHaveSchemaOverride)
+    {
+        char* schema = (char*) malloc(point_schema_override.size() * sizeof(char));
+        strncpy(schema, point_schema_override.c_str(), point_schema_override.size());
+        statement->WriteCLob( &schema_locator, schema ); 
+        statement->Bind(&schema_locator);
+    }
     if (bInsertHeaderBlob) {
         OCILobLocator** locator =(OCILobLocator**) VSIMalloc( sizeof(OCILobLocator*) * 1 );
         statement->Define( locator, 1 ); 
@@ -538,9 +567,8 @@
     char* wkt = (char*) malloc(boundary_wkt.size() * sizeof(char));
     strncpy(wkt, boundary_wkt.c_str(), boundary_wkt.size());    
     if (!boundary_column_u.empty()){
-        OCILobLocator* locator ; 
-        statement->WriteCLob( &locator, wkt ); 
-        statement->Bind(&locator);
+        statement->WriteCLob( &boundary_locator, wkt ); 
+        statement->Bind(&boundary_locator);
         statement->Bind(&srid);        
     }
 
@@ -626,6 +654,7 @@
     ("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.")
     ("block-table-partition-column", po::value< string >(), "The column name in which to put the partition id for the block as specified in --block-table-partition-value")
     ("block-table-partition-value", po::value< boost::int32_t >(), "The value for the partition id for the block to be placed in the column specified by --block-table-partition-column")
+    ("point-schema-override", po::value< string >(), "A schema document to set for the pc_other_attrs column")
     ("overwrite,d", po::value<bool>()->zero_tokens(), "Drop block table before inserting data.")
     ("block-capacity", po::value<boost::uint32_t>()->default_value(3000), "Maximum number of points to be inserted into each block")
     ("precision,p", po::value<boost::uint32_t>()->default_value(8), "Number of decimal points to write into SQL for point coordinate data.  Used in user_sdo_geom_metadata entry and defining the PC_EXTENT for the point cloud object.")
@@ -639,6 +668,7 @@
     ("cached", po::value<bool>()->zero_tokens(), "Cache the entire file on the first read")
 
 
+
 ;
 
 return file_options;
@@ -683,6 +713,7 @@
     
     std::string aux_columns("");
     std::string aux_values("");
+    std::string point_schema_override("");
     
     bool bUseExistingBlockTable = false;
     bool bDropTable = false;
@@ -966,6 +997,15 @@
                     std::cout << "Setting output pre-block-sql to: " << sql << std::endl; // Tell filename instead
         }
 
+        if (vm.count("point-schema-override")) 
+        {
+            std::string point_schema_file = vm["point-schema-override"].as< string >();
+            point_schema_override = ReadSQLData(point_schema_file);
+
+            if (verbose)
+                std::cout << "Setting output point-schema-override to: " << point_schema_file << std::endl;
+        }
+
         if (vm.count("solid")) 
         {
             bUseSolidGeometry = vm["solid"].as< bool >();
@@ -1229,7 +1269,8 @@
                         header_blob_column,
                         header_data,
                         base_table_boundary_column,
-                        base_table_boundary_wkt);
+                        base_table_boundary_wkt,
+                        point_schema_override);
 
 
         if (!pre_block_sql.empty()) {


More information about the Liblas-commits mailing list