API / geotoolkit / las / Las20Stream / 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.
↳
Las20Stream↳↳
Las20Stream
Constructors
Constructors
• new Las20Stream(options)
Constructor
| Name | Type | Description |
|---|---|---|
options | Options | The options |
LasStreamParser.constructor
Methods
▸ getClassName(): string
string
▸ getSectionGroups(): LasSectionGroup[]
Gets all the section groups. Doesn't include sections not in groups.
array of LasSectionGroup
LasStreamParser.getSectionGroups
▸ getSections(): LasParameterSection[]
Returns all sections not part of a group
array of LasSection
▸ 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
});| Name | Type | Description |
|---|---|---|
fullload | boolean | If true, the stream will be fully read and parsed during its opening. (This is discouraged) |
Optional success | Callback | A function called when the headers have been parsed and the stream is ready |
Optional error | Callback | A function called if the header parsing failed |
Promise<Las20Stream>
A promise fulfilled when the headers have been parsed and the stream is ready
▸ Static getClassName(): string
string
▸ 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
});| Name | Type | Description |
|---|---|---|
reader | LineReader | The reader to test |
Optional success | Callback | A function called when the nature of the given reader has been detected |
Optional error | Callback | A function called if a major error occurs |
Promise<{ details: string ; isLAS20: boolean }>
A promise fulfilled when the nature of the given reader has been detected