[Liblas-commits] hg: Add liblas::Index back -- octree indexing by
Gary Huber
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Aug 4 14:43:30 EDT 2010
changeset 78e653b322d9 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=78e653b322d9
summary: Add liblas::Index back -- octree indexing by Gary Huber
diffstat:
include/liblas/detail/index/indexcell.hpp | 105 ++
include/liblas/detail/index/indexoutput.hpp | 76 +
include/liblas/lasindex.hpp | 263 +++++
src/CMakeLists.txt | 13 +
src/detail/index/indexcell.cpp | 277 +++++
src/detail/index/indexoutput.cpp | 392 +++++++
src/lasindex.cpp | 1408 +++++++++++++++++++++++++++
7 files changed, 2534 insertions(+), 0 deletions(-)
diffs (truncated from 2599 to 300 lines):
diff -r bbbac5b90be9 -r 78e653b322d9 include/liblas/detail/index/indexcell.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/liblas/detail/index/indexcell.hpp Wed Aug 04 13:43:22 2010 -0500
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * $Id$
+ *
+ * Project: libLAS - http://liblas.org - A BSD library for LAS format data.
+ * Purpose: index cell implementation for C++ libLAS
+ * Author: Gary Huber, gary at garyhuberart.com
+ *
+ ******************************************************************************
+ *
+ * (C) Copyright Gary Huber 2010, gary at garyhuberart.com
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of the Martin Isenburg or Iowa Department
+ * of Natural Resources nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ ****************************************************************************/
+
+#ifndef LIBLAS_DETAIL_INDEXCELL_HPP_INCLUDED
+#define LIBLAS_DETAIL_INDEXCELL_HPP_INCLUDED
+
+#include <boost/cstdint.hpp>
+#include <map>
+
+namespace liblas { namespace detail {
+
+typedef int16_t ElevExtrema;
+typedef uint32_t ElevRange;
+typedef uint8_t ConsecPtAccumulator;
+typedef std::map<uint32_t, ConsecPtAccumulator> IndexCellData;
+typedef std::map<uint32_t, IndexCellData> IndexSubCellData;
+
+class IndexCell
+{
+public:
+ IndexCell();
+
+private:
+ uint32_t m_FileOffset;
+ uint32_t m_NumPoints;
+ ElevExtrema m_MinZ, m_MaxZ;
+ IndexCellData m_PtRecords;
+ IndexSubCellData m_ZCellRecords;
+ IndexSubCellData m_SubCellRecords;
+
+public:
+ void SetFileOffset(uint32_t fos);
+ void SetNumPoints(uint32_t nmp);
+ uint32_t GetFileOffset(void) const;
+ uint32_t GetNumRecords(void) const;
+ uint32_t GetNumPoints(void) const;
+ uint32_t GetNumSubCellRecords(void) const;
+ uint32_t GetNumZCellRecords(void) const;
+ ElevExtrema GetMinZ(void) const {return m_MinZ;};
+ ElevExtrema GetMaxZ(void) const {return m_MaxZ;};
+ bool RoomToAdd(uint32_t a);
+ void AddPointRecord(uint32_t a);
+ void AddPointRecord(uint32_t a, uint8_t b);
+ bool IncrementPointRecord(uint32_t a);
+ void RemoveMainRecords(void);
+ void RemoveAllRecords(void);
+ void UpdateZBounds(double TestZ);
+ ElevRange GetZRange(void) const;
+ void AddZCell(uint32_t a, uint32_t b);
+ bool IncrementZCell(uint32_t a, uint32_t b);
+ void AddSubCell(uint32_t a, uint32_t b);
+ bool IncrementSubCell(uint32_t a, uint32_t b);
+ uint8_t GetPointRecordCount(uint32_t a);
+ const IndexCellData::iterator GetFirstRecord(void);
+ const IndexCellData::iterator GetEnd(void);
+ const IndexSubCellData::iterator GetFirstSubCellRecord(void);
+ const IndexSubCellData::iterator GetEndSubCell(void);
+ const IndexSubCellData::iterator GetFirstZCellRecord(void);
+ const IndexSubCellData::iterator GetEndZCell(void);
+
+
+};
+
+}} // namespace liblas::detail
+
+#endif // LIBLAS_DETAIL_INDEXCELL_HPP_INCLUDED
diff -r bbbac5b90be9 -r 78e653b322d9 include/liblas/detail/index/indexoutput.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/liblas/detail/index/indexoutput.hpp Wed Aug 04 13:43:22 2010 -0500
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * $Id$
+ *
+ * Project: libLAS - http://liblas.org - A BSD library for LAS format data.
+ * Purpose: index output implementation for C++ libLAS
+ * Author: Gary Huber, gary at garyhuberart.com
+ *
+ ******************************************************************************
+ *
+ * (C) Copyright Gary Huber 2010, gary at garyhuberart.com
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of the Martin Isenburg or Iowa Department
+ * of Natural Resources nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ ****************************************************************************/
+
+#ifndef LIBLAS_DETAIL_INDEXOUTPUT_HPP_INCLUDED
+#define LIBLAS_DETAIL_INDEXOUTPUT_HPP_INCLUDED
+
+#include <boost/cstdint.hpp>
+#include <liblas/lasindex.hpp>
+#include <liblas/detail/index/indexcell.hpp>
+
+namespace liblas { namespace detail {
+
+class IndexOutput
+{
+friend class liblas::Index;
+public:
+ IndexOutput(liblas::Index *indexsource);
+
+private:
+ liblas::Index *m_index;
+ liblas::VariableRecord m_indexVLRHeaderRecord, m_indexVLRCellRecord;
+ IndexVLRData m_indexVLRHeaderData, m_indexVLRCellPointData, m_indexVLRTempData;
+ uint32_t m_VLRCommonDataSize, m_VLRDataSizeLocation, m_FirstCellLocation, m_LastCellLocation, m_DataRecordSize,
+ m_TempWritePos;
+ bool m_FirstCellInVLR, m_SomeDataReadyToWrite;
+
+protected:
+ bool InitiateOutput(void);
+ bool OutputCell(liblas::detail::IndexCell *CellBlock, uint32_t CurCellX, uint32_t CurCellY);
+ bool InitializeVLRData(uint32_t CurCellX, uint32_t CurCellY);
+ bool FinalizeOutput(void);
+
+};
+
+}} // namespace liblas::detail
+
+#endif // LIBLAS_DETAIL_INDEXOUTPUT_HPP_INCLUDED
diff -r bbbac5b90be9 -r 78e653b322d9 include/liblas/lasindex.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/liblas/lasindex.hpp Wed Aug 04 13:43:22 2010 -0500
@@ -0,0 +1,263 @@
+/******************************************************************************
+ * $Id$
+ *
+ * Project: libLAS - http://liblas.org - A BSD library for LAS format data.
+ * Purpose: LAS index class
+ * Author: Gary Huber, gary at garyhuberart.com
+ *
+ ******************************************************************************
+ * Copyright (c) 2010, Gary Huber, gary at garyhuberart.com
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of the Martin Isenburg or Iowa Department
+ * of Natural Resources nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ ****************************************************************************/
+
+#ifndef LIBLAS_LASINDEX_HPP_INCLUDED
+#define LIBLAS_LASINDEX_HPP_INCLUDED
+
+#include <boost/cstdint.hpp>
+#include <liblas/lasreader.hpp>
+#include <liblas/lasheader.hpp>
+#include <liblas/lasvariablerecord.hpp>
+#include <liblas/detail/index/indexcell.hpp>
+
+// std
+#include <stdexcept> // std::out_of_range
+#include <cstdio> // file io
+#include <iostream> // file io
+#include <cstdlib> // std::size_t
+#include <vector> // std::vector
+
+namespace liblas {
+
+#define LIBLAS_INDEX_MAXMEMDEFAULT 10000000 // 10 megs default
+#define LIBLAS_INDEX_VERSIONMAJOR 1
+#define LIBLAS_INDEX_VERSIONMINOR 0
+
+typedef std::vector<uint8_t> IndexVLRData;
+typedef std::vector<liblas::detail::IndexCell> IndexCellRow;
+typedef std::vector<IndexCellRow> IndexCellDataBlock;
+
+class liblas::detail::IndexCell;
+class IndexData;
+
+/// Point data record composed with X, Y, Z coordinates and attributes.
+class Index
+{
+public:
+ Index();
+ Index(liblas::Reader *reader, std::ostream *ofs = 0, const char *tmpfilenme = 0, const char *outfilenme = 0, const char *indexauthor = 0,
+ const char *indexcomment = 0, const char *indexdate = 0,
+ double zbinht = 0.0, uint32_t maxmem = LIBLAS_INDEX_MAXMEMDEFAULT, int debugoutputlevel = 0, FILE *debugger = 0);
+ Index(std::istream *ifs, std::ostream *ofs = 0, const char *tmpfilenme = 0, const char *outfilenme = 0, const char *indexauthor = 0,
+ const char *indexcomment = 0, const char *indexdate = 0,
+ double zbinht = 0.0, uint32_t maxmem = LIBLAS_INDEX_MAXMEMDEFAULT, int debugoutputlevel = 0, FILE *debugger = 0);
+ Index(IndexData const& ParamSrc);
+ ~Index();
+
+ // Blocked copying operations, declared but not defined.
+ /// Copy constructor.
+ Index(Index const& other);
+ /// Assignment operator.
+ Index& operator=(Index const& rhs);
+
+private:
+
+ Reader *m_reader;
+ Header m_header;
+ bool m_indexBuilt, m_tempFileStarted, m_readerCreated, m_readOnly, m_forceNewIndex;
+ int m_debugOutputLevel;
+ uint32_t m_pointRecordsCount, m_maxMemoryUsage, m_cellsX, m_cellsY, m_cellsZ, m_totalCells,
+ m_tempFileWrittenBytes, m_DataVLR_ID;
+ int32_t m_LowXCellCompletelyIn, m_HighXCellCompletelyIn, m_LowYCellCompletelyIn, m_HighYCellCompletelyIn,
+ m_LowZCellCompletelyIn, m_HighZCellCompletelyIn;
+ int32_t m_LowXBorderCell, m_HighXBorderCell, m_LowYBorderCell, m_HighYBorderCell,
+ m_LowZBorderCell, m_HighZBorderCell;
+ double m_minX, m_maxX, m_minY, m_maxY, m_minZ, m_maxZ, m_scaleX, m_scaleY, m_scaleZ,
+ m_offsetX, m_offsetY, m_offsetZ, m_rangeX, m_rangeY, m_rangeZ, m_cellSizeZ, m_cellSizeX, m_cellSizeY;
+ double m_filterMinXCell, m_filterMaxXCell, m_filterMinYCell, m_filterMaxYCell, m_filterMinZCell, m_filterMaxZCell;
+ std::string m_tempFileName;
+ std::string m_outFileName;
More information about the Liblas-commits
mailing list