Liblas Study Notes 2-build grid indexes and liblas Study Notes

Source: Internet
Author: User

Liblas Study Notes 2-build grid indexes and liblas Study Notes

The main code file is index. hpp index. cpp.

Index. hpp defines several macros

// Maximum memory limit. The default value is 10 MB.

# Define LIBLAS_INDEX_MAXMEMDEFAULT 10000000 // 10 megs default

// Minimum Memory, 1 MB by default

# Define LIBLAS_INDEX_MINMEMDEFAULT 1000000 // 1 meg at least has to be allowed

// Maximum number of grids, up to 0.25 million

# Deprecision LIBLAS_INDEX_MAXCELLS 250000

// Average number of vertices in each grid. The default value is 100.

# Define LIBLAS_INDEX_OPTPTSPERCELL 100

// Average the maximum number of points in each grid. The reference is not found in the whole cpp. It is useless and meaningless.

# Define LIBLAS_INDEX_MAXPTSPERCELL 1000

 

There are two main types of indexes: IndexData and Index. IndexData provides Index-related parameters. Before creating an Index, you must construct an IndexData object. The setting of the IndexData object parameter value is directly related to the Index construction of the Index object.

 

(1) construct an IndexData object

The IndexData class provides three constructor functions: No parameter, copy constructor, and Index object initialization function. Because the Index and IndexData objects have the same attributes: m_reader, You can initialize these attributes for each other.

(2) Set index building Parameters

Liblas provides multiple parameter setting functions. SetInitialValues can be used to set all parameters and function prototype.

Bool SetInitialValues (std: istream * ifs = 0, Reader * reader = 0, std: ostream * ofs = 0, Reader * idxreader = 0,

Const char * tmpfilenme = 0, constchar * indexauthor = 0,

Const char * indexcomment = 0, constchar * indexdate = 0, doublezbinht = 0.0,

Boost: uint32_t maxmem = LIBLAS_INDEX_MAXMEMDEFAULT, intdebugoutputlevel = 0, bool readonly = 0,

Boolwritestandaloneindex = 0, bool forcenewindex = 0, FILE * debugger = 0 );

Ifs: Input las file; reader: Reader object corresponding to the input file; ofs: output file. If the index is set to a separate file, this is the output index file, if you set the index to be included in the source las file, a new file will be created, which contains the index + Source las file. Tmpfilenme: name of the new file; indexauthor, indexcomment, indexdate: basic information of the index file;

Zbinht: grid size in the Z direction; maxmen: Memory limit; debugoutputlevel: debug information output level; writestandaloneindex: 1, the index file is used as a separate file, if the value is 0, the index file is a file with the source las file. forcenewindex: If the value is 1, an index is created no matter whether the index file exists. If the value is 0, if an index already exists, it will not be rebuilt;

(3) construct an Index object

Liblas: IndexindexPt (indexData );

(4) set the queryer

IndexData. SetFilterValues (dftXMin, dftXMax, dftYMin, dftYMax, dftZMin, dftZMax, indexPt );

(5) execute the query

Constvector <boost: uint32_t> resultPtsIDVec = indexPt. Filter (indexData );

Code

Const char * pSrcFileName = "D :\\ pipeline_5G.las"; const char * pIndexTempFilePath = "D: \ temp_index"; const char * pTempFileName = "IndexTemp "; // const char * pDesFileName = "D: \ dem. tif "; std: ifstream ifs; ifs. open (pSrcFileName, std: ios: in | std: ios: binary); if (ifs = NULL) {cout <"null" <endl ;} std: ofstream ofs; ofs. open (pIndexTempFilePath, std: ios: out | std: ios: binary); // std: ifstream ifsIndex; // ifsIndex. open (pIndexFilePath, std: ios: in | std: ios: binary); liblas: ReaderFactory f; liblas: Reader reader = f. createWithStream (ifs); // liblas: Reader readerID = f. createWithStream (ifsIndex); liblas: Header const & header = reader. getHeader (); printf ("Points count: % d \ n", header. getPointRecordsCount (); // calculate the maximum and minimum values of double dXMin = header. getMinX (); double dXMax = header. getMaxX (); double dYMin = header. getMinY (); double dYMax = header. getMaxY (); double dZMin = header. getMinZ (); double dZMax = header. getMaxZ (); const char * pIndexAut = "ryb"; const char * pIndexComm = "test1"; const char * pIndexDate = "20140923"; liblas: IndexData indexData; indexData. setInitialValues (& ifs, & reader, & ofs, NULL, pTempFileName, pIndexAut, pIndexComm, pIndexDate, 0, 000000000u, 2, false, 0); indexData. setBuildEmbedValues (& reader, & ofs, pTempFileName, pIndexAut, pIndexComm, pIndexDate, 0, 100000000U, 2, 0); // set the index file to include liblas in the las file :: index indexPt (indexData); cout <"Cell size is X:" <indexPt. getCellsX () <"Y" <indexPt. getCellsY () <"Z" <indexPt. getCellsZ () <endl; double dftXMin = dXMin; double dftXMax = dXMax; double dftYMin = dYMin + 500; double dftYMax = dYMax-220; double dftZMax = dZMax-100; double dftZMin = dZMin + 20; indexData. setFilterValues (dftXMin, dftXMax, dftYMin, dftYMax, dftZMin, dftZMax, indexPt); const vector <boost: uint32_t> resultPtsIDVec = indexPt. filter (indexData); double tt21 = MPI_Wtime (); cout <resultPtsIDVec. size () <endl;





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.