[Liblas-commits] r1245 - in trunk: apps include/liblas src

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Apr 20 14:05:41 EDT 2009


Author: hobu
Date: Mon Apr 20 14:05:40 2009
New Revision: 1245
URL: http://liblas.org/changeset/1245

Log:
an actually working lasindex prototype ;) 

Modified:
   trunk/apps/lasindex.cpp
   trunk/include/liblas/lasindex.hpp
   trunk/include/liblas/lasreader.hpp
   trunk/src/lasindex.cpp
   trunk/src/lasreader.cpp

Modified: trunk/apps/lasindex.cpp
==============================================================================
--- trunk/apps/lasindex.cpp	(original)
+++ trunk/apps/lasindex.cpp	Mon Apr 20 14:05:40 2009
@@ -118,4 +118,6 @@
     std::vector<liblas::uint32_t>* ids = idx->intersects(289815.12,4320979.06, 289818.01,4320982.59);
     
     std::cout << "Vec length" << ids->size() << std::endl;
+    delete reader;
+    delete istrm;
 }

Modified: trunk/include/liblas/lasindex.hpp
==============================================================================
--- trunk/include/liblas/lasindex.hpp	(original)
+++ trunk/include/liblas/lasindex.hpp	Mon Apr 20 14:05:40 2009
@@ -69,7 +69,8 @@
     LASIndex(std::string& filename);
     /// Copy constructor.
     LASIndex(LASIndex const& other);
-
+    ~LASIndex();
+    
     /// Assignment operator.
     LASIndex& operator=(LASIndex const& rhs);
     

Modified: trunk/include/liblas/lasreader.hpp
==============================================================================
--- trunk/include/liblas/lasreader.hpp	(original)
+++ trunk/include/liblas/lasreader.hpp	Mon Apr 20 14:05:40 2009
@@ -103,8 +103,8 @@
     LASPoint m_point;
     std::vector<LASVariableRecord> m_vlrs;
     
-    LASIndex* m_index;
     bool m_doindex;
+    LASIndex* m_index;
 };
 
 } // namespace liblas

Modified: trunk/src/lasindex.cpp
==============================================================================
--- trunk/src/lasindex.cpp	(original)
+++ trunk/src/lasindex.cpp	Mon Apr 20 14:05:40 2009
@@ -43,15 +43,6 @@
 #include <liblas/cstdint.hpp>
 #include <liblas/guid.hpp>
 
-//std
-// #include <algorithm>
-// #include <fstream>
-// #include <stdexcept>
-// #include <string>
-// #include <vector>
-// #include <cstring> // std::memset, std::memcpy, std::strncpy
-// #include <cassert>
-// #include <ctime>
 
 
 namespace liblas
@@ -62,7 +53,6 @@
 {
     m_storage = SpatialIndex::StorageManager::createNewLASStorageManager();
     Init();
-    // m_storage = SpatialIndex::StorageManager::createNewMemoryStorageManager();
 }
 
 void LASIndex::Init()
@@ -97,12 +87,22 @@
     int ret = stat(indexname.c_str(),&stats);
     if (!ret) {
         std::cout << "loading existing index " << indexname << std::endl;
-        m_storage = SpatialIndex::StorageManager::loadDiskStorageManager(filename);
+        try{
+            m_storage = SpatialIndex::StorageManager::loadDiskStorageManager(filename);
+        } catch (Tools::IllegalStateException& e) {
+            std::string s = e.what();
+            std::cout << "error loading index" << s <<std::endl; exit(1);
+        }
     }
     else
     {
         std::cout << "Creating new index ... " << std::endl;
-        m_storage = SpatialIndex::StorageManager::createNewDiskStorageManager(filename, 24);
+        try{
+            m_storage = SpatialIndex::StorageManager::createNewDiskStorageManager(filename, 3);
+        } catch (Tools::IllegalStateException& e) {
+            std::string s = e.what();
+            std::cout << "error creating index" << s <<std::endl; exit(1);
+        }
 	}
 
     Init();
@@ -113,6 +113,17 @@
 
 }
 
+
+LASIndex::~LASIndex() 
+{
+    std::cout << "~LASIndex called" << std::endl;
+    delete m_rtree;
+    delete m_buffer;
+    delete m_storage;
+
+}
+
+
 LASIndex& LASIndex::operator=(LASIndex const& rhs)
 {
     std::cout << "Index assignment called" << std::endl;

Modified: trunk/src/lasreader.cpp
==============================================================================
--- trunk/src/lasreader.cpp	(original)
+++ trunk/src/lasreader.cpp	Mon Apr 20 14:05:40 2009
@@ -55,10 +55,10 @@
 {
 
 LASReader::LASReader(std::istream& ifs) :
-    m_pimpl(detail::ReaderFactory::Create(ifs))
+    m_pimpl(detail::ReaderFactory::Create(ifs)),
+    m_doindex(false)
 {
-    //MakePIMPL(ifs);
-    m_doindex = false;
+    m_index = 0;
     Init();
 }
 
@@ -66,6 +66,7 @@
 {
     // empty, but required so we can implement PIMPL using
     // std::auto_ptr with incomplete type (Reader).
+    if (m_index != 0) delete m_index;
 }
 
 std::size_t LASReader::GetVersion() const


More information about the Liblas-commits mailing list