Log I/O
Loading...
Searching...
No Matches
LasFileReader Class Referencesealed

Class for reading LAS files. More...

Public Member Functions

IList< LasMessageGetMessages ()
 Return messages related to the previous LAS file read operation.
 
 LasFileReader (FileInfo file, string characterEncoding="ISO-8859-1")
 Create a LAS file reader for the specified disk file.
 
 LasFileReader (Stream inputStream, string characterEncoding="ISO-8859-1")
 Create a LAS file reader for the specified stream.
 

Static Public Member Functions

static string GuessEncoding (FileInfo file)
 Guess text encoding of the specified file.
 
static double IsLasFile (FileInfo file, byte[] content=null)
 Check if the specified file appears to be a LAS file.
 

Detailed Description

Class for reading LAS files.

Typical usage:

    LasFileReader reader = new LasFileReader(new FileInfo("/path/to/file.LAS"));
    IList<LasFile> lasFiles = reader.Read();

The method always returns a list of LasFile instances in case the disk file contains multiple logical files in sequence.

This class supports all versions of the LAS format.

See also
LAS 3.0 Specification
Author
Petroware AS

Constructor & Destructor Documentation

◆ LasFileReader() [1/2]

LasFileReader ( Stream inputStream,
string characterEncoding = "ISO-8859-1" )

Create a LAS file reader for the specified stream.

Parameters
inputStreamStream to read. Non-null.
characterEncodingCharacter encoding to use during file read. Typically "UTF-8", "US_ASCII" or "ISO-8859-1". Non-null. Defaults to "ISO-8859-1".
Exceptions
ArgumentNullExceptionIf inputStream or characterEncoding is null.
ArgumentExceptionIf characterEncoding is invalid.

◆ LasFileReader() [2/2]

LasFileReader ( FileInfo file,
string characterEncoding = "ISO-8859-1" )

Create a LAS file reader for the specified disk file.

Parameters
fileDisk file to read. Non-null.
characterEncodingCharacter encoding to use during file read. Typically "UTF-8", "US-ASCII" or "ISO-8859-1". Non-null. Defaults to "ISO-8859-1".
Exceptions
ArgumentNullExceptionIf file or characterEncoding is null.
ArgumentExceptionIf characterEncoding is invalid.

Member Function Documentation

◆ GetMessages()

IList< LasMessage > GetMessages ( )

Return messages related to the previous LAS file read operation.

Returns
List of messages associated with the read operation. Never null.

◆ GuessEncoding()

static string GuessEncoding ( FileInfo file)
static

Guess text encoding of the specified file.

LAS files are supposed to be encoded as US-ASCII (7 bit ASCII), but are commonly encoded differently to accomodate for meta-data using language specific characters. Such meta-data will end up wrong (typically containing replacement characters often rendered as "?" in output) if read by the standard encoding.

This method will distingusih between US-ASCII, UTF8 or 8-bit ASCII (ISO 8859-1) and does not detect more esoteric encodings like UTF16 etc.

Parameters
fileFile to check. Non-null.
Returns
The most probable encoding of the file. Returns "ISO 8859-1" if not specifically detected as US_ASCII or UTF8. Never null.
Exceptions
ArgumentNullExceptionIf file is null.

◆ IsLasFile()

static double IsLasFile ( FileInfo file,
byte[] content = null )
static

Check if the specified file appears to be a LAS file.

The check can be done with or without considering the content of the file. In the latter case, only the file name (typically its extension) is considered. In the former case a portion from the start of the file is used to match for known patterns. By passing the portion as an argument, the client code can read this once and then pass it to different classifiers in order to determine its most likely type.

Getting a portion of a file can be done by:

    FileInfo file = ...;
    BinaryReader reader = new BinaryReader(file.OpenRead());
    byte[] content = new byte[2000]; //say
    reader.Read(content, 0, content.Length);
    reader.Close();
Parameters
fileFile to check. Null to classify on content only.
contentA number of bytes from the start of the file. Null to classify on file name only.
Returns
Probability that the file is a LAS file. [0.0,1.0].

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