[Liblas-commits] hg: checkpoint on laszip chunking work
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed May 11 12:13:30 EDT 2011
details: http://hg.liblas.orghg/rev/c3ef23b1c1dc
changeset: 2933:c3ef23b1c1dc
user: Michael P. Gerlek <mpg at flaxen.com>
date: Mon May 09 17:11:21 2011 -0700
description:
checkpoint on laszip chunking work
Subject: hg: sync w/ laszip; seek tests currently failing
details: http://hg.liblas.orghg/rev/76362ccb40fa
changeset: 2934:76362ccb40fa
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed May 11 09:12:55 2011 -0700
description:
sync w/ laszip; seek tests currently failing
Subject: hg: merge
details: http://hg.liblas.orghg/rev/91e31e884124
changeset: 2935:91e31e884124
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed May 11 09:13:06 2011 -0700
description:
merge
diffstat:
apps/kdx_util.cpp | 92 ++-
apps/las2oci.cpp | 72 ++-
include/liblas/bounds.hpp | 2 +-
include/liblas/detail/reader/zipreader.hpp | 5 +-
include/liblas/detail/writer/zipwriter.hpp | 2 +
include/liblas/detail/zippoint.hpp | 7 +-
schemas/8-dimension-schema.xml | 109 +++
schemas/las.xml | 2 +-
src/chipper.cpp | 4 +-
src/detail/reader/header.cpp | 2 +
src/detail/reader/zipreader.cpp | 795 +++++++++++++---------------
src/detail/writer/header.cpp | 4 +-
src/detail/writer/zipwriter.cpp | 41 +-
src/detail/zippoint.cpp | 181 +++---
test/unit/zipreader_test.cpp | 8 +-
15 files changed, 768 insertions(+), 558 deletions(-)
diffs (truncated from 1736 to 300 lines):
diff -r b702e41a99b0 -r 91e31e884124 apps/kdx_util.cpp
--- a/apps/kdx_util.cpp Sun Apr 10 21:10:11 2011 -0500
+++ b/apps/kdx_util.cpp Wed May 11 09:13:06 2011 -0700
@@ -105,30 +105,65 @@
point_data.clear();
+ // Full 8-byte dimension - Dim #1
double x = p.GetX();
+
+ // Full 8-byte dimension - Dim #2
double y = p.GetY();
+
+ // Full 8-byte dimension - Dim #3
double z = p.GetZ();
+
+ // Full 8-byte dimension - Dim #4
double t = p.GetTime();
+
+ // Full 8-byte dimension - Dim #5
+ double c = static_cast<double>(p.GetClassification().GetClass());
+
+ // Full 8-byte dimension - Dim #6
+ double intensity = static_cast<double>(p.GetIntensity());
+ // double intensity = 34.0;
+
+ // Composed 8-byte dimension - Dim #7
+ boost::int8_t returnNumber = (boost::int8_t)p.GetReturnNumber(); // 1 byte
+ boost::int8_t numberOfReturns = (boost::int8_t)p.GetNumberOfReturns(); // 1 byte
+ boost::int8_t scanDirFlag = (boost::int8_t)p.GetScanDirection(); // 1 byte
+ boost::int8_t edgeOfFlightLine = (boost::int8_t)p.GetFlightLineEdge(); // 1 byte
+ boost::int8_t scanAngleRank = p.GetScanAngleRank(); // 1 byte
+ boost::uint8_t userData = p.GetUserData(); // 1 byte
+ boost::uint16_t pointSourceId = p.GetPointSourceID(); // 2 bytes
+
+
+ // Composed 8-byte dimension - Dim #8
+ liblas::Color const& color = p.GetColor();
+ boost::uint16_t red = color.GetRed();
+ boost::uint16_t green = color.GetGreen();
+ boost::uint16_t blue = color.GetBlue();
+ boost::uint16_t alpha = 0;
- // std::cout.precision(6);
- // std::cout.setf(std::ios::fixed);
- // // std::cout << "X: " << x << " y: " << y << " z: " << z << std::endl;
- double c = static_cast<double>(p.GetClassification().GetClass());
boost::uint8_t* x_b = reinterpret_cast<boost::uint8_t*>(&x);
boost::uint8_t* y_b = reinterpret_cast<boost::uint8_t*>(&y);
boost::uint8_t* z_b = reinterpret_cast<boost::uint8_t*>(&z);
boost::uint8_t* t_b = reinterpret_cast<boost::uint8_t*>(&t);
boost::uint8_t* c_b = reinterpret_cast<boost::uint8_t*>(&c);
+
+ boost::uint8_t* intensity_b = reinterpret_cast<boost::uint8_t*>(&intensity);
+
+ boost::uint8_t* returnNumber_b = reinterpret_cast<boost::uint8_t*>(&returnNumber);
+ boost::uint8_t* numberOfReturns_b = reinterpret_cast<boost::uint8_t*>(&numberOfReturns);
+ boost::uint8_t* scanDirFlag_b = reinterpret_cast<boost::uint8_t*>(&scanDirFlag);
+ boost::uint8_t* edgeOfFlightLine_b = reinterpret_cast<boost::uint8_t*>(&edgeOfFlightLine);
+ boost::uint8_t* scanAngleRank_b = reinterpret_cast<boost::uint8_t*>(&scanAngleRank);
+ boost::uint8_t* userData_b = reinterpret_cast<boost::uint8_t*>(&userData);
+ boost::uint8_t* pointSourceId_b = reinterpret_cast<boost::uint8_t*>(&pointSourceId);
- // doubles are 8 bytes long. For each double, push back the
- // byte. We do this for all four values (x,y,z,t)
- // // little-endian
- // for (int i=0; i<sizeof(double); i++) {
- // point_data.push_back(y_b[i]);
- // }
- //
+ boost::uint8_t* red_b = reinterpret_cast<boost::uint8_t*>(&red);
+ boost::uint8_t* green_b = reinterpret_cast<boost::uint8_t*>(&green);
+ boost::uint8_t* blue_b = reinterpret_cast<boost::uint8_t*>(&blue);
+ boost::uint8_t* alpha_b = reinterpret_cast<boost::uint8_t*>(&alpha);
+
// big-endian
for (int i = sizeof(double) - 1; i >= 0; i--) {
@@ -142,7 +177,6 @@
for (int i = sizeof(double) - 1; i >= 0; i--) {
point_data.push_back(z_b[i]);
}
-
for (int i = sizeof(double) - 1; i >= 0; i--) {
point_data.push_back(t_b[i]);
@@ -155,6 +189,40 @@
point_data.push_back(c_b[i]);
}
+ // Intensity is only two bytes, but
+ // we need to store it in an 8 byte big-endian
+ // double to satisfy OPC
+ for (int i = sizeof(double) - 1; i >= 0; i--) {
+ point_data.push_back(intensity_b[i]);
+ }
+
+
+ // Pack dimension with a number of fields totalling 8 bytes
+ point_data.push_back(returnNumber_b[0]);
+ point_data.push_back(numberOfReturns_b[0]);
+ point_data.push_back(scanDirFlag_b[0]);
+ point_data.push_back(edgeOfFlightLine_b[0]);
+ point_data.push_back(scanAngleRank_b[0]);
+ point_data.push_back(userData_b[0]);
+ for (int i = sizeof(uint16_t) - 1; i >= 0; i--) {
+ point_data.push_back(pointSourceId_b[i]);
+ }
+
+ // Pack dimension with RGBA for a total of 8 bytes
+ for (int i = sizeof(uint16_t) - 1; i >= 0; i--) {
+ point_data.push_back(red_b[i]);
+ }
+ for (int i = sizeof(uint16_t) - 1; i >= 0; i--) {
+ point_data.push_back(green_b[i]);
+ }
+ for (int i = sizeof(uint16_t) - 1; i >= 0; i--) {
+ point_data.push_back(blue_b[i]);
+ }
+ for (int i = sizeof(uint16_t) - 1; i >= 0; i--) {
+ point_data.push_back(alpha_b[i]);
+ }
+
+
return true;
}
diff -r b702e41a99b0 -r 91e31e884124 apps/las2oci.cpp
--- a/apps/las2oci.cpp Sun Apr 10 21:10:11 2011 -0500
+++ b/apps/las2oci.cpp Wed May 11 09:13:06 2011 -0700
@@ -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(false);
+ 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,16 @@
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) + 1);
+ strncpy(schema, point_schema_override.c_str(), point_schema_override.size());
+ schema[point_schema_override.size()] = '\0';
+ statement->WriteCLob( &schema_locator, schema );
+ statement->Bind(&schema_locator);
+ }
if (bInsertHeaderBlob) {
OCILobLocator** locator =(OCILobLocator**) VSIMalloc( sizeof(OCILobLocator*) * 1 );
statement->Define( locator, 1 );
@@ -538,9 +568,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 +655,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 +669,7 @@
("cached", po::value<bool>()->zero_tokens(), "Cache the entire file on the first read")
+
;
return file_options;
@@ -683,6 +714,7 @@
std::string aux_columns("");
std::string aux_values("");
+ std::string point_schema_override("");
bool bUseExistingBlockTable = false;
bool bDropTable = false;
@@ -966,6 +998,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 >();
@@ -1219,7 +1260,7 @@
point_cloud_name,
aux_columns,
aux_values,
- 5, // we're assuming 5d for now (x, y, z, time, classification)
+ 8, // we're assuming 8d for now (x, y, z, time, classification, intensity, packed_struct, colors)
More information about the Liblas-commits
mailing list