Log I/O
Loading...
Searching...
No Matches
ILasDataListener Interface Reference

Provides a mechanism for the client to monitor and process data during the LAS read operation, and also to abort the process if requested by the user or for other reasons. More...

Public Member Functions

bool DataRead (LasSection dataSection, LasFile lasFile)
 A notification from LasFileReader indicating that a new portion of data has been read into the specified LAS data section.
 

Detailed Description

Provides a mechanism for the client to monitor and process data during the LAS read operation, and also to abort the process if requested by the user or for other reasons.

Convenient for handling LAS files that are larger than physical memory. In this case, the client should clear the curves associated with the data section either at each invocation or at some interval.

 Typical usage:

    class DataListener : ILasDataListener
    {
      public bool DataRead(LasSection dataSection, LasFile lasFile)
      {
        // Parse LasRecords into LasCurves.
        IList<LasCurve> lasCurves = lasFile.GetCurves(dataSection);

        // Process data section
        :
        // Clear curve data to save memory
        // and to trigger new conversion on next GetCurves invocation.
        dataSection.ClearCurves();

        // Continue the process
        return true;
      }
    }

 Advanced usage: Limit number of calls to lasFile.getCurves(...) to reduce parsing overhead:

    class BatchedDataListener : ILasDataListener
    { 
       private int batchSize_;
       private int callCounter_;

       public BatchedDataListener(int batchSize){
         batchSize_ = batchSize;
       }

       public bool DataRead(LasSection dataSection, LasFile lasFile) {
         // Track number of times dataRead is called within batch size.
         callCounter_++;

         if (callCounter_ >= batchSize_) {

           // Get realized curves. This clears the DataRecords.
           IList<LasCurve> curves = lasFile.GetCurves(dataSection);

           // Process curve data
           ...

           // Remove realized curves for processed batch.
           lasFile.ClearCurves(dataSection);

           // Reset call counter 
           callCounter_ = 0;
         }

         return true;
       }
    }

   ...

    BatchedDataListener dataListener = new BatchedDataListener(batchSize);

    IList<LasFile> lasFiles = reader.Read(true, false, dataListener);

    // There may be unprocessed curve data in the lasFile if the last part of the data section is
    // smaller than the batch size.
    for (var lasFile in lasFiles ) {
      for (var dataSection in lasFile.GetDataSections()){
        // Clearing curves to ensure new conversion from LasDataRecords to List of
        // curves is triggered. Previous batch may be buffered depending on LasDataListener
        // implementation.
        lasFile.clearCurves(dataSection);

        IList<LasCurve> curves = lasFile.GetCurves(dataSection);

        // Process remaining curve data.
      }
    }

    ...

  
Author
Petroware AS

Member Function Documentation

◆ DataRead()

bool DataRead ( LasSection dataSection,
LasFile lasFile )

A notification from LasFileReader indicating that a new portion of data has been read into the specified LAS data section.

After the client has processed the data, it may clear the curve data in order to save memory storage. See LasFile.ClearCurves.

It is also possible for the client to abort the reading process at this time, by returning false from this method. This will close all resources and throw an OperationCanceledException back to the client.

NOTE: The portions of data that has been read is always a whole number of data rows, and data rows are always delivered in order.

The typical approach for processing a multi data section file in a streaming manner is to first read the file structure (no bulk-data) and subsequenlty read the file once per existing data section. In each reading cycle only data from the data section in question should be processed and data from other data sections should be ignored.

See also LasFileReader.Read(bool,bool,ILasDataListener).

Parameters
dataSectionData section that has been populated with new data. Never null.
lasFileLAS file owner of the data section. Never null.
Returns
True to continue reading, false to abort the process.

The documentation for this interface was generated from the following file: