42 #ifndef LIBLAS_LASINDEX_HPP_INCLUDED 43 #define LIBLAS_LASINDEX_HPP_INCLUDED 49 #include <liblas/detail/index/indexcell.hpp> 61 #define LIBLAS_INDEX_MAXMEMDEFAULT 10000000 // 10 megs default 62 #define LIBLAS_INDEX_MINMEMDEFAULT 1000000 // 1 meg at least has to be allowed 63 #define LIBLAS_INDEX_VERSIONMAJOR 1 64 #define LIBLAS_INDEX_VERSIONMINOR 2 // minor version 2 begins 11/15/10 65 #define LIBLAS_INDEX_MAXSTRLEN 512 66 #define LIBLAS_INDEX_MAXCELLS 250000 67 #define LIBLAS_INDEX_OPTPTSPERCELL 100 68 #define LIBLAS_INDEX_MAXPTSPERCELL 1000 69 #define LIBLAS_INDEX_RESERVEFILTERDEFAULT 1000000 // 1 million points will be reserved on large files for filter result 73 #define LIBLAS_INDEX_PADLASTVLR 139 bool m_indexBuilt, m_tempFileStarted, m_readerCreated, m_readOnly, m_writestandaloneindex, m_forceNewIndex;
140 int m_debugOutputLevel;
141 uint8_t m_versionMajor, m_versionMinor;
142 uint32_t m_pointRecordsCount, m_maxMemoryUsage, m_cellsX, m_cellsY, m_cellsZ, m_totalCells,
144 liblas::detail::TempFileOffsetType m_tempFileWrittenBytes;
145 double m_rangeX, m_rangeY, m_rangeZ, m_cellSizeZ, m_cellSizeX, m_cellSizeY;
146 std::string m_tempFileName;
147 std::string m_indexAuthor;
148 std::string m_indexComment;
149 std::string m_indexDate;
150 std::vector<uint32_t> m_filterResult;
152 FILE *m_tempFile, *m_outputFile;
155 void SetValues(
void);
156 bool IndexInit(
void);
157 void ClearOldIndex(
void);
158 bool BuildIndex(
void);
160 uint32_t GetDefaultReserve(
void);
162 void SetCellFilterBounds(
IndexData & ParamSrc);
164 bool FilterPointSeries(uint32_t & PointID, uint32_t & PointsScanned,
165 uint32_t
const PointsToIgnore, uint32_t
const x, uint32_t
const y, uint32_t
const z,
166 liblas::detail::ConsecPtAccumulator
const ConsecutivePts,
IndexIterator *Iterator,
168 bool VLRInteresting(int32_t MinCellX, int32_t MinCellY, int32_t MaxCellX, int32_t MaxCellY,
170 bool CellInteresting(int32_t x, int32_t y,
IndexData const& ParamSrc);
171 bool SubCellInteresting(int32_t SubCellID, int32_t XCellID, int32_t YCellID,
IndexData const& ParamSrc);
172 bool ZCellInteresting(int32_t ZCellID,
IndexData const& ParamSrc);
173 bool FilterOnePoint(int32_t x, int32_t y, int32_t z, int32_t PointID, int32_t LastPointID,
bool &LastPtRead,
176 bool IdentifyCell(
Point const& CurPt, uint32_t& CurCellX, uint32_t& CurCellY)
const;
178 bool IdentifyCellZ(
Point const& CurPt, uint32_t& CurCellZ)
const;
180 bool IdentifySubCell(
Point const& CurPt, uint32_t x, uint32_t y, uint32_t& CurSubCell)
const;
182 bool PurgePointsToTempFile(IndexCellDataBlock& CellBlock);
184 bool LoadCellFromTempFile(liblas::detail::IndexCell *CellBlock,
185 uint32_t CurCellX, uint32_t CurCellY);
187 FILE *OpenTempFile(
void);
189 void CloseTempFile(
void);
192 bool SaveIndexInLASFile(
void);
194 bool SaveIndexInStandAloneFile(
void);
196 void CalcRangeX(
void) {m_rangeX = (m_bounds.
max)(0) - (m_bounds.
min)(0);}
197 void CalcRangeY(
void) {m_rangeY = (m_bounds.
max)(1) - (m_bounds.
min)(1);}
198 void CalcRangeZ(
void) {m_rangeZ = (m_bounds.
max)(2) - (m_bounds.
min)(2);}
201 bool FileError(
const char *Reporter);
202 bool InputFileError(
const char *Reporter)
const;
203 bool OutputFileError(
const char *Reporter)
const;
204 bool DebugOutputError(
const char *Reporter)
const;
205 bool PointCountError(
const char *Reporter)
const;
206 bool PointBoundsError(
const char *Reporter)
const;
207 bool MemoryError(
const char *Reporter)
const;
208 bool InitError(
const char *Reporter)
const;
209 bool InputBoundsError(
const char *Reporter)
const;
212 bool OutputCellStats(IndexCellDataBlock& CellBlock)
const;
213 bool OutputCellGraph(std::vector<uint32_t> CellPopulation, uint32_t MaxPointsPerCell)
const;
222 const std::vector<uint32_t>& Filter(
IndexData & ParamSrc);
224 IndexIterator* Filter(
double LowFilterX,
double HighFilterX,
double LowFilterY,
double HighFilterY,
225 double LowFilterZ,
double HighFilterZ, uint32_t ChunkSize);
266 const char *GetIndexAuthorStr(
void)
const;
267 const char *GetIndexCommentStr(
void)
const;
268 const char *GetIndexDateStr(
void)
const;
358 bool SetInitialValues(std::istream *ifs = 0,
Reader *reader = 0, std::ostream *ofs = 0,
Reader *idxreader = 0,
359 const char *tmpfilenme = 0,
const char *indexauthor = 0,
360 const char *indexcomment = 0,
const char *indexdate = 0,
double zbinht = 0.0,
362 bool writestandaloneindex = 0,
bool forcenewindex = 0, FILE *debugger = 0);
365 bool SetBuildEmbedValues(
Reader *reader, std::ostream *ofs,
const char *tmpfilenme,
const char *indexauthor = 0,
366 const char *indexcomment = 0,
const char *indexdate = 0,
double zbinht = 0.0,
370 bool SetBuildAloneValues(
Reader *reader, std::ostream *ofs,
const char *tmpfilenme,
const char *indexauthor = 0,
371 const char *indexcomment = 0,
const char *indexdate = 0,
double zbinht = 0.0,
375 bool SetReadEmbedValues(
Reader *reader,
int debugoutputlevel = 0, FILE *debugger = 0);
378 bool SetReadAloneValues(
Reader *reader,
Reader *idxreader,
int debugoutputlevel = 0, FILE *debugger = 0);
382 bool SetReadOrBuildEmbedValues(
Reader *reader, std::ostream *ofs,
const char *tmpfilenme,
const char *indexauthor = 0,
383 const char *indexcomment = 0,
const char *indexdate = 0,
double zbinht = 0.0,
388 bool SetReadOrBuildAloneValues(
Reader *reader, std::ostream *ofs,
const char *tmpfilenme,
const char *indexauthor = 0,
389 const char *indexcomment = 0,
const char *indexdate = 0,
double zbinht = 0.0,
393 bool SetFilterValues(
double LowFilterX,
double HighFilterX,
double LowFilterY,
double HighFilterY,
double LowFilterZ,
double HighFilterZ,
403 void SetValues(
void);
404 bool CalcFilterEnablers(
void);
420 int32_t m_LowXCellCompletelyIn, m_HighXCellCompletelyIn, m_LowYCellCompletelyIn, m_HighYCellCompletelyIn,
422 int32_t m_LowXBorderCell, m_HighXBorderCell, m_LowYBorderCell, m_HighYBorderCell,
442 const char *GetIndexAuthorStr(
void)
const;
443 const char *GetIndexCommentStr(
void)
const;
444 const char *GetIndexDateStr(
void)
const;
460 void SetMaxMem(uint32_t maxmem) {m_maxMemoryUsage = maxmem;}
480 IndexIterator(
Index *IndexSrc,
double LowFilterX,
double HighFilterX,
double LowFilterY,
double HighFilterY,
481 double LowFilterZ,
double HighFilterZ, uint32_t ChunkSize);
490 void ResetPosition(
void);
491 uint8_t MinMajorVersion(
void) {
return(1);}
492 uint8_t MinMinorVersion(
void) {
return(2);}
496 const std::vector<uint32_t>& advance(int32_t n);
498 const std::vector<uint32_t>& operator()(int32_t n);
500 inline const std::vector<uint32_t>&
operator++() {
return (advance(1));}
502 inline const std::vector<uint32_t>&
operator++(
int) {
return (advance(1));}
504 inline const std::vector<uint32_t>&
operator--() {
return (advance(-1));}
506 inline const std::vector<uint32_t>&
operator--(
int) {
return (advance(-1));}
508 inline const std::vector<uint32_t>&
operator+=(int32_t n) {
return (advance(n));}
510 inline const std::vector<uint32_t>&
operator+(int32_t n) {
return (advance(n));}
512 inline const std::vector<uint32_t>&
operator-=(int32_t n) {
return (advance(-n));}
514 inline const std::vector<uint32_t>&
operator-(int32_t n) {
return (advance(-n));}
516 inline const std::vector<uint32_t>&
operator[](int32_t n) {
return ((*
this)(n));}
518 bool ValidateIndexVersion(uint8_t VersionMajor, uint8_t VersionMinor) {
return (VersionMajor > MinMajorVersion() || (VersionMajor == MinMajorVersion() && VersionMinor >= MinMinorVersion()));}
521 template <
typename T,
typename Q>
525 if (static_cast<size_t>(pos) +
sizeof(T) > src.size())
526 throw std::out_of_range(
"liblas::detail::ReadVLRData_n: array index out of range");
528 memcpy(&dest, &src[pos],
sizeof(T));
530 LIBLAS_SWAP_BYTES_N(dest,
sizeof(T));
532 pos = pos +
static_cast<Q
>(
sizeof(T));
535 template <
typename T,
typename Q>
539 if (static_cast<size_t>(pos) +
sizeof(T) > src.size())
540 throw std::out_of_range(
"liblas::detail::ReadVLRDataNoInc_n: array index out of range");
542 memcpy(&dest, &src[pos],
sizeof(T));
544 LIBLAS_SWAP_BYTES_N(dest,
sizeof(T));
547 template <
typename T,
typename Q>
551 if (static_cast<size_t>(pos) + static_cast<size_t>(srclen) > src.size())
552 throw std::out_of_range(
"liblas::detail::ReadeVLRData_str: array index out of range");
554 memcpy(dest, &src[pos], srclen);
556 pos = pos +
static_cast<Q
>(srclen);
559 template <
typename T,
typename Q>
563 if (static_cast<size_t>(pos) + static_cast<size_t>(srclen) > src.size())
564 throw std::out_of_range(
"liblas::detail::ReadVLRDataNoInc_str: array index out of range");
566 std::memcpy(dest, &src[pos], srclen);
571 #endif // LIBLAS_LASINDEX_HPP_INCLUDED bool GetForceNewIndex(void) const
Definition: index.hpp:437
IndexData m_indexData
Definition: index.hpp:472
void SetIndexAuthorStr(const char *ias)
Definition: index.hpp:274
void ReadVLRData_n(T &dest, IndexVLRData const &src, Q &pos)
Definition: index.hpp:522
void ReadVLRDataNoInc_n(T &dest, IndexVLRData const &src, Q const &pos)
Definition: index.hpp:536
void SetDebugOutputLevel(int debugoutputlevel)
Definition: index.hpp:461
bool GetStandaloneIndex(void) const
Definition: index.hpp:436
Reader * m_idxreader
Definition: index.hpp:409
const std::vector< uint32_t > & operator-=(int32_t n)
returns set of filter-compliant points beginning n points backwards from the end of the last set...
Definition: index.hpp:512
uint32_t GetCellsY(void) const
Definition: index.hpp:244
uint32_t GetCellsX(void) const
Definition: index.hpp:243
Representation of variable-length record data.
Definition: variablerecord.hpp:59
IndexIterator * GetIterator(void)
Definition: index.hpp:430
#define LAS_DLL
Definition: export.hpp:58
double GetRangeX(void) const
Definition: index.hpp:236
Reader * GetReader(void) const
Definition: index.hpp:439
const std::vector< uint32_t > & operator++()
returns next set of filter-compliant points with no skipped points
Definition: index.hpp:500
void SetIndexCommentStr(const char *ics)
Definition: index.hpp:275
const std::vector< uint32_t > & operator[](int32_t n)
returns filter-compliant points as though the first point returned is element n in a zero-based array...
Definition: index.hpp:516
FILE * m_debugger
Definition: index.hpp:427
double GetMaxFilterY(void) const
Definition: index.hpp:448
uint8_t GetVersionMinor(void) const
Definition: index.hpp:270
class LAS_DLL IndexIterator
Definition: index.hpp:80
void SetCellsX(uint32_t cellsX)
Definition: index.hpp:284
double m_LowYBorderPartCell
Definition: index.hpp:419
const std::vector< uint32_t > & operator++(int)
returns next set of filter-compliant points with no skipped points
Definition: index.hpp:502
bool GetStandaloneIndex(void) const
Definition: index.hpp:255
std::istream * m_ifs
Definition: index.hpp:412
Bounds< double > m_filter
Definition: index.hpp:411
void SetDebugger(FILE *debugger)
Definition: index.hpp:464
int32_t m_LowZBorderCell
Definition: index.hpp:422
void SetReader(Reader *reader)
Definition: index.hpp:452
FILE * GetDebugger(void) const
Definition: index.hpp:253
Index * m_index
Definition: index.hpp:473
bool GetForceNewIndex(void) const
Definition: index.hpp:256
double GetMaxY(void) const
Definition: index.hpp:232
Reader * GetIndexReader(void) const
Definition: index.hpp:263
int GetDebugOutputLevel(void) const
Definition: index.hpp:440
bool m_writestandaloneindex
Definition: index.hpp:426
double GetMinZ(void) const
Definition: index.hpp:233
void SetMinX(double minX)
Definition: index.hpp:277
double GetMaxFilterX(void) const
Definition: index.hpp:446
void SetMaxY(double maxY)
Definition: index.hpp:280
const char * m_tempFileName
Definition: index.hpp:414
const char * m_indexComment
Definition: index.hpp:416
const std::vector< uint32_t > & operator+=(int32_t n)
returns next set of filter-compliant points with n-1 skipped points, for n<0 acts like -=() ...
Definition: index.hpp:508
void SetOStream(std::ostream *ofs)
Definition: index.hpp:454
double GetMinFilterZ(void) const
Definition: index.hpp:449
void SetStandaloneIndex(bool writestandaloneindex)
Definition: index.hpp:463
uint32_t m_maxMemoryUsage
Definition: index.hpp:424
Definition: index.hpp:346
class LAS_DLL IndexData
Definition: index.hpp:79
IndexIterator * m_iterator
Definition: index.hpp:410
double GetMaxX(void) const
Definition: index.hpp:230
const char * GetTempFileName(void) const
Definition: index.hpp:441
void SetCellsY(uint32_t cellsY)
Definition: index.hpp:285
FILE * GetDebugger(void) const
Definition: index.hpp:434
void SetIndexComment(const char *indexcomment)
Definition: index.hpp:457
std::vector< IndexCellRow > IndexCellDataBlock
Definition: index.hpp:77
uint32_t GetCellsZ(void) const
Definition: index.hpp:246
const char * m_indexDate
Definition: index.hpp:417
Header * GetIndexHeader(void)
Definition: index.hpp:261
void SetPointRecordsCount(uint32_t prc)
Definition: index.hpp:283
void SetIterator(IndexIterator *setIt)
Definition: index.hpp:429
void SetIndexDateStr(const char *ids)
Definition: index.hpp:276
std::vector< liblas::detail::IndexCell > IndexCellRow
Definition: index.hpp:76
void SetCellsZ(uint32_t cellsZ)
Definition: index.hpp:286
Definition: index.hpp:467
const char * m_indexAuthor
Definition: index.hpp:415
bool IndexFailed(void) const
Definition: index.hpp:217
Bounds< double > const & GetBounds(void) const
Definition: index.hpp:239
Defines public interface to LAS reader implementation.
Definition: reader.hpp:66
uint32_t GetMaxMemoryUsage(void) const
Definition: index.hpp:438
Definition: index.hpp:119
double GetCellSizeZ(void) const
Definition: index.hpp:251
int32_t m_LowZCellCompletelyIn
Definition: index.hpp:420
void SetIndexAuthor(const char *indexauthor)
Definition: index.hpp:456
void SetMaxZ(double maxZ)
Definition: index.hpp:282
bool IndexReady(void) const
Definition: index.hpp:218
Header * GetPointHeader(void)
Definition: index.hpp:260
uint32_t m_conformingPtsFound
Definition: index.hpp:477
std::vector< uint8_t > IndexVLRData
Definition: index.hpp:75
int GetDebugOutputLevel(void) const
Definition: index.hpp:258
void SetMaxMem(uint32_t maxmem)
Definition: index.hpp:460
Reader * m_reader
Definition: index.hpp:408
double m_cellSizeZ
Definition: index.hpp:418
void SetMaxX(double maxX)
Definition: index.hpp:278
Namespace grouping all elements of libLAS public interface.
Definition: bounds.hpp:60
Reader * GetReader(void) const
Definition: index.hpp:262
T() max(std::size_t const &index) const
Definition: bounds.hpp:307
void SetMinZ(double minZ)
Definition: index.hpp:281
int m_debugOutputLevel
Definition: index.hpp:425
void SetTmpFileName(const char *tmpfilenme)
Definition: index.hpp:455
T() min(std::size_t const &index) const
Definition: bounds.hpp:287
void ReadeVLRData_str(char *dest, IndexVLRData const &src, T const srclen, Q &pos)
Definition: index.hpp:548
const char * GetTempFileName(void) const
Definition: index.hpp:264
double GetMaxFilterZ(void) const
Definition: index.hpp:450
Point data record composed with X, Y, Z coordinates and attributes.
Definition: point.hpp:68
const std::vector< uint32_t > & operator--(int)
returns set of filter-compliant points skipping backwards 1 from the end of the last set ...
Definition: index.hpp:506
bool GetReadOnly(void) const
Definition: index.hpp:254
uint32_t GetDataVLR_ID(void) const
Definition: index.hpp:249
const std::vector< uint32_t > & operator+(int32_t n)
returns next set of filter-compliant points with n-1 skipped points, for n<0 acts like -() ...
Definition: index.hpp:510
void ReadVLRDataNoInc_str(char *dest, IndexVLRData const &src, T const srclen, Q pos)
Definition: index.hpp:560
const std::vector< uint32_t > & operator-(int32_t n)
returns set of filter-compliant points beginning n points backwards from the end of the last set...
Definition: index.hpp:514
const std::vector< uint32_t > & operator--()
returns set of filter-compliant points skipping backwards 1 from the end of the last set ...
Definition: index.hpp:504
std::ostream * m_ofs
Definition: index.hpp:413
uint32_t GetMaxMemoryUsage(void) const
Definition: index.hpp:257
void SetReadOnly(bool readonly)
Definition: index.hpp:462
void SetIndexDate(const char *indexdate)
Definition: index.hpp:458
void SetDataVLR_ID(uint32_t DataVLR_ID)
Definition: index.hpp:273
double GetMinX(void) const
Definition: index.hpp:229
void SetMinY(double minY)
Definition: index.hpp:279
double GetMinFilterY(void) const
Definition: index.hpp:447
double GetMinY(void) const
Definition: index.hpp:231
uint32_t m_totalPointsScanned
Definition: index.hpp:475
uint32_t GetPointRecordsCount(void) const
Definition: index.hpp:241
void SetCellSizeZ(double cellsizez)
Definition: index.hpp:459
double GetRangeY(void) const
Definition: index.hpp:237
bool GetReadOnly(void) const
Definition: index.hpp:435
uint32_t m_chunkSize
Definition: index.hpp:474
Definition: schema.hpp:80
#define LIBLAS_INDEX_MAXMEMDEFAULT
Definition: index.hpp:61
bool ValidateIndexVersion(uint8_t VersionMajor, uint8_t VersionMinor)
tests viability of index for filtering with iterator
Definition: index.hpp:518
double GetRangeZ(void) const
Definition: index.hpp:238
double GetMinFilterX(void) const
Definition: index.hpp:445
double GetCellSizeZ(void) const
Definition: index.hpp:433
void SetIStream(std::istream *ifs)
Definition: index.hpp:453
double GetMaxZ(void) const
Definition: index.hpp:234
uint8_t GetVersionMajor(void) const
Definition: index.hpp:269