Last updated

API / geotoolkit / las / Las20Stream / Las20Stream

Class: Las20Stream

las.Las20Stream.Las20Stream

This class implements a LAS 2.0 parser using a stream paradigm.

This parser implements an API similar to Las20 for convenience.
Therefore it will provide las sections and las section group like a regular LASParser.

However this stream parser has to be 'opened' to trigger the loading of the stream and the parsing of the sections.
When opening the stream, only the header sections will be loaded and parsed (Version, Well, Curve, Parameter, Other).
The data section won't be loaded nor parsed by default.

As a result, 'bulk' access to the data using (for example) 'group.getCurveData' will not work.
However the LasStreamDataSection provides new ways of accessing the data like getDataInRange(startDepth, endDepth).

Note that, as the LAS 2.0 format has no index, this parser will index it on the fly.
As a consequence, initial getDataInRange calls on a this parser may take longer than subsequent ones.

Also, to access the data in a not stream based way, it can be forced to read its content fully during the open().
This is discouraged as the purpose of the LasStreamParser is to avoid loading the whole LAS data in memory (to prevent memory issues for large datasets).
If opened in this 'full load' mode, the 'bulk' access to the data will work.

See the documentation of the open() function for more details.

Hierarchy

Table of contents

Constructors
Methods

Contents

Constructors

new Las20Stream(options)

new Las20Stream(options)

Constructor

Parameters

Name Type Description
optionsOptionsThe options

Overrides

LasStreamParser.constructor

Methods

getClassName

getClassName(): string

Returns

string

Inherited from

LasStreamParser.getClassName


getSectionGroups

getSectionGroups(): LasSectionGroup[]

Gets all the section groups. Doesn't include sections not in groups.

Returns

LasSectionGroup[]

array of LasSectionGroup

Overrides

LasStreamParser.getSectionGroups


getSections

getSections(): LasParameterSection[]

Returns all sections not part of a group

Returns

LasParameterSection[]

array of LasSection

Overrides

LasStreamParser.getSections


open

open(fullload, success?, error?): Promise<Las20Stream>

Opens the LAS 2.0 stream and parse its headers.

The stream can also be opened in 'legacy mode' in order to be accessed like a non-stream based parser.
However this is discouraged as it can lead to memory issues for huge dataset.

Once this stream has been opened, its 'header' sections can be accessed using getSections().
See example for accessing the data in either 'legacy/non-stream' mode or 'stream' mode.

Note that, for convenience, this function returns a Promise AND accepts callbacks (that do not contribute to the returned promise).
One is free to use either the Promise or the callback to be 'notified' when the stream is ready.

Example

import {Las20Stream} from '@int/geotoolkit/las/Las20Stream';
import {BrowserFileStream} from '@int/geotoolkit/util/stream/BrowserFileStream';
import {LineReader} from '@int/geotoolkit/util/stream/LineReader';

new Las20Stream({
'reader': new LineReader({
'stream': new BrowserFileStream({
'file': file
})
})
})
.open(true)
.then((stream) => {
// load table
}).catch((e) => {
// error
});

Parameters

Name Type Description
fullloadbooleanIf true, the stream will be fully read and parsed during its opening. (This is discouraged)
Optional successCallbackA function called when the headers have been parsed and the stream is ready
Optional errorCallbackA function called if the header parsing failed

Returns

Promise<Las20Stream>

A promise fulfilled when the headers have been parsed and the stream is ready

Overrides

LasStreamParser.open


getClassName

Static getClassName(): string

Returns

string

Inherited from

LasStreamParser.getClassName


isLAS20

Static isLAS20(reader, success?, error?): Promise<{ details: string ; isLAS20: boolean }>

Tests if the given reader looks like a LAS 2.0
Note that a success does not mean that the given reader is a LAS 2.0 but only that the type has been detected.
To find out if it is a LAS 2.0, one should look at the result given in the promise/callback.
{isLAS20:true, details:"Mode information about the isLAS20 result"}

Note that, for convenience, this function returns a Promise AND accepts callbacks (that do not contribute to the returned promise).
One is free to use either the Promise or the callback to be 'notified' when the stream is ready.

Example

Las20Stream.isLAS20(lineReader).then( (result) => {
if (result['isLAS20'] === true) {
// Can be parsed using Las20Stream
} else {
// Can't be parsed using Las20Stream
}
}).catch((e) => {
// Can't be parsed using Las20Stream
});

Parameters

Name Type Description
readerLineReaderThe reader to test
Optional successCallbackA function called when the nature of the given reader has been detected
Optional errorCallbackA function called if a major error occurs

Returns

Promise<{ details: string ; isLAS20: boolean }>

A promise fulfilled when the nature of the given reader has been detected