[Liblas-commits] hg: we write 8 dimensions now
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Apr 20 14:53:03 EDT 2011
details: http://hg.liblas.orghg/rev/bbfdf7108456
changeset: 2925:bbfdf7108456
user: Howard Butler <hobu.inc at gmail.com>
date: Wed Apr 20 13:52:38 2011 -0500
description:
we write 8 dimensions now
Subject: hg: write all LAS dimensions packed into a 64 byte field for Oracle
details: http://hg.liblas.orghg/rev/8c5b463da441
changeset: 2926:8c5b463da441
user: Howard Butler <hobu.inc at gmail.com>
date: Wed Apr 20 13:52:53 2011 -0500
description:
write all LAS dimensions packed into a 64 byte field for Oracle
diffstat:
apps/kdx_util.cpp | 92 +++++++++++++++++++++++++++++++++++++++++++++++-------
apps/las2oci.cpp | 2 +-
2 files changed, 81 insertions(+), 13 deletions(-)
diffs (141 lines):
diff -r 8dc016250ac4 -r 8c5b463da441 apps/kdx_util.cpp
--- a/apps/kdx_util.cpp Fri Apr 15 11:07:52 2011 -0500
+++ b/apps/kdx_util.cpp Wed Apr 20 13:52:53 2011 -0500
@@ -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 8dc016250ac4 -r 8c5b463da441 apps/las2oci.cpp
--- a/apps/las2oci.cpp Fri Apr 15 11:07:52 2011 -0500
+++ b/apps/las2oci.cpp Wed Apr 20 13:52:53 2011 -0500
@@ -1219,7 +1219,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)
srid,
nCapacity,
precision,
More information about the Liblas-commits
mailing list