[Liblas-commits] hg: 4 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Jul 13 16:29:38 EDT 2010


changeset 55c6b1607e4a in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=55c6b1607e4a
summary: whitespace normalization

changeset 2bcbcbec9a90 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=2bcbcbec9a90
summary: make return values const

changeset 273f1bf1d486 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=273f1bf1d486
summary: port to use liblas::Bounds and only work for KDTree index types from now on

changeset 44578bc94c3f in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=44578bc94c3f
summary: remove liblas::Index in preparation for a new implementation

diffstat:

 apps/CMakeLists.txt                 |   10 +-
 apps/las2oci.cpp                    |  199 ++++++++++++----
 doc/compilation.txt                 |   32 +--
 include/liblas/index/datastream.hpp |  100 --------
 include/liblas/index/index.hpp      |  197 -----------------
 include/liblas/index/query.hpp      |  113 ---------
 include/liblas/index/storage.hpp    |  110 ---------
 include/liblas/index/visitor.hpp    |   82 -------
 include/liblas/lasbounds.hpp        |    4 +-
 src/CMakeLists.txt                  |   19 -
 src/index/datastream.cpp            |  134 -----------
 src/index/index.cpp                 |  415 ------------------------------------
 src/index/query.cpp                 |  216 ------------------
 src/index/storage.cpp               |  187 ----------------
 src/index/visitor.cpp               |  101 --------
 src/lasbounds.cpp                   |    2 +
 16 files changed, 157 insertions(+), 1764 deletions(-)

diffs (truncated from 2247 to 300 lines):

diff -r 1d8806139dc7 -r 44578bc94c3f apps/CMakeLists.txt
--- a/apps/CMakeLists.txt	Tue Jul 13 12:51:41 2010 -0500
+++ b/apps/CMakeLists.txt	Tue Jul 13 15:29:28 2010 -0500
@@ -38,9 +38,6 @@
     set(LAS2OGR las2ogr)
 endif()
 
-if(SPATIALINDEX_FOUND)
-    set(LASINDEX lasindex)
-endif()
 
 if(ORACLE_FOUND AND GDAL_FOUND)
     set(LAS2OCI las2oci)
@@ -48,7 +45,7 @@
 
 set(LIBLAS_UTILITIES
     ${LASINFO} ${LASMERGE} ${LAS2LAS} ${LAS2TXT} ${TXT2LAS} 
-    ${LAS2OGR} ${LASINDEX} ${LAS2OCI} ${LAS2LAS2} ${BIGFILE_TEST})
+    ${LAS2OGR}  ${LAS2OCI} ${LAS2LAS2} ${BIGFILE_TEST})
 
 # TODO: Experimental and requires testing --mloskot
 # Generate user-specific settings for Visual Studio project
@@ -116,11 +113,6 @@
     target_link_libraries(${LASMERGE} ${LIBLAS_C_LIB_NAME})
 endif()
 
-# Build lasindex
-if(LASINDEX)
-    add_executable(${LASINDEX} lasindex.cpp)
-    target_link_libraries(${LASINDEX} ${APPS_CPP_DEPENDENCIES})
-endif()
 
 # Build las2ogr
 if(LAS2OGR)
diff -r 1d8806139dc7 -r 44578bc94c3f apps/las2oci.cpp
--- a/apps/las2oci.cpp	Tue Jul 13 12:51:41 2010 -0500
+++ b/apps/las2oci.cpp	Tue Jul 13 15:29:28 2010 -0500
@@ -10,7 +10,7 @@
 #include <liblas/laspoint.hpp>
 #include <liblas/lasreader.hpp>
 #include <liblas/lasheader.hpp>
-#include <liblas/index/index.hpp>
+#include <liblas/lasbounds.hpp>
 
 #include <string>
 #include <sstream>
@@ -24,10 +24,6 @@
 
 #include <sys/stat.h>
 
-#ifdef HAVE_SPATIALINDEX
-#include <spatialindex/SpatialIndex.h>
-#endif
-
 #include <oci.h>
 
 using namespace std;
@@ -39,6 +35,101 @@
 #define compare_no_case(a,b,n)  strncasecmp( (a), (b), (n) )
 #endif
 
+#include <boost/array.hpp>
+#include <boost/shared_ptr.hpp>
+
+typedef std::vector<liblas::uint32_t> IDVector;
+typedef boost::shared_ptr< IDVector > IDVectorPtr;
+
+class IndexResult 
+{
+public:
+    IndexResult(uint32_t id) : bounds(), m_id(id) {}
+    // 
+    // /// Copy constructor.
+    // IndexResult(IndexResult const& other);
+
+    // /// Assignment operator.
+    // IndexResult& operator=(IndexResult const& rhs);
+        
+    IDVector const& GetIDs() const { return ids; }
+    void SetIDs(IDVector& v) {ids = v;}
+    const liblas::Bounds GetBounds() const { return bounds; }
+    void SetBounds(const liblas::Bounds b) {bounds = b;}
+    uint32_t GetID() const {return m_id;}
+    void SetID(uint32_t v) {m_id = v;}
+
+private:
+    IDVector ids;
+    liblas::Bounds bounds;
+    liblas::uint32_t m_id;
+
+};
+
+typedef std::vector<IndexResult> ResultsVector;
+class KDXIndexSummary
+{
+public:
+    KDXIndexSummary(std::istream& input);    
+    boost::shared_ptr<liblas::Bounds> bounds;
+    ResultsVector& GetResults() { return m_results; }
+private:
+    ResultsVector m_results;
+    bool m_first;    
+};
+
+KDXIndexSummary::KDXIndexSummary(std::istream& input) :  bounds(), m_first(true)
+{
+    long id_count = 0;
+    long id = 0;
+    long i = 0;
+
+    
+    double low[2];
+    double high[2];
+    
+    double mins[2];
+    double maxs[2];
+    
+    bool first = true;
+    
+    while(input) {
+        input >> id >> id_count >> low[0] >> low[1] >> high[0] >> high[1];
+        // printf("count:%d %.2f %.2f %.2f %.2f\n", id_count, low[0], low[1], high[0], high[1]);
+        
+        if (first) {
+            mins[0] = low[0];
+            mins[1] = low[1];
+            maxs[0] = high[0];
+            maxs[1] = high[1];
+            first = false;
+        }
+        
+        mins[0] = std::min(mins[0], low[0]);
+        mins[1] = std::min(mins[1], low[1]);
+        
+        maxs[0] = std::max(maxs[0], high[0]);
+        maxs[1] = std::max(maxs[1], high[1]);
+        // if (!input.good()) continue;
+        
+        IDVector ids;
+        for (int j=0; j<id_count; j++) {
+            input >> i;
+            ids.push_back(i);
+        }
+        liblas::Bounds 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);
+        m_results.push_back(result);
+    }
+
+    liblas::Bounds b2(mins[0], mins[1], maxs[0], maxs[1]);
+    (*bounds) = b2;
+}
+
 typedef struct
 {
     long* pc_ids;
@@ -369,12 +460,12 @@
 
     return true;
 }
-bool GetResultData( const LASQueryResult& result, 
+bool GetResultData( const IndexResult& result, 
                     liblas::Reader* reader, 
                     std::vector<liblas::uint8_t>& data, 
                     int nDimension)
 {
-    list<SpatialIndex::id_type> const& ids = result.GetIDs();
+    IDVector const& ids = result.GetIDs();
 
 
     // d 8-byte IEEE  big-endian doubles, where d is the PC_TOT_DIMENSIONS value
@@ -389,7 +480,7 @@
     
     data.clear();
     
-    list<SpatialIndex::id_type>::const_iterator i;
+    IDVector::const_iterator i;
     vector<liblas::uint8_t>::iterator pi;
     
     liblas::uint32_t block_id = result.GetID();
@@ -398,7 +489,7 @@
     
     for (i=ids.begin(); i!=ids.end(); ++i) 
     {
-        SpatialIndex::id_type id = *i;
+        liblas::uint32_t id = *i;
 
         bool doRead = reader->ReadPointAt(id);
         if (doRead) {
@@ -470,26 +561,22 @@
 
 }
 
-extent* GetExtent(  const SpatialIndex::Region* b,
+extent* GetExtent(  const liblas::Bounds b,
                     bool bUse3d
                  )
 {
     double x0, x1, y0, y1, z0, z1;
     // const SpatialIndex::Region* b = result.GetBounds();
 
-    x0 = b->getLow(0); 
-    x1 = b->getHigh(0); 
-    y0 = b->getLow(1); 
-    y1 = b->getHigh(1);
+    x0 = b.min(0); 
+    x1 = b.max(0); 
+    y0 = b.min(1); 
+    y1 = b.max(1);
     z0 = 0;
     z1 = 20000;
     if (bUse3d) {
-        try {
-            z0 = b->getLow(2);
-            z1 = b->getHigh(2);
-        } catch (Tools::IndexOutOfBoundsException& e) {
-            
-        }
+        z0 = b.min(2);
+        z1 = b.max(2);
     }
     extent* e = (extent*) malloc (sizeof(extent));
     e->x0 = x0; e->x1 = x1;
@@ -524,7 +611,7 @@
 
 bool FillBlocks( OWConnection* connection, 
                 OWStatement* statement,
-                const LASQueryResult& result, 
+                const IndexResult& result, 
                 liblas::Reader* reader,
                 blocks* b,
                 long index,
@@ -537,8 +624,8 @@
               )
 {
 
-
-    list<SpatialIndex::id_type> const& ids = result.GetIDs();
+    IDVector ids = result.GetIDs();
+    // list<SpatialIndex::id_type> const& ids = result.GetIDs();
     
     
     b->pc_ids[index] = pc_id;
@@ -651,7 +738,7 @@
     return true;
 }
 bool InsertBlock(OWConnection* connection, 
-                const LASQueryResult& result, 
+                const IndexResult& result, 
                 blocks* block,
                 long block_index,
                 int srid, 
@@ -664,7 +751,7 @@
 {
     ostringstream oss;
 
-    list<SpatialIndex::id_type> const& ids = result.GetIDs();
+    IDVector const& ids = result.GetIDs();
     // const SpatialIndex::Region* b = result.GetBounds();
     liblas::uint32_t num_points = ids.size();
 
@@ -767,7 +854,7 @@
 
 bool InsertBlocks(
                 OWConnection* con, 
-                const std::list<LASQueryResult>& results,
+                const ResultsVector& results,
                 long nCommitInterval, 
                 int srid, 
                 liblas::Reader* reader2, 
@@ -779,7 +866,7 @@
                 long nDimensions
                 )
 {
-    std::list<LASQueryResult>::const_iterator i;
+    IDVector::const_iterator i;
 
     long commit_interval = 1000;
     blocks* b = CreateBlock(commit_interval);
@@ -798,11 +885,11 @@
     long j = 0;
     bool inserted = false;
     
-    std::vector<LASQueryResult> results_vec = std::vector<LASQueryResult>();
-    for (i = results.begin(); i != results.end(); i++) {
-        results_vec.push_back(*i);
-    }
-    
+    // IDVector results_vec; //= std::vector<LASQueryResult>();
+    // for (i = results.begin(); i != results.end(); i++) {
+    //     results_vec.push_back(*i);
+    // }
+    // 
     long total_blocks = results.size();
     long blocks_written = 0;
     long blocks_left= 0;
@@ -822,7 +909,7 @@


More information about the Liblas-commits mailing list