[Liblas-commits] r1267 - in trunk: include/liblas src
liblas-commits at liblas.org
liblas-commits at liblas.org
Sat May 16 23:37:32 EDT 2009
Author: hobu
Date: Sat May 16 23:37:32 2009
New Revision: 1267
URL: http://liblas.org/changeset/1267
Log:
push the storage manager for the spatial index into the liblas:: namespace
Modified:
trunk/include/liblas/lasindex.hpp
trunk/src/lasindex.cpp
Modified: trunk/include/liblas/lasindex.hpp
==============================================================================
--- trunk/include/liblas/lasindex.hpp (original)
+++ trunk/include/liblas/lasindex.hpp Sat May 16 23:37:32 2009
@@ -45,12 +45,8 @@
#include <liblas/lasvariablerecord.hpp>
#include <liblas/laspoint.hpp>
-
-#ifdef HAVE_SPATIALINDEX
#include <spatialindex/SpatialIndex.h>
-#endif
-
//std
#include <string>
@@ -138,52 +134,6 @@
}
};
-} // namespace liblas
-
-namespace SpatialIndex
-{
-
-
- namespace StorageManager
- {
- extern IStorageManager* returnLASStorageManager(Tools::PropertySet& in);
- extern IStorageManager* createNewLASStorageManager();
-
- class LASStorageManager : public SpatialIndex::IStorageManager
- {
- public:
- LASStorageManager(Tools::PropertySet&);
-
- virtual ~LASStorageManager();
-
- virtual void loadByteArray(const id_type id, size_t& len, uint8_t** data);
- virtual void storeByteArray(id_type& id, const size_t len, const uint8_t* const data);
- virtual void deleteByteArray(const id_type id);
-
- private:
- class Entry
- {
- public:
- byte* m_pData;
- size_t m_length;
-
- Entry(size_t l, const uint8_t* const d) : m_pData(0), m_length(l)
- {
- m_pData = new uint8_t[m_length];
- memcpy(m_pData, d, m_length);
- }
-
- ~Entry() { delete[] m_pData; }
- }; // Entry
-
- std::vector<Entry*> m_buffer;
- std::stack<id_type> m_emptyPages;
- }; // MemoryStorageManager
- }
-}
-
-namespace liblas
-{
class LASDataStream : public SpatialIndex::IDataStream
{
public:
@@ -201,10 +151,51 @@
void rewind() throw (Tools::NotSupportedException);
bool readPoint();
+
+protected:
liblas::LASReader* m_reader;
SpatialIndex::RTree::Data* m_pNext;
SpatialIndex::id_type m_id;
};
+
+
+
+
+extern SpatialIndex::IStorageManager* returnLASStorageManager(Tools::PropertySet& in);
+extern SpatialIndex::IStorageManager* createNewLASStorageManager();
+
+class LASStorageManager : public SpatialIndex::IStorageManager
+{
+public:
+ LASStorageManager(Tools::PropertySet&);
+
+ virtual ~LASStorageManager();
+
+ virtual void loadByteArray(const SpatialIndex::id_type id, size_t& len, uint8_t** data);
+ virtual void storeByteArray(SpatialIndex::id_type& id, const size_t len, const uint8_t* const data);
+ virtual void deleteByteArray(const SpatialIndex::id_type id);
+
+private:
+ class Entry
+ {
+ public:
+ byte* m_pData;
+ size_t m_length;
+
+ Entry(size_t l, const uint8_t* const d) : m_pData(0), m_length(l)
+ {
+ m_pData = new uint8_t[m_length];
+ memcpy(m_pData, d, m_length);
+ }
+
+ ~Entry() { delete[] m_pData; }
+ }; // Entry
+
+ std::vector<Entry*> m_buffer;
+ std::stack<SpatialIndex::id_type> m_emptyPages;
+}; // MemoryStorageManager
+
+
}
#endif // LIBLAS_LASINDEX_HPP_INCLUDED
Modified: trunk/src/lasindex.cpp
==============================================================================
--- trunk/src/lasindex.cpp (original)
+++ trunk/src/lasindex.cpp Sat May 16 23:37:32 2009
@@ -57,7 +57,7 @@
LASIndex::LASIndex()
{
- m_storage = SpatialIndex::StorageManager::createNewLASStorageManager();
+ m_storage = createNewLASStorageManager();
Init();
}
@@ -111,7 +111,7 @@
std::string s = e.what();
std::cout << "error creating index" << s <<std::endl; exit(1);
}
- }
+ }
Init();
}
@@ -187,111 +187,106 @@
}
-} // namespace liblas
-
-SpatialIndex::IStorageManager* SpatialIndex::StorageManager::returnLASStorageManager(Tools::PropertySet& ps)
+SpatialIndex::IStorageManager* returnLASStorageManager(Tools::PropertySet& ps)
{
- IStorageManager* sm = new LASStorageManager(ps);
- return sm;
+ SpatialIndex::IStorageManager* sm = new LASStorageManager(ps);
+ return sm;
}
-SpatialIndex::IStorageManager* SpatialIndex::StorageManager::createNewLASStorageManager()
+SpatialIndex::IStorageManager* createNewLASStorageManager()
{
- Tools::PropertySet ps;
- return returnLASStorageManager(ps);
+ Tools::PropertySet ps;
+ return returnLASStorageManager(ps);
}
-SpatialIndex::StorageManager::LASStorageManager::LASStorageManager(Tools::PropertySet& ps)
+LASStorageManager::LASStorageManager(Tools::PropertySet& ps)
{
}
-SpatialIndex::StorageManager::LASStorageManager::~LASStorageManager()
+LASStorageManager::~LASStorageManager()
{
- for (std::vector<Entry*>::iterator it = m_buffer.begin(); it != m_buffer.end(); it++) delete *it;
+ for (std::vector<Entry*>::iterator it = m_buffer.begin(); it != m_buffer.end(); it++) delete *it;
}
-void SpatialIndex::StorageManager::LASStorageManager::loadByteArray(const id_type id, size_t& len, uint8_t** data)
+void LASStorageManager::loadByteArray(const SpatialIndex::id_type id, size_t& len, uint8_t** data)
{
- Entry* e;
- try
- {
- e = m_buffer.at(id);
- if (e == 0) throw Tools::InvalidPageException(id);
- }
- catch (std::out_of_range)
- {
- throw Tools::InvalidPageException(id);
- }
+ Entry* e;
+ try
+ {
+ e = m_buffer.at(id);
+ if (e == 0) throw Tools::InvalidPageException(id);
+ }
+ catch (std::out_of_range)
+ {
+ throw Tools::InvalidPageException(id);
+ }
- len = e->m_length;
- *data = new uint8_t[len];
+ len = e->m_length;
+ *data = new uint8_t[len];
- memcpy(*data, e->m_pData, len);
+ memcpy(*data, e->m_pData, len);
}
-void SpatialIndex::StorageManager::LASStorageManager::storeByteArray(id_type& id, const size_t len, const uint8_t* const data)
+void LASStorageManager::storeByteArray(SpatialIndex::id_type& id, const size_t len, const uint8_t* const data)
{
- if (id == NewPage)
- {
- Entry* e = new Entry(len, data);
+ if (id == SpatialIndex::StorageManager::NewPage)
+ {
+ Entry* e = new Entry(len, data);
- if (m_emptyPages.empty())
- {
- m_buffer.push_back(e);
- id = m_buffer.size() - 1;
- }
- else
- {
- id = m_emptyPages.top(); m_emptyPages.pop();
- m_buffer[id] = e;
- }
- }
- else
- {
- Entry* e_old;
- try
- {
- e_old = m_buffer.at(id);
- if (e_old == 0) throw Tools::InvalidPageException(id);
- }
- catch (std::out_of_range)
- {
- throw Tools::InvalidPageException(id);
- }
+ if (m_emptyPages.empty())
+ {
+ m_buffer.push_back(e);
+ id = m_buffer.size() - 1;
+ }
+ else
+ {
+ id = m_emptyPages.top(); m_emptyPages.pop();
+ m_buffer[id] = e;
+ }
+ }
+ else
+ {
+ Entry* e_old;
+ try
+ {
+ e_old = m_buffer.at(id);
+ if (e_old == 0) throw Tools::InvalidPageException(id);
+ }
+ catch (std::out_of_range)
+ {
+ throw Tools::InvalidPageException(id);
+ }
- Entry* e = new Entry(len, data);
+ Entry* e = new Entry(len, data);
- delete e_old;
- m_buffer[id] = e;
- }
+ delete e_old;
+ m_buffer[id] = e;
+ }
}
-void SpatialIndex::StorageManager::LASStorageManager::deleteByteArray(const id_type id)
+void LASStorageManager::deleteByteArray(const SpatialIndex::id_type id)
{
- Entry* e;
- try
- {
- e = m_buffer.at(id);
- if (e == 0) throw Tools::InvalidPageException(id);
- }
- catch (std::out_of_range)
- {
- throw Tools::InvalidPageException(id);
- }
+ Entry* e;
+ try
+ {
+ e = m_buffer.at(id);
+ if (e == 0) throw Tools::InvalidPageException(id);
+ }
+ catch (std::out_of_range)
+ {
+ throw Tools::InvalidPageException(id);
+ }
- m_buffer[id] = 0;
- m_emptyPages.push(id);
+ m_buffer[id] = 0;
+ m_emptyPages.push(id);
- delete e;
+ delete e;
}
-namespace liblas
-{
-
LASDataStream::LASDataStream(LASReader *reader) : m_reader(reader), m_pNext(0), m_id(0)
More information about the Liblas-commits
mailing list