[Liblas-commits] hg: support doing 2d indexing
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri Oct 23 13:19:35 EDT 2009
changeset 6ead09c2f4b9 in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=6ead09c2f4b9
summary: support doing 2d indexing
diffstat:
apps/las2oci.cpp | 12 +++++++++++-
apps/lasindex.cpp | 27 +++++++++++----------------
include/liblas/index/datastream.hpp | 13 +++++++++++--
include/liblas/index/index.hpp | 8 ++++++++
src/index/datastream.cpp | 4 ++--
src/index/index.cpp | 4 ++--
6 files changed, 45 insertions(+), 23 deletions(-)
diffs (194 lines):
diff -r bef66b66faee -r 6ead09c2f4b9 apps/las2oci.cpp
--- a/apps/las2oci.cpp Fri Oct 23 09:24:13 2009 -0500
+++ b/apps/las2oci.cpp Fri Oct 23 12:16:35 2009 -0500
@@ -719,6 +719,7 @@
double dFillFactor = 0.99;
int srid = 0;
long precision = 8;
+ long idx_dimension = 3;
for (int i = 1; i < argc; i++)
{
@@ -769,6 +770,15 @@
i++;
srid=atoi(argv[i]);
}
+
+ else if ( strcmp(argv[i],"--idx-dimension") == 0 ||
+ strcmp(argv[i],"-dim") == 0
+ )
+ {
+ i++;
+ idx_dimension=atoi(argv[i]);
+ }
+
else if ( strcmp(argv[i],"--cloud-column-name") == 0 ||
strcmp(argv[i],"-cn") == 0
)
@@ -931,7 +941,7 @@
}
LASReader* reader = new LASReader(*istrm);
- LASIndexDataStream* idxstrm = new LASIndexDataStream(reader);
+ LASIndexDataStream* idxstrm = new LASIndexDataStream(reader, idx_dimension);
LASIndex* idx = new LASIndex(input);
idx->SetType(LASIndex::eExternalIndex);
diff -r bef66b66faee -r 6ead09c2f4b9 apps/lasindex.cpp
--- a/apps/lasindex.cpp Fri Oct 23 09:24:13 2009 -0500
+++ b/apps/lasindex.cpp Fri Oct 23 12:16:35 2009 -0500
@@ -52,7 +52,8 @@
int main(int argc, char* argv[])
{
std::string input;
- std::string output;
+
+ long dimension = 3;
for (int i = 1; i < argc; i++)
{
@@ -72,27 +73,19 @@
i++;
input = std::string(argv[i]);
}
- else if ( std::strcmp(argv[i],"--output") == 0 ||
- std::strcmp(argv[i],"--out") == 0 ||
- std::strcmp(argv[i],"-out") == 0 ||
- std::strcmp(argv[i],"-o") == 0
+ else if ( std::strcmp(argv[i],"--dimension") == 0 ||
+ std::strcmp(argv[i],"-dim") == 0 ||
+ std::strcmp(argv[i],"-d") == 0
)
{
i++;
- output = std::string(argv[i]);
+ dimension = atoi(argv[i]);
}
- else if (i == argc - 2 && output.empty() && input.empty())
+ else if (input.empty())
{
input = std::string(argv[i]);
}
- else if (i == argc - 1 && output.empty() && input.empty())
- {
- input = std::string(argv[i]);
- }
- else if (i == argc - 1 && output.empty() && input.empty())
- {
- output = std::string(argv[i]);
- }
+
else
{
usage();
@@ -110,12 +103,14 @@
LASReader* reader = new LASReader(*istrm);
std::cout << "Indexing " << input<< " "<<std::endl;
- LASIndexDataStream* idxstrm = new LASIndexDataStream(reader);
+ LASIndexDataStream* idxstrm = new LASIndexDataStream(reader, dimension);
+
LASIndex* idx = new LASIndex(input);
idx->SetType(LASIndex::eExternalIndex);
idx->SetLeafCapacity(10000);
idx->SetFillFactor(0.8);
+ idx->SetDimension(dimension);
idx->Initialize(*idxstrm);
delete idx;
diff -r bef66b66faee -r 6ead09c2f4b9 include/liblas/index/datastream.hpp
--- a/include/liblas/index/datastream.hpp Fri Oct 23 09:24:13 2009 -0500
+++ b/include/liblas/index/datastream.hpp Fri Oct 23 12:16:35 2009 -0500
@@ -65,7 +65,7 @@
class LASIndexDataStream : public SpatialIndex::IDataStream
{
public:
- LASIndexDataStream(LASReader* reader);
+ LASIndexDataStream(LASReader* reader, long dimension);
~LASIndexDataStream();
SpatialIndex::IData* getNext();
@@ -74,12 +74,21 @@
::uint32_t size() throw (Tools::NotSupportedException);
void rewind() throw (Tools::NotSupportedException);
+ /// Sets the index dimension
+ /// \param v - dimension value. Defaults to 3.
+ void SetDimension(uint32_t v) { m_idxDimension = v; }
+
+ /// Get index dimension
+ /// \return index dimension value.
+ uint32_t GetDimension() { return m_idxDimension; }
+
protected:
liblas::LASReader* m_reader;
SpatialIndex::RTree::Data* m_pNext;
SpatialIndex::id_type m_id;
-
+ uint32_t m_idxDimension;
+
bool readPoint();
};
diff -r bef66b66faee -r 6ead09c2f4b9 include/liblas/index/index.hpp
--- a/include/liblas/index/index.hpp Fri Oct 23 09:24:13 2009 -0500
+++ b/include/liblas/index/index.hpp Fri Oct 23 12:16:35 2009 -0500
@@ -146,6 +146,14 @@
/// Gets the index type
/// \return index type.
IndexType GetType() { return m_idxType; }
+
+ /// Sets the index dimension
+ /// \param v - dimension value. Defaults to 3.
+ void SetDimension(uint32_t v) { m_idxDimension = v; }
+
+ /// Get index dimension
+ /// \return index dimension value.
+ uint32_t GetDimension() { return m_idxDimension; }
LASVariableRecord* GetVLR();
diff -r bef66b66faee -r 6ead09c2f4b9 src/index/datastream.cpp
--- a/src/index/datastream.cpp Fri Oct 23 09:24:13 2009 -0500
+++ b/src/index/datastream.cpp Fri Oct 23 12:16:35 2009 -0500
@@ -57,7 +57,7 @@
-LASIndexDataStream::LASIndexDataStream(LASReader *reader) : m_reader(reader), m_pNext(0), m_id(0)
+LASIndexDataStream::LASIndexDataStream(LASReader *reader, long dimension) : m_reader(reader), m_pNext(0), m_id(0), m_idxDimension(dimension)
{
bool read = readPoint();
if (read) m_id = 0;
@@ -87,7 +87,7 @@
max[0] = x; max[1] = y; max[2] = z;
- SpatialIndex::Region r = SpatialIndex::Region(min, max, 3);
+ SpatialIndex::Region r = SpatialIndex::Region(min, max, m_idxDimension);
m_pNext = new SpatialIndex::RTree::Data(0, 0, r, m_id);
// std::cout << "Read point " << r << "Id: " << m_id << std::endl;
diff -r bef66b66faee -r 6ead09c2f4b9 src/index/index.cpp
--- a/src/index/index.cpp Fri Oct 23 09:24:13 2009 -0500
+++ b/src/index/index.cpp Fri Oct 23 12:16:35 2009 -0500
@@ -331,7 +331,7 @@
throw std::runtime_error("Spatial index has not been initialized");
try {
- m_rtree->insertData(0, 0, SpatialIndex::Region(min, max, 3), id);
+ m_rtree->insertData(0, 0, SpatialIndex::Region(min, max, m_idxDimension), id);
} catch (Tools::Exception& e) {
std::ostringstream os;
os << "Spatial Index Error: " << e.what();
@@ -361,7 +361,7 @@
std::vector<uint32_t>* vect = new std::vector<uint32_t>;
LASVisitor* visitor = new LASVisitor(vect);
- SpatialIndex::Region* region = new SpatialIndex::Region(min, max, 3);
+ SpatialIndex::Region* region = new SpatialIndex::Region(min, max, m_idxDimension);
try {
m_rtree->intersectsWithQuery(*region, *visitor);
More information about the Liblas-commits
mailing list