[Liblas-commits] hg: support chipping files automatically if not
pre-processed by...
liblas-commits at liblas.org
liblas-commits at liblas.org
Sat Aug 14 22:21:53 EDT 2010
changeset 889a3f634938 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=889a3f634938
summary: support chipping files automatically if not pre-processed by lasblock for las2oci loading
diffstat:
apps/CMakeLists.txt | 2 +-
apps/kdx_util.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
apps/kdx_util.hpp | 4 +++-
apps/las2oci.cpp | 19 +++++++++++--------
4 files changed, 66 insertions(+), 12 deletions(-)
diffs (141 lines):
diff -r 8ea8aeee6173 -r 889a3f634938 apps/CMakeLists.txt
--- a/apps/CMakeLists.txt Sat Aug 14 20:46:07 2010 -0500
+++ b/apps/CMakeLists.txt Sat Aug 14 21:21:48 2010 -0500
@@ -128,7 +128,7 @@
# Build las2oci
if(LAS2OCI)
- add_executable(${LAS2OCI} las2oci.cpp oci_wrapper.cpp kdx_util.cpp oci_util.cpp laskernel.cpp)
+ add_executable(${LAS2OCI} las2oci.cpp oci_wrapper.cpp kdx_util.cpp oci_util.cpp laskernel.cpp chipper.cpp)
target_link_libraries(${LAS2OCI} ${APPS_CPP_DEPENDENCIES} ${Boost_LIBRARIES})
endif()
diff -r 8ea8aeee6173 -r 889a3f634938 apps/kdx_util.cpp
--- a/apps/kdx_util.cpp Sat Aug 14 20:46:07 2010 -0500
+++ b/apps/kdx_util.cpp Sat Aug 14 21:21:48 2010 -0500
@@ -1,6 +1,56 @@
#include "kdx_util.hpp"
+KDXIndexSummary::KDXIndexSummary(liblas::Reader& reader, boost::uint32_t capacity, bool verbose)
+{
+ liblas::chipper::Chipper c(&reader, capacity);
+ if (verbose)
+ std::cout << "Blocking" <<std::endl;
+
+ c.Chip();
+
+
+ double mins[2];
+ double maxs[2];
+
+ bool first = true;
+
+ boost::uint32_t num_blocks = c.GetBlockCount();
+
+ if (verbose)
+ std::cout << "Writing " << num_blocks << " blocks to " << std::endl;
+
+ boost::uint32_t prog = 0;
+
+ for ( boost::uint32_t i = 0; i < num_blocks; ++i )
+ {
+ const liblas::chipper::Block& b = c.GetBlock(i);
+
+ std::vector<uint32_t> ids = b.GetIDs();
+ liblas::Bounds<double> const& bnd = b.GetBounds();
+ if (first) {
+ mins[0] = bnd.min(0);
+ mins[1] = bnd.min(1);
+ maxs[0] = bnd.max(0);
+ maxs[1] = bnd.max(1);
+ first = false;
+ }
+
+ mins[0] = std::min(mins[0], bnd.min(0));
+ mins[1] = std::min(mins[1], bnd.min(1));
+
+ maxs[0] = std::max(maxs[0], bnd.max(0));
+ maxs[1] = std::max(maxs[1], bnd.max(1));
+
+ IndexResult result(static_cast<uint32_t>(i));
+ result.SetIDs(ids);
+ result.SetBounds(bnd);
+ m_results.push_back(result);
+ }
+
+ bounds = boost::shared_ptr<liblas::Bounds<double > >(new liblas::Bounds<double>(mins[0], mins[1], maxs[0], maxs[1]));
+
+}
KDXIndexSummary::KDXIndexSummary(std::istream& input) : bounds(), m_first(true)
{
@@ -42,8 +92,7 @@
ids.push_back(i);
}
liblas::Bounds<double> b(low[0], low[1], high[0],high[1]);
- // SpatialIndex::Region* pr = new SpatialIndex::Region(low, high, 2);
- // printf("Ids size: %d %.3f\n", ids.size(), pr->getLow(0));
+
IndexResult result(static_cast<uint32_t>(id));
result.SetIDs(ids);
result.SetBounds(b);
diff -r 8ea8aeee6173 -r 889a3f634938 apps/kdx_util.hpp
--- a/apps/kdx_util.hpp Sat Aug 14 20:46:07 2010 -0500
+++ b/apps/kdx_util.hpp Sat Aug 14 21:21:48 2010 -0500
@@ -3,6 +3,7 @@
#include <boost/shared_ptr.hpp>
#include <liblas/liblas.hpp>
+#include "chipper.hpp"
#include <fstream>
#include <sstream>
@@ -48,7 +49,8 @@
class KDXIndexSummary
{
public:
- KDXIndexSummary(std::istream& input);
+ KDXIndexSummary(std::istream& input);
+ KDXIndexSummary(liblas::Reader& reader, boost::uint32_t capacity, bool verbose);
boost::shared_ptr<liblas::Bounds<double > > bounds;
ResultsVector& GetResults() { return m_results; }
private:
diff -r 8ea8aeee6173 -r 889a3f634938 apps/las2oci.cpp
--- a/apps/las2oci.cpp Sat Aug 14 20:46:07 2010 -0500
+++ b/apps/las2oci.cpp Sat Aug 14 21:21:48 2010 -0500
@@ -1110,10 +1110,19 @@
}
+
+
+ std::istream* istrm2;
+ istrm2 = OpenInput(input, false);
+ liblas::Reader* reader2 = new liblas::Reader(*istrm2);
+
+ std::vector<uint8_t> header_data = GetHeaderData(input, reader2->GetHeader().GetDataOffset());
+
KDXIndexSummary* query = 0;
if (!KDTreeIndexExists(input)) {
- std::cout << "KDTree .kdx file does not exist for file, unable to proceed" << std::endl;
- exit(1);
+ if (verbose)
+ std::cout << "Chipping data for loading into Oracle with " << nCapacity<< " block capacity" << std::endl;
+ query = new KDXIndexSummary(*reader2, nCapacity, verbose);
} else {
std::cout << "Using kdtree ... " << std::endl;
std::ostringstream os;
@@ -1127,12 +1136,6 @@
ResultsVector::iterator i;
- std::istream* istrm2;
- istrm2 = OpenInput(input, false);
- liblas::Reader* reader2 = new liblas::Reader(*istrm2);
-
- std::vector<uint8_t> header_data = GetHeaderData(input, reader2->GetHeader().GetDataOffset());
-
long pc_id = CreatePCEntry( con,
query,
block_table_name,
More information about the Liblas-commits
mailing list