Skip to content

Commit

Permalink
chore: lint fix and remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
alekzvik committed Nov 24, 2024
1 parent 1299f8b commit 68e8c66
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 40 deletions.
7 changes: 3 additions & 4 deletions modules/las/src/las-arrow-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
import type {LoaderWithParser} from '@loaders.gl/loader-utils';
import type {ArrowTable} from '@loaders.gl/schema';

import {LASLoaderOptions, LASWorkerLoader} from './las-loader';
import {LASLoaderOptions, LASLoader} from './las-loader';
import {convertMeshToTable} from '@loaders.gl/schema-utils';
import {parseLAS} from './lib/parse-las';

/**
* Worker loader for LAS - Point Cloud Data
*/
export const LASArrowLoader = {
...LASWorkerLoader,
...LASLoader,
dataType: null as unknown as ArrowTable,
batchType: null as never,
worker: false,
parse: async (arrayBuffer: ArrayBuffer) => {
const mesh = parseLAS(arrayBuffer);
const mesh = await LASLoader.parse(arrayBuffer);
const arrowTable = convertMeshToTable(mesh, 'arrow-table');
return arrowTable;
}
Expand Down
4 changes: 2 additions & 2 deletions modules/las/src/las-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const LASFormat = {
module: 'las',
extensions: ['las', 'laz'], // LAZ is the "compressed" flavor of LAS,
mimeTypes: ['application/octet-stream'], // TODO - text version?
text: true,
text: false,
binary: true,
tests: ['LAS']
tests: ['LASF']
} as const satisfies Format;
8 changes: 0 additions & 8 deletions modules/las/src/las-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,8 @@ export const LASWorkerLoader = {
dataType: null as unknown as LASMesh,
batchType: null as never,

name: 'LAS',
id: 'las',
module: 'las',
version: VERSION,
worker: true,
extensions: ['las', 'laz'], // LAZ is the "compressed" flavor of LAS,
mimeTypes: ['application/octet-stream'], // TODO - text version?
text: true,
binary: true,
tests: ['LAS'],
options: {
las: {
shape: 'mesh',
Expand Down
2 changes: 1 addition & 1 deletion modules/las/src/lib/get-las-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {deduceMeshSchema} from '@loaders.gl/schema-utils';
import type {LASHeader} from './las-types';

/**
* Gets schema from PLY header
* Gets schema from LAS header
* @param lasHeader
* @param metadata
* @returns Schema
Expand Down
34 changes: 14 additions & 20 deletions modules/las/src/lib/laslaz-decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import type {LASHeader} from './las-types';
import {WasmLasZipDecompressor} from './libs/laz_rs_wasm';

type LASPoint = {
position: [number, number, number],
intensity: number,
classification: number,
color?: [number, number, number]
}
position: [number, number, number];
intensity: number;
classification: number;
color?: [number, number, number];
};

type LASReader = (dv: DataView) => LASPoint;

Expand Down Expand Up @@ -113,7 +113,7 @@ const POINT_FORMAT_READERS: LASReaders = {
classification: dv.getUint8(16),
color: [dv.getUint16(30, true), dv.getUint16(32, true), dv.getUint16(34, true)]
};
},
}
};

/**
Expand Down Expand Up @@ -163,12 +163,12 @@ function parseLASHeader(arraybuffer: ArrayBuffer): LASHeader {
pointsStructSize: readAs(arraybuffer, Uint16Array, 32 * 3 + 8 + 1),
pointsCount: readAs(arraybuffer, Uint32Array, 32 * 3 + 11),
versionAsString,
isCompressed,
isCompressed
};

let start = 32 * 3 + 35;

o.scale = readAs(arraybuffer, Float64Array, start, 3);
o.scale = readAs(arraybuffer, Float64Array, start, 3);
start += 24; // 8*3
o.offset = readAs(arraybuffer, Float64Array, start, 3);
start += 24;
Expand All @@ -178,14 +178,14 @@ function parseLASHeader(arraybuffer: ArrayBuffer): LASHeader {
o.maxs = [bounds[0], bounds[2], bounds[4]];
o.mins = [bounds[1], bounds[3], bounds[5]];

start += 20 // 8*20
start += 20; // 8*20

if (version === 14) {
o.pointsCount = Number(readAs(arraybuffer, BigUint64Array, start))
o.pointsCount = Number(readAs(arraybuffer, BigUint64Array, start));
}

const colorPointFormats = new Set([2, 3, 5, 7, 8, 10])
o.hasColor = colorPointFormats.has(pointsFormatId)
const colorPointFormats = new Set([2, 3, 5, 7, 8, 10]);
o.hasColor = colorPointFormats.has(pointsFormatId);
return o as LASHeader;
}

Expand Down Expand Up @@ -392,20 +392,12 @@ class LASDecoder {
decoder: (dv: DataView) => LASPoint;
pointsCount: number;
pointSize: number;
scale: [number, number, number];
offset?: [number, number, number];
mins?: number[];
maxs?: number[];

constructor(buffer: ArrayBuffer, len: number, header: LASHeader) {
this.arrayb = buffer;
this.decoder = POINT_FORMAT_READERS[header.pointsFormatId];
this.pointsCount = len;
this.pointSize = header.pointsStructSize;
this.scale = header.scale;
this.offset = header.offset;
this.mins = header.mins;
this.maxs = header.maxs;
}

/**
Expand Down Expand Up @@ -531,3 +523,5 @@ export class LASFile {
}
}

/* eslint no-use-before-define: 2 */
// export const LASModuleWasLoaded = false;
6 changes: 1 addition & 5 deletions modules/las/src/lib/parse-las.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ type LASChunk = {
count: number;
buffer: ArrayBuffer;
hasMoreData: boolean;
versionAsString?: string;
isCompressed?: boolean;
};

/**
* Parsing of .las file
* @param arrayBuffer
* @param options
* @returns LASHeader
* @returns LASMesh
*/
export function parseLAS(arrayBuffer: ArrayBuffer, options?: LASLoaderOptions): LASMesh {
return parseLASMesh(arrayBuffer, options);
Expand Down Expand Up @@ -177,8 +175,6 @@ export function parseLASChunked(rawData: ArrayBuffer, skip: number, onParseData:
totalRead += chunk.count;

header.totalRead = totalRead;
header.versionAsString = chunk.versionAsString;
header.isCompressed = chunk.isCompressed;

const unpacker = new Unpacker(chunk.buffer, chunk.count, header);

Expand Down

0 comments on commit 68e8c66

Please sign in to comment.